Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Francois Dugast <francois.dugast@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t v2 5/9] lib/intel_compute: Add i915 path in compute library
Date: Fri, 8 Sep 2023 11:13:45 +0200	[thread overview]
Message-ID: <ZPrlyf9TLmKQiIBp@fdugast-desk.home> (raw)
In-Reply-To: <20230905133309.365109-6-zbigniew.kempczynski@intel.com>

On Tue, Sep 05, 2023 at 03:33:05PM +0200, Zbigniew Kempczyński wrote:
> Add code which fills requirement to run compute workload on i915.
> 
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> Cc: Christoph Manszewski <christoph.manszewski@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Cc: Mauro Carvalho Chehab <mchehab@kernel.org>

Reviewed-by: Francois Dugast <francois.dugast@intel.com>

> ---
>  lib/intel_compute.c | 50 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 49 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/intel_compute.c b/lib/intel_compute.c
> index a1e87ef46f..4344844825 100644
> --- a/lib/intel_compute.c
> +++ b/lib/intel_compute.c
> @@ -8,6 +8,7 @@
>  
>  #include <stdint.h>
>  
> +#include "i915/gem_create.h"
>  #include "igt.h"
>  #include "xe_drm.h"
>  #include "lib/igt_syncobj.h"
> @@ -38,6 +39,7 @@ struct bo_dict_entry {
>  	uint32_t size;
>  	void *data;
>  	const char *name;
> +	uint32_t handle;
>  };
>  
>  struct bo_execenv {
> @@ -47,6 +49,10 @@ struct bo_execenv {
>  	/* Xe part */
>  	uint32_t vm;
>  	uint32_t exec_queue;
> +
> +	/* i915 part */
> +	struct drm_i915_gem_execbuffer2 execbuf;
> +	struct drm_i915_gem_exec_object2 *obj;
>  };
>  
>  static void bo_execenv_create(int fd, struct bo_execenv *execenv)
> @@ -101,6 +107,33 @@ static void bo_execenv_bind(struct bo_execenv *execenv,
>  		}
>  
>  		syncobj_destroy(fd, sync.handle);
> +	} else {
> +		struct drm_i915_gem_execbuffer2 *execbuf = &execenv->execbuf;
> +		struct drm_i915_gem_exec_object2 *obj;
> +
> +		obj = calloc(entries, sizeof(*obj));
> +		execenv->obj = obj;
> +
> +		for (int i = 0; i < entries; i++) {
> +			bo_dict[i].handle = gem_create(fd, bo_dict[i].size);
> +			bo_dict[i].data = gem_mmap__device_coherent(fd, bo_dict[i].handle,
> +								    0, bo_dict[i].size,
> +								    PROT_READ | PROT_WRITE);
> +			igt_debug("[i: %2d name: %20s] handle: %u, data: %p, addr: %16llx, size: %llx\n",
> +				  i, bo_dict[i].name,
> +				  bo_dict[i].handle, bo_dict[i].data,
> +				  (long long)bo_dict[i].addr,
> +				  (long long)bo_dict[i].size);
> +
> +			obj[i].handle = bo_dict[i].handle;
> +			obj[i].offset = CANONICAL(bo_dict[i].addr);
> +			obj[i].flags = EXEC_OBJECT_PINNED | EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
> +			if (bo_dict[i].addr == ADDR_OUTPUT)
> +				obj[i].flags |= EXEC_OBJECT_WRITE;
> +		}
> +
> +		execbuf->buffers_ptr = to_user_pointer(obj);
> +		execbuf->buffer_count = entries;
>  	}
>  }
>  
> @@ -123,6 +156,12 @@ static void bo_execenv_unbind(struct bo_execenv *execenv,
>  		}
>  
>  		syncobj_destroy(fd, sync.handle);
> +	} else {
> +		for (int i = 0; i < entries; i++) {
> +			gem_close(fd, bo_dict[i].handle);
> +			munmap(bo_dict[i].data, bo_dict[i].size);
> +		}
> +		free(execenv->obj);
>  	}
>  }
>  
> @@ -130,8 +169,17 @@ static void bo_execenv_exec(struct bo_execenv *execenv, uint64_t start_addr)
>  {
>  	int fd = execenv->fd;
>  
> -	if (execenv->driver == INTEL_DRIVER_XE)
> +	if (execenv->driver == INTEL_DRIVER_XE) {
>  		xe_exec_wait(fd, execenv->exec_queue, start_addr);
> +	} else {
> +		struct drm_i915_gem_execbuffer2 *execbuf = &execenv->execbuf;
> +		struct drm_i915_gem_exec_object2 *obj = execenv->obj;
> +		int num_objects = execbuf->buffer_count;
> +
> +		execbuf->flags = I915_EXEC_RENDER;
> +		gem_execbuf(fd, execbuf);
> +		gem_sync(fd, obj[num_objects - 1].handle); /* batch handle */
> +	}
>  }
>  
>  /*
> -- 
> 2.34.1
> 

  reply	other threads:[~2023-09-08  9:14 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 13:33 [igt-dev] [PATCH i-g-t v2 0/9] Extend compute square to i915 and Xe Zbigniew Kempczyński
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 1/9] lib/intel_compute: Migrate xe_compute library to intel_compute Zbigniew Kempczyński
2023-09-06 16:42   ` Kamil Konieczny
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 2/9] lib/intel_compute: Add compatibility flags for running compute Zbigniew Kempczyński
2023-09-08  9:03   ` Francois Dugast
2023-09-08 11:07     ` Zbigniew Kempczyński
2023-09-08 11:29     ` Mauro Carvalho Chehab
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 3/9] lib/intel_compute: Reorganize the code for i915 version preparation Zbigniew Kempczyński
2023-09-08  9:05   ` Francois Dugast
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 4/9] lib/intel_compute: Add name field for debugging purposes Zbigniew Kempczyński
2023-09-08  9:05   ` Francois Dugast
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 5/9] lib/intel_compute: Add i915 path in compute library Zbigniew Kempczyński
2023-09-08  9:13   ` Francois Dugast [this message]
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 6/9] intel/gem_compute: Add test which runs compute workload on i915 Zbigniew Kempczyński
2023-09-08  9:15   ` Francois Dugast
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 7/9] lib/intel_compute: Add XeHP implementation of compute pipeline Zbigniew Kempczyński
2023-09-08 13:55   ` Francois Dugast
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 8/9] lib/intel_compute: Adding pvc compute pipeline implementation Zbigniew Kempczyński
2023-09-08 13:56   ` Francois Dugast
2023-09-05 13:33 ` [igt-dev] [PATCH i-g-t v2 9/9] tests/gem|xe_compute: Update documentation regarding test requirements Zbigniew Kempczyński
2023-09-08 13:56   ` Francois Dugast
2023-09-05 18:23 ` [igt-dev] ✗ Fi.CI.BAT: failure for Extend compute square to i915 and Xe (rev2) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZPrlyf9TLmKQiIBp@fdugast-desk.home \
    --to=francois.dugast@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=zbigniew.kempczynski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox