Skip to content

Commit afa58b4

Browse files
clrkwllmsdlezcano
authored andcommitted
thermal/x86_pkg_temp: Make pkg_temp_lock a raw_spinlock_t
The spinlock pkg_temp_lock has the potential of being taken in atomic context because it can be acquired from the thermal IRQ vector. It's static and limited scope so go ahead and make it a raw spinlock. Signed-off-by: Clark Williams <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Zhang Rui <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fd96a31 commit afa58b4

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
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)

drivers/thermal/st/stm_thermal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ static int stm_thermal_resume(struct device *dev)
478478
}
479479
#endif /* CONFIG_PM_SLEEP */
480480

481-
SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops, stm_thermal_suspend, stm_thermal_resume);
481+
static SIMPLE_DEV_PM_OPS(stm_thermal_pm_ops,
482+
stm_thermal_suspend, stm_thermal_resume);
482483

483484
static const struct thermal_zone_of_device_ops stm_tz_ops = {
484485
.get_temp = stm_thermal_get_temp,

0 commit comments

Comments
 (0)