Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally
@ 2026-08-03 23:01 Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 1/8] drm/xe/rtp: Maintain OA whitelists separately Ashutosh Dixit
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

Backport of the following series to Linux 7.1.y:

https://lore.kernel.org/intel-xe/20260615224227.34880-1-ashutosh.dixit@intel.com/

Ashutosh Dixit (8):
  drm/xe/rtp: Maintain OA whitelists separately
  drm/xe/rtp: Keep track of non-OA nonpriv slots
  drm/xe/rtp: Generalize whitelist_apply_to_hwe
  drm/xe/rtp: Save OA nonpriv registers to register save/restore lists
  drm/xe/rtp: Toggle 'deny' bit to (de-)whitelist OA regs
  drm/xe/rtp: (De-)whitelist OA registers for all hwe's for a gt
  drm/xe/oa: (De-)whitelist OA registers on OA stream open/release
  drm/xe/rtp: Ensure locking/ref counting for OA whitelists

 drivers/gpu/drm/xe/xe_gt_debugfs.c      |  4 +-
 drivers/gpu/drm/xe/xe_hw_engine.c       |  2 +
 drivers/gpu/drm/xe/xe_hw_engine_types.h |  8 +++
 drivers/gpu/drm/xe/xe_oa.c              |  7 ++
 drivers/gpu/drm/xe/xe_oa_types.h        |  3 +
 drivers/gpu/drm/xe/xe_reg_whitelist.c   | 87 +++++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_reg_whitelist.h   |  4 ++
 7 files changed, 108 insertions(+), 7 deletions(-)

-- 
2.54.0


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

* [PATCH 7.1.y 1/8] drm/xe/rtp: Maintain OA whitelists separately
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 2/8] drm/xe/rtp: Keep track of non-OA nonpriv slots Ashutosh Dixit
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit 31e2437561621b4867c08efc890bf629d017df03 ]

OA registers are dynamically whitelisted (and again dewhitelisted) on OA
stream open/close. Maintaining OA whitelists separately from non-OA
register whitlists simplifies this management of OA register
whitelisting/dewhitelisting.

(cherry picked from commit c478244a9e2d14b3f1f92e8bd293919e554622a5)
[ adapted RTP table from struct wrapper macro `XE_RTP_TABLE_SR()` back to plain `struct xe_rtp_entry_sr[]` array and restored the 5-arg `xe_rtp_process_to_sr()` call with `ARRAY_SIZE()` ]

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-3-ashutosh.dixit@intel.com
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
---
 drivers/gpu/drm/xe/xe_gt_debugfs.c      | 4 +++-
 drivers/gpu/drm/xe/xe_hw_engine.c       | 2 ++
 drivers/gpu/drm/xe/xe_hw_engine_types.h | 8 ++++++++
 drivers/gpu/drm/xe/xe_reg_whitelist.c   | 6 ++++++
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_gt_debugfs.c b/drivers/gpu/drm/xe/xe_gt_debugfs.c
index f45306308cd66..c38bcacb27e4a 100644
--- a/drivers/gpu/drm/xe/xe_gt_debugfs.c
+++ b/drivers/gpu/drm/xe/xe_gt_debugfs.c
@@ -149,8 +149,10 @@ static int register_save_restore(struct xe_gt *gt, struct drm_printer *p)
 	drm_printf(p, "\n");
 
 	drm_printf(p, "Whitelist\n");
-	for_each_hw_engine(hwe, gt, id)
+	for_each_hw_engine(hwe, gt, id) {
 		xe_reg_whitelist_dump(&hwe->reg_whitelist, p);
+		xe_reg_whitelist_dump(&hwe->oa_whitelist, p);
+	}
 
 	return 0;
 }
