intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes
@ 2023-03-29 17:33 Matt Roper
  2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
                   ` (7 more replies)
  0 siblings, 8 replies; 12+ messages in thread
From: Matt Roper @ 2023-03-29 17:33 UTC (permalink / raw)
  To: intel-xe; +Cc: matthew.d.roper

Xe's internal batchbuffer code is not properly considering the hardware
prefetch requirements.  It is also emitting duplicate
MI_BATCH_BUFFER_END instructions in the workaround batchbuffer.

Matt Roper (3):
  drm/xe: Include hardware prefetch buffer in batchbuffer allocations
  drm/xe: Adjust batchbuffer space warning when creating a job
  drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer

 drivers/gpu/drm/xe/xe_bb.c | 29 +++++++++++++++++++++++++----
 drivers/gpu/drm/xe/xe_gt.c |  2 --
 2 files changed, 25 insertions(+), 6 deletions(-)

-- 
2.39.2


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
@ 2023-03-29 17:33 ` Matt Roper
  2023-03-31 20:14   ` Lucas De Marchi
  2023-03-29 17:33 ` [Intel-xe] [PATCH 2/3] drm/xe: Adjust batchbuffer space warning when creating a job Matt Roper
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Matt Roper @ 2023-03-29 17:33 UTC (permalink / raw)
  To: intel-xe; +Cc: matthew.d.roper

The hardware prefetches several cachelines of data from batchbuffers
before they are parsed.  This prefetching only stops when the parser
encounters an MI_BATCH_BUFFER_END instruction (or a nested
MI_BATCH_BUFFER_START), so we must ensure that there is enough padding
at the end of the batchbuffer to prevent the prefetcher from running
past the end of the allocation and potentially faulting.

Bspec: 45717
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/xe/xe_bb.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
index 5b24018e2a80..f326f117ba3b 100644
--- a/drivers/gpu/drm/xe/xe_bb.c
+++ b/drivers/gpu/drm/xe/xe_bb.c
@@ -8,11 +8,26 @@
 #include "regs/xe_gpu_commands.h"
 #include "xe_device.h"
 #include "xe_engine_types.h"
+#include "xe_gt.h"
 #include "xe_hw_fence.h"
 #include "xe_sa.h"
 #include "xe_sched_job.h"
 #include "xe_vm_types.h"
 
+static int bb_prefetch(struct xe_gt *gt)
+{
+	struct xe_device *xe = gt->xe;
+
+	if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
+		/*
+		 * RCS and CCS require 1K, although other engines would be
+		 * okay with 512.
+		 */
+		return SZ_1K;
+	else
+		return SZ_512;
+}
+
 struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
 {
 	struct xe_bb *bb = kmalloc(sizeof(*bb), GFP_KERNEL);
@@ -21,8 +36,14 @@ struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
 	if (!bb)
 		return ERR_PTR(-ENOMEM);
 
-	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool :
-			      &gt->usm.bb_pool, 4 * dwords + 4);
+	/*
+	 * We need to allocate space for the requested number of dwords,
+	 * one additional MI_BATCH_BUFFER_END dword, and additional buffer
+	 * space to accomodate the platform-specific hardware prefetch
+	 * requirements.
+	 */
+	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : &gt->usm.bb_pool,
+			      4 * (dwords + 1) + bb_prefetch(gt));
 	if (IS_ERR(bb->bo)) {
 		err = PTR_ERR(bb->bo);
 		goto err;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Intel-xe] [PATCH 2/3] drm/xe: Adjust batchbuffer space warning when creating a job
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
  2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
@ 2023-03-29 17:33 ` Matt Roper
  2023-03-29 17:33 ` [Intel-xe] [PATCH 3/3] drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer Matt Roper
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Matt Roper @ 2023-03-29 17:33 UTC (permalink / raw)
  To: intel-xe; +Cc: matthew.d.roper

