Skip to contentSkip to conversation

Use drm_clflush* instead of clflush

PATCH Superseded Michael Cheng 4 participants 8 messages Jan 27, 2022 – Jan 29, 2022

Subsystems (2)

v1 of 13 Superseded Latest is v13 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 drm/i915/gt: Re-work intel_write_status_page

In reply to Michael Cheng

Re-work intel_write_status_page to use drm_clflush_virt_range. This will prevent compiler errors when building for non-x86 architectures.

---
 drivers/gpu/drm/i915/gt/intel_engine.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +4 -9
index 08559ace0ada..e6189fffa7a3 100644
@@ -4,6 +4,7 @@
 
 #include <asm/cacheflush.h>
 #include <drm/drm_util.h>
+#include <drm/drm_cache.h>
 
 #include <linux/hashtable.h>
 #include <linux/irq_work.h>
@@ -144,15 +145,9 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)
 	 * of extra paranoia to try and ensure that the HWS takes the value
 	 * we give and that it doesn't end up trapped inside the CPU!
 	 */
-	if (static_cpu_has(X86_FEATURE_CLFLUSH)) {
-		mb();
-		clflush(&engine->status_page.addr[reg]);
-		engine->status_page.addr[reg] = value;
-		clflush(&engine->status_page.addr[reg]);
-		mb();
-	} else {
-		WRITE_ONCE(engine->status_page.addr[reg], value);
-	}
+	drm_clflush_virt_range(&engine->status_page.addr[reg], PAGE_SIZE);
+	WRITE_ONCE(engine->status_page.addr[reg], value);
+	drm_clflush_virt_range(&engine->status_page.addr[reg], PAGE_SIZE);
 }
 
 /*
Signature · 1 line
2.25.1
#4 lore raw

PATCH 2/2 drm/i915/gt: Re-work invalidate_csb_entries

In reply to Michael Cheng

Re-work invalidate_csb_entries to use drm_clflush_virt_range. This will prevent compiler errors when building for non-x86 architectures.

---
 drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +2 -2
index 960a9aaf4f3a..90b5daf9433d 100644
@@ -1647,8 +1647,8 @@ cancel_port_requests(struct intel_engine_execlists * const execlists,
 
 static void invalidate_csb_entries(const u64 *first, const u64 *last)
 {
-	clflush((void *)first);
-	clflush((void *)last);
+	drm_clflush_virt_range((void *)first, sizeof(*first));
+	drm_clflush_virt_range((void *)last, sizeof(*last));
 }
 
 /*
Signature · 1 line
2.25.1
#0 lore raw

cover Use drm_clflush* instead of clflush

This patch series re-work a few i915 functions to use drm_clflush_virt_range instead of calling clflush directly. This will prevent errors when building for non-x86 architectures.

Michael Cheng (2):
drm/i915/gt: Re-work intel_write_status_page
drm/i915/gt: Re-work invalidate_csb_entries

 drivers/gpu/drm/i915/gt/intel_engine.h              | 13 ++++---------
 .../gpu/drm/i915/gt/intel_execlists_submission.c    |  4 ++--
 2 files changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
2.25.1
#6 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for Use drm_clflush* instead of clflush

== Series Details ==

== Series Details ==

Series: Use drm_clflush* instead of clflush
URL : https://patchwork.freedesktop.org/series/99450/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
#7 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for Use drm_clflush* instead of clflush

In reply to Michael Cheng
== Series Details ==

== Series Details ==

Series: Use drm_clflush* instead of clflush
URL : https://patchwork.freedesktop.org/series/99450/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_11154 -> Patchwork_22132
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_22132 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_22132, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/index.html

Participating hosts (43 -> 41)
------------------------------

Additional (1): fi-pnv-d510
Missing (3): fi-bsw-cyan fi-icl-u2 fi-bdw-samus

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_22132:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@gt_mocs:
- bat-dg1-6: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11154/bat-dg1-6/igt@i915_selftest@live@gt_mocs.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/bat-dg1-6/igt@i915_selftest@live@gt_mocs.html

Known issues
------------

Here are the changes found in Patchwork_22132 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_cs_nop@sync-fork-compute0:
- fi-snb-2600: NOTRUN -> [SKIP][3] ([fdo#109271]) +17 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-snb-2600/igt@amdgpu/[email protected]

* igt@amdgpu/amd_cs_nop@sync-fork-gfx0:
- fi-skl-6600u: NOTRUN -> [SKIP][4] ([fdo#109271]) +17 similar issues
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-skl-6600u/igt@amdgpu/[email protected]

* igt@i915_selftest@live@hangcheck:
- bat-dg1-5: [PASS][5] -> [DMESG-FAIL][6] ([i915#4494] / [i915#4957])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11154/bat-dg1-5/igt@i915_selftest@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/bat-dg1-5/igt@i915_selftest@[email protected]
- fi-hsw-4770: [PASS][7] -> [INCOMPLETE][8] ([i915#4785])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11154/fi-hsw-4770/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-hsw-4770/igt@i915_selftest@[email protected]

* igt@prime_vgem@basic-userptr:
- fi-pnv-d510: NOTRUN -> [SKIP][9] ([fdo#109271]) +57 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-pnv-d510/igt@[email protected]

* igt@runner@aborted:
- fi-hsw-4770: NOTRUN -> [FAIL][10] ([fdo#109271] / [i915#1436] / [i915#4312])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-hsw-4770/igt@[email protected]
- bat-dg1-6: NOTRUN -> [FAIL][11] ([i915#4312])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/bat-dg1-6/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@hangcheck:
- fi-snb-2600: [INCOMPLETE][12] ([i915#3921]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_11154/fi-snb-2600/igt@i915_selftest@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/fi-snb-2600/igt@i915_selftest@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1436]: https://gitlab.freedesktop.org/drm/intel/issues/1436
[i915#3921]: https://gitlab.freedesktop.org/drm/intel/issues/3921
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4494]: https://gitlab.freedesktop.org/drm/intel/issues/4494
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#4897]: https://gitlab.freedesktop.org/drm/intel/issues/4897
[i915#4957]: https://gitlab.freedesktop.org/drm/intel/issues/4957

Build changes
-------------

* Linux: CI_DRM_11154 -> Patchwork_22132

CI-20190529: 20190529
CI_DRM_11154: 401e42aa274384a2660ad4b54af9ef6a86429cb1 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6336: ae2eb9e18bc58a4c45f28cfd80962938198dec3c @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_22132: 83fa55f11e7b79ce579f3f23dbf7c9bf14655bcc @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

83fa55f11e7b drm/i915/gt: Re-work invalidate_csb_entries 926d9e54027d drm/i915/gt: Re-work intel_write_status_page

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_22132/index.html

#2 lore raw

Re: [Intel-gfx] [PATCH 1/2] drm/i915/gt: Re-work intel_write_status_page

In reply to Michael Cheng
Quoted 27 lines · Michael Cheng

Re-work intel_write_status_page to use drm_clflush_virt_range. This will prevent compiler errors when building for non-x86 architectures.

---
 drivers/gpu/drm/i915/gt/intel_engine.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +1 -2
index 08559ace0ada..e6189fffa7a3 100644
@@ -4,6 +4,7 @@
 
 #include <asm/cacheflush.h>
 #include <drm/drm_util.h>
+#include <drm/drm_cache.h>
 
 #include <linux/hashtable.h>
 #include <linux/irq_work.h>
@@ -144,15 +145,9 @@ intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value)
         * of extra paranoia to try and ensure that the HWS takes the value
         * we give and that it doesn't end up trapped inside the CPU!
         */
-       if (static_cpu_has(X86_FEATURE_CLFLUSH)) {
-               mb();

drivers/gpu/drm/i915/gt/intel_engine.h intel_write_status_page(struct intel_engine_cs *engine, int reg, u32 value) · line 150

Quoted 10 lines
drivers/gpu/drm/i915/gt/intel_engine.h +3 -7
-               clflush(&engine->status_page.addr[reg]);
-               engine->status_page.addr[reg] = value;
-               clflush(&engine->status_page.addr[reg]);
-               mb();
-       } else {
-               WRITE_ONCE(engine->status_page.addr[reg], value);
-       }
+       drm_clflush_virt_range(&engine->status_page.addr[reg], PAGE_SIZE);
+       WRITE_ONCE(engine->status_page.addr[reg], value);
+       drm_clflush_virt_range(&engine->status_page.addr[reg], PAGE_SIZE);

s/PAGE_SIZE/sizeof(value) ?

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_engine.h +0 -1
 }
 
 /*
 
--

2.25.1

Reviewed-by on v1 2/2
#5 lore raw

Re: [Intel-gfx] [PATCH 2/2] drm/i915/gt: Re-work invalidate_csb_entries

In reply to Michael Cheng
Quoted 14 lines · Michael Cheng

Re-work invalidate_csb_entries to use drm_clflush_virt_range. This will prevent compiler errors when building for non-x86 architectures.

---
 drivers/gpu/drm/i915/gt/intel_execlists_submission.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +0 -0
index 960a9aaf4f3a..90b5daf9433d 100644

drivers/gpu/drm/i915/gt/intel_execlists_submission.c cancel_port_requests(struct intel_engine_execlists * const execlists, · line 1651

Quoted 7 lines
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +2 -2
@@ -1647,8 +1647,8 @@ cancel_port_requests(struct intel_engine_execlists * const execlists,
 
 static void invalidate_csb_entries(const u64 *first, const u64 *last)
 {
-       clflush((void *)first);
-       clflush((void *)last);
+       drm_clflush_virt_range((void *)first, sizeof(*first));
+       drm_clflush_virt_range((void *)last, sizeof(*last));

Could maybe drop the (void *) casting,

Quoted 6 lines
drivers/gpu/drm/i915/gt/intel_execlists_submission.c +0 -1
 }
 
 /*
--

2.25.1

Reviewed-by on v1 1/2
#3 lore raw

Re: [Intel-gfx] [PATCH 1/2] drm/i915/gt: Re-work intel_write_status_page

In reply to Michael Cheng
Quoted 13 lines

-----Original Message-----
From: Cheng, Michael <[email protected]>
Sent: Thursday, January 27, 2022 3:41 PM
To: [email protected]
Cc: Cheng, Michael <[email protected]>; Bowman, Casey G <[email protected]>; De Marchi, Lucas <[email protected]>; Boyer, Wayne <[email protected]>; [email protected]; Kuoppala, Mika <[email protected]>; [email protected]
Subject: [PATCH 1/2] drm/i915/gt: Re-work intel_write_status_page

Quoted 4 lines

Re-work intel_write_status_page to use drm_clflush_virt_range. This will prevent compiler errors when building for non-x86 architectures.

Quoted 41 lines
---
 drivers/gpu/drm/i915/gt/intel_engine.h | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine.h +4 -9
index 08559ace0ada..e6189fffa7a3 100644
@@ -4,6 +4,7 @@
 
 #include <asm/cacheflush.h>
 #include <drm/drm_util.h>
+#include <drm/drm_cache.h>
 
 #include <linux/hashtable.h>
 #include <linux/irq_work.h>
@@ -144,15 +145,9 @@ intel_write_status_page(struct intel_engine_cs
 *engine, int reg, u32 value)
 	 * of extra paranoia to try and ensure that the HWS takes the value
 	 * we give and that it doesn't end up trapped inside the CPU!
 	 */
-	if (static_cpu_has(X86_FEATURE_CLFLUSH)) {
-		mb();
-		clflush(&engine->status_page.addr[reg]);
-		engine->status_page.addr[reg] = value;
-		clflush(&engine->status_page.addr[reg]);
-		mb();
-	} else {
-		WRITE_ONCE(engine->status_page.addr[reg], value);
-	}
+	drm_clflush_virt_range(&engine->status_page.addr[reg],
 PAGE_SIZE);
+	WRITE_ONCE(engine->status_page.addr[reg], value);
+	drm_clflush_virt_range(&engine->status_page.addr[reg],
 PAGE_SIZE);

}

/*
--
2.25.1