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>
This commit is contained in:
parent
e67c2e1c96
commit
487576e3cf
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue