Commit ef5e3c2f authored by José Roberto de Souza's avatar José Roberto de Souza Committed by Rodrigo Vivi

drm/xe: Add max engine priority to xe query

Intel Vulkan driver needs to know what is the maximum priority to fill
a device info struct for applications.

Right now we getting this information by creating a engine and setting
priorities from min to high to know what is the maximum priority for
running process but this leads to info messages to be printed to
dmesg:

xe 0000:03:00.0: [drm] Ioctl argument check failed at drivers/gpu/drm/xe/xe_engine.c:178: value == DRM_SCHED_PRIORITY_HIGH && !capable(CAP_SYS_NICE)

It does not cause any harm but when executing a test suite like
crucible it causes thousands of those messages to be printed.

So here adding one more property to drm_xe_query_config to fetch the
max engine priority.

Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarJosé Roberto de Souza <jose.souza@intel.com>
Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 9bddebf1
...@@ -169,14 +169,20 @@ struct xe_engine *xe_engine_lookup(struct xe_file *xef, u32 id) ...@@ -169,14 +169,20 @@ struct xe_engine *xe_engine_lookup(struct xe_file *xef, u32 id)
return e; return e;
} }
enum xe_engine_priority
xe_engine_device_get_max_priority(struct xe_device *xe)
{
return capable(CAP_SYS_NICE) ? XE_ENGINE_PRIORITY_HIGH :
XE_ENGINE_PRIORITY_NORMAL;
}
static int engine_set_priority(struct xe_device *xe, struct xe_engine *e, static int engine_set_priority(struct xe_device *xe, struct xe_engine *e,
u64 value, bool create) u64 value, bool create)
{ {
if (XE_IOCTL_ERR(xe, value > XE_ENGINE_PRIORITY_HIGH)) if (XE_IOCTL_ERR(xe, value > XE_ENGINE_PRIORITY_HIGH))
return -EINVAL; return -EINVAL;
if (XE_IOCTL_ERR(xe, value == XE_ENGINE_PRIORITY_HIGH && if (XE_IOCTL_ERR(xe, value > xe_engine_device_get_max_priority(xe)))
!capable(CAP_SYS_NICE)))
return -EPERM; return -EPERM;
return e->ops->set_priority(e, value); return e->ops->set_priority(e, value);
......
...@@ -54,5 +54,6 @@ int xe_engine_set_property_ioctl(struct drm_device *dev, void *data, ...@@ -54,5 +54,6 @@ int xe_engine_set_property_ioctl(struct drm_device *dev, void *data,
struct drm_file *file); struct drm_file *file);
int xe_engine_get_property_ioctl(struct drm_device *dev, void *data, int xe_engine_get_property_ioctl(struct drm_device *dev, void *data,
struct drm_file *file); struct drm_file *file);
enum xe_engine_priority xe_engine_device_get_max_priority(struct xe_device *xe);
#endif #endif
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "xe_bo.h" #include "xe_bo.h"
#include "xe_device.h" #include "xe_device.h"
#include "xe_engine.h"
#include "xe_ggtt.h" #include "xe_ggtt.h"
#include "xe_gt.h" #include "xe_gt.h"
#include "xe_guc_hwconfig.h" #include "xe_guc_hwconfig.h"
...@@ -194,6 +195,8 @@ static int query_config(struct xe_device *xe, struct drm_xe_device_query *query) ...@@ -194,6 +195,8 @@ static int query_config(struct xe_device *xe, struct drm_xe_device_query *query)
config->info[XE_QUERY_CONFIG_GT_COUNT] = xe->info.tile_count; config->info[XE_QUERY_CONFIG_GT_COUNT] = xe->info.tile_count;
config->info[XE_QUERY_CONFIG_MEM_REGION_COUNT] = config->info[XE_QUERY_CONFIG_MEM_REGION_COUNT] =
hweight_long(xe->info.mem_region_mask); hweight_long(xe->info.mem_region_mask);
config->info[XE_QUERY_CONFIG_MAX_ENGINE_PRIORITY] =
xe_engine_device_get_max_priority(xe);
if (copy_to_user(query_ptr, config, size)) { if (copy_to_user(query_ptr, config, size)) {
kfree(config); kfree(config);
......
...@@ -184,7 +184,8 @@ struct drm_xe_query_config { ...@@ -184,7 +184,8 @@ struct drm_xe_query_config {
#define XE_QUERY_CONFIG_VA_BITS 3 #define XE_QUERY_CONFIG_VA_BITS 3
#define XE_QUERY_CONFIG_GT_COUNT 4 #define XE_QUERY_CONFIG_GT_COUNT 4
#define XE_QUERY_CONFIG_MEM_REGION_COUNT 5 #define XE_QUERY_CONFIG_MEM_REGION_COUNT 5
#define XE_QUERY_CONFIG_NUM_PARAM XE_QUERY_CONFIG_MEM_REGION_COUNT + 1 #define XE_QUERY_CONFIG_MAX_ENGINE_PRIORITY 6
#define XE_QUERY_CONFIG_NUM_PARAM XE_QUERY_CONFIG_MAX_ENGINE_PRIORITY + 1
__u64 info[]; __u64 info[];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment