Skip to contentSkip to conversation

drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu

PATCH Superseded Ravi Kumar Vodapalli 3 participants 5 messages Nov 3, 2025 – Nov 4, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu

Currently i915 pmu driver gets registered with linux perf subsystem with its callback functions implemented, it is using spin_lock for synchronization where ever is needed. linux perf subsystem in some instance is using raw_spin_locks for synchronization and calls the i915 pmu callback functions with raw_spin_lock held.

The issue is
When PREEMPT_RT is configured in kernel config the normal spin_lock behaves as mutex lock and when these are called with raw_spin_lock held race condition can occur.So in the path of the raw_spin_lock held convert spin_lock into raw_spin_lock where ever is needed.

---
 drivers/gpu/drm/i915/i915_pmu.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_pmu.c +11 -11
index 5bc696bfbb0f..d760ec44a98c 100644
@@ -230,7 +230,7 @@ static u64 get_rc6(struct intel_gt *gt)
 		intel_gt_pm_put_async(gt, wakeref);
 	}
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
 	if (wakeref) {
 		store_sample(pmu, gt_id, __I915_SAMPLE_RC6, val);
@@ -251,7 +251,7 @@ static u64 get_rc6(struct intel_gt *gt)
 	else
 		store_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED, val);
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
 
 	return val;
 }
@@ -302,7 +302,7 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
 	if (!pmu->registered)
 		return;
 
-	spin_lock_irq(&pmu->lock);
+	raw_spin_lock_irq(&pmu->lock);
 
 	park_rc6(gt);
 
@@ -314,7 +314,7 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
 	if (pmu->unparked == 0)
 		pmu->timer_enabled = false;
 
-	spin_unlock_irq(&pmu->lock);
+	raw_spin_unlock_irq(&pmu->lock);
 }
 
 void i915_pmu_gt_unparked(struct intel_gt *gt)
@@ -324,7 +324,7 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
 	if (!pmu->registered)
 		return;
 
