From: Francois Dugast <francois.dugast@intel.com>
To: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
Cc: <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t v3 09/11] lib/intel_blt: add support for matrix mem-copy
Date: Wed, 28 May 2025 10:23:41 +0200 [thread overview]
Message-ID: <aDbIDROnBnbIbMOM@fdugast-desk> (raw)
In-Reply-To: <20250523080126.75295-10-zbigniew.kempczynski@intel.com>
On Fri, May 23, 2025 at 10:01:24AM +0200, Zbigniew Kempczyński wrote:
> Linear copy in intel_blt supports passing large buffers (which
> requires to be spread over couple mem-copies). For matrix this is
> a little bit more complicated so I left simple case in which
Patch LGTM but a nit: impersonal style is preferred over "I did X".
With that:
Reviewed-by: Francois Dugast <francois.dugast@intel.com>
> pitch/width/height must be within mem-copy command limits -
> 18-bit width * 18-bit height gives 64GiB object so testing
> copying bigger buffer would be an overkill.
>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
> ---
> lib/intel_blt.c | 69 +++++++++++++++++++++++++++++++++----------------
> 1 file changed, 47 insertions(+), 22 deletions(-)
>
> diff --git a/lib/intel_blt.c b/lib/intel_blt.c
> index 265f5ed50f..77a03aff4e 100644
> --- a/lib/intel_blt.c
> +++ b/lib/intel_blt.c
> @@ -1893,17 +1893,18 @@ static uint64_t emit_blt_mem_copy(int fd, uint64_t ahnd,
> {
> struct xe_mem_copy_data data = {};
> uint64_t dst_offset, src_offset, shift;
> - uint32_t height, width_max, remain;
> + uint32_t width, height, width_max, height_max, remain;
> uint32_t bbe = MI_BATCH_BUFFER_END;
> uint32_t *bb;
>
> if (mem->mode == MODE_BYTE) {
> data.dw01.byte_copy.width = -1;
> - width_max = data.dw01.byte_copy.width + 1;
> + height_max = width_max = data.dw01.byte_copy.width + 1;
> shift = width_max;
> } else {
> data.dw01.page_copy.width = -1;
> width_max = data.dw01.page_copy.width + 1;
> + height_max = 1;
> shift = width_max << 8;
> }
>
> @@ -1914,6 +1915,7 @@ static uint64_t emit_blt_mem_copy(int fd, uint64_t ahnd,
>
> bb = bo_map(fd, mem->bb.handle, mem->bb.size, mem->driver);
>
> + width = mem->src.width;
> height = mem->dst.height;
>
> data.dw00.client = 0x2;
> @@ -1930,34 +1932,57 @@ static uint64_t emit_blt_mem_copy(int fd, uint64_t ahnd,
> data.dw09.src_mocs = mem->src.mocs_index;
> data.dw09.dst_mocs = mem->dst.mocs_index;
>
> - remain = mem->src.width;
> + /* For matrix we don't iterate */
> + if (mem->copy_type == TYPE_MATRIX) {
> + if (width > width_max) {
> + width = width_max;
> + igt_warn("src width is bigger than max width [%u > %u => %u], truncating it\n",
> + mem->src.width, width_max, width);
> + }
>
> - /* Truncate pitches to match operation bits */
> - if (mem->src.pitch > width_max)
> - data.dw03.src_pitch = width_max - 1;
> - else
> - data.dw03.src_pitch = mem->src.pitch;
> + if (height > height_max) {
> + height = height_max;
> + igt_warn("src height is bigger than max height [%u > %u => %u], truncating it\n",
> + mem->src.height, height_max, height);
> + }
>
> - if (mem->dst.pitch > width_max)
> - data.dw04.dst_pitch = width_max - 1;
> - else
> - data.dw04.dst_pitch = mem->dst.pitch;
> -
> - while (remain) {
> - data.dw01.val = min_t(uint32_t, width_max, remain) - 1;
> + data.dw01.byte_copy.width = width - 1;
> + data.dw03.src_pitch = mem->src.pitch - 1;
> + data.dw04.dst_pitch = mem->dst.pitch - 1;
>
> igt_assert(bb_pos + sizeof(data) < mem->bb.size);
> memcpy(bb + bb_pos, &data, sizeof(data));
> bb_pos += sizeof(data);
> + } else {
> + remain = mem->src.width;
>
> - remain -= remain > width_max ? width_max : remain;
> - src_offset += shift;
> - dst_offset += shift;
> + /* Truncate pitches to match operation bits */
> + if (mem->src.pitch > width_max)
> + data.dw03.src_pitch = width_max - 1;
> + else
> + data.dw03.src_pitch = mem->src.pitch;
>
> - data.dw05.src_address_lo = src_offset;
> - data.dw06.src_address_hi = src_offset >> 32;
> - data.dw07.dst_address_lo = dst_offset;
> - data.dw08.dst_address_hi = dst_offset >> 32;
> + if (mem->dst.pitch > width_max)
> + data.dw04.dst_pitch = width_max - 1;
> + else
> + data.dw04.dst_pitch = mem->dst.pitch;
> +
> + while (remain) {
> + data.dw01.val = min_t(uint32_t, width_max, remain) - 1;
> +
> + igt_assert(bb_pos + sizeof(data) < mem->bb.size);
> + memcpy(bb + bb_pos, &data, sizeof(data));
> + bb_pos += sizeof(data);
> +
> + remain -= remain > width_max ? width_max : remain;
> + src_offset += shift;
> + dst_offset += shift;
> +
> + data.dw05.src_address_lo = src_offset;
> + data.dw06.src_address_hi = src_offset >> 32;
> + data.dw07.dst_address_lo = dst_offset;
> + data.dw08.dst_address_hi = dst_offset >> 32;
> + }
> }
>
> if (emit_bbe) {
> --
> 2.43.0
>
next prev parent reply other threads:[~2025-05-28 8:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-23 8:01 [PATCH i-g-t v3 00/11] Improve mem-copy/mem-set lib and tests Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 01/11] lib/intel_cmds_info: rename M to TYPE in blt_memop_type Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 02/11] lib/intel_blt: separate mem-copy and mem-set Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 03/11] lib/intel_cmds_info: add blt_memop_mode (byte/page) Zbigniew Kempczyński
2025-05-27 12:19 ` Francois Dugast
2025-05-23 8:01 ` [PATCH i-g-t v3 04/11] lib/intel_blt: add emit batchbuffer end Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 05/11] lib/intel_blt: use struct instead of inline coding Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 06/11] tests/xe_copy_basic: replace size to rect which keeps objects geometry Zbigniew Kempczyński
2025-05-27 19:15 ` Francois Dugast
2025-05-28 19:28 ` Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 07/11] tests/xe_copy_basic: add testcase with large buffer size Zbigniew Kempczyński
2025-05-27 19:16 ` Francois Dugast
2025-05-23 8:01 ` [PATCH i-g-t v3 08/11] tests/xe_copy_basic: add subtest to verify mem-copy in pages Zbigniew Kempczyński
2025-05-27 19:23 ` Francois Dugast
2025-05-30 6:10 ` Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 09/11] lib/intel_blt: add support for matrix mem-copy Zbigniew Kempczyński
2025-05-28 8:23 ` Francois Dugast [this message]
2025-05-30 6:17 ` Zbigniew Kempczyński
2025-05-23 8:01 ` [PATCH i-g-t v3 10/11] tests/xe_copy_basic: add mem-copy matrix subtests Zbigniew Kempczyński
2025-05-28 8:26 ` Francois Dugast
2025-05-23 8:01 ` [PATCH i-g-t v3 11/11] lib/intel_blt: add mem-copy debug facility Zbigniew Kempczyński
2025-05-28 8:29 ` Francois Dugast
2025-05-23 10:45 ` ✗ i915.CI.BAT: failure for Improve mem-copy/mem-set lib and tests (rev2) Patchwork
2025-05-23 11:36 ` ✓ Xe.CI.BAT: success " Patchwork
2025-05-23 19:54 ` ✓ Xe.CI.Full: " 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=aDbIDROnBnbIbMOM@fdugast-desk \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.