drm/amdgpu: fix the ioctl direction for DRM_IOCTL_AMDGPU_GEM_VA
Subsystems (3)
PATCH 1/1 drm/amdgpu: fix the ioctl direction for DRM_IOCTL_AMDGPU_GEM_VA
Though drmCommandWriteRead() is used in libdrm [1], DRM_IOCTL_AMDGPU_GEM_VA uses DRM_IOW for encoding.
[1] https://gitlab.freedesktop.org/mesa/drm/-/blob/main/amdgpu/amdgpu_bo.c?ref_type=heads
--- include/uapi/drm/amdgpu_drm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/drm/amdgpu_drm.h +1 -1
@@ -63,7 +63,7 @@ extern "C" {#define DRM_IOCTL_AMDGPU_INFO DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_INFO, struct drm_amdgpu_info)#define DRM_IOCTL_AMDGPU_GEM_METADATA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_METADATA, struct drm_amdgpu_gem_metadata)#define DRM_IOCTL_AMDGPU_GEM_WAIT_IDLE DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_WAIT_IDLE, union drm_amdgpu_gem_wait_idle) -#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOW(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va) +#define DRM_IOCTL_AMDGPU_GEM_VA DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_VA, struct drm_amdgpu_gem_va)#define DRM_IOCTL_AMDGPU_WAIT_CS DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_WAIT_CS, union drm_amdgpu_wait_cs)#define DRM_IOCTL_AMDGPU_GEM_OP DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_OP, struct drm_amdgpu_gem_op)#define DRM_IOCTL_AMDGPU_GEM_USERPTR DRM_IOWR(DRM_COMMAND_BASE + DRM_AMDGPU_GEM_USERPTR, struct drm_amdgpu_gem_userptr)
Signature · 1 line
2.45.2
Hi Yamato-san,
Quoted 4 lines · Masatake YAMATO
Though
drmCommandWriteRead()is used in libdrm [1],DRM_IOCTL_AMDGPU_GEM_VAusesDRM_IOWfor encoding.[1] https://gitlab.freedesktop.org/mesa/drm/-/blob/main/amdgpu/amdgpu_bo.c?ref_type=heads
AFAICT libdrm doesn't read from the struct drm_amdgpu_gem_va it passes to the ioctl after the latter returns though.
Also, while amdgpu_gem_va_ioctl (the ioctl implementation in the kernel) modifies the struct:
args->va_address &= AMDGPU_GMC_HOLE_MASK;
that looks like an implementation detail which could be avoided if necessary, and shouldn't be propagated back to user space.
I'd suggest fixing libdrm to use drmCommandWrite instead.
Signature · 2 lines
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast
Hi,
Quoted 12 lines
Hi Yamato-san,
Quoted 4 lines · Masatake YAMATO
Though
drmCommandWriteRead()is used in libdrm [1],DRM_IOCTL_AMDGPU_GEM_VAusesDRM_IOWfor encoding.[1] https://gitlab.freedesktop.org/mesa/drm/-/blob/main/amdgpu/amdgpu_bo.c?ref_type=heads
AFAICT libdrm doesn't read from the struct
drm_amdgpu_gem_vait passes to the ioctl after the latter returns though.
Quoted 8 lines
Also, while
amdgpu_gem_va_ioctl(the ioctl implementation in the kernel) modifies the struct:args->va_address &= AMDGPU_GMC_HOLE_MASK;that looks like an implementation detail which could be avoided if necessary, and shouldn't be propagated back to user space.
I'd suggest fixing libdrm to use drmCommandWrite instead.
Thank you.
After reading this mail, I inspected drm_ioctl.c.
I was surprised that drm_ioctl() uses only the offset from DRM_COMMAND_BASE when choosing the real handler for a cmd. Therefore we can switch from drmCommandWriteRead to drmCommandWrite without breaking applications using the library.
Masatake YAMATO
Quoted 5 lines
Signature · 3 lines
-- Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer https://redhat.com \ Libre software enthusiast