diff --git a/drivers/gpu/drm/xe/xe_hw_engine.c b/drivers/gpu/drm/xe/xe_hw_engine.c
index a7441a66e94c2..b5a869c720af7 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine.c
+++ b/drivers/gpu/drm/xe/xe_hw_engine.c
@@ -575,6 +575,8 @@ static void hw_engine_init_early(struct xe_gt *gt, struct xe_hw_engine *hwe,
 	hw_engine_setup_default_state(hwe);
 
 	xe_reg_sr_init(&hwe->reg_whitelist, hwe->name, gt_to_xe(gt));
+	xe_reg_sr_init(&hwe->oa_whitelist, hwe->name, gt_to_xe(gt));
+	xe_reg_sr_init(&hwe->oa_sr, hwe->name, gt_to_xe(gt));
 	xe_reg_whitelist_process_engine(hwe);
 }
 
diff --git a/drivers/gpu/drm/xe/xe_hw_engine_types.h b/drivers/gpu/drm/xe/xe_hw_engine_types.h
index e4191a7a2c318..04ca7545d22c3 100644
--- a/drivers/gpu/drm/xe/xe_hw_engine_types.h
+++ b/drivers/gpu/drm/xe/xe_hw_engine_types.h
@@ -128,6 +128,14 @@ struct xe_hw_engine {
 	 * @reg_whitelist: table with registers to be whitelisted
 	 */
 	struct xe_reg_sr reg_whitelist;
+	/**
+	 * @oa_whitelist: oa registers to be whitelisted
+	 */
+	struct xe_reg_sr oa_whitelist;
+	/**
+	 * @oa_sr: oa nonpriv whitelist registers, changed on oa stream open/close
+	 */
+	struct xe_reg_sr oa_sr;
 	/**
 	 * @reg_lrc: LRC workaround registers
 	 */
diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 506501d77f389..a0bbf4b745a1f 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -89,6 +89,9 @@ static const struct xe_rtp_entry_sr register_whitelist[] = {
 			 WHITELIST(VFLSKPD,
 				   RING_FORCE_TO_NONPRIV_ACCESS_RW))
 	},
