Skip to content

Commit fc32150

Browse files
clrkwllmsKAGA-KOKO
authored andcommitted
thermal/x86_pkg_temp: Make pkg_temp_lock a raw_spinlock_t
The pkg_temp_lock spinlock is acquired in the thermal vector handler which is truly atomic context even on PREEMPT_RT kernels. The critical sections are tiny, so change it to a raw spinlock. Signed-off-by: Clark Williams <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 51e69e6 commit fc32150

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

drivers/thermal/intel/x86_pkg_temp_thermal.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int max_id __read_mostly;
6363
/* Array of zone pointers */
6464
static struct zone_device **zones;
6565
/* Serializes interrupt notification, work and hotplug */
66-
static DEFINE_SPINLOCK(pkg_temp_lock);
66+
static DEFINE_RAW_SPINLOCK(pkg_temp_lock);
6767
/* Protects zone operation in the work function against hotplug removal */
6868
static DEFINE_MUTEX(thermal_zone_mutex);
6969

@@ -266,12 +266,12 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work)
266266
u64 msr_val, wr_val;
267267

268268
mutex_lock(&thermal_zone_mutex);
269-
spin_lock_irq(&pkg_temp_lock);
269+
raw_spin_lock_irq(&pkg_temp_lock);
270270
++pkg_work_cnt;
271271

272272
zonedev = pkg_temp_thermal_get_dev(cpu);
273273
if (!zonedev) {
274-
spin_unlock_irq(&pkg_temp_lock);
274+
raw_spin_unlock_irq(&pkg_temp_lock);
275275
mutex_unlock(&thermal_zone_mutex);
276276
return;
277277
}
@@ -285,7 +285,7 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work)
285285
}
286286

287287
enable_pkg_thres_interrupt();
288-
spin_unlock_irq(&pkg_temp_lock);
288+
raw_spin_unlock_irq(&pkg_temp_lock);
289289

290290
/*
291291
* If tzone is not NULL, then thermal_zone_mutex will prevent the
@@ -310,7 +310,7 @@ static int pkg_thermal_notify(u64 msr_val)
310310
struct zone_device *zonedev;
311311
unsigned long flags;
312312

313-
spin_lock_irqsave(&pkg_temp_lock, flags);
313+
raw_spin_lock_irqsave(&pkg_temp_lock, flags);
314314
++pkg_interrupt_cnt;
315315

316316
disable_pkg_thres_interrupt();
@@ -322,7 +322,7 @@ static int pkg_thermal_notify(u64 msr_val)
322322
pkg_thermal_schedule_work(zonedev->cpu, &zonedev->work);
323323
}
324324

325-
spin_unlock_irqrestore(&pkg_temp_lock, flags);
325+
raw_spin_unlock_irqrestore(&pkg_temp_lock, flags);
326326
return 0;
327327
}
328328

@@ -368,9 +368,9 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
368368
zonedev->msr_pkg_therm_high);
369369

370370
cpumask_set_cpu(cpu, &zonedev->cpumask);
371-
spin_lock_irq(&pkg_temp_lock);
371+
raw_spin_lock_irq(&pkg_temp_lock);
372372
zones[id] = zonedev;
373-
spin_unlock_irq(&pkg_temp_lock);
373+
raw_spin_unlock_irq(&pkg_temp_lock);
374374
return 0;
375375
}
376376

@@ -407,7 +407,7 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)
407407
}
408408

409409
/* Protect against work and interrupts */
410-
spin_lock_irq(&pkg_temp_lock);
410+
raw_spin_lock_irq(&pkg_temp_lock);
411411

412412
/*
413413
* Check whether this cpu was the current target and store the new
@@ -439,9 +439,9 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)
439439
* To cancel the work we need to drop the lock, otherwise
440440
* we might deadlock if the work needs to be flushed.
441441
*/
442-
spin_unlock_irq(&pkg_temp_lock);
442+
raw_spin_unlock_irq(&pkg_temp_lock);
443443
cancel_delayed_work_sync(&zonedev->work);
444-
spin_lock_irq(&pkg_temp_lock);
444+
raw_spin_lock_irq(&pkg_temp_lock);
445445
/*
446446
* If this is not the last cpu in the package and the work
447447
* did not run after we dropped the lock above, then we
@@ -452,7 +452,7 @@ static int pkg_thermal_cpu_offline(unsigned int cpu)
452452
pkg_thermal_schedule_work(target, &zonedev->work);
453453
}
454454

455-
spin_unlock_irq(&pkg_temp_lock);
455+
raw_spin_unlock_irq(&pkg_temp_lock);
456456

457457
/* Final cleanup if this is the last cpu */
458458
if (lastcpu)

0 commit comments

Comments
 (0)