<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: black;">
Reviewed by: nicholas.johnstone@intel.com</div>
<div id="appendonsend" style="color: inherit;"></div>
<div class="elementToProof"><br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Best,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
Nick</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<b>From:</b> Ruhl, Michael J<br>
<b>Sent:</b> Wednesday, May 7, 2025 2:37 PM<br>
<b>To:</b> intel-xe@lists.freedesktop.org; Johnstone, Nicholas; Box, David E; Vivi, Rodrigo; De Marchi, Lucas<br>
<b>Cc:</b> Ruhl, Michael J<br>
<b>Subject:</b> [PATCH v2] drm/xe/vsec: Allow for kernel context access </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-size: 11pt;">The PMT driver API allows kernel level access to device<br>
data. Because of this, the mutex lock use by the Xe copy<br>
callback function turns out to be a poor choice.<br>
<br>
Change the mutex to a spinlock to avoid sleeping when it<br>
isn't allowed.<br>
<br>
Fixes: 0c45e76fcc62 ("drm/xe/vsec: Support BMG devices")<br>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com><br>
---<br>
v2: checkpatch fix, update email address<br>
<br>
drivers/gpu/drm/xe/xe_device.c | 5 ++---<br>
drivers/gpu/drm/xe/xe_device_types.h | 2 +-<br>
drivers/gpu/drm/xe/xe_vsec.c | 4 ++--<br>
3 files changed, 5 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c<br>
index 75e753e0a682..72c81b8203a5 100644<br>
--- a/drivers/gpu/drm/xe/xe_device.c<br>
+++ b/drivers/gpu/drm/xe/xe_device.c<br>
@@ -8,6 +8,7 @@<br>
#include <linux/aperture.h><br>
#include <linux/delay.h><br>
#include <linux/fault-inject.h><br>
+#include <linux/spinlock.h><br>
#include <linux/units.h><br>
<br>
#include <drm/drm_atomic_helper.h><br>
@@ -488,9 +489,7 @@ struct xe_device *xe_device_create(struct pci_dev *pdev,<br>
goto err;<br>
}<br>
<br>
- err = drmm_mutex_init(&xe->drm, &xe->pmt.lock);<br>
- if (err)<br>
- goto err;<br>
+ spin_lock_init(&xe->pmt.lock);<br>
<br>
err = xe_display_create(xe);<br>
if (WARN_ON(err))<br>
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h<br>
index 06c65dace026..b57e1ba7cbdf 100644<br>
--- a/drivers/gpu/drm/xe/xe_device_types.h<br>
+++ b/drivers/gpu/drm/xe/xe_device_types.h<br>
@@ -527,7 +527,7 @@ struct xe_device {<br>
/** @pmt: Support the PMT driver callback interface */<br>
struct {<br>
/** @pmt.lock: protect access for telemetry data */<br>
- struct mutex lock;<br>
+ spinlock_t lock;<br>
} pmt;<br>
<br>
/**<br>
diff --git a/drivers/gpu/drm/xe/xe_vsec.c b/drivers/gpu/drm/xe/xe_vsec.c<br>
index b378848d3b7b..df44e28abbdf 100644<br>
--- a/drivers/gpu/drm/xe/xe_vsec.c<br>
+++ b/drivers/gpu/drm/xe/xe_vsec.c<br>
@@ -6,7 +6,7 @@<br>
#include <linux/errno.h><br>
#include <linux/intel_vsec.h><br>
#include <linux/module.h><br>
-#include <linux/mutex.h><br>
+#include <linux/spinlock.h><br>
#include <linux/pci.h><br>
#include <linux/types.h><br>
<br>
@@ -164,7 +164,7 @@ static int xe_pmt_telem_read(struct pci_dev *pdev, u32 guid, u64 *data, loff_t u<br>
<br>
telem_addr += offset + user_offset;<br>
<br>
- guard(mutex)(&xe->pmt.lock);<br>
+ guard(spinlock)(&xe->pmt.lock);<br>
<br>
/* indicate that we are not at an appropriate power level */<br>
if (!xe_pm_runtime_get_if_active(xe))<br>
--<br>
2.49.0<br>
<br>
</div>
</body>
</html>