aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaurice Petallo <mauricex.r.petallo@intel.com>2014-11-27 21:11:41 -0500
committerZhang Rui <rui.zhang@intel.com>2014-12-08 22:38:16 -0500
commit05629296eec7e18038ca90ca4d5fa03824026429 (patch)
treed532279f840899c2d3f6091eb668abf738b34bb5
parent009d0431c3914de64666bec0d350e54fdd59df6a (diff)
thermal: Intel SoC DTS: Don't do thermal zone update inside spin_lock
The driver calls spin_lock_irqsave during DTS interrupt. The interrupt handle then calls thermal_zone_device_update which implicitly calls a sleep function and produce the following bug: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:97 in_atomic(): 1, irqs_disabled(): 1, pid: 920, name: irq/86-soc_dts CPU: 0 PID: 920 Comm: irq/86-soc_dts Tainted: G E 3.17.0-rc2+ #1 Hardware name: Intel Corp. VALLEYVIEW B3 PLATFORM/NOTEBOOK, BIOS BYTICRB1.86C.0092.R31.1408290850 08/29/2014 00000000 00000000 c25dbe74 c1818cfd f3cc488c c25dbe9c c1059305 c1b4063b 00000001 00000001 00000398 f3cc488c f6817644 f6817644 f3ecc6c0 c25dbea8 c18208f2 f6817400 c25dbebc c159b0bb c25dbedc f6817400 f32a2300 c25dbee8 Call Trace: [<c1818cfd>] dump_stack+0x48/0x60 [<c1059305>] __might_sleep+0xec/0xf4 [<c18208f2>] mutex_lock+0x1c/0x34 [<c159b0bb>] thermal_zone_get_temp+0x34/0x59 [<c159bde5>] thermal_zone_device_update+0x2d/0xcb [<f85da16a>] ? iosf_mbi_write+0x6c/0x74 [iosf_mbi] [<f7c7445d>] soc_irq_thread_fn+0x10c/0x163 [intel_soc_dts_thermal] [<c107b72b>] irq_thread_fn+0x18/0x2a [<c107bedb>] irq_thread+0x81/0x11f [<c107b713>] ? irq_finalize_oneshot+0x7c/0x7c [<c107bf79>] ? irq_thread+0x11f/0x11f [<c107be5a>] ? wake_threads_waitq+0x31/0x31 [<c1054217>] kthread+0x87/0x8c [<c1821e41>] ret_from_kernel_thread+0x21/0x30 [<c1054190>] ? __kthread_parkme+0x55/0x55 Signed-off-by: Maurice Petallo <mauricex.r.petallo@intel.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Acked-by: Eduardo Valentin <edubezval@gmail.com> CC: Kweh, Hock Leong <hock.leong.kweh@intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/intel_soc_dts_thermal.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/thermal/intel_soc_dts_thermal.c b/drivers/thermal/intel_soc_dts_thermal.c
index a6a0a18ec0aa..5580f5b24eb9 100644
--- a/drivers/thermal/intel_soc_dts_thermal.c
+++ b/drivers/thermal/intel_soc_dts_thermal.c
@@ -360,6 +360,9 @@ static void proc_thermal_interrupt(void)
360 u32 sticky_out; 360 u32 sticky_out;
361 int status; 361 int status;
362 u32 ptmc_out; 362 u32 ptmc_out;
363 unsigned long flags;
364
365 spin_lock_irqsave(&intr_notify_lock, flags);
363 366
364 /* Clear APIC interrupt */ 367 /* Clear APIC interrupt */
365 status = iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_READ, 368 status = iosf_mbi_read(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_READ,
@@ -378,21 +381,20 @@ static void proc_thermal_interrupt(void)
378 /* reset sticky bit */ 381 /* reset sticky bit */
379 status = iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE, 382 status = iosf_mbi_write(BT_MBI_UNIT_PMC, BT_MBI_BUNIT_WRITE,
380 SOC_DTS_OFFSET_PTTSS, sticky_out); 383 SOC_DTS_OFFSET_PTTSS, sticky_out);
384 spin_unlock_irqrestore(&intr_notify_lock, flags);
385
381 for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { 386 for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) {
382 pr_debug("TZD update for zone %d\n", i); 387 pr_debug("TZD update for zone %d\n", i);
383 thermal_zone_device_update(soc_dts[i]->tzone); 388 thermal_zone_device_update(soc_dts[i]->tzone);
384 } 389 }
385 } 390 } else
391 spin_unlock_irqrestore(&intr_notify_lock, flags);
386 392
387} 393}
388 394
389static irqreturn_t soc_irq_thread_fn(int irq, void *dev_data) 395static irqreturn_t soc_irq_thread_fn(int irq, void *dev_data)
390{ 396{
391 unsigned long flags;
392
393 spin_lock_irqsave(&intr_notify_lock, flags);
394 proc_thermal_interrupt(); 397 proc_thermal_interrupt();
395 spin_unlock_irqrestore(&intr_notify_lock, flags);
396 pr_debug("proc_thermal_interrupt\n"); 398 pr_debug("proc_thermal_interrupt\n");
397 399
398 return IRQ_HANDLED; 400 return IRQ_HANDLED;