anv: Fetch max_context_priority from drm_xe_query_config

A new property was added to drm_xe_query_config with the max engine
priority for running process, so we can use it directly on
anv_xe_physical_device_get_parameters() and nuke
anv_xe_physical_device_max_priority_update().

Signed-off-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22112>
This commit is contained in:
José Roberto de Souza 2023-03-23 13:19:01 -07:00 committed by Marge Bot
parent 972d2a89d9
commit f868c1727d
4 changed files with 49 additions and 68 deletions

View File

@ -805,20 +805,6 @@ anv_physical_device_get_parameters(struct anv_physical_device *device)
}
}
static void
anv_physical_device_max_priority_update(struct anv_physical_device *device)
{
switch (device->info.kmd_type) {
case INTEL_KMD_TYPE_I915:
break;
case INTEL_KMD_TYPE_XE:
anv_xe_physical_device_max_priority_update(device);
break;
default:
unreachable("Missing");
}
}
static VkResult
anv_physical_device_try_create(struct vk_instance *vk_instance,
struct _drmDevice *drm_device,
@ -1004,7 +990,6 @@ anv_physical_device_try_create(struct vk_instance *vk_instance,
device->info.has_compute_engine = intel_engines_count(device->engine_info,
INTEL_ENGINE_CLASS_COMPUTE);
anv_physical_device_init_queue_families(device);
anv_physical_device_max_priority_update(device);
anv_physical_device_init_perf(device, fd);

View File

@ -46,18 +46,6 @@ VkResult anv_xe_device_setup_vm(struct anv_device *device)
return VK_SUCCESS;
}
VkResult
anv_xe_physical_device_get_parameters(struct anv_physical_device *device)
{
device->has_exec_timeline = true;
/* max_context_priority will be updated in
* anv_xe_physical_device_max_priority_update()
*/
device->max_context_priority = VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR;
return VK_SUCCESS;
}
enum drm_sched_priority
anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority)
{
@ -74,51 +62,60 @@ anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority)
}
}
void
anv_xe_physical_device_max_priority_update(struct anv_physical_device *device)
static VkQueueGlobalPriorityKHR
drm_sched_priority_to_vk_priority(enum drm_sched_priority drm_sched_priority)
{
if (!device->engine_info->num_engines)
return;
switch (drm_sched_priority) {
case DRM_SCHED_PRIORITY_MIN:
return VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR;
case DRM_SCHED_PRIORITY_NORMAL:
return VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR;
case DRM_SCHED_PRIORITY_HIGH:
return VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR;
default:
unreachable("Invalid drm_sched_priority");
return VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR;
}
}
struct drm_xe_vm_create create_vm = {};
if (intel_ioctl(device->local_fd, DRM_IOCTL_XE_VM_CREATE, &create_vm))
return;
static void *
xe_query_alloc_fetch(struct anv_physical_device *device, uint32_t query_id)
{
struct drm_xe_device_query query = {
.query = query_id,
};
if (intel_ioctl(device->local_fd, DRM_IOCTL_XE_DEVICE_QUERY, &query))
return NULL;
const VkQueueGlobalPriorityKHR priorities[] = {
VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR,
VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR,
VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR,
};
struct drm_xe_engine_destroy destroy_engine;
struct drm_xe_vm_destroy destroy_vm = {
.vm_id = create_vm.vm_id,
};
struct drm_xe_engine_create create_engine = {
.instances = (uintptr_t)device->engine_info->engines,
.width = 1,
.num_placements = 1,
.vm_id = create_vm.vm_id,
};
if (intel_ioctl(device->local_fd, DRM_IOCTL_XE_ENGINE_CREATE,
&create_engine))
goto destroy_vm;
void *data = calloc(1, query.size);
if (!data)
return NULL;
for (unsigned i = 0; i < ARRAY_SIZE(priorities); i++) {
struct drm_xe_engine_set_property engine_property = {
.engine_id = create_engine.engine_id,
.property = XE_ENGINE_SET_PROPERTY_PRIORITY,
engine_property.value = anv_vk_priority_to_drm_sched_priority(priorities[i]),
};
if (intel_ioctl(device->local_fd, DRM_IOCTL_XE_ENGINE_SET_PROPERTY,
&engine_property))
break;
device->max_context_priority = priorities[i];
query.data = (uintptr_t)data;
if (intel_ioctl(device->local_fd, DRM_IOCTL_XE_DEVICE_QUERY, &query)) {
free(data);
return NULL;
}
destroy_engine.engine_id = create_engine.engine_id;
intel_ioctl(device->local_fd, DRM_IOCTL_XE_ENGINE_DESTROY, &destroy_engine);
destroy_vm:
intel_ioctl(device->local_fd, DRM_IOCTL_XE_VM_DESTROY, &destroy_vm);
return data;
}
VkResult
anv_xe_physical_device_get_parameters(struct anv_physical_device *device)
{
struct drm_xe_query_config *config;
config = xe_query_alloc_fetch(device, DRM_XE_DEVICE_QUERY_CONFIG);
if (!config)
return vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED,
"unable to query device config");
device->has_exec_timeline = true;
device->max_context_priority =
drm_sched_priority_to_vk_priority(config->info[XE_QUERY_CONFIG_MAX_ENGINE_PRIORITY]);
free(config);
return VK_SUCCESS;
}
VkResult

View File

@ -38,7 +38,5 @@ VkResult anv_xe_device_check_status(struct vk_device *vk_device);
VkResult
anv_xe_physical_device_get_parameters(struct anv_physical_device *device);
void
anv_xe_physical_device_max_priority_update(struct anv_physical_device *device);
enum drm_sched_priority
anv_vk_priority_to_drm_sched_priority(VkQueueGlobalPriorityKHR vk_priority);

View File

@ -30,6 +30,7 @@
#include "xe/anv_device.h"
#include "drm-uapi/xe_drm.h"
#include "drm-uapi/gpu_scheduler.h"
VkResult
anv_xe_create_engine(struct anv_device *device,