[PATCH] [PATCH v3] drm/i915: move struct_mutex from drm_device to drm_i915_private
Luiz Otavio Mello
luiz.mello at estudante.ufscar.br
Fri Jul 18 19:55:43 UTC 2025
Includes the missing file drm_device.h, which was unintentionally
omitted in v1.
i915 is the only remaining user of struct_mutex lock.
Move it from drm_device to drm_i915_private so it is only used within
the i915 driver.
Also update intel_guc_log.c to use the new location of struct_mutex.
Signed-off-by: Luiz Otavio Mello <luiz.mello at estudante.ufscar.br>
---
Hi,
In this version, I fixed a typo in a comment in i915_irq.c where I mistakenly wrote "BLK" instead of "BKL".
I also corrected the usage of struct_mutex in i915_irq.c to properly reference it through drm_i915_private.
Additionally, I removed the TODO from Documentation/gpu/todo.rst since this task has now been completed.
Signed-off-by: Luiz Otavio Mello <luiz.mello at estudante.ufscar.br>
---
Documentation/gpu/todo.rst | 25 ----------------------
drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 4 ++--
drivers/gpu/drm/i915/i915_drv.h | 8 +++++++
drivers/gpu/drm/i915/i915_irq.c | 4 ++--
include/drm/drm_device.h | 10 ---------
5 files changed, 12 insertions(+), 39 deletions(-)
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index c57777a24e03..ff8f4ee32bee 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -173,31 +173,6 @@ Contact: Simona Vetter
Level: Intermediate
-Get rid of dev->struct_mutex from GEM drivers
----------------------------------------------
-
-``dev->struct_mutex`` is the Big DRM Lock from legacy days and infested
-everything. Nowadays in modern drivers the only bit where it's mandatory is
-serializing GEM buffer object destruction. Which unfortunately means drivers
-have to keep track of that lock and either call ``unreference`` or
-``unreference_locked`` depending upon context.
-
-Core GEM doesn't have a need for ``struct_mutex`` any more since kernel 4.8,
-and there's a GEM object ``free`` callback for any drivers which are
-entirely ``struct_mutex`` free.
-
-For drivers that need ``struct_mutex`` it should be replaced with a driver-
-private lock. The tricky part is the BO free functions, since those can't
-reliably take that lock any more. Instead state needs to be protected with
-suitable subordinate locks or some cleanup work pushed to a worker thread. For
-performance-critical drivers it might also be better to go with a more
-fine-grained per-buffer object and per-context lockings scheme. Currently only
-the ``msm`` and `i915` drivers use ``struct_mutex``.
-
-Contact: Simona Vetter, respective driver maintainers
-
-Level: Advanced
-
Move Buffer Object Locking to dma_resv_lock()
---------------------------------------------
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
index e8a04e476c57..7135fdb0ebb4 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
@@ -678,7 +678,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level)
if (level < GUC_LOG_LEVEL_DISABLED || level > GUC_LOG_LEVEL_MAX)
return -EINVAL;
- mutex_lock(&i915->drm.struct_mutex);
+ mutex_lock(&i915->struct_mutex);
if (log->level == level)
goto out_unlock;
@@ -696,7 +696,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level)
log->level = level;
out_unlock:
- mutex_unlock(&i915->drm.struct_mutex);
+ mutex_unlock(&i915->struct_mutex);
return ret;
}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d0e1980dcba2..0384dae6fa97 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -224,6 +224,14 @@ struct drm_i915_private {
bool irqs_enabled;
+ /*
+ * Currently, struct_mutex is only used by the i915 driver as a replacement
+ * for BKL.
+ *
+ * For this reason, it is no longer part of struct drm_device.
+ */
+ struct mutex struct_mutex;
+
/* LPT/WPT IOSF sideband protection */
struct mutex sbi_lock;
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 95042879bec4..7b29062fed50 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -166,7 +166,7 @@ static void ivb_parity_work(struct work_struct *work)
* In order to prevent a get/put style interface, acquire struct mutex
* any time we access those registers.
*/
- mutex_lock(&dev_priv->drm.struct_mutex);
+ mutex_lock(&dev_priv->struct_mutex);
/* If we've screwed up tracking, just let the interrupt fire again */
if (drm_WARN_ON(&dev_priv->drm, !dev_priv->l3_parity.which_slice))
@@ -224,7 +224,7 @@ static void ivb_parity_work(struct work_struct *work)
gen5_gt_enable_irq(gt, GT_PARITY_ERROR(dev_priv));
spin_unlock_irq(gt->irq_lock);
- mutex_unlock(&dev_priv->drm.struct_mutex);
+ mutex_unlock(&dev_priv->struct_mutex);
}
static irqreturn_t valleyview_irq_handler(int irq, void *arg)
diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index e2f894f1b90a..c374c58fb975 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -177,16 +177,6 @@ struct drm_device {
/** @unique: Unique name of the device */
char *unique;
- /**
- * @struct_mutex:
- *
- * Lock for others (not &drm_minor.master and &drm_file.is_master)
- *
- * TODO: This lock used to be the BKL of the DRM subsystem. Move the
- * lock into i915, which is the only remaining user.
- */
- struct mutex struct_mutex;
-
/**
* @master_mutex:
*
--
2.50.1
More information about the dri-devel
mailing list