summaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/tu_drm.c
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-01-10 15:27:28 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:01:41 -0700
commitfcf24f47aac414cbd634be5085002a5698618678 (patch)
treef1021b1d8c854d1e0934007049b0989d7b6bdc09 /src/freedreno/vulkan/tu_drm.c
parenta25a803127c5f59ce9049d22c85e5dd7771014f6 (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/freedreno/vulkan/tu_drm.c')
-rw-r--r--src/freedreno/vulkan/tu_drm.c70
1 files changed, 47 insertions, 23 deletions
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;
-}