From: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
To: intel-xe@lists.freedesktop.org, nicholas.johnstone@intel.com,
david.e.box@intel.com, rodrigo.vivi@intel.com,
lucas.demarchi@intel.com
Cc: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
Subject: [PATCH v3] drm/xe/vsec: Allow for kernel context access
Date: Mon, 12 May 2025 14:18:35 -0400 [thread overview]
Message-ID: <20250512182012.181644-1-michael.j.ruhl@intel.com> (raw)
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
next reply other threads:[~2025-05-12 18:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-12 18:18 Michael J. Ruhl [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250512182012.181644-1-michael.j.ruhl@intel.com \
--to=michael.j.ruhl@intel.com \
--cc=david.e.box@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=nicholas.johnstone@intel.com \
--cc=rodrigo.vivi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox