Skip to contentSkip to conversation

sleeping function called from invalid context at kernel/mutex.c

DISCUSSION Applied Sitsofe Wheeler 3 participants 4 messages Sep 30, 2008 – Oct 2, 2008 5 messages not in the archive x86

lore
Share & tools
lore
#0 lore raw

This turned up in a linux-tip from yesterday after resuming from a suspend on an EeePC 900:

[ 1176.720189] ACPI: Preparing to enter system sleep state S3
[ 1176.745011] Intel machine check architecture supported.
[ 1176.745011] Intel machine check reporting enabled on CPU#0.
[ 1176.745011] Back to C!
[ 1176.745011] BUG: sleeping function called from invalid context at kernel/mutex.c:207
[ 1176.745011] in_atomic(): 0, irqs_disabled(): 1, pid: 4513, name: pm-suspend
[ 1176.745011] 3 locks held by pm-suspend/4513:
[ 1176.745011]  #0:  (&buffer->mutex){--..}, at: [<c01b89c0>] sysfs_write_file+0x30/0x100
[ 1176.745011]  #1:  (pm_mutex){--..}, at: [<c014ef5a>] enter_state+0x4a/0x140
[ 1176.745011]  #2:  (dpm_list_mtx){--..}, at: [<c029c254>] device_pm_lock+0x14/0x20
[ 1176.745011] irq event stamp: 28504
[ 1176.745011] hardirqs last  enabled at (28503): [<c014a92b>] trace_hardirqs_on+0xb/0x10
[ 1176.745011] hardirqs last disabled at (28504): [<c014593b>] trace_hardirqs_off+0xb/0x10
[ 1176.745011] softirqs last  enabled at (27690): [<c012bd53>] __do_softirq+0xa3/0xc0
[ 1176.745011] softirqs last disabled at (27685): [<c012bdc5>] do_softirq+0x55/0x60
[ 1176.745011] Pid: 4513, comm: pm-suspend Not tainted 2.6.27-rc7-tipskw-00976-g30d1868-dirty #25
[ 1176.745011]  [<c012bdc5>] ? do_softirq+0x55/0x60
[ 1176.745011]  [<c011fe74>] __might_sleep+0xe4/0x110
[ 1176.745011]  [<c03cfd44>] mutex_lock_nested+0x24/0x50
[ 1176.745011]  [<c0116772>] microcode_update_cpu+0x22/0xf0
[ 1176.745011]  [<c014593b>] ? trace_hardirqs_off+0xb/0x10
[ 1176.745011]  [<c03d178c>] ? _spin_unlock_irqrestore+0x3c/0x60
[ 1176.745011]  [<c0116855>] mc_sysdev_resume+0x15/0x20
[ 1176.745011]  [<c029754b>] __sysdev_resume+0x3b/0x50
[ 1176.745011]  [<c0297997>] sysdev_resume+0x57/0x90
[ 1176.745011]  [<c029cf00>] device_power_up+0x10/0x20
[ 1176.745011]  [<c014ee8f>] suspend_devices_and_enter+0x11f/0x140
[ 1176.745011]  [<c014efbb>] enter_state+0xab/0x140
[ 1176.745011]  [<c014f0f4>] state_store+0xa4/0xe0
[ 1176.745011]  [<c014f050>] ? state_store+0x0/0xe0
[ 1176.745011]  [<c0205934>] kobj_attr_store+0x24/0x30
[ 1176.745011]  [<c01b8a37>] sysfs_write_file+0xa7/0x100
[ 1176.745011]  [<c017b4da>] vfs_write+0x9a/0x120
[ 1176.745011]  [<c01b8990>] ? sysfs_write_file+0x0/0x100
[ 1176.745011]  [<c017b622>] sys_write+0x42/0x70
[ 1176.745011]  [<c010334d>] sysenter_do_call+0x12/0x35
[ 1176.745011]  =======================
[ 1176.745011] Force enabled HPET at resume
[ 1176.748667] ACPI: Waking up from system sleep state S3
[ 1176.801657] ACPI: EC: non-query interrupt received, switching to interrupt mode
Signature · 1 line
Sitsofe | http://sucs.org/~sits/
#6 lore raw
In reply to a message not in the archive

[ cc'd: lkml ]

Quoted 11 lines · Dmitry Adamushko
Quoted 9 lines · Ingo Molnar
Quoted 2 lines · Peter Oruba

microcode_update_cpu() is still there, being called from microcode_init_cpu() and mc_sysdev_resume().

ah, microcode_update_cpu, not update_microcode_cpu. So yes, the problem
is still there with the latest code.

Right, I've been looking at the wrong tree. Please find the fix enclosed. Compiles ok, shouldn't break anything else.

Quoted 3 lines

Ingo

Signature · 2 lines
Best regards,
Dmitry Adamushko
#7 lore raw

err... I appologize for spamming. I've forgot to attach the fix.

Quoted 28 lines · Dmitry Adamushko
Quoted 11 lines · Ingo Molnar
Quoted 9 lines · Peter Oruba
Quoted 3 lines

microcode_update_cpu() is still there, being called from microcode_init_cpu() and mc_sysdev_resume().

ah, microcode_update_cpu, not update_microcode_cpu. So yes, the problem
is still there with the latest code.

Right, I've been looking at the wrong tree. Please find the fix enclosed. Compiles ok, shouldn't break anything else.

Quoted 3 lines

Ingo

--
Best regards,
Dmitry Adamushko

Signature · 2 lines
Best regards,
Dmitry Adamushko

Subject: x86-microcode: update locking scheme

Fix the following "sleeping function called from invalid context" warning:

...
__might_sleep
mutex_lock_nested
microcode_update_cpu
mc_sysdev_resume
__sysdev_resume
sysdev_resume
device_power_up
...

arch/x86/kernel/microcode_core.c +6 -7
index 8db2eb5..936d8d5 100644
@@ -324,10 +324,6 @@ void microcode_update_cpu(int cpu)
 	struct ucode_cpu_info *uci = ucode_cpu_info + cpu;
 	int err = 0;
 
-	/* We should bind the task to the CPU */
-	BUG_ON(raw_smp_processor_id() != cpu);
-
-	mutex_lock(&microcode_mutex);
 	/*
 	 * Check if the system resume is in progress (uci->valid != NULL),
 	 * otherwise just request a firmware:
@@ -340,11 +336,8 @@ void microcode_update_cpu(int cpu)
 			err = microcode_ops->request_microcode_fw(cpu,
 					&microcode_pdev->dev);
 	}
-
 	if (!err)
 		microcode_ops->apply_microcode(cpu);
-
-	mutex_unlock(&microcode_mutex);
 }
 
 static void microcode_init_cpu(int cpu)
@@ -352,7 +345,13 @@ static void microcode_init_cpu(int cpu)
 	cpumask_t old = current->cpus_allowed;
 
 	set_cpus_allowed_ptr(current, &cpumask_of_cpu(cpu));
+	/* We should bind the task to the CPU */
+	BUG_ON(raw_smp_processor_id() != cpu);
+
+	mutex_lock(&microcode_mutex);
 	microcode_update_cpu(cpu);
+	mutex_unlock(&microcode_mutex);
+
 	set_cpus_allowed_ptr(current, &old);
 }
 
Applied
#8 lore raw
Quoted 2 lines · Dmitry Adamushko
Quoted 2 lines

Right, I've been looking at the wrong tree. Please find the fix enclosed. Compiles ok, shouldn't break anything else.

applied to tip/x86/microcode, thanks Dmitry!

Ingo