We should WARN (not BUG) when creating a job if the batchbuffer does not
have sufficient space and padding.  The hardware prefetch requirements
should also be considered.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/xe/xe_bb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
index f326f117ba3b..7172801ee570 100644
--- a/drivers/gpu/drm/xe/xe_bb.c
+++ b/drivers/gpu/drm/xe/xe_bb.c
@@ -63,10 +63,10 @@ __xe_bb_create_job(struct xe_engine *kernel_eng, struct xe_bb *bb, u64 *addr)
 {
 	u32 size = drm_suballoc_size(bb->bo);
 
-	XE_BUG_ON((bb->len * 4 + 1) > size);
-
 	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
+	WARN_ON(bb->len * 4 + bb_prefetch(kernel_eng->gt) > size);
+
 	xe_sa_bo_flush_write(bb->bo);
 
 	return xe_sched_job_create(kernel_eng, addr);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Intel-xe] [PATCH 3/3] drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
  2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
  2023-03-29 17:33 ` [Intel-xe] [PATCH 2/3] drm/xe: Adjust batchbuffer space warning when creating a job Matt Roper
@ 2023-03-29 17:33 ` Matt Roper
  2023-03-29 17:36 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes Patchwork
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Matt Roper @ 2023-03-29 17:33 UTC (permalink / raw)
  To: intel-xe; +Cc: matthew.d.roper

The MI_BATCH_BUFFER_END is already added automatically by
__xe_bb_create_job(); including it in the construction of the workaround
batchbuffer results in an unnecessary duplicate.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/xe/xe_gt.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index fd7a5b43ba3e..bc821f431c45 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -203,8 +203,6 @@ static int emit_wa_job(struct xe_gt *gt, struct xe_engine *e)
 			bb->cs[bb->len++] = entry->set_bits;
 		}
 	}
-	bb->cs[bb->len++] = MI_NOOP;
-	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	batch_ofs = xe_bo_ggtt_addr(gt->kernel_bb_pool.bo);
 	job = xe_bb_create_wa_job(e, bb, batch_ofs);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
                   ` (2 preceding siblings ...)
  2023-03-29 17:33 ` [Intel-xe] [PATCH 3/3] drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer Matt Roper
@ 2023-03-29 17:36 ` Patchwork
  2023-03-29 17:36 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2023-03-29 17:36 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

== Series Details ==

Series: Minor batchbuffer handling fixes
URL   : https://patchwork.freedesktop.org/series/115812/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: ===
commit 5de0375b04455c7c8e516f53715eedde50f5ae45
Author:     Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
AuthorDate: Thu Mar 23 15:05:18 2023 +0100
Commit:     Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
CommitDate: Wed Mar 29 11:24:42 2023 +0200

    drm/xe: Display api changes update
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
=== git am output follows ===
Applying: drm/xe: Include hardware prefetch buffer in batchbuffer allocations
Applying: drm/xe: Adjust batchbuffer space warning when creating a job
Applying: drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Intel-xe] ✗ CI.KUnit: failure for Minor batchbuffer handling fixes
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
                   ` (3 preceding siblings ...)
  2023-03-29 17:36 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes Patchwork
@ 2023-03-29 17:36 ` Patchwork
  2023-03-29 18:20   ` Michal Wajdeczko
  2023-03-29 17:59 ` [Intel-xe] [PATCH 0/3] " Souza, Jose
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 12+ messages in thread
From: Patchwork @ 2023-03-29 17:36 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

== Series Details ==

Series: Minor batchbuffer handling fixes
URL   : https://patchwork.freedesktop.org/series/115812/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/drivers/chan_user.c:6:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/x86/um/os-Linux/registers.c:8:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/drivers/fd.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/execvp.c:24:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[4]: *** [../scripts/Makefile.build:252: arch/x86/um/os-Linux/registers.o] Error 1
make[3]: *** [../scripts/Makefile.build:494: arch/x86/um/os-Linux] Error 2
make[3]: *** Waiting for unfinished jobs....
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/file.c:8:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/execvp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:252: arch/um/drivers/fd.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:252: arch/um/drivers/chan_user.o] Error 1
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/skas/process.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/file.o] Error 1
make[4]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/skas/process.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:494: arch/um/os-Linux/skas] Error 2
make[2]: *** [../scripts/Makefile.build:494: arch/um/os-Linux] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [../scripts/Makefile.build:494: arch/x86/um] Error 2
make[2]: *** [../scripts/Makefile.build:494: arch/um/drivers] Error 2
In file included from /usr/include/stdlib.h:1013,
                 from arch/um/kernel/config.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[3]: *** [../scripts/Makefile.build:252: arch/um/kernel/config.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [../scripts/Makefile.build:494: arch/um/kernel] Error 2
make[1]: *** [/kernel/Makefile:2025: .] Error 2
make: *** [Makefile:226: __sub-make] Error 2

[17:36:29] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[17:36:33] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
                   ` (4 preceding siblings ...)
  2023-03-29 17:36 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
