Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/xe/vsec: Allow for kernel context access
@ 2025-05-12 18:18 Michael J. Ruhl
  2025-05-12 18:25 ` ✓ CI.Patch_applied: success for drm/xe/vsec: Allow for kernel context access (rev3) Patchwork
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Michael J. Ruhl @ 2025-05-12 18:18 UTC (permalink / raw)
  To: intel-xe, nicholas.johnstone, david.e.box, rodrigo.vivi,
	lucas.demarchi
  Cc: Michael J. Ruhl

The PMT driver API allows kernel level access to device
data.  Because of this, the mutex lock use by the Xe copy
callback function turns out to be a poor choice.

Since the context of the caller can not be known, change
the mutex to a raw_spinlock to account for all use cases.

Fixes: 0c45e76fcc62 ("drm/xe/vsec: Support BMG devices")
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
---
v2: checkpatch fix, update email address
v3: use raw_spinlock

drivers/gpu/drm/xe/xe_device.c       | 5 ++---
 drivers/gpu/drm/xe/xe_device_types.h | 2 +-
 drivers/gpu/drm/xe/xe_vsec.c         | 4 ++--
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
index 399ae5f40321..0caa77d24f44 100644
--- a/drivers/gpu/drm/xe/xe_device.c
+++ b/drivers/gpu/drm/xe/xe_device.c
@@ -8,6 +8,7 @@
 #include <linux/aperture.h>
 #include <linux/delay.h>
 #include <linux/fault-inject.h>
+#include <linux/spinlock.h>
 #include <linux/units.h>
 
 #include <drm/drm_atomic_helper.h>
@@ -486,9 +487,7 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,
 		goto err;
 	}
 
-	err = drmm_mutex_init(&xe->drm, &xe->pmt.lock);
-	if (err)
-		goto err;
+	raw_spin_lock_init(&xe->pmt.lock);
 
 	err = xe_display_create(xe);
 	if (WARN_ON(err))
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 06c65dace026..8f680a89ddb7 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -527,7 +527,7 @@ struct xe_device {
 	/** @pmt: Support the PMT driver callback interface */
 	struct {
 		/** @pmt.lock: protect access for telemetry data */
-		struct mutex lock;
+		raw_spinlock_t lock;
 	} pmt;
 
 	/**
diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c
index b378848d3b7b..3941e1760ea3 100644
--- a/drivers/gpu/drm/xe/xe_vsec.c
+++ b/drivers/gpu/drm/xe/xe_vsec.c
@@ -6,7 +6,7 @@
 #include <linux/errno.h>
 #include <linux/intel_vsec.h>
 #include <linux/module.h>
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 #include <linux/pci.h>
 #include <linux/types.h>
 
@@ -164,7 +164,7 @@ static int xe_pmt_telem_read(struct pci_dev *pdev, u32 guid, u64 *data, loff_t u
 
 	telem_addr += offset + user_offset;
 
-	guard(mutex)(&xe->pmt.lock);
+	guard(raw_spinlock)(&xe->pmt.lock);
 
 	/* indicate that we are not at an appropriate power level */
 	if (!xe_pm_runtime_get_if_active(xe))
-- 
2.49.0


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

end of thread, other threads:[~2025-05-26 22:21 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 18:18 [PATCH v3] drm/xe/vsec: Allow for kernel context access Michael J. Ruhl
2025-05-12 18:25 ` ✓ CI.Patch_applied: success for drm/xe/vsec: Allow for kernel context access (rev3) Patchwork
2025-05-12 18:25 ` ✓ CI.checkpatch: " Patchwork
2025-05-12 18:27 ` ✓ CI.KUnit: " Patchwork
2025-05-12 18:37 ` ✗ CI.Build: failure " Patchwork
2025-05-13  3:49 ` [PATCH v3] drm/xe/vsec: Allow for kernel context access Lucas De Marchi
2025-05-13 13:02 ` ✓ CI.Patch_applied: success for drm/xe/vsec: Allow for kernel context access (rev3) Patchwork
2025-05-13 13:02 ` ✓ CI.checkpatch: " Patchwork
2025-05-13 13:04 ` ✓ CI.KUnit: " Patchwork
2025-05-13 13:12 ` ✓ CI.Build: " Patchwork
2025-05-13 13:14 ` ✓ CI.Hooks: " Patchwork
2025-05-13 13:16 ` ✓ CI.checksparse: " Patchwork
2025-05-13 16:20 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-14  4:56 ` ✓ Xe.CI.BAT: success " Patchwork
2025-05-26 22:21 ` ✗ CI.Patch_applied: failure " Patchwork

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