-	spin_lock_irq(&pmu->lock);
+	raw_spin_lock_irq(&pmu->lock);
 
 	/*
 	 * Re-enable sampling timer when GPU goes active.
@@ -334,7 +334,7 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
 
 	pmu->unparked |= BIT(gt->info.id);
 
-	spin_unlock_irq(&pmu->lock);
+	raw_spin_unlock_irq(&pmu->lock);
 }
 
 static void
@@ -740,7 +740,7 @@ static void i915_pmu_enable(struct perf_event *event)
 	if (bit == -1)
 		goto update;
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
 	/*
 	 * Update the bitmask of enabled events and increment
@@ -782,7 +782,7 @@ static void i915_pmu_enable(struct perf_event *event)
 		engine->pmu.enable_count[sample]++;
 	}
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
 
 update:
 	/*
@@ -803,7 +803,7 @@ static void i915_pmu_disable(struct perf_event *event)
 	if (bit == -1)
 		return;
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
 	if (is_engine_event(event)) {
 		u8 sample = engine_event_sample(event);
@@ -836,7 +836,7 @@ static void i915_pmu_disable(struct perf_event *event)
 		pmu->timer_enabled &= pmu_needs_timer(pmu);
 	}
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
 }
 
 static void i915_pmu_event_start(struct perf_event *event, int flags)
@@ -1154,7 +1154,7 @@ void i915_pmu_register(struct drm_i915_private *i915)
 	};
 	int ret = -ENOMEM;
 
-	spin_lock_init(&pmu->lock);
+	raw_spin_lock_init(&pmu->lock);
 	hrtimer_setup(&pmu->timer, i915_sample, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
 	init_rc6(pmu);
 
Signature · 1 line
2.34.1
#1 lore raw

✗ Fi.CI.BUILD: failure for drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu

== Series Details ==

== Series Details ==

Series: drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu
URL : https://patchwork.freedesktop.org/series/156951/
State : failure

== Summary ==

Error: make failed
CALL scripts/checksyscalls.sh
DESCEND objtool
INSTALL libsubcmd_headers
CC [M] drivers/gpu/drm/i915/i915_pmu.o
In file included from ./include/linux/sched.h:37,

                 from ./include/linux/ratelimit.h:6,
                 from ./include/linux/dev_printk.h:16,
                 from ./include/linux/device.h:15,
                 from ./include/linux/pm_runtime.h:11,
                 from drivers/gpu/drm/i915/i915_pmu.c:7:
drivers/gpu/drm/i915/i915_pmu.c: In function ‘get_rc6’:
drivers/gpu/drm/i915/i915_pmu.c:235:31: error: passing argument 1 of ‘_raw_spin_lock_irqsave’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  235 |         raw_spin_lock_irqsave(&pmu->lock, flags);
      |                               ^~~~~~~~~~
      |                               |
      |                               spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:244:48: note: in definition of macro ‘raw_spin_lock_irqsave’
244 | flags = _raw_spin_lock_irqsave(lock); \
| ^~~~
In file included from ./include/linux/spinlock.h:312:
./include/linux/spinlock_api_smp.h:32:65: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)

      |                                                 ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c:256:36: error: passing argument 1 of ‘_raw_spin_unlock_irqrestore’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  256 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
      |                                    ^~~~~~~~~~
      |                                    |
      |                                    spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:282:45: note: in definition of macro ‘raw_spin_unlock_irqrestore’
282 | _raw_spin_unlock_irqrestore(lock, flags); \
| ^~~~
./include/linux/spinlock_api_smp.h:43:45: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)

      |                             ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c: In function ‘i915_pmu_gt_parked’:
drivers/gpu/drm/i915/i915_pmu.c:307:27: error: passing argument 1 of ‘_raw_spin_lock_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  307 |         raw_spin_lock_irq(&pmu->lock);
      |                           ^~~~~~~~~~
      |                           |
      |                           spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:274:60: note: in definition of macro ‘raw_spin_lock_irq’
274 | #define raw_spin_lock_irq(lock) _raw_spin_lock_irq(lock)
| ^~~~
./include/linux/spinlock_api_smp.h:29:52: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)

      |                                    ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c:319:29: error: passing argument 1 of ‘_raw_spin_unlock_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  319 |         raw_spin_unlock_irq(&pmu->lock);
      |                             ^~~~~~~~~~
      |                             |
      |                             spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:277:62: note: in definition of macro ‘raw_spin_unlock_irq’
277 | #define raw_spin_unlock_irq(lock) _raw_spin_unlock_irq(lock)
| ^~~~
./include/linux/spinlock_api_smp.h:41:54: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}

   41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
      |                                      ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c: In function ‘i915_pmu_gt_unparked’:
drivers/gpu/drm/i915/i915_pmu.c:329:27: error: passing argument 1 of ‘_raw_spin_lock_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  329 |         raw_spin_lock_irq(&pmu->lock);
      |                           ^~~~~~~~~~
      |                           |
      |                           spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:274:60: note: in definition of macro ‘raw_spin_lock_irq’
274 | #define raw_spin_lock_irq(lock) _raw_spin_lock_irq(lock)
| ^~~~
./include/linux/spinlock_api_smp.h:29:52: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)

      |                                    ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c:339:29: error: passing argument 1 of ‘_raw_spin_unlock_irq’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  339 |         raw_spin_unlock_irq(&pmu->lock);
      |                             ^~~~~~~~~~
      |                             |
      |                             spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:277:62: note: in definition of macro ‘raw_spin_unlock_irq’
277 | #define raw_spin_unlock_irq(lock) _raw_spin_unlock_irq(lock)
| ^~~~
./include/linux/spinlock_api_smp.h:41:54: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}

   41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
      |                                      ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c: In function ‘i915_pmu_enable’:
drivers/gpu/drm/i915/i915_pmu.c:745:31: error: passing argument 1 of ‘_raw_spin_lock_irqsave’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  745 |         raw_spin_lock_irqsave(&pmu->lock, flags);
      |                               ^~~~~~~~~~
      |                               |
      |                               spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:244:48: note: in definition of macro ‘raw_spin_lock_irqsave’
244 | flags = _raw_spin_lock_irqsave(lock); \
| ^~~~
./include/linux/spinlock_api_smp.h:32:65: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)

      |                                                 ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c:787:36: error: passing argument 1 of ‘_raw_spin_unlock_irqrestore’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  787 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
      |                                    ^~~~~~~~~~
      |                                    |
      |                                    spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:282:45: note: in definition of macro ‘raw_spin_unlock_irqrestore’
282 | _raw_spin_unlock_irqrestore(lock, flags); \
| ^~~~
./include/linux/spinlock_api_smp.h:43:45: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)

      |                             ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c: In function ‘i915_pmu_disable’:
drivers/gpu/drm/i915/i915_pmu.c:808:31: error: passing argument 1 of ‘_raw_spin_lock_irqsave’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  808 |         raw_spin_lock_irqsave(&pmu->lock, flags);
      |                               ^~~~~~~~~~
      |                               |
      |                               spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:244:48: note: in definition of macro ‘raw_spin_lock_irqsave’
244 | flags = _raw_spin_lock_irqsave(lock); \
| ^~~~
./include/linux/spinlock_api_smp.h:32:65: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)

      |                                                 ~~~~~~~~~~~~~~~~^~~~
drivers/gpu/drm/i915/i915_pmu.c:841:36: error: passing argument 1 of ‘_raw_spin_unlock_irqrestore’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  841 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
      |                                    ^~~~~~~~~~
      |                                    |
      |                                    spinlock_t * {aka struct spinlock *}

./include/linux/spinlock.h:282:45: note: in definition of macro ‘raw_spin_unlock_irqrestore’
282 | _raw_spin_unlock_irqrestore(lock, flags); \
| ^~~~
./include/linux/spinlock_api_smp.h:43:45: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)

      |                             ~~~~~~~~~~~~~~~~^~~~

drivers/gpu/drm/i915/i915_pmu.c: In function ‘i915_pmu_register’:
drivers/gpu/drm/i915/i915_pmu.c:1159:28: error: passing argument 1 of ‘__raw_spin_lock_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
1159 | raw_spin_lock_init(&pmu->lock);
./include/linux/spinlock.h:108:31: note: in definition of macro ‘raw_spin_lock_init’
108 | __raw_spin_lock_init((lock), #lock, &__key, LD_WAIT_SPIN); \
| ^~~~
./include/linux/spinlock.h:101:52: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘spinlock_t *’ {aka ‘struct spinlock *’}
101 | extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,

      |                                    ~~~~~~~~~~~~~~~~^~~~

cc1: all warnings being treated as errors
make[6]: *** [scripts/Makefile.build:287: drivers/gpu/drm/i915/i915_pmu.o] Error 1 make[5]: *** [scripts/Makefile.build:556: drivers/gpu/drm/i915] Error 2 make[4]: *** [scripts/Makefile.build:556: drivers/gpu/drm] Error 2 make[3]: *** [scripts/Makefile.build:556: drivers/gpu] Error 2 make[2]: *** [scripts/Makefile.build:556: drivers] Error 2
make[1]: *** [/home/kbuild/kernel/Makefile:2010: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
Build failed, no error log produced

#2 lore raw
In reply to Ravi Kumar Vodapalli
kernel test robot noticed the following build errors:

Hi Ravi,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.18-rc4 next-20251104] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ravi-Kumar-Vodapalli/drm-i915-pmu-Use-raw_spin_lock-where-ever-needed-in-i915-pmu/20251104-025356
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/20251103185141.854074-1-ravi.kumar.vodapalli%40intel.com
patch subject: [PATCH] drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20251104/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from include/linux/sched.h:37,

                    from include/linux/ratelimit.h:6,
                    from include/linux/dev_printk.h:16,
                    from include/linux/device.h:15,
                    from include/linux/pm_runtime.h:11,
                    from drivers/gpu/drm/i915/i915_pmu.c:7:
   drivers/gpu/drm/i915/i915_pmu.c: In function 'get_rc6':
>> drivers/gpu/drm/i915/i915_pmu.c:233:31: error: passing argument 1 of '_raw_spin_lock_irqsave' from incompatible pointer type [-Wincompatible-pointer-types]
     233 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
         |                               |
         |                               spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:244:48: note: in definition of macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   In file included from include/linux/spinlock.h:312:
   include/linux/spinlock_api_smp.h:32:65: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                 ~~~~~~~~~~~~~~~~^~~~
>> drivers/gpu/drm/i915/i915_pmu.c:254:36: error: passing argument 1 of '_raw_spin_unlock_irqrestore' from incompatible pointer type [-Wincompatible-pointer-types]
     254 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
         |                                    |
         |                                    spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:282:45: note: in definition of macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                             ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_pmu_gt_parked':
>> drivers/gpu/drm/i915/i915_pmu.c:305:27: error: passing argument 1 of '_raw_spin_lock_irq' from incompatible pointer type [-Wincompatible-pointer-types]
     305 |         raw_spin_lock_irq(&pmu->lock);
         |                           ^~~~~~~~~~
         |                           |
         |                           spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:274:60: note: in definition of macro 'raw_spin_lock_irq'
     274 | #define raw_spin_lock_irq(lock)         _raw_spin_lock_irq(lock)
         |                                                            ^~~~
   include/linux/spinlock_api_smp.h:29:52: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
         |                                    ~~~~~~~~~~~~~~~~^~~~
>> drivers/gpu/drm/i915/i915_pmu.c:317:29: error: passing argument 1 of '_raw_spin_unlock_irq' from incompatible pointer type [-Wincompatible-pointer-types]
     317 |         raw_spin_unlock_irq(&pmu->lock);
         |                             ^~~~~~~~~~
         |                             |
         |                             spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:277:62: note: in definition of macro 'raw_spin_unlock_irq'
     277 | #define raw_spin_unlock_irq(lock)       _raw_spin_unlock_irq(lock)
         |                                                              ^~~~
   include/linux/spinlock_api_smp.h:41:54: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
         |                                      ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_pmu_gt_unparked':
   drivers/gpu/drm/i915/i915_pmu.c:327:27: error: passing argument 1 of '_raw_spin_lock_irq' from incompatible pointer type [-Wincompatible-pointer-types]
     327 |         raw_spin_lock_irq(&pmu->lock);
         |                           ^~~~~~~~~~
         |                           |
         |                           spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:274:60: note: in definition of macro 'raw_spin_lock_irq'
     274 | #define raw_spin_lock_irq(lock)         _raw_spin_lock_irq(lock)
         |                                                            ^~~~
   include/linux/spinlock_api_smp.h:29:52: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
         |                                    ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c:337:29: error: passing argument 1 of '_raw_spin_unlock_irq' from incompatible pointer type [-Wincompatible-pointer-types]
     337 |         raw_spin_unlock_irq(&pmu->lock);
         |                             ^~~~~~~~~~
         |                             |
         |                             spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:277:62: note: in definition of macro 'raw_spin_unlock_irq'
     277 | #define raw_spin_unlock_irq(lock)       _raw_spin_unlock_irq(lock)
         |                                                              ^~~~
   include/linux/spinlock_api_smp.h:41:54: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
         |                                      ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_pmu_enable':
   drivers/gpu/drm/i915/i915_pmu.c:743:31: error: passing argument 1 of '_raw_spin_lock_irqsave' from incompatible pointer type [-Wincompatible-pointer-types]
     743 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
         |                               |
         |                               spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:244:48: note: in definition of macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   include/linux/spinlock_api_smp.h:32:65: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                 ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c:785:36: error: passing argument 1 of '_raw_spin_unlock_irqrestore' from incompatible pointer type [-Wincompatible-pointer-types]
     785 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
         |                                    |
         |                                    spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:282:45: note: in definition of macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                             ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_pmu_disable':
   drivers/gpu/drm/i915/i915_pmu.c:806:31: error: passing argument 1 of '_raw_spin_lock_irqsave' from incompatible pointer type [-Wincompatible-pointer-types]
     806 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
         |                               |
         |                               spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:244:48: note: in definition of macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   include/linux/spinlock_api_smp.h:32:65: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                 ~~~~~~~~~~~~~~~~^~~~
   drivers/gpu/drm/i915/i915_pmu.c:839:36: error: passing argument 1 of '_raw_spin_unlock_irqrestore' from incompatible pointer type [-Wincompatible-pointer-types]
     839 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
         |                                    |
         |                                    spinlock_t * {aka struct spinlock *}
   include/linux/spinlock.h:282:45: note: in definition of macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: expected 'raw_spinlock_t *' {aka 'struct raw_spinlock *'} but argument is of type 'spinlock_t *' {aka 'struct spinlock *'}
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                             ~~~~~~~~~~~~~~~~^~~~
   In file included from include/linux/ratelimit_types.h:7,
                    from include/linux/ratelimit.h:5:
   drivers/gpu/drm/i915/i915_pmu.c: In function 'i915_pmu_register':
>> include/linux/spinlock_types_raw.h:69:9: error: incompatible types when assigning to type 'spinlock_t' {aka 'struct spinlock'} from type 'raw_spinlock_t' {aka 'struct raw_spinlock'}
      69 |         (raw_spinlock_t) __RAW_SPIN_LOCK_INITIALIZER(lockname)
         |         ^
   include/linux/spinlock.h:113:24: note: in expansion of macro '__RAW_SPIN_LOCK_UNLOCKED'
     113 |         do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/gpu/drm/i915/i915_pmu.c:1157:9: note: in expansion of macro 'raw_spin_lock_init'
    1157 |         raw_spin_lock_init(&pmu->lock);
         |         ^~~~~~~~~~~~~~~~~~

vim +/_raw_spin_lock_irqsave +233 drivers/gpu/drm/i915/i915_pmu.c

217
218 static u64 get_rc6(struct intel_gt *gt)
219 {
220 struct drm_i915_private *i915 = gt->i915;
221 const unsigned int gt_id = gt->info.id;
222 struct i915_pmu *pmu = &i915->pmu;
223 intel_wakeref_t wakeref;
224 unsigned long flags;
225 u64 val;
226
227 wakeref = intel_gt_pm_get_if_awake(gt);
228 if (wakeref) {
229 val = __get_rc6(gt);
230 intel_gt_pm_put_async(gt, wakeref);
231 }
232

 > 233		raw_spin_lock_irqsave(&pmu->lock, flags);
   234	
   235		if (wakeref) {
   236			store_sample(pmu, gt_id, __I915_SAMPLE_RC6, val);
   237		} else {
   238			/*
   239			 * We think we are runtime suspended.
   240			 *
   241			 * Report the delta from when the device was suspended to now,
   242			 * on top of the last known real value, as the approximated RC6
   243			 * counter value.
   244			 */
   245			val = ktime_since_raw(pmu->sleep_last[gt_id]);
   246			val += read_sample(pmu, gt_id, __I915_SAMPLE_RC6);
   247		}
   248	
   249		if (val < read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED))
   250			val = read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED);
   251		else
   252			store_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED, val);
   253	
 > 254		raw_spin_unlock_irqrestore(&pmu->lock, flags);
   255	
   256		return val;
   257	}
   258	
   259	static void init_rc6(struct i915_pmu *pmu)
   260	{
   261		struct drm_i915_private *i915 = pmu_to_i915(pmu);
   262		struct intel_gt *gt;
   263		unsigned int i;
   264	
   265		for_each_gt(gt, i915, i) {
   266			intel_wakeref_t wakeref;
   267	
   268			with_intel_runtime_pm(gt->uncore->rpm, wakeref) {
   269				u64 val = __get_rc6(gt);
   270	
   271				store_sample(pmu, i, __I915_SAMPLE_RC6, val);
   272				store_sample(pmu, i, __I915_SAMPLE_RC6_LAST_REPORTED,
   273					     val);
   274				pmu->sleep_last[i] = ktime_get_raw();
   275			}
   276		}
   277	}
   278	
   279	static void park_rc6(struct intel_gt *gt)
   280	{
   281		struct i915_pmu *pmu = &gt->i915->pmu;
   282	
   283		store_sample(pmu, gt->info.id, __I915_SAMPLE_RC6, __get_rc6(gt));
   284		pmu->sleep_last[gt->info.id] = ktime_get_raw();
   285	}
   286	
   287	static void __i915_pmu_maybe_start_timer(struct i915_pmu *pmu)
   288	{
   289		if (!pmu->timer_enabled && pmu_needs_timer(pmu)) {
   290			pmu->timer_enabled = true;
   291			pmu->timer_last = ktime_get();
   292			hrtimer_start_range_ns(&pmu->timer,
   293					       ns_to_ktime(PERIOD), 0,
   294					       HRTIMER_MODE_REL_PINNED);
   295		}
   296	}
   297	
   298	void i915_pmu_gt_parked(struct intel_gt *gt)
   299	{
   300		struct i915_pmu *pmu = &gt->i915->pmu;
   301	
   302		if (!pmu->registered)
   303			return;
   304	
 > 305		raw_spin_lock_irq(&pmu->lock);
   306	
   307		park_rc6(gt);
   308	
   309		/*
   310		 * Signal sampling timer to stop if only engine events are enabled and
   311		 * GPU went idle.
   312		 */
   313		pmu->unparked &= ~BIT(gt->info.id);
   314		if (pmu->unparked == 0)
   315			pmu->timer_enabled = false;
   316	
 > 317		raw_spin_unlock_irq(&pmu->lock);

318 }
319

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw
In reply to Ravi Kumar Vodapalli
kernel test robot noticed the following build errors:

