[PATCH] drm/amdgpu: fix the ioctl direction for DRM_IOCTL_AMDGPU_GEM_VA
Masatake YAMATO
yamato at redhat.com
Wed Aug 7 00:34:22 UTC 2024
Hi,
>
> Hi Yamato-san,
>
>
> On 2024-08-06 04:43, Masatake YAMATO wrote:
>> 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
>
> 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.
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
>
> --
> Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
> https://redhat.com \ Libre software enthusiast
>
More information about the amd-gfx
mailing list