@ 2023-03-29 17:59 ` Souza, Jose
  2023-03-29 18:08 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes (rev2) Patchwork
  2023-03-29 18:09 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Souza, Jose @ 2023-03-29 17:59 UTC (permalink / raw)
  To: intel-xe, Roper,  Matthew D

On Wed, 2023-03-29 at 10:33 -0700, Matt Roper wrote:
> Xe's internal batchbuffer code is not properly considering the hardware
> prefetch requirements.  It is also emitting duplicate
> MI_BATCH_BUFFER_END instructions in the workaround batchbuffer.
> 
> Matt Roper (3):
>   drm/xe: Include hardware prefetch buffer in batchbuffer allocations
>   drm/xe: Adjust batchbuffer space warning when creating a job
>   drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer
> 
>  drivers/gpu/drm/xe/xe_bb.c | 29 +++++++++++++++++++++++++----
>  drivers/gpu/drm/xe/xe_gt.c |  2 --
>  2 files changed, 25 insertions(+), 6 deletions(-)
> 

Whole series is Reviewed-by: José Roberto de Souza <jose.souza@intel.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes (rev2)
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
                   ` (5 preceding siblings ...)
  2023-03-29 17:59 ` [Intel-xe] [PATCH 0/3] " Souza, Jose
@ 2023-03-29 18:08 ` Patchwork
  2023-03-29 18:09 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2023-03-29 18:08 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

== Series Details ==

Series: Minor batchbuffer handling fixes (rev2)
URL   : https://patchwork.freedesktop.org/series/115812/
State : success

== Summary ==

=== Applying kernel patches on branch 'drm-xe-next' with base: ===
commit 5de0375b04455c7c8e516f53715eedde50f5ae45
Author:     Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
AuthorDate: Thu Mar 23 15:05:18 2023 +0100
Commit:     Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
CommitDate: Wed Mar 29 11:24:42 2023 +0200

    drm/xe: Display api changes update
    
    Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
=== git am output follows ===
Applying: drm/xe: Include hardware prefetch buffer in batchbuffer allocations
Applying: drm/xe: Adjust batchbuffer space warning when creating a job
Applying: drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer



^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Intel-xe] ✗ CI.KUnit: failure for Minor batchbuffer handling fixes (rev2)
  2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
                   ` (6 preceding siblings ...)
  2023-03-29 18:08 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes (rev2) Patchwork
@ 2023-03-29 18:09 ` Patchwork
  7 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2023-03-29 18:09 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

== Series Details ==

Series: Minor batchbuffer handling fixes (rev2)
URL   : https://patchwork.freedesktop.org/series/115812/
State : failure

== Summary ==

+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
ERROR:root:In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/helper.c:6:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/irq.c:8:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/execvp.c:24:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/x86/um/os-Linux/registers.c:8:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/drivers/fd.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/file.c:8:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/execvp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[4]: *** [../scripts/Makefile.build:252: arch/x86/um/os-Linux/registers.o] Error 1
make[3]: *** [../scripts/Makefile.build:494: arch/x86/um/os-Linux] Error 2
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/irq.o] Error 1
make[3]: *** [../scripts/Makefile.build:252: arch/um/drivers/fd.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/helper.o] Error 1
make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/file.o] Error 1
In file included from /usr/include/stdlib.h:1013,
                 from ../arch/um/os-Linux/skas/process.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[4]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/skas/process.o] Error 1