Hi Ravi,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-intel/for-linux-next]
[also build test ERROR on drm-intel/for-linux-next-fixes drm-tip/drm-tip linus/master v6.18-rc4 next-20251104] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Ravi-Kumar-Vodapalli/drm-i915-pmu-Use-raw_spin_lock-where-ever-needed-in-i915-pmu/20251104-025356
base:   git://anongit.freedesktop.org/drm-intel for-linux-next
patch link:    https://lore.kernel.org/r/20251103185141.854074-1-ravi.kumar.vodapalli%40intel.com
patch subject: [PATCH] drm/i915/pmu: Use raw_spin_lock where ever needed in i915 pmu
config: x86_64-randconfig-014-20251104 (https://download.01.org/0day-ci/archive/20251104/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251104/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/gpu/drm/i915/i915_pmu.c:233:24: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     233 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
   include/linux/spinlock.h:244:34: note: expanded from macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   include/linux/spinlock_api_smp.h:32:65: note: passing argument to parameter 'lock' here
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                                 ^
   drivers/gpu/drm/i915/i915_pmu.c:254:29: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     254 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
   include/linux/spinlock.h:282:31: note: expanded from macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: passing argument to parameter 'lock' here
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                                             ^
   drivers/gpu/drm/i915/i915_pmu.c:305:20: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     305 |         raw_spin_lock_irq(&pmu->lock);
         |                           ^~~~~~~~~~
   include/linux/spinlock.h:274:53: note: expanded from macro 'raw_spin_lock_irq'
     274 | #define raw_spin_lock_irq(lock)         _raw_spin_lock_irq(lock)
         |                                                            ^~~~
   include/linux/spinlock_api_smp.h:29:52: note: passing argument to parameter 'lock' here
      29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
         |                                                    ^
   drivers/gpu/drm/i915/i915_pmu.c:317:22: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     317 |         raw_spin_unlock_irq(&pmu->lock);
         |                             ^~~~~~~~~~
   include/linux/spinlock.h:277:56: note: expanded from macro 'raw_spin_unlock_irq'
     277 | #define raw_spin_unlock_irq(lock)       _raw_spin_unlock_irq(lock)
         |                                                              ^~~~
   include/linux/spinlock_api_smp.h:41:54: note: passing argument to parameter 'lock' here
      41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
         |                                                      ^
   drivers/gpu/drm/i915/i915_pmu.c:327:20: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     327 |         raw_spin_lock_irq(&pmu->lock);
         |                           ^~~~~~~~~~
   include/linux/spinlock.h:274:53: note: expanded from macro 'raw_spin_lock_irq'
     274 | #define raw_spin_lock_irq(lock)         _raw_spin_lock_irq(lock)
         |                                                            ^~~~
   include/linux/spinlock_api_smp.h:29:52: note: passing argument to parameter 'lock' here
      29 | void __lockfunc _raw_spin_lock_irq(raw_spinlock_t *lock)
         |                                                    ^
   drivers/gpu/drm/i915/i915_pmu.c:337:22: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     337 |         raw_spin_unlock_irq(&pmu->lock);
         |                             ^~~~~~~~~~
   include/linux/spinlock.h:277:56: note: expanded from macro 'raw_spin_unlock_irq'
     277 | #define raw_spin_unlock_irq(lock)       _raw_spin_unlock_irq(lock)
         |                                                              ^~~~
   include/linux/spinlock_api_smp.h:41:54: note: passing argument to parameter 'lock' here
      41 | void __lockfunc _raw_spin_unlock_irq(raw_spinlock_t *lock)      __releases(lock);
         |                                                      ^
   drivers/gpu/drm/i915/i915_pmu.c:743:24: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     743 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
   include/linux/spinlock.h:244:34: note: expanded from macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   include/linux/spinlock_api_smp.h:32:65: note: passing argument to parameter 'lock' here
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                                 ^
   drivers/gpu/drm/i915/i915_pmu.c:785:29: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     785 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
   include/linux/spinlock.h:282:31: note: expanded from macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: passing argument to parameter 'lock' here
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                                             ^
   drivers/gpu/drm/i915/i915_pmu.c:806:24: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     806 |         raw_spin_lock_irqsave(&pmu->lock, flags);
         |                               ^~~~~~~~~~
   include/linux/spinlock.h:244:34: note: expanded from macro 'raw_spin_lock_irqsave'
     244 |                 flags = _raw_spin_lock_irqsave(lock);   \
         |                                                ^~~~
   include/linux/spinlock_api_smp.h:32:65: note: passing argument to parameter 'lock' here
      32 | unsigned long __lockfunc _raw_spin_lock_irqsave(raw_spinlock_t *lock)
         |                                                                 ^
   drivers/gpu/drm/i915/i915_pmu.c:839:29: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
     839 |         raw_spin_unlock_irqrestore(&pmu->lock, flags);
         |                                    ^~~~~~~~~~
   include/linux/spinlock.h:282:31: note: expanded from macro 'raw_spin_unlock_irqrestore'
     282 |                 _raw_spin_unlock_irqrestore(lock, flags);       \
         |                                             ^~~~
   include/linux/spinlock_api_smp.h:43:45: note: passing argument to parameter 'lock' here
      43 | _raw_spin_unlock_irqrestore(raw_spinlock_t *lock, unsigned long flags)
         |                                             ^
   drivers/gpu/drm/i915/i915_pmu.c:1157:2: error: incompatible pointer types passing 'spinlock_t *' (aka 'struct spinlock *') to parameter of type 'raw_spinlock_t *' (aka 'struct raw_spinlock *') [-Werror,-Wincompatible-pointer-types]
    1157 |         raw_spin_lock_init(&pmu->lock);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:108:23: note: expanded from macro 'raw_spin_lock_init'
     108 |         __raw_spin_lock_init((lock), #lock, &__key, LD_WAIT_SPIN);      \
         |                              ^~~~~~

include/linux/spinlock.h:101:52: note: passing argument to parameter 'lock' here
101 | extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
| ^
11 errors generated.

vim +233 drivers/gpu/drm/i915/i915_pmu.c

217
218 static u64 get_rc6(struct intel_gt *gt)
219 {
220 struct drm_i915_private *i915 = gt->i915;
221 const unsigned int gt_id = gt->info.id;
222 struct i915_pmu *pmu = &i915->pmu;
223 intel_wakeref_t wakeref;
224 unsigned long flags;
225 u64 val;
226
227 wakeref = intel_gt_pm_get_if_awake(gt);
228 if (wakeref) {
229 val = __get_rc6(gt);
230 intel_gt_pm_put_async(gt, wakeref);
231 }
232

 > 233		raw_spin_lock_irqsave(&pmu->lock, flags);

234
235 if (wakeref) {
236 store_sample(pmu, gt_id, __I915_SAMPLE_RC6, val);
237 } else {
238 /*
239 * We think we are runtime suspended.
240 *
241 * Report the delta from when the device was suspended to now,
242 * on top of the last known real value, as the approximated RC6
243 * counter value.
244 */
245 val = ktime_since_raw(pmu->sleep_last[gt_id]);
246 val += read_sample(pmu, gt_id, __I915_SAMPLE_RC6);
247 }
248
249 if (val < read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED))
250 val = read_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED);
251 else
252 store_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED, val);
253
254 raw_spin_unlock_irqrestore(&pmu->lock, flags);
255
256 return val;
257 }
258

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw
In reply to Ravi Kumar Vodapalli
Quoted 7 lines · Ravi Kumar Vodapalli

