mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-01 13:20:25 +01:00
intel: Refactor intel_gem_create_context_engines()
This function was returning a int but there was no meaninfull errno code being returned, also context_id is a uint32_t what would be problematic if i915 even returned 2147483648(-1). So here changing the return type and add context_id pointer parameter. 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/18974>
This commit is contained in:
parent
f8c9b5a96b
commit
ce4a7e7d40
5 changed files with 33 additions and 24 deletions
|
|
@ -296,11 +296,9 @@ iris_create_engines_context(struct iris_context *ice, int priority)
|
|||
intel_engines_count(engines_info, INTEL_ENGINE_CLASS_COMPUTE) > 0)
|
||||
engine_classes[IRIS_BATCH_COMPUTE] = INTEL_ENGINE_CLASS_COMPUTE;
|
||||
|
||||
int engines_ctx =
|
||||
intel_gem_create_context_engines(fd, engines_info, num_batches,
|
||||
engine_classes);
|
||||
|
||||
if (engines_ctx < 0) {
|
||||
uint32_t engines_ctx;
|
||||
if (!intel_gem_create_context_engines(fd, engines_info, num_batches,
|
||||
engine_classes, &engines_ctx)) {
|
||||
free(engines_info);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,11 @@ intel_gem_supports_syncobj_wait(int fd)
|
|||
return ret == -1 && errno == ETIME;
|
||||
}
|
||||
|
||||
int
|
||||
bool
|
||||
intel_gem_create_context_engines(int fd,
|
||||
const struct intel_query_engine_info *info,
|
||||
int num_engines, enum intel_engine_class *engine_classes)
|
||||
int num_engines, enum intel_engine_class *engine_classes,
|
||||
uint32_t *context_id)
|
||||
{
|
||||
assert(info != NULL);
|
||||
assert(num_engines <= 64);
|
||||
|
|
@ -95,7 +96,7 @@ intel_gem_create_context_engines(int fd,
|
|||
engine_class == INTEL_ENGINE_CLASS_COPY ||
|
||||
engine_class == INTEL_ENGINE_CLASS_COMPUTE);
|
||||
if (engine_counts[engine_class] <= 0)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
/* Run through the engines reported by the kernel looking for the next
|
||||
* matching instance. We loop in case we want to create multiple
|
||||
|
|
@ -111,9 +112,8 @@ intel_gem_create_context_engines(int fd,
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (engine_instance < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (engine_instance < 0)
|
||||
return false;
|
||||
|
||||
engines_param.engines[i].engine_class = intel_engine_class_to_i915(engine_class);
|
||||
engines_param.engines[i].engine_instance = engine_instance;
|
||||
|
|
@ -136,9 +136,10 @@ intel_gem_create_context_engines(int fd,
|
|||
.extensions = (uintptr_t)&set_engines,
|
||||
};
|
||||
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_CREATE_EXT, &create) == -1)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return create.ctx_id;
|
||||
*context_id = create.ctx_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -159,9 +159,11 @@ intel_i915_query_alloc(int fd, uint64_t query_id, int32_t *query_length)
|
|||
|
||||
bool intel_gem_supports_syncobj_wait(int fd);
|
||||
|
||||
int intel_gem_create_context_engines(int fd,
|
||||
const struct intel_query_engine_info *info,
|
||||
int num_engines, enum intel_engine_class *engine_classes);
|
||||
bool
|
||||
intel_gem_create_context_engines(int fd,
|
||||
const struct intel_query_engine_info *info,
|
||||
int num_engines, enum intel_engine_class *engine_classes,
|
||||
uint32_t *context_id);
|
||||
|
||||
bool intel_gem_read_render_timestamp(int fd, uint64_t *value);
|
||||
|
||||
|
|
|
|||
|
|
@ -3155,15 +3155,19 @@ anv_device_setup_context(struct anv_device *device,
|
|||
for (uint32_t j = 0; j < queueCreateInfo->queueCount; j++)
|
||||
engine_classes[engine_count++] = queue_family->engine_class;
|
||||
}
|
||||
device->context_id =
|
||||
intel_gem_create_context_engines(device->fd,
|
||||
physical_device->engine_info,
|
||||
engine_count, engine_classes);
|
||||
if (!intel_gem_create_context_engines(device->fd,
|
||||
physical_device->engine_info,
|
||||
engine_count, engine_classes,
|
||||
(uint32_t *)&device->context_id))
|
||||
result = vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"kernel context creation failed");
|
||||
} else {
|
||||
assert(num_queues == 1);
|
||||
device->context_id = anv_gem_create_context(device);
|
||||
}
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
if (device->context_id == -1) {
|
||||
result = vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -2804,15 +2804,19 @@ anv_device_setup_context(struct anv_device *device,
|
|||
for (uint32_t j = 0; j < queueCreateInfo->queueCount; j++)
|
||||
engine_classes[engine_count++] = queue_family->engine_class;
|
||||
}
|
||||
device->context_id =
|
||||
intel_gem_create_context_engines(device->fd,
|
||||
physical_device->engine_info,
|
||||
engine_count, engine_classes);
|
||||
if (!intel_gem_create_context_engines(device->fd,
|
||||
physical_device->engine_info,
|
||||
engine_count, engine_classes,
|
||||
(uint32_t *)&device->context_id))
|
||||
result = vk_errorf(device, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"kernel context creation failed");
|
||||
} else {
|
||||
assert(num_queues == 1);
|
||||
device->context_id = anv_gem_create_context(device);
|
||||
}
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
if (device->context_id == -1) {
|
||||
result = vk_error(device, VK_ERROR_INITIALIZATION_FAILED);
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue