aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2018-12-21 14:49:30 +0100
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commit6401ad389e9cec6f523e4e4e989c190fb25a8dfc (patch)
treedb6fb8a7ca0b9bcb46b30aa65b87b4f17b1bbda3 /src
parentb0562e272f8a2a41d0639b65a5158b0c3b2dfd3b (diff)
turnip: Implement pipe-less param query.
Diffstat (limited to 'src')
-rw-r--r--src/freedreno/vulkan/tu_device.c23
-rw-r--r--src/freedreno/vulkan/tu_drm.c21
-rw-r--r--src/freedreno/vulkan/tu_private.h2
3 files changed, 31 insertions, 15 deletions
diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c
index e595152d465..b42bb4cb03b 100644
--- a/src/freedreno/vulkan/tu_device.c
+++ b/src/freedreno/vulkan/tu_device.c
@@ -149,7 +149,6 @@ tu_physical_device_init(struct tu_physical_device *device,
drmVersionPtr version;
int fd;
int master_fd = -1;
- struct fd_pipe *tmp_pipe = NULL;
uint64_t val;
fd = open(path, O_RDWR | O_CLOEXEC);
@@ -214,35 +213,31 @@ tu_physical_device_init(struct tu_physical_device *device,
device->drm_device = fd_device_new_dup(fd);
if (!device->drm_device) {
+ if (instance->debug_flags & TU_DEBUG_STARTUP)
+ tu_logi("Could not create the libdrm device");
result = vk_errorf(
instance, VK_ERROR_INITIALIZATION_FAILED, "could not create the libdrm device");
goto fail;
}
- tmp_pipe = fd_pipe_new(device->drm_device, FD_PIPE_3D);
- if (!tmp_pipe) {
- result = vk_errorf(
- instance, VK_ERROR_INITIALIZATION_FAILED, "could not open the 3D pipe");
- goto fail;
- }
-
- if (fd_pipe_get_param(tmp_pipe, FD_GPU_ID, &val)) {
+ if (tu_drm_query_param(device, MSM_PARAM_GPU_ID, &val)) {
+ 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 (fd_pipe_get_param(tmp_pipe, FD_GMEM_SIZE, &val)) {
+ if (tu_drm_query_param(device, MSM_PARAM_GMEM_SIZE, &val)) {
+ 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;
- fd_pipe_del(tmp_pipe);
- tmp_pipe = NULL;
-
memset(device->name, 0, sizeof(device->name));
sprintf(device->name, "FD%d", device->gpu_id);
@@ -285,8 +280,6 @@ tu_physical_device_init(struct tu_physical_device *device,
return VK_SUCCESS;
fail:
- if (tmp_pipe)
- fd_pipe_del(tmp_pipe);
if (device->drm_device)
fd_device_del(device->drm_device);
close(fd);
diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c
index b8a4c6f8a98..11c3b008155 100644
--- a/src/freedreno/vulkan/tu_drm.c
+++ b/src/freedreno/vulkan/tu_drm.c
@@ -92,3 +92,24 @@ tu_gem_info_iova(struct tu_device *dev, uint32_t gem_handle)
{
return tu_gem_info(dev, gem_handle, MSM_INFO_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 5b5315ed15e..454a051336e 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1203,6 +1203,8 @@ 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) \
\