[RFC PATCH 9/9] drm/rustgem: create dummy IOCTL with number 0x00

Daniel Vetter daniel at ffwll.ch
Thu Apr 13 09:08:36 UTC 2023


On Fri, Mar 17, 2023 at 09:12:13AM -0300, Maíra Canal wrote:
> In order to declare IOCTLs with the current Rust abstractions, we use
> the kernel::declare_drm_ioctls! macro. This macro considers that the
> IOCTLs are in the right order and there are no gaps. This isn't the case
> for vgem, which start the IOCTLs with 0x01, instead of 0x00.
> 
> With the intention to use the kernel::declare_drm_ioctls! macro, create
> a dummy IOCTL with number 0x00, that returns EINVAL.
> 
> Signed-off-by: Maíra Canal <mcanal at igalia.com>

Random idea, but we might want to push a dummy nop and einval ioctl to the
gem rust stuff, that's generally handy. We have it on the C side too :-)
-Daniel

> ---
>  drivers/gpu/drm/rustgem/file.rs | 8 ++++++++
>  drivers/gpu/drm/rustgem/vgem.rs | 1 +
>  include/uapi/drm/vgem_drm.h     | 4 ++++
>  3 files changed, 13 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rustgem/file.rs b/drivers/gpu/drm/rustgem/file.rs
> index a3714e8ca206..f26b74204361 100644
> --- a/drivers/gpu/drm/rustgem/file.rs
> +++ b/drivers/gpu/drm/rustgem/file.rs
> @@ -27,6 +27,14 @@ impl drm::file::DriverFile for File {
>  }
>  
>  impl File {
> +    pub(crate) fn dummy(
> +        _device: &VgemDevice,
> +        _data: &mut bindings::drm_vgem_dummy,
> +        _file: &DrmFile,
> +    ) -> Result<u32> {
> +        Err(EINVAL)
> +    }
> +
>      /// vgem_fence_attach_ioctl (DRM_IOCTL_VGEM_FENCE_ATTACH):
>      ///
>      /// Create and attach a fence to the vGEM handle. This fence is then exposed
> diff --git a/drivers/gpu/drm/rustgem/vgem.rs b/drivers/gpu/drm/rustgem/vgem.rs
> index c2fc55bb39bd..64e8f1c2cbca 100644
> --- a/drivers/gpu/drm/rustgem/vgem.rs
> +++ b/drivers/gpu/drm/rustgem/vgem.rs
> @@ -55,6 +55,7 @@ impl drv::Driver for VgemDriver {
>      const FEATURES: u32 = drv::FEAT_GEM | drv::FEAT_RENDER;
>  
>      kernel::declare_drm_ioctls! {
> +        (VGEM_DUMMY, drm_vgem_dummy, ioctl::RENDER_ALLOW, file::File::dummy),
>          (VGEM_FENCE_ATTACH, drm_vgem_fence_attach, ioctl::RENDER_ALLOW, file::File::attach),
>          (VGEM_FENCE_SIGNAL, drm_vgem_fence_signal, ioctl::RENDER_ALLOW, file::File::signal),
>      }
> diff --git a/include/uapi/drm/vgem_drm.h b/include/uapi/drm/vgem_drm.h
> index 53ee3af0b25a..1348f8e819ed 100644
> --- a/include/uapi/drm/vgem_drm.h
> +++ b/include/uapi/drm/vgem_drm.h
> @@ -36,9 +36,12 @@ extern "C" {
>  /* Please note that modifications to all structs defined here are
>   * subject to backwards-compatibility constraints.
>   */
> +#define DRM_VGEM_DUMMY		0x0
>  #define DRM_VGEM_FENCE_ATTACH	0x1
>  #define DRM_VGEM_FENCE_SIGNAL	0x2
>  
> +struct drm_vgem_dummy { };
> +
>  struct drm_vgem_fence_attach {
>  	__u32 handle;
>  	__u32 flags;
> @@ -54,6 +57,7 @@ struct drm_vgem_fence_signal {
>  
>  /* Note: this is an enum so that it can be resolved by Rust bindgen. */
>  enum {
> +	DRM_IOCTL_VGEM_DUMMY		= DRM_IOW(DRM_COMMAND_BASE + DRM_VGEM_DUMMY, struct drm_vgem_dummy),
>  	DRM_IOCTL_VGEM_FENCE_ATTACH	= DRM_IOWR(DRM_COMMAND_BASE + DRM_VGEM_FENCE_ATTACH, struct drm_vgem_fence_attach),
>  	DRM_IOCTL_VGEM_FENCE_SIGNAL	= DRM_IOW(DRM_COMMAND_BASE + DRM_VGEM_FENCE_SIGNAL, struct drm_vgem_fence_signal),
>  };
> -- 
> 2.39.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the dri-devel mailing list