All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jianxun Zhang <jianxun.zhang@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	<intel-xe@lists.freedesktop.org>
Cc: <saurabhg.gupta@intel.com>, <alex.zuo@intel.com>,
	<joonas.lahtinen@linux.intel.com>, <matthew.brost@intel.com>,
	<shuicheng.lin@intel.com>, <dri-devel@lists.freedesktop.org>,
	<Michal.Wajdeczko@intel.com>, <michal.mzorek@intel.com>
Subject: Re: [PATCH v8 3/6] drm/xe/uapi: Define drm_xe_vm_get_property
Date: Thu, 13 Mar 2025 15:10:05 -0700	[thread overview]
Message-ID: <2dcbd24b-e9cb-4a67-9e9b-3bd38ec8cef5@intel.com> (raw)
In-Reply-To: <20250313183415.133863-4-jonathan.cavitt@intel.com>



On 3/13/25 11:34, Jonathan Cavitt wrote:
> Add initial declarations for the drm_xe_vm_get_property ioctl.
> 
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> ---
>   include/uapi/drm/xe_drm.h | 69 +++++++++++++++++++++++++++++++++++++++
>   1 file changed, 69 insertions(+)
> 
> diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h
> index 616916985e3f..0ed52666b4e9 100644
> --- a/include/uapi/drm/xe_drm.h
> +++ b/include/uapi/drm/xe_drm.h
> @@ -81,6 +81,7 @@ extern "C" {
>    *  - &DRM_IOCTL_XE_EXEC
>    *  - &DRM_IOCTL_XE_WAIT_USER_FENCE
>    *  - &DRM_IOCTL_XE_OBSERVATION
> + *  - &DRM_IOCTL_XE_VM_GET_PROPERTY
>    */
>   
>   /*
> @@ -102,6 +103,7 @@ extern "C" {
>   #define DRM_XE_EXEC			0x09
>   #define DRM_XE_WAIT_USER_FENCE		0x0a
>   #define DRM_XE_OBSERVATION		0x0b
> +#define DRM_XE_VM_GET_PROPERTY		0x0c
>   
>   /* Must be kept compact -- no holes */
>   
> @@ -117,6 +119,7 @@ extern "C" {
>   #define DRM_IOCTL_XE_EXEC			DRM_IOW(DRM_COMMAND_BASE + DRM_XE_EXEC, struct drm_xe_exec)
>   #define DRM_IOCTL_XE_WAIT_USER_FENCE		DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_WAIT_USER_FENCE, struct drm_xe_wait_user_fence)
>   #define DRM_IOCTL_XE_OBSERVATION		DRM_IOW(DRM_COMMAND_BASE + DRM_XE_OBSERVATION, struct drm_xe_observation_param)
> +#define DRM_IOCTL_XE_VM_GET_PROPERTY	DRM_IOWR(DRM_COMMAND_BASE + DRM_XE_VM_GET_PROPERTY, struct drm_xe_vm_get_property)
>   
>   /**
>    * DOC: Xe IOCTL Extensions
> @@ -1189,6 +1192,72 @@ struct drm_xe_vm_bind {
>   	__u64 reserved[2];
>   };
>   
> +/** struct xe_vm_fault - Describes faults for %DRM_XE_VM_GET_PROPERTY_FAULTS */
> +struct xe_vm_fault {
> +	/** @address: Address of the fault */
> +	__u64 address;
> +#define DRM_XE_FAULT_ADDRESS_TYPE_NONE_EXT		0
> +#define DRM_XE_FAULT_ADDRESS_TYPE_READ_INVALID_EXT	1
> +#define DRM_XE_FAULT_ADDRESS_TYPE_WRITE_INVALID_EXT	2
> +	/** @address_type: Type of address access that resulted in fault */
> +	__u32 address_type;
> +	/** @address_precision: Precision of faulted address */
> +	__u32 address_precision;
> +	/** @fault_level: fault level of the fault */
> +	__u8 fault_level;
> +	/** @engine_class: class of engine fault was reported on */
> +	__u8 engine_class;
> +	/** @engine_instance: instance of engine fault was reported on */
> +	__u8 engine_instance;
> +	/** @pad: MBZ */
> +	__u8 pad[5];
> +	/** @reserved: MBZ */
> +	__u64 reserved[3];
> +};
> +
> +/**
> + * struct drm_xe_vm_get_property - Input of &DRM_IOCTL_XE_VM_GET_PROPERTY
> + *
> + * The user provides a VM ID and a property to query for.  The ioctl will return
> + * the size of the data expected to be returned in @size.  Performing the query
> + * again with memory allocated to @data of size @size will return the requested
> + * data to the allocated memory.
> + *
> + * Some get property requests may be scalar values and require no memory allocation.
> + * In such cases, the first call to this ioctl will not set @size and will return
> + * the requested value to @value instead.
A kernel driver cannot assume user space always plays nicely (two calls 
in the expected order). Instead, the design should be able to deal with 
all possibilities.

I suggest rewording this comment from another angle for two different 
behaviors. Something like "caller passes size with zero, ioctl returns 
actual size of a property only; caller passes a non-zero size, ioctl returns
error if size < prop's size, otherwise the size of prop and fills the 
data in memory"

In this way, the usage doesn't rely on the order of calls from user space.
> + *
> + * The @property can be:
> + *  - %DRM_XE_VM_GET_PROPERTY_FAULTS
> + */
> +struct drm_xe_vm_get_property {
> +	/** @extensions: Pointer to the first extension struct, if any */
> +	__u64 extensions;
> +
> +	/** @vm_id: The ID of the VM to query the properties of */
> +	__u32 vm_id;
> +
> +#define DRM_XE_VM_GET_PROPERTY_FAULTS		0
> +	/** @property: property to get */
> +	__u32 property;
> +
> +	/** @size: Size to allocate for @data */
> +	__u32 size;
> +
> +	/** @pad: MBZ */
> +	__u32 pad;
> +
> +	union {
> +		/** @data: Pointer to user-defined array of flexible size and type */
> +		__u64 data;
> +		/** @value: Return value for scalar queries */
> +		__u64 value;
> +	};
> +
> +	/** @reserved: MBZ */
> +	__u64 reserved[3];
> +};
> +
>   /**
>    * struct drm_xe_exec_queue_create - Input of &DRM_IOCTL_XE_EXEC_QUEUE_CREATE
>    *


  reply	other threads:[~2025-03-13 22:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-13 18:34 [PATCH v8 0/6] drm/xe/xe_vm: Implement xe_vm_get_property_ioctl Jonathan Cavitt
2025-03-13 18:34 ` [PATCH v8 1/6] drm/xe/xe_gt_pagefault: Disallow writes to read-only VMAs Jonathan Cavitt
2025-03-13 18:34 ` [PATCH v8 2/6] drm/xe/xe_gt_pagefault: Move pagefault struct to header Jonathan Cavitt
2025-03-14 17:01   ` Michal Wajdeczko
2025-03-14 22:06     ` Cavitt, Jonathan
2025-03-15 14:45       ` Michal Wajdeczko
2025-03-17 20:55         ` Cavitt, Jonathan
2025-03-18  8:44           ` Michal Wajdeczko
2025-03-13 18:34 ` [PATCH v8 3/6] drm/xe/uapi: Define drm_xe_vm_get_property Jonathan Cavitt
2025-03-13 22:10   ` Jianxun Zhang [this message]
2025-03-13 18:34 ` [PATCH v8 4/6] drm/xe/xe_gt_pagefault: Add address_type field to pagefaults Jonathan Cavitt
2025-03-13 18:34 ` [PATCH v8 5/6] drm/xe/xe_vm: Add per VM fault info Jonathan Cavitt
2025-03-13 18:34 ` [PATCH v8 6/6] drm/xe/xe_vm: Implement xe_vm_get_property_ioctl Jonathan Cavitt
2025-03-18 17:48   ` Jianxun Zhang
2025-03-18 18:12     ` Cavitt, Jonathan
2025-03-18 20:21       ` Jianxun Zhang
2025-03-19 23:58   ` Jianxun Zhang
2025-03-20 14:10     ` Cavitt, Jonathan
2025-03-13 19:10 ` ✓ CI.Patch_applied: success for drm/xe/xe_vm: Implement xe_vm_get_property_ioctl (rev8) Patchwork
2025-03-13 19:10 ` ✗ CI.checkpatch: warning " Patchwork
2025-03-13 19:12 ` ✓ CI.KUnit: success " Patchwork
2025-03-13 19:24 ` ✗ CI.Build: failure " Patchwork
2025-03-13 21:26   ` Cavitt, Jonathan
2025-03-13 22:12 ` ✓ CI.Patch_applied: success for drm/xe/xe_vm: Implement xe_vm_get_property_ioctl (rev9) Patchwork
2025-03-13 22:12 ` ✗ CI.checkpatch: warning " Patchwork
2025-03-13 22:13 ` ✓ CI.KUnit: success " Patchwork
2025-03-13 22:19 ` ✗ CI.Build: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2dcbd24b-e9cb-4a67-9e9b-3bd38ec8cef5@intel.com \
    --to=jianxun.zhang@intel.com \
    --cc=Michal.Wajdeczko@intel.com \
    --cc=alex.zuo@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=matthew.brost@intel.com \
    --cc=michal.mzorek@intel.com \
    --cc=saurabhg.gupta@intel.com \
    --cc=shuicheng.lin@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.