aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan/tu_drm.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2020-06-17 12:33:07 -0700
committerMarge Bot <[email protected]>2020-06-26 19:34:17 +0000
commit487576e3cfd7768ba274aab7f1ea40a6877c8e50 (patch)
tree0ac7414cb9fece0d34a612e469d6bc3e465a50af /src/freedreno/vulkan/tu_drm.c
parente67c2e1c96c17b5b57f214297adba2a8a302f994 (diff)
turnip: Fix error handling of DRM_MSM_GEM_INFO ioctls.
drmCommandWriteRead gives us a -errno, and we only checked for -1 (-EPERM, incidentally). All the callers wanted 0 for errors, which they were getting by the fact that req.value was 0-initialized in our stack allocation (though this only works as long as the kernel doesn't return an error after setting req.value to something), and -EPERM not really being an answer we would expect from an ioctl at this stage in the driver. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2769>
Diffstat (limited to 'src/freedreno/vulkan/tu_drm.c')
-rw-r--r--src/freedreno/vulkan/tu_drm.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/freedreno/vulkan/tu_drm.c b/src/freedreno/vulkan/tu_drm.c
index 5e91adaf89e..f886c875088 100644
--- a/src/freedreno/vulkan/tu_drm.c
+++ b/src/freedreno/vulkan/tu_drm.c
@@ -168,7 +168,7 @@ tu_gem_close(const struct tu_device *dev, uint32_t gem_handle)
drmIoctl(dev->physical_device->local_fd, DRM_IOCTL_GEM_CLOSE, &req);
}
-/** Return UINT64_MAX on error. */
+/** Helper for DRM_MSM_GEM_INFO, returns 0 on error. */
static uint64_t
tu_gem_info(const struct tu_device *dev, uint32_t gem_handle, uint32_t info)
{
@@ -179,20 +179,26 @@ tu_gem_info(const struct tu_device *dev, uint32_t gem_handle, uint32_t info)
int ret = drmCommandWriteRead(dev->physical_device->local_fd,
DRM_MSM_GEM_INFO, &req, sizeof(req));
- if (ret == -1)
- return UINT64_MAX;
+ if (ret < 0)
+ return 0;
return req.value;
}
-/** Return UINT64_MAX on error. */
+/** Returns the offset for CPU-side mmap of the gem handle.
+ *
+ * Returns 0 on error (an invalid mmap offset in the DRM UBI).
+ */
uint64_t
tu_gem_info_offset(const struct tu_device *dev, uint32_t gem_handle)
{
return tu_gem_info(dev, gem_handle, MSM_INFO_GET_OFFSET);
}
-/** Return UINT64_MAX on error. */
+/** Returns the the iova of the BO in GPU memory.
+ *
+ * Returns 0 on error (an invalid iova in the MSM DRM UABI).
+ */
uint64_t
tu_gem_info_iova(const struct tu_device *dev, uint32_t gem_handle)
{