Currently i915 pmu driver gets registered with linux perf subsystem with its callback functions implemented, it is using spin_lock for synchronization where ever is needed. linux perf subsystem in some instance is using raw_spin_locks for synchronization and calls the i915 pmu callback functions with raw_spin_lock held.

Quoted 5 lines

The issue is
When PREEMPT_RT is configured in kernel config the normal spin_lock behaves as mutex lock and when these are called with raw_spin_lock held race condition can occur.So in the path of the raw_spin_lock held convert spin_lock into raw_spin_lock where ever is needed.

Here one more spin_lock is there in path of raw_spin_lock in drivers/gpu/drm/i915/i915_pmu.c __i915_pmu_event_read()--> get_rc6()-->__get_rc6()--> intel_rc6_residency_ns()-->spin_lock_irqsave(&uncore->lock, flags);

Here spin lock is taken with "uncore->lock" variable, converting this lock to raw_spin_lock is not straight forward because at many places in code this lock is used

drivers/gpu/drm/i915/gt/intel_rc6.c
drivers/gpu/drm/i915/gt/intel_workarounds.c
drivers/gpu/drm/i915/intel_uncore.

Thanks,
Ravi Kumar V

Quoted 108 lines
---
  drivers/gpu/drm/i915/i915_pmu.c | 22 +++++++++++-----------
  1 file changed, 11 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/i915_pmu.c +11 -11