make[3]: *** [../scripts/Makefile.build:494: arch/um/os-Linux/skas] Error 2
make[2]: *** [../scripts/Makefile.build:494: arch/um/os-Linux] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [../scripts/Makefile.build:494: arch/um/drivers] Error 2
make[2]: *** [../scripts/Makefile.build:494: arch/x86/um] Error 2
In file included from /usr/include/stdlib.h:1013,
                 from arch/um/kernel/config.c:7:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
   26 | {
      | ^
make[3]: *** [../scripts/Makefile.build:252: arch/um/kernel/config.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [../scripts/Makefile.build:494: arch/um/kernel] Error 2
make[1]: *** [/kernel/Makefile:2025: .] Error 2
make: *** [Makefile:226: __sub-make] Error 2

[18:08:34] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[18:08:38] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-xe]  ✗ CI.KUnit: failure for Minor batchbuffer handling fixes
  2023-03-29 17:36 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
@ 2023-03-29 18:20   ` Michal Wajdeczko
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Wajdeczko @ 2023-03-29 18:20 UTC (permalink / raw)
  To: intel-xe, Matt Roper


On 29.03.2023 19:36, Patchwork wrote:
> == Series Details ==
> 
> Series: Minor batchbuffer handling fixes
> URL   : https://patchwork.freedesktop.org/series/115812/
> State : failure
> 
> == Summary ==
> 
> + trap cleanup EXIT
> + /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig

below patch [1] worked for me to avoid such build errors on my system

[1]
https://lore.kernel.org/lkml/20230318041555.4192172-1-davidgow@google.com/raw

> ERROR:root:In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/um/drivers/chan_user.c:6:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/x86/um/os-Linux/registers.c:8:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/um/drivers/fd.c:7:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/um/os-Linux/execvp.c:24:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> make[4]: *** [../scripts/Makefile.build:252: arch/x86/um/os-Linux/registers.o] Error 1
> make[3]: *** [../scripts/Makefile.build:494: arch/x86/um/os-Linux] Error 2
> make[3]: *** Waiting for unfinished jobs....
> In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/um/os-Linux/file.c:8:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/execvp.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
> make[3]: *** [../scripts/Makefile.build:252: arch/um/drivers/fd.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
> make[3]: *** [../scripts/Makefile.build:252: arch/um/drivers/chan_user.o] Error 1
> In file included from /usr/include/stdlib.h:1013,
>                  from ../arch/um/os-Linux/skas/process.c:7:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> make[3]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/file.o] Error 1
> make[4]: *** [../scripts/Makefile.build:252: arch/um/os-Linux/skas/process.o] Error 1
> make[4]: *** Waiting for unfinished jobs....
> make[3]: *** [../scripts/Makefile.build:494: arch/um/os-Linux/skas] Error 2
> make[2]: *** [../scripts/Makefile.build:494: arch/um/os-Linux] Error 2
> make[2]: *** Waiting for unfinished jobs....
> make[2]: *** [../scripts/Makefile.build:494: arch/x86/um] Error 2
> make[2]: *** [../scripts/Makefile.build:494: arch/um/drivers] Error 2
> In file included from /usr/include/stdlib.h:1013,
>                  from arch/um/kernel/config.c:7:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h: In function ‘atof’:
> /usr/include/x86_64-linux-gnu/bits/stdlib-float.h:26:1: error: SSE register return with SSE disabled
>    26 | {
>       | ^
> make[3]: *** [../scripts/Makefile.build:252: arch/um/kernel/config.o] Error 1
> make[3]: *** Waiting for unfinished jobs....
> make[2]: *** [../scripts/Makefile.build:494: arch/um/kernel] Error 2
> make[1]: *** [/kernel/Makefile:2025: .] Error 2
> make: *** [Makefile:226: __sub-make] Error 2
> 
> [17:36:29] Configuring KUnit Kernel ...
> Generating .config ...
> Populating config with:
> $ make ARCH=um O=.kunit olddefconfig
> [17:36:33] Building KUnit Kernel ...
> Populating config with:
> $ make ARCH=um O=.kunit olddefconfig
> Building with:
> $ make ARCH=um O=.kunit --jobs=48
> + cleanup
> ++ stat -c %u:%g /kernel
> + chown -R 1003:1003 /kernel
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations
  2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
@ 2023-03-31 20:14   ` Lucas De Marchi
  2023-03-31 20:34     ` Matt Roper
  0 siblings, 1 reply; 12+ messages in thread
From: Lucas De Marchi @ 2023-03-31 20:14 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-xe

On Wed, Mar 29, 2023 at 10:33:32AM -0700, Matt Roper wrote:
>The hardware prefetches several cachelines of data from batchbuffers
>before they are parsed.  This prefetching only stops when the parser
>encounters an MI_BATCH_BUFFER_END instruction (or a nested
>MI_BATCH_BUFFER_START), so we must ensure that there is enough padding
>at the end of the batchbuffer to prevent the prefetcher from running
>past the end of the allocation and potentially faulting.
>
>Bspec: 45717
>Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
>---
> drivers/gpu/drm/xe/xe_bb.c | 25 +++++++++++++++++++++++--
> 1 file changed, 23 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
>index 5b24018e2a80..f326f117ba3b 100644
>--- a/drivers/gpu/drm/xe/xe_bb.c
>+++ b/drivers/gpu/drm/xe/xe_bb.c
>@@ -8,11 +8,26 @@
> #include "regs/xe_gpu_commands.h"
> #include "xe_device.h"
> #include "xe_engine_types.h"
>+#include "xe_gt.h"
> #include "xe_hw_fence.h"
> #include "xe_sa.h"
> #include "xe_sched_job.h"
> #include "xe_vm_types.h"
>
>+static int bb_prefetch(struct xe_gt *gt)
>+{
>+	struct xe_device *xe = gt->xe;
>+
>+	if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
>+		/*
>+		 * RCS and CCS require 1K, although other engines would be
>+		 * okay with 512.
>+		 */
>+		return SZ_1K;
>+	else
>+		return SZ_512;
>+}
>+
> struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> {
> 	struct xe_bb *bb = kmalloc(sizeof(*bb), GFP_KERNEL);
>@@ -21,8 +36,14 @@ struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> 	if (!bb)
> 		return ERR_PTR(-ENOMEM);
>
>-	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool :
>-			      &gt->usm.bb_pool, 4 * dwords + 4);
>+	/*
>+	 * We need to allocate space for the requested number of dwords,
>+	 * one additional MI_BATCH_BUFFER_END dword, and additional buffer
>+	 * space to accomodate the platform-specific hardware prefetch
>+	 * requirements.
>+	 */
>+	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : &gt->usm.bb_pool,
>+			      4 * (dwords + 1) + bb_prefetch(gt));

if the command buffer for the CS is 512 or 1024, wouldn't it be
sufficient to just align the end rather than increase it by that?

Lucas De Marchi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations
  2023-03-31 20:14   ` Lucas De Marchi
@ 2023-03-31 20:34     ` Matt Roper
  0 siblings, 0 replies; 12+ messages in thread
From: Matt Roper @ 2023-03-31 20:34 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: intel-xe

On Fri, Mar 31, 2023 at 01:14:15PM -0700, Lucas De Marchi wrote:
> On Wed, Mar 29, 2023 at 10:33:32AM -0700, Matt Roper wrote:
> > The hardware prefetches several cachelines of data from batchbuffers
> > before they are parsed.  This prefetching only stops when the parser
> > encounters an MI_BATCH_BUFFER_END instruction (or a nested
> > MI_BATCH_BUFFER_START), so we must ensure that there is enough padding
> > at the end of the batchbuffer to prevent the prefetcher from running
> > past the end of the allocation and potentially faulting.
> > 
> > Bspec: 45717
> > Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_bb.c | 25 +++++++++++++++++++++++--
> > 1 file changed, 23 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
> > index 5b24018e2a80..f326f117ba3b 100644
> > --- a/drivers/gpu/drm/xe/xe_bb.c
> > +++ b/drivers/gpu/drm/xe/xe_bb.c
> > @@ -8,11 +8,26 @@
> > #include "regs/xe_gpu_commands.h"
> > #include "xe_device.h"
> > #include "xe_engine_types.h"
> > +#include "xe_gt.h"
> > #include "xe_hw_fence.h"
> > #include "xe_sa.h"
> > #include "xe_sched_job.h"
> > #include "xe_vm_types.h"
> > 
> > +static int bb_prefetch(struct xe_gt *gt)
> > +{
> > +	struct xe_device *xe = gt->xe;
> > +
> > +	if (GRAPHICS_VERx100(xe) >= 1250 && !xe_gt_is_media_type(gt))
> > +		/*
> > +		 * RCS and CCS require 1K, although other engines would be
> > +		 * okay with 512.
> > +		 */
> > +		return SZ_1K;
> > +	else
> > +		return SZ_512;
> > +}
> > +
> > struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> > {
> > 	struct xe_bb *bb = kmalloc(sizeof(*bb), GFP_KERNEL);
> > @@ -21,8 +36,14 @@ struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
> > 	if (!bb)
> > 		return ERR_PTR(-ENOMEM);
> > 
> > -	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool :
> > -			      &gt->usm.bb_pool, 4 * dwords + 4);
> > +	/*
> > +	 * We need to allocate space for the requested number of dwords,
> > +	 * one additional MI_BATCH_BUFFER_END dword, and additional buffer
> > +	 * space to accomodate the platform-specific hardware prefetch
> > +	 * requirements.
> > +	 */
> > +	bb->bo = xe_sa_bo_new(!usm ? &gt->kernel_bb_pool : &gt->usm.bb_pool,
> > +			      4 * (dwords + 1) + bb_prefetch(gt));
> 
> if the command buffer for the CS is 512 or 1024, wouldn't it be
> sufficient to just align the end rather than increase it by that?

I thought that initially, but the spec indicates that the prefetch
doesn't just happen in .5K chunks or whatever, but that they're
continuously happening as each command in the batch buffer is executed.
So if you complete a 1 DW instructions, a new DW is prefetched at the
current HEAD + 0.5K.  If that falls outside the batchbuffer (and
potentially outside the bound pages), the hardware can fault.

The MI_BATCH_BUFFER_START bspec page (45718) also gives some more
clarity on this:

        "It keeps fetching command data as and when space is available
        in the storage upon execution of commands. In case of batch
        buffer execution, DMA engine stops prefetching the command data
        only on executing MI_BATCH_BUFFER_END command and
        MI_BATCH_BUFFER_START in case of chained batch buffers."


Matt

> 
> Lucas De Marchi

-- 
Matt Roper
Graphics Software Engineer
Linux GPU Platform Enablement
Intel Corporation

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-03-31 20:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 17:33 [Intel-xe] [PATCH 0/3] Minor batchbuffer handling fixes Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 1/3] drm/xe: Include hardware prefetch buffer in batchbuffer allocations Matt Roper
2023-03-31 20:14   ` Lucas De Marchi
2023-03-31 20:34     ` Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 2/3] drm/xe: Adjust batchbuffer space warning when creating a job Matt Roper
2023-03-29 17:33 ` [Intel-xe] [PATCH 3/3] drm/xe: Don't emit extra MI_BATCH_BUFFER_END in WA batchbuffer Matt Roper
2023-03-29 17:36 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes Patchwork
2023-03-29 17:36 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork
2023-03-29 18:20   ` Michal Wajdeczko
2023-03-29 17:59 ` [Intel-xe] [PATCH 0/3] " Souza, Jose
2023-03-29 18:08 ` [Intel-xe] ✓ CI.Patch_applied: success for Minor batchbuffer handling fixes (rev2) Patchwork
2023-03-29 18:09 ` [Intel-xe] ✗ CI.KUnit: failure " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).