Mesa (master): turnip: Fix error handling of DRM_MSM_GEM_INFO ioctls.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jun 26 20:04:39 UTC 2020
Module: Mesa
Branch: master
Commit: 487576e3cfd7768ba274aab7f1ea40a6877c8e50
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=487576e3cfd7768ba274aab7f1ea40a6877c8e50
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jun 17 12:33:07 2020 -0700
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>
---
src/freedreno/vulkan/tu_drm.c | 16 +++++++++++-----
1 file 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)
{
More information about the mesa-commit
mailing list