index 5bc696bfbb0f..d760ec44a98c 100644
@@ -230,7 +230,7 @@ static u64 get_rc6(struct intel_gt *gt)
  		intel_gt_pm_put_async(gt, wakeref);
  	}
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
  	if (wakeref) {
  		store_sample(pmu, gt_id, __I915_SAMPLE_RC6, val);
@@ -251,7 +251,7 @@ static u64 get_rc6(struct intel_gt *gt)
  	else
  		store_sample(pmu, gt_id, __I915_SAMPLE_RC6_LAST_REPORTED, val);
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
 
  	return val;
  }
@@ -302,7 +302,7 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
  	if (!pmu->registered)
  		return;
 
-	spin_lock_irq(&pmu->lock);
+	raw_spin_lock_irq(&pmu->lock);
 
  	park_rc6(gt);
 
@@ -314,7 +314,7 @@ void i915_pmu_gt_parked(struct intel_gt *gt)
  	if (pmu->unparked == 0)
  		pmu->timer_enabled = false;
 
-	spin_unlock_irq(&pmu->lock);
+	raw_spin_unlock_irq(&pmu->lock);
  }
 
  void i915_pmu_gt_unparked(struct intel_gt *gt)
@@ -324,7 +324,7 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
  	if (!pmu->registered)
  		return;
 
