Add DRM_XE_DEVICE_QUERY_MEMPOLICY and struct drm_xe_query_mempolicy so userspace can discover which DRM_XE_GEM_CREATE_MEMPOLICY_MODE_* values the driver accepts in DRM_XE_GEM_CREATE_EXTENSION_SET_MEMPOLICY before creating a BO.
The reply carries a bitmask where bit n set means mode value n is supported. Requesting an unsupported mode fails with -EOPNOTSUPP. A kernel without the query returns -EINVAL for it, which userspace can treat as the extension being unavailable. Signed-off-by: Himal Prasad Ghimiray <[email protected]> --- include/uapi/drm/xe_drm.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/uapi/drm/xe_drm.h b/include/uapi/drm/xe_drm.h index 8818ed57b153..1db3202c4518 100644 --- a/include/uapi/drm/xe_drm.h +++ b/include/uapi/drm/xe_drm.h @@ -710,6 +710,7 @@ struct drm_xe_query_pxp_status { * - %DRM_XE_DEVICE_QUERY_OA_UNITS * - %DRM_XE_DEVICE_QUERY_PXP_STATUS * - %DRM_XE_DEVICE_QUERY_EU_STALL + * - %DRM_XE_DEVICE_QUERY_MEMPOLICY * * If size is set to 0, the driver fills it with the required size for * the requested type of data to query. If size is equal to the required @@ -764,6 +765,7 @@ struct drm_xe_device_query { #define DRM_XE_DEVICE_QUERY_OA_UNITS 8 #define DRM_XE_DEVICE_QUERY_PXP_STATUS 9 #define DRM_XE_DEVICE_QUERY_EU_STALL 10 +#define DRM_XE_DEVICE_QUERY_MEMPOLICY 11 /** @query: The type of data to query */ __u32 query; @@ -824,6 +826,30 @@ struct drm_xe_gem_create_mempolicy { __u64 maxnode; }; +/** + * struct drm_xe_query_mempolicy - Host NUMA mempolicy capabilities + * + * If the query field of struct drm_xe_device_query is equal to + * %DRM_XE_DEVICE_QUERY_MEMPOLICY, then the reply uses this structure. It + * reports which modes of %DRM_XE_GEM_CREATE_EXTENSION_SET_MEMPOLICY the + * driver supports. Requesting an unsupported mode fails with -EOPNOTSUPP. + * A kernel without this query returns -EINVAL for it and does not support + * the extension. + */ +struct drm_xe_query_mempolicy { + /** + * @supported_modes: Bitmask of supported modes, bit n set means + * %DRM_XE_GEM_CREATE_MEMPOLICY_MODE_* value n is supported + */ + __u32 supported_modes; + + /** @pad: MBZ */ + __u32 pad; + + /** @reserved: Reserved */ + __u64 reserved[3]; +}; + /** * struct drm_xe_gem_create - Input of &DRM_IOCTL_XE_GEM_CREATE - A structure for * gem creation -- 2.43.0