+};
+
+static const struct xe_rtp_entry_sr oa_whitelist[] = {
 
 #define WHITELIST_DENY(r, f) WHITELIST(r, (f) | RING_FORCE_TO_NONPRIV_DENY)
 
@@ -193,6 +196,9 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 	xe_rtp_process_to_sr(&ctx, register_whitelist, ARRAY_SIZE(register_whitelist),
 			     &hwe->reg_whitelist, false);
 	whitelist_apply_to_hwe(hwe);
+
+	xe_rtp_process_to_sr(&ctx, oa_whitelist, ARRAY_SIZE(oa_whitelist),
+			     &hwe->oa_whitelist, false);
 }
 
 /**
-- 
2.54.0


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

* [PATCH 7.1.y 2/8] drm/xe/rtp: Keep track of non-OA nonpriv slots
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 1/8] drm/xe/rtp: Maintain OA whitelists separately Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 3/8] drm/xe/rtp: Generalize whitelist_apply_to_hwe Ashutosh Dixit
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit 15739920b71ef3c56868973b4e7e3164a793d09d ]

In order to dynamically whitelist/dewhitelist OA registers on OA stream
open/close, we need to keep track of nonpriv slots occupied by non-OA
register whitelists.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-4-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index a0bbf4b745a1f..00f00002afcef 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -147,7 +147,7 @@ static const struct xe_rtp_entry_sr oa_whitelist[] = {
 	},
 };
 
-static void whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
+static int whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
 {
 	struct xe_reg_sr *sr = &hwe->reg_whitelist;
 	struct xe_reg_sr_entry *entry;
@@ -179,6 +179,8 @@ static void whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
 
 		slot++;
 	}
+
+	return slot;
 }
 
 /**
@@ -192,10 +194,11 @@ static void whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
 void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 {
 	struct xe_rtp_process_ctx ctx = XE_RTP_PROCESS_CTX_INITIALIZER(hwe);
+	int first_oa_slot;
 
 	xe_rtp_process_to_sr(&ctx, register_whitelist, ARRAY_SIZE(register_whitelist),
 			     &hwe->reg_whitelist, false);
-	whitelist_apply_to_hwe(hwe);
+	first_oa_slot = whitelist_apply_to_hwe(hwe);
 
 	xe_rtp_process_to_sr(&ctx, oa_whitelist, ARRAY_SIZE(oa_whitelist),
 			     &hwe->oa_whitelist, false);
-- 
2.54.0


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

* [PATCH 7.1.y 3/8] drm/xe/rtp: Generalize whitelist_apply_to_hwe
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 1/8] drm/xe/rtp: Maintain OA whitelists separately Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 2/8] drm/xe/rtp: Keep track of non-OA nonpriv slots Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 4/8] drm/xe/rtp: Save OA nonpriv registers to register save/restore lists Ashutosh Dixit
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit c3ff77d7235ccef7a0883c2fd981f70ef3aafd21 ]

Generalize whitelist_apply_to_hwe to construct both non-OA and OA
whitelist nonpriv registers.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-5-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 00f00002afcef..1a7d69ef4fe82 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -147,9 +147,10 @@ static const struct xe_rtp_entry_sr oa_whitelist[] = {
 	},
 };
 
-static int whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
+static int whitelist_apply_to_hwe(struct xe_hw_engine *hwe, struct xe_reg_sr *in,
+				  struct xe_reg_sr *out, int first_slot)
 {
-	struct xe_reg_sr *sr = &hwe->reg_whitelist;
+	struct xe_reg_sr *sr = in;
 	struct xe_reg_sr_entry *entry;
 	struct drm_printer p;
 	unsigned long reg;
@@ -158,7 +159,7 @@ static int whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
 	xe_gt_dbg(hwe->gt, "Add %s whitelist to engine\n", sr->name);
 	p = xe_gt_dbg_printer(hwe->gt);
 
-	slot = 0;
+	slot = first_slot;
 	xa_for_each(&sr->xa, reg, entry) {
 		struct xe_reg_sr_entry hwe_entry = {
 			.reg = RING_FORCE_TO_NONPRIV(hwe->mmio_base, slot),
@@ -175,7 +176,7 @@ static int whitelist_apply_to_hwe(struct xe_hw_engine *hwe)
 		}
 
 		xe_reg_whitelist_print_entry(&p, 0, reg, entry);
-		xe_reg_sr_add(&hwe->reg_sr, &hwe_entry, hwe->gt);
+		xe_reg_sr_add(out, &hwe_entry, hwe->gt);
 
 		slot++;
 	}
@@ -198,7 +199,7 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 
 	xe_rtp_process_to_sr(&ctx, register_whitelist, ARRAY_SIZE(register_whitelist),
 			     &hwe->reg_whitelist, false);
-	first_oa_slot = whitelist_apply_to_hwe(hwe);
+	first_oa_slot = whitelist_apply_to_hwe(hwe, &hwe->reg_whitelist, &hwe->reg_sr, 0);
 
 	xe_rtp_process_to_sr(&ctx, oa_whitelist, ARRAY_SIZE(oa_whitelist),
 			     &hwe->oa_whitelist, false);
-- 
2.54.0


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

* [PATCH 7.1.y 4/8] drm/xe/rtp: Save OA nonpriv registers to register save/restore lists
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (2 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 3/8] drm/xe/rtp: Generalize whitelist_apply_to_hwe Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 5/8] drm/xe/rtp: Toggle 'deny' bit to (de-)whitelist OA regs Ashutosh Dixit
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit 3a3c3e56db2923daaf1a5353cd6463a4cdaf4ffa ]

Now we can save OA whitelisting nonpriv registers to register save/restore
lists. OA nonpriv registers are saved to both hwe->oa_sr as well as
hwe->reg_sr.

During probe, resume and gt-reset flows KMD will apply hwe->reg_sr,
ensuring OA registers are de-whitelisted after these events. For
engine-reset, hwe->reg_sr is registered with GuC and GuC will apply these
registers, ensuring OA registers are de-whitelisted after engine resets.

hwe->oa_sr is used for whitelisting or de-whitelisting OA registers during
OA operation, by toggling the 'deny' bit on oa stream open/close.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-6-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 1a7d69ef4fe82..dbaa387a35613 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -203,6 +203,17 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 
 	xe_rtp_process_to_sr(&ctx, oa_whitelist, ARRAY_SIZE(oa_whitelist),
 			     &hwe->oa_whitelist, false);
+	/*
+	 * Save oa nonpriv registers to hwe->oa_sr, from which oa registers are whitelisted
+	 * or de-whitelisted, by toggling the 'deny' bit on oa stream open/close
+	 */
+	whitelist_apply_to_hwe(hwe, &hwe->oa_whitelist, &hwe->oa_sr, first_oa_slot);
+
+	/*
+	 * Also save oa nonpriv registers to hwe->reg_sr, to ensure oa registers are not
+	 * whitelisted by default after probe, gt reset, resume and engine reset
+	 */
+	whitelist_apply_to_hwe(hwe, &hwe->oa_whitelist, &hwe->reg_sr, first_oa_slot);
 }
 
 /**
-- 
2.54.0


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

* [PATCH 7.1.y 5/8] drm/xe/rtp: Toggle 'deny' bit to (de-)whitelist OA regs
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (3 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 4/8] drm/xe/rtp: Save OA nonpriv registers to register save/restore lists Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 6/8] drm/xe/rtp: (De-)whitelist OA registers for all hwe's for a gt Ashutosh Dixit
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit aeaa7d2bb017272ab9e18759fe00bf758cd3299f ]

Whitelist or de-whitelist OA registers by setting or resetting the 'deny'
bit in OA nonpriv registers and writing new register values to HW.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-7-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index dbaa387a35613..1a53abbd9a74f 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -216,6 +216,21 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 	whitelist_apply_to_hwe(hwe, &hwe->oa_whitelist, &hwe->reg_sr, first_oa_slot);
 }
 
+__maybe_unused static void __whitelist_oa_regs(struct xe_hw_engine *hwe, bool whitelist)
+{
+	struct xe_reg_sr_entry *entry;
+	unsigned long reg;
+
+	xa_for_each(&hwe->oa_sr.xa, reg, entry) {
+		if (whitelist)
+			entry->set_bits &= ~RING_FORCE_TO_NONPRIV_DENY;
+		else
+			entry->set_bits |= RING_FORCE_TO_NONPRIV_DENY;
+	}
+
+	xe_reg_sr_apply_mmio(&hwe->oa_sr, hwe->gt);
+}
+
 /**
  * xe_reg_whitelist_print_entry - print one whitelist entry
  * @p: DRM printer
-- 
2.54.0


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

* [PATCH 7.1.y 6/8] drm/xe/rtp: (De-)whitelist OA registers for all hwe's for a gt
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (4 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 5/8] drm/xe/rtp: Toggle 'deny' bit to (de-)whitelist OA regs Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 7/8] drm/xe/oa: (De-)whitelist OA registers on OA stream open/release Ashutosh Dixit
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit 6f73bf8fffa728aa5d5ee143ba318fa0744113a2 ]

Whitelist or de-whitelist OA registers for all hwe's on the gt on which the
OA stream is opened. This simplifies the case where an oa unit has 0
attached hwe's (but which monitors OA events on the associated GT).

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-8-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 34 +++++++++++++++++++++++++--
 drivers/gpu/drm/xe/xe_reg_whitelist.h |  4 ++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 1a53abbd9a74f..2ecf273c5f401 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -9,7 +9,7 @@
 #include "regs/xe_gt_regs.h"
 #include "regs/xe_oa_regs.h"
 #include "xe_device.h"
-#include "xe_gt_types.h"
+#include "xe_gt.h"
 #include "xe_gt_printk.h"
 #include "xe_platform_types.h"
 #include "xe_reg_sr.h"
@@ -216,7 +216,7 @@ void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe)
 	whitelist_apply_to_hwe(hwe, &hwe->oa_whitelist, &hwe->reg_sr, first_oa_slot);
 }
 
-__maybe_unused static void __whitelist_oa_regs(struct xe_hw_engine *hwe, bool whitelist)
+static void __whitelist_oa_regs(struct xe_hw_engine *hwe, bool whitelist)
 {
 	struct xe_reg_sr_entry *entry;
 	unsigned long reg;
@@ -231,6 +231,36 @@ __maybe_unused static void __whitelist_oa_regs(struct xe_hw_engine *hwe, bool wh
 	xe_reg_sr_apply_mmio(&hwe->oa_sr, hwe->gt);
 }
 
+/**
+ * xe_reg_whitelist_oa_regs - whitelist oa registers for gt
+ * @gt: gt to whitelist oa registers for
+ *
+ * Whitelist OA registers by resetting RING_FORCE_TO_NONPRIV_DENY
+ */
+void xe_reg_whitelist_oa_regs(struct xe_gt *gt)
+{
+	struct xe_hw_engine *hwe;
+	enum xe_hw_engine_id id;
+
+	for_each_hw_engine(hwe, gt, id)
+		__whitelist_oa_regs(hwe, true);
+}
+
+/**
+ * xe_reg_dewhitelist_oa_regs - dewhitelist oa registers for gt
+ * @gt: gt to dewhitelist oa registers for
+ *
+ * Dewhitelist OA registers by setting RING_FORCE_TO_NONPRIV_DENY
+ */
+void xe_reg_dewhitelist_oa_regs(struct xe_gt *gt)
+{
+	struct xe_hw_engine *hwe;
+	enum xe_hw_engine_id id;
+
+	for_each_hw_engine(hwe, gt, id)
+		__whitelist_oa_regs(hwe, false);
+}
+
 /**
  * xe_reg_whitelist_print_entry - print one whitelist entry
  * @p: DRM printer
diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.h b/drivers/gpu/drm/xe/xe_reg_whitelist.h
index 69b121d377da0..f243b6ac60b7e 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.h
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.h
@@ -9,12 +9,16 @@
 #include <linux/types.h>
 
 struct drm_printer;
+struct xe_gt;
 struct xe_hw_engine;
 struct xe_reg_sr;
 struct xe_reg_sr_entry;
 
 void xe_reg_whitelist_process_engine(struct xe_hw_engine *hwe);
 
+void xe_reg_whitelist_oa_regs(struct xe_gt *gt);
+void xe_reg_dewhitelist_oa_regs(struct xe_gt *gt);
+
 void xe_reg_whitelist_print_entry(struct drm_printer *p, unsigned int indent,
 				  u32 reg, struct xe_reg_sr_entry *entry);
 
-- 
2.54.0


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

* [PATCH 7.1.y 7/8] drm/xe/oa: (De-)whitelist OA registers on OA stream open/release
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (5 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 6/8] drm/xe/rtp: (De-)whitelist OA registers for all hwe's for a gt Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-03 23:01 ` [PATCH 7.1.y 8/8] drm/xe/rtp: Ensure locking/ref counting for OA whitelists Ashutosh Dixit
  2026-08-05  1:13 ` [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Sasha Levin
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit f8e6874f46f19a6a2a0f24a81689f90641bb402a ]

Whitelist OA registers on stream open and de-whitelist on stream
close/release. Whitelisting is only done when 'stream->sample' is
true. 'stream->sample' is only true when (a) xe_observation_paranoid is set
to false by system admin, or (b) the process is perfmon_capable(). This
therefore enforces the OA register whitelisting security requirements.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-9-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_oa.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index d908f4e039063..5111c6519c6db 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -35,6 +35,7 @@
 #include "xe_oa.h"
 #include "xe_observation.h"
 #include "xe_pm.h"
+#include "xe_reg_whitelist.h"
 #include "xe_sched_job.h"
 #include "xe_sriov.h"
 #include "xe_sync.h"
@@ -866,6 +867,9 @@ static void xe_oa_stream_destroy(struct xe_oa_stream *stream)
 
 	mutex_destroy(&stream->stream_lock);
 
+	if (stream->sample)
+		xe_reg_dewhitelist_oa_regs(stream->gt);
+
 	xe_oa_disable_metric_set(stream);
 	xe_exec_queue_put(stream->k_exec_q);
 
@@ -1871,6 +1875,9 @@ static int xe_oa_stream_open_ioctl_locked(struct xe_oa *oa,
 		goto err_disable;
 	}
 
+	if (stream->sample)
+		xe_reg_whitelist_oa_regs(stream->gt);
+
 	/* Hold a reference on the drm device till stream_fd is released */
 	drm_dev_get(&stream->oa->xe->drm);
 