-	spin_lock_irq(&pmu->lock);
+	raw_spin_lock_irq(&pmu->lock);
 
  	/*
  	 * Re-enable sampling timer when GPU goes active.
@@ -334,7 +334,7 @@ void i915_pmu_gt_unparked(struct intel_gt *gt)
 
  	pmu->unparked |= BIT(gt->info.id);
 
-	spin_unlock_irq(&pmu->lock);
+	raw_spin_unlock_irq(&pmu->lock);
  }
 
  static void
@@ -740,7 +740,7 @@ static void i915_pmu_enable(struct perf_event *event)
  	if (bit == -1)
  		goto update;
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
  	/*
  	 * Update the bitmask of enabled events and increment
@@ -782,7 +782,7 @@ static void i915_pmu_enable(struct perf_event *event)
  		engine->pmu.enable_count[sample]++;
  	}
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
 
  update:
  	/*
@@ -803,7 +803,7 @@ static void i915_pmu_disable(struct perf_event *event)
  	if (bit == -1)
  		return;
 
-	spin_lock_irqsave(&pmu->lock, flags);
+	raw_spin_lock_irqsave(&pmu->lock, flags);
 
  	if (is_engine_event(event)) {
  		u8 sample = engine_event_sample(event);
@@ -836,7 +836,7 @@ static void i915_pmu_disable(struct perf_event *event)
  		pmu->timer_enabled &= pmu_needs_timer(pmu);
  	}
 
-	spin_unlock_irqrestore(&pmu->lock, flags);
+	raw_spin_unlock_irqrestore(&pmu->lock, flags);
  }
 
  static void i915_pmu_event_start(struct perf_event *event, int flags)
@@ -1154,7 +1154,7 @@ void i915_pmu_register(struct drm_i915_private *i915)
  	};
  	int ret = -ENOMEM;
 
-	spin_lock_init(&pmu->lock);
+	raw_spin_lock_init(&pmu->lock);
  	hrtimer_setup(&pmu->timer, i915_sample, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
  	init_rc6(pmu);