diff options
author | Chia-I Wu <[email protected]> | 2019-01-10 15:27:28 -0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-03-11 10:01:41 -0700 |
commit | fcf24f47aac414cbd634be5085002a5698618678 (patch) | |
tree | f1021b1d8c854d1e0934007049b0989d7b6bdc09 /src | |
parent | a25a803127c5f59ce9049d22c85e5dd7771014f6 (diff) |
turnip: add wrappers around DRM_MSM_GET_PARAM
Add tu_drm_get_gpu_id and tu_drm_get_gmem_size.
Diffstat (limited to 'src')
-rw-r--r-- | src/freedreno/vulkan/tu_device.c | 7 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_drm.c | 70 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 10 |
3 files changed, 55 insertions, 32 deletions
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 65a0e405452..e321f4ad39f 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -152,7 +152,6 @@ tu_physical_device_init(struct tu_physical_device *device, drmVersionPtr version; int fd; int master_fd = -1; - uint64_t val; fd = open(path, O_RDWR | O_CLOEXEC); if (fd < 0) { @@ -214,23 +213,21 @@ tu_physical_device_init(struct tu_physical_device *device, device->master_fd = master_fd; device->local_fd = fd; - if (tu_drm_query_param(device, MSM_PARAM_GPU_ID, &val)) { + if (tu_drm_get_gpu_id(device, &device->gpu_id)) { if (instance->debug_flags & TU_DEBUG_STARTUP) tu_logi("Could not query the GPU ID"); result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GPU ID"); goto fail; } - device->gpu_id = val; - if (tu_drm_query_param(device, MSM_PARAM_GMEM_SIZE, &val)) { + if (tu_drm_get_gmem_size(device, &device->gmem_size)) { if (instance->debug_flags & TU_DEBUG_STARTUP) tu_logi("Could not query the GMEM size"); result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, "could not get GMEM size"); goto fail; } - device->gmem_size = val; memset(device->name, 0, sizeof(device->name)); sprintf(device->name, "FD%d", device->gpu_id); diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c index d0d1cd8d4f6..b28de8f2c06 100644 --- a/src/freedreno/vulkan/tu_drm.c +++ b/src/freedreno/vulkan/tu_drm.c @@ -31,6 +31,53 @@ #include "drm/msm_drm.h" +static int +tu_drm_get_param(const struct tu_physical_device *dev, + uint32_t param, + uint64_t *value) +{ + /* Technically this requires a pipe, but the kernel only supports one pipe + * anyway at the time of writing and most of these are clearly pipe + * independent. */ + struct drm_msm_param req = { + .pipe = MSM_PIPE_3D0, + .param = param, + }; + + int ret = drmCommandWriteRead(dev->local_fd, DRM_MSM_GET_PARAM, &req, + sizeof(req)); + if (ret) + return ret; + + *value = req.value; + + return 0; +} + +int +tu_drm_get_gpu_id(const struct tu_physical_device *dev, uint32_t *id) +{ + uint64_t value; + int ret = tu_drm_get_param(dev, MSM_PARAM_GPU_ID, &value); + if (ret) + return ret; + + *id = value; + return 0; +} + +int +tu_drm_get_gmem_size(const struct tu_physical_device *dev, uint32_t *size) +{ + uint64_t value; + int ret = tu_drm_get_param(dev, MSM_PARAM_GMEM_SIZE, &value); + if (ret) + return ret; + + *size = value; + return 0; +} + /** * Return gem handle on success. Return 0 on failure. */ @@ -90,26 +137,3 @@ tu_gem_info_iova(struct tu_device *dev, uint32_t gem_handle) { return tu_gem_info(dev, gem_handle, MSM_INFO_GET_IOVA); } - -int -tu_drm_query_param(struct tu_physical_device *dev, - uint32_t param, - uint64_t *value) -{ - /* Technically this requires a pipe, but the kernel only supports one pipe - * anyway at the time of writing and most of these are clearly pipe - * independent. */ - struct drm_msm_param req = { - .pipe = MSM_PIPE_3D0, - .param = param, - }; - - int ret = drmCommandWriteRead(dev->local_fd, DRM_MSM_GET_PARAM, &req, - sizeof(req)); - if (ret) - return ret; - - *value = req.value; - - return 0; -} diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 7209785840e..a2deb98abf8 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1189,6 +1189,12 @@ struct tu_fence uint32_t temp_syncobj; }; +int +tu_drm_get_gpu_id(const struct tu_physical_device *dev, uint32_t *id); + +int +tu_drm_get_gmem_size(const struct tu_physical_device *dev, uint32_t *size); + uint32_t tu_gem_new(struct tu_device *dev, uint64_t size, uint32_t flags); void @@ -1197,10 +1203,6 @@ uint64_t tu_gem_info_offset(struct tu_device *dev, uint32_t gem_handle); uint64_t tu_gem_info_iova(struct tu_device *dev, uint32_t gem_handle); -int -tu_drm_query_param(struct tu_physical_device *dev, - uint32_t param, - uint64_t *value); #define TU_DEFINE_HANDLE_CASTS(__tu_type, __VkType) \ \ |