[PATCH i-g-t V2 1/2] drm-uapi/xe: Add new flag in mmap offset ioctl

Matt Roper matthew.d.roper at intel.com
Wed Nov 6 17:35:49 UTC 2024


On Wed, Oct 23, 2024 at 03:13:26PM +0530, Tejas Upadhyay wrote:
> Add flag in mmap offset for querying special defined
> mmap offset for specific purpose like pci membarrier
> which requires to write 4K doorbell page mapped at
> defined offset.
> 
> For user to query special offset, special flag can be
> passed in mmap_offset ioctl and used in mmap as follows,
> struct drm_xe_gem_mmap_offset mmo = {
> 	.handle = 0, (this must be set to 0)
> 	.flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
> };
> igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo);
> map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
> 
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
> ---
>  include/drm-uapi/xe_drm.h | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/include/drm-uapi/xe_drm.h b/include/drm-uapi/xe_drm.h
> index f0a450db9..a04d6f1de 100644
> --- a/include/drm-uapi/xe_drm.h
> +++ b/include/drm-uapi/xe_drm.h

This header is supposed to be a direct copy of the kernel header; we
shouldn't be making manual changes to it since those will just get
delted the next time somebody resyncs with the kernel.

Definitions for uapi that isn't upstream yet can be put in a local
header.  E.g., see lib/i915/i915_drm_local.h for the i915 equivalent.


Matt

> @@ -817,7 +817,18 @@ struct drm_xe_gem_mmap_offset {
>  	/** @handle: Handle for the object being mapped. */
>  	__u32 handle;
>  
> -	/** @flags: Must be zero */
> +/**
> + * For user to query special offset we are adding special flag in
> + * mmap_offset ioctl which needs to be passed as follows,
> + * struct drm_xe_gem_mmap_offset mmo = {
> + *      .handle = 0, (this must be set to 0)
> + *      .flags = DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER,
> + * };
> + * igt_ioctl(fd, DRM_IOCTL_XE_GEM_MMAP_OFFSET, &mmo);
> + * map = mmap(NULL, size, PROT_WRITE, MAP_SHARED, fd, mmo);
> +*/
> +#define DRM_XE_MMAP_OFFSET_FLAG_PCI_BARRIER     (1 << 0)
> +	/** @flags: Flag to indicate if any special offset, zero otherwise */
>  	__u32 flags;
>  
>  	/** @offset: The fake offset to use for subsequent mmap call */
> -- 
> 2.34.1
> 

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation


More information about the igt-dev mailing list