[PATCH i-g-t 2/3] lib/xe_eudebug: Add support for exec queue placements events.

Manszewski, Christoph christoph.manszewski at intel.com
Wed Nov 13 11:02:13 UTC 2024


On 13.11.2024 09:51, Dominik Grzegorzek wrote:
> Adds definition and support for DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS,
> which is sent during exec_queue creation/discovery.
> 
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>

Reviewed-by: Christoph Manszewski <christoph.manszewski at intel.com>

> ---
>   lib/xe/xe_eudebug.c | 101 ++++++++++++++++++++++++++++++++++++++++++--
>   1 file changed, 97 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/xe/xe_eudebug.c b/lib/xe/xe_eudebug.c
> index 74aa26024..c5814421b 100644
> --- a/lib/xe/xe_eudebug.c
> +++ b/lib/xe/xe_eudebug.c
> @@ -77,6 +77,8 @@ static const char *type_to_str(unsigned int type)
>   		return "vm";
>   	case DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE:
>   		return "exec_queue";
> +	case DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS:
> +		return "exec_queue_placements";
>   	case DRM_XE_EUDEBUG_EVENT_EU_ATTENTION:
>   		return "attention";
>   	case DRM_XE_EUDEBUG_EVENT_VM_BIND:
> @@ -120,6 +122,18 @@ static const char *flags_to_str(unsigned int flags)
>   	return "flags unknown";
>   }
>   
> +static const char *eu_engine_class_to_str(uint16_t engine_class)
> +{
> +	switch (engine_class) {
> +	case DRM_XE_ENGINE_CLASS_COMPUTE:
> +		return "ccs";
> +	case DRM_XE_ENGINE_CLASS_RENDER:
> +		return "rcs";
> +	default:
> +		return "unsupported class";
> +	}
> +}
> +
>   static const char *event_members_to_str(struct drm_xe_eudebug_event *e, char *buf)
>   {
>   	switch (e->type) {
> @@ -145,6 +159,26 @@ static const char *event_members_to_str(struct drm_xe_eudebug_event *e, char *bu
>   			ee->exec_queue_handle, ee->engine_class, ee->width);
>   		break;
>   	}
> +	case DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS: {
> +		struct drm_xe_eudebug_event_exec_queue_placements *ee = (void *)e;
> +		struct drm_xe_engine_class_instance *instances = (void *)(ee->instances);
> +		int i, l;
> +
> +		l = sprintf(buf, "client_handle=%llu, vm_handle=%llu, "
> +			    "exec_queue_handle=%llu, lrc_handle=%llu, "
> +			    "num_placements=%d, gt_id=%d, mask=[",
> +			    ee->client_handle, ee->vm_handle,
> +			    ee->exec_queue_handle, ee->lrc_handle,
> +			    ee->num_placements, instances[0].gt_id);
> +
> +		for (i = 0; i < ee->num_placements; i++)
> +			l += sprintf(buf + l, "%s%d pad%d, ",
> +				     eu_engine_class_to_str(instances[i].engine_class),
> +				     instances[i].engine_instance, instances[i].pad);
> +		buf[l - 2] = ']';
> +
> +		break;
> +	}
>   	case DRM_XE_EUDEBUG_EVENT_EU_ATTENTION: {
>   		struct drm_xe_eudebug_event_eu_attention *ea = (void *)e;
>   
> @@ -423,6 +457,17 @@ static int match_fields(struct drm_xe_eudebug_event *a, void *data)
>   			ret = 1;
>   		break;
>   	}
> +	case DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS: {
> +		struct drm_xe_eudebug_event_exec_queue_placements *ae = (void *)a;
> +		struct drm_xe_eudebug_event_exec_queue_placements *be = (void *)b;
> +
> +		if (ae->num_placements == be->num_placements &&
> +		    memcmp(ae->instances, be->instances,
> +			   sizeof(uint64_t) * ae->num_placements) == 0)
> +			ret = 1;
> +
> +		break;
> +	}
>   	case DRM_XE_EUDEBUG_EVENT_VM_BIND: {
>   		struct drm_xe_eudebug_event_vm_bind *ea = (void *)a;
>   		struct drm_xe_eudebug_event_vm_bind *eb = (void *)b;
> @@ -490,6 +535,13 @@ static int match_client_handle(struct drm_xe_eudebug_event *e, void *data)
>   			return 1;
>   		break;
>   	}
> +	case DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS: {
> +		struct drm_xe_eudebug_event_exec_queue_placements *ee = (void *)e;
> +
> +		if (ee->client_handle == h)
> +			return 1;
> +		break;
> +	}
>   	case DRM_XE_EUDEBUG_EVENT_VM_BIND: {
>   		struct drm_xe_eudebug_event_vm_bind *evmb = (void *)e;
>   
> @@ -986,10 +1038,11 @@ xe_eudebug_event_log_match_opposite(struct xe_eudebug_event_log *l, uint32_t fil
>   			if (XE_EUDEBUG_EVENT_IS_FILTERED(ev1->type, filter))
>   				continue;
>   
> -			/* No opposite matching for binds */
> +			/* No opposite matching for some events */
>   			if ((ev1->type >= DRM_XE_EUDEBUG_EVENT_VM_BIND &&
>   			     ev1->type <= DRM_XE_EUDEBUG_EVENT_VM_BIND_UFENCE) ||
> -			    ev1->type == DRM_XE_EUDEBUG_EVENT_VM_BIND_OP_METADATA)
> +			    ev1->type == DRM_XE_EUDEBUG_EVENT_VM_BIND_OP_METADATA ||
> +			    ev1->type == DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS)
>   				continue;
>   
>   			ev2 = opposite_event_match(l, ev1, ev1);
> @@ -1679,6 +1732,36 @@ static void exec_queue_event(struct xe_eudebug_client *c, uint32_t flags,
>   	xe_eudebug_event_log_write(c->log, (void *)&ee);
>   }
>   
> +static void exec_queue_placements_event(struct xe_eudebug_client *c,
> +					int client_fd, uint32_t vm_id,
> +					uint32_t exec_queue_handle,
> +					uint16_t width, uint16_t lrc_no,
> +					uint16_t num_placements,
> +					struct drm_xe_engine_class_instance *eci)
> +{
> +	struct drm_xe_eudebug_event_exec_queue_placements *ee;
> +	struct drm_xe_engine_class_instance *instances;
> +	size_t sz = sizeof(*ee) + num_placements * sizeof(uint64_t);
> +
> +	ee = calloc(1, sz);
> +	igt_assert(ee);
> +
> +	base_event(c, to_base(*ee), DRM_XE_EUDEBUG_EVENT_EXEC_QUEUE_PLACEMENTS,
> +		   DRM_XE_EUDEBUG_EVENT_CREATE, sz);
> +
> +	ee->client_handle = client_fd;
> +	ee->vm_handle = vm_id;
> +	ee->exec_queue_handle = exec_queue_handle;
> +	ee->num_placements = num_placements;
> +
> +	instances = (struct drm_xe_engine_class_instance *)(ee->instances);
> +	for (int j = 0; j < num_placements; j++)
> +		instances[j] = eci[j * width + lrc_no];
> +
> +	xe_eudebug_event_log_write(c->log, (void *)ee);
> +	free(ee);
> +}
> +
>   static void metadata_event(struct xe_eudebug_client *c, uint32_t flags,
>   			   int client_fd, uint32_t id, uint64_t type, uint64_t len)
>   {
> @@ -1853,6 +1936,7 @@ void xe_eudebug_client_vm_destroy(struct xe_eudebug_client *c, int fd, uint32_t
>   uint32_t xe_eudebug_client_exec_queue_create(struct xe_eudebug_client *c, int fd,
>   					     struct drm_xe_exec_queue_create *create)
>   {
> +	struct drm_xe_engine_class_instance *instances;
>   	struct drm_xe_ext_set_property *ext;
>   	bool send = false;
>   	uint16_t class;
> @@ -1860,7 +1944,8 @@ uint32_t xe_eudebug_client_exec_queue_create(struct xe_eudebug_client *c, int fd
>   	igt_assert(c);
>   	igt_assert(create);
>   
> -	class = ((struct drm_xe_engine_class_instance *)(create->instances))[0].engine_class;
> +	instances = (struct drm_xe_engine_class_instance *)(create->instances);
> +	class = instances[0].engine_class;
>   
>   	igt_assert_eq(igt_ioctl(fd, DRM_IOCTL_XE_EXEC_QUEUE_CREATE, create), 0);
>   
> @@ -1871,10 +1956,18 @@ uint32_t xe_eudebug_client_exec_queue_create(struct xe_eudebug_client *c, int fd
>   		    ext->value & DRM_XE_EXEC_QUEUE_EUDEBUG_FLAG_ENABLE)
>   			send = true;
>   
> -	if (send)
> +	if (send) {
>   		exec_queue_event(c, DRM_XE_EUDEBUG_EVENT_CREATE, fd, create->vm_id,
>   				 create->exec_queue_id, class, create->width);
>   
> +		for (int i = 0; i < create->width; i++) {
> +			exec_queue_placements_event(c, fd, create->vm_id, create->exec_queue_id,
> +						    create->width, i,
> +						    create->num_placements,
> +						    instances);
> +		}
> +	}
> +
>   	return create->exec_queue_id;
>   }
>   


More information about the igt-dev mailing list