-- 
2.54.0


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

* [PATCH 7.1.y 8/8] drm/xe/rtp: Ensure locking/ref counting for OA whitelists
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (6 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 7/8] drm/xe/oa: (De-)whitelist OA registers on OA stream open/release Ashutosh Dixit
@ 2026-08-03 23:01 ` Ashutosh Dixit
  2026-08-05  1:13 ` [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Sasha Levin
  8 siblings, 0 replies; 11+ messages in thread
From: Ashutosh Dixit @ 2026-08-03 23:01 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman

[ Upstream commit 645f1a2589bd4782e25490e5ecc05b7043c36cbf ]

Since multiple OA streams might be open in parallel on a gt, ensure that
proper locking is in place. Also ensure that OA registers are whitelisted
when the first OA stream is open and de-whitelisted after the last OA
stream is closed.

Fixes: 828a8eaf37c3 ("drm/xe/oa: Add MMIO trigger support")
Cc: stable@vger.kernel.org # v6.12+
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Link: https://patch.msgid.link/20260615224227.34880-10-ashutosh.dixit@intel.com
---
 drivers/gpu/drm/xe/xe_oa_types.h      | 3 +++
 drivers/gpu/drm/xe/xe_reg_whitelist.c | 9 +++++++++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_oa_types.h b/drivers/gpu/drm/xe/xe_oa_types.h
index b03ffd5134834..c0ddfae755b6a 100644
--- a/drivers/gpu/drm/xe/xe_oa_types.h
+++ b/drivers/gpu/drm/xe/xe_oa_types.h
@@ -126,6 +126,9 @@ struct xe_oa_gt {
 
 	/** @oa_unit: array of oa_units */
 	struct xe_oa_unit *oa_unit;
+
+	/** @whitelist_count: number of open streams for which oa registers are whitelisted */
+	u32 whitelist_count;
 };
 
 /**
diff --git a/drivers/gpu/drm/xe/xe_reg_whitelist.c b/drivers/gpu/drm/xe/xe_reg_whitelist.c
index 2ecf273c5f401..dad47988bdf6d 100644
--- a/drivers/gpu/drm/xe/xe_reg_whitelist.c
+++ b/drivers/gpu/drm/xe/xe_reg_whitelist.c
@@ -242,6 +242,10 @@ void xe_reg_whitelist_oa_regs(struct xe_gt *gt)
 	struct xe_hw_engine *hwe;
 	enum xe_hw_engine_id id;
 
+	lockdep_assert_held(&gt->oa.gt_lock);
+	if (gt->oa.whitelist_count++)
+		return;
+
 	for_each_hw_engine(hwe, gt, id)
 		__whitelist_oa_regs(hwe, true);
 }
@@ -257,6 +261,11 @@ void xe_reg_dewhitelist_oa_regs(struct xe_gt *gt)
 	struct xe_hw_engine *hwe;
 	enum xe_hw_engine_id id;
 
+	lockdep_assert_held(&gt->oa.gt_lock);
+	xe_assert(gt_to_xe(gt), gt->oa.whitelist_count);
+	if (--gt->oa.whitelist_count)
+		return;
+
 	for_each_hw_engine(hwe, gt, id)
 		__whitelist_oa_regs(hwe, false);
 }
-- 
2.54.0


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

* Re: [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally
  2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
                   ` (7 preceding siblings ...)
  2026-08-03 23:01 ` [PATCH 7.1.y 8/8] drm/xe/rtp: Ensure locking/ref counting for OA whitelists Ashutosh Dixit
@ 2026-08-05  1:13 ` Sasha Levin
  2026-08-05  2:53   ` Dixit, Ashutosh
  8 siblings, 1 reply; 11+ messages in thread
From: Sasha Levin @ 2026-08-05  1:13 UTC (permalink / raw)
  To: stable; +Cc: Sasha Levin, Greg Kroah-Hartman, Ashutosh Dixit

On Mon, Aug 03, 2026 at 04:01:28PM -0700, Ashutosh Dixit wrote:
> Backport of the following series to Linux 7.1.y:
>
> https://lore.kernel.org/intel-xe/20260615224227.34880-1-ashutosh.dixit@intel.com/

Patches 2/8 through 8/8 tag "[ Upstream commit <sha> ]" with commits that
aren't in Linus' tree...

-- 
Thanks,
Sasha

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

* Re: [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally
  2026-08-05  1:13 ` [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Sasha Levin
@ 2026-08-05  2:53   ` Dixit, Ashutosh
  0 siblings, 0 replies; 11+ messages in thread
From: Dixit, Ashutosh @ 2026-08-05  2:53 UTC (permalink / raw)
  To: Sasha Levin; +Cc: stable, Greg Kroah-Hartman

On Tue, 04 Aug 2026 18:13:27 -0700, Sasha Levin wrote:
>
> On Mon, Aug 03, 2026 at 04:01:28PM -0700, Ashutosh Dixit wrote:
> > Backport of the following series to Linux 7.1.y:
> >
> > https://lore.kernel.org/intel-xe/20260615224227.34880-1-ashutosh.dixit@intel.com/
>
> Patches 2/8 through 8/8 tag "[ Upstream commit <sha> ]" with commits that
> aren't in Linus' tree...

Sorry about that. The new series with upstream commit sha's fixed is here:

https://lore.kernel.org/stable/20260805024300.3406307-1-ashutosh.dixit@intel.com/

Thanks.
--
Ashutosh

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

end of thread, other threads:[~2026-08-05  2:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 23:01 [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 1/8] drm/xe/rtp: Maintain OA whitelists separately Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 2/8] drm/xe/rtp: Keep track of non-OA nonpriv slots Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 3/8] drm/xe/rtp: Generalize whitelist_apply_to_hwe Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 4/8] drm/xe/rtp: Save OA nonpriv registers to register save/restore lists Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 5/8] drm/xe/rtp: Toggle 'deny' bit to (de-)whitelist OA regs Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 6/8] drm/xe/rtp: (De-)whitelist OA registers for all hwe's for a gt Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 7/8] drm/xe/oa: (De-)whitelist OA registers on OA stream open/release Ashutosh Dixit
2026-08-03 23:01 ` [PATCH 7.1.y 8/8] drm/xe/rtp: Ensure locking/ref counting for OA whitelists Ashutosh Dixit
2026-08-05  1:13 ` [PATCH 7.1.y 0/8] drivers/gpu/drm/xe: Don't whitelist OA registers unconditionally Sasha Levin
2026-08-05  2:53   ` Dixit, Ashutosh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox