Skip to content

Commit 1bd3db8

Browse files
LuizOt31rodrigovivi
authored andcommitted
drm/i915: Replace struct_mutex in intel_guc_log
Remove the use of struct_mutex from intel_guc_log.c and replace it with a dedicated lock, guc_lock, defined within the intel_guc_log struct.      The struct_mutex was previously used to protect concurrent access and modification of intel_guc_log->level in intel_guc_log_set_level(). However, it was suggested that the lock should reside within the intel_guc_log struct itself.      Initialize the new guc_lock in intel_guc_log_init_early(), alongside the existing relay.lock. The lock is initialized using drmm_mutex_init(), which also ensures it is properly destroyed when the driver is unloaded. Signed-off-by: Luiz Otavio Mello <luiz.mello@estudante.ufscar.br> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://lore.kernel.org/r/20250908131518.36625-5-luiz.mello@estudante.ufscar.br Acked-by: Tvrtko Ursulin <tursulin@ursulin.net> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 1bafff0 commit 1bd3db8

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

drivers/gpu/drm/i915/gt/uc/intel_guc_log.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ void intel_guc_log_init_early(struct intel_guc_log *log)
518518
struct drm_i915_private *i915 = guc_to_i915(guc);
519519

520520
drmm_mutex_init(&i915->drm, &log->relay.lock);
521+
drmm_mutex_init(&i915->drm, &log->guc_lock);
521522
INIT_WORK(&log->relay.flush_work, copy_debug_logs_work);
522523
log->relay.started = false;
523524
}
@@ -683,7 +684,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level)
683684
if (level < GUC_LOG_LEVEL_DISABLED || level > GUC_LOG_LEVEL_MAX)
684685
return -EINVAL;
685686

686-
mutex_lock(&i915->struct_mutex);
687+
mutex_lock(&log->guc_lock);
687688

688689
if (log->level == level)
689690
goto out_unlock;
@@ -701,7 +702,7 @@ int intel_guc_log_set_level(struct intel_guc_log *log, u32 level)
701702
log->level = level;
702703

703704
out_unlock:
704-
mutex_unlock(&i915->struct_mutex);
705+
mutex_unlock(&log->guc_lock);
705706

706707
return ret;
707708
}

drivers/gpu/drm/i915/gt/uc/intel_guc_log.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ enum {
4242
struct intel_guc_log {
4343
u32 level;
4444

45+
/*
46+
* Protects concurrent access and modification of intel_guc_log->level.
47+
*
48+
* This lock replaces the legacy struct_mutex usage in
49+
* intel_guc_log system.
50+
*/
51+
struct mutex guc_lock;
52+
4553
/* Allocation settings */
4654
struct {
4755
s32 bytes; /* Size in bytes */

0 commit comments

Comments
 (0)