Skip to contentSkip to conversation

2.4.22 ACPI power off via sysrq not working

DISCUSSION Andi Kleen 3 participants 3 messages Oct 3, 2003 – Oct 7, 2003 1 message not in the archive ACPI

lore
Share & tools
lore

Andi Kleen

author
#1 lore raw
In reply to a message not in the archive
Quoted 6 lines · Sylvain Pasche

Hi,

If I want to halt the system using sys-rq - o key, I get an oops instead of a power down.
Inside pm.c:159, there is:

Quoted 7 lines
	if (in_interrupt())
		BUG();

But if we look at the trace, we are in the interrupt of the keyboard handler.
One fix would be to comment out the BUG line, but there's certainly "a better way to do it".

Use this patch.

drivers/acpi/system.c renamed from drivers/acpi/system.c-o +12 -2
diff -u linux/drivers/acpi/system.c-o linux/drivers/acpi/system.c
@@ -1192,11 +1192,21 @@
 
 #if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
 
+static int po_cb_active; 
+
+static void acpi_po_tramp(void *x)
+{ 
+	acpi_power_off();	
+} 
+
 /* Simple wrapper calling power down function. */
 static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
 	struct kbd_struct *kbd, struct tty_struct *tty)
-{
-	acpi_power_off();
+{	
+	static struct tq_struct tq = { .routine = acpi_po_tramp };
+	if (po_cb_active++)
+		return;
+	schedule_task(&tq); 
 }
 
 struct sysrq_key_op sysrq_acpi_poweroff_op = {

-Andi

#2 lore raw
Quoted 27 lines · Andi Kleen
Quoted 2 lines · Sylvain Pasche

If I want to halt the system using sys-rq - o key, I get an oops instead of a power down.

Use this patch.

diff -u linux/drivers/acpi/system.c-o linux/drivers/acpi/system.c

drivers/acpi/system.c renamed from drivers/acpi/system.c-o +8 -2
@@ -1192,11 +1192,21 @@
 
 #if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
 
+static int po_cb_active; 
+
+static void acpi_po_tramp(void *x)
+{ 
+	acpi_power_off();	
+} 
+
 /* Simple wrapper calling power down function. */
 static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
 	struct kbd_struct *kbd, struct tty_struct *tty)
-{
-	acpi_power_off();
+{	

drivers/acpi/system.c

Quoted 10 lines
drivers/acpi/system.c renamed from drivers/acpi/system.c-o +4 -1
+	static struct tq_struct tq = { .routine = acpi_po_tramp };
+	if (po_cb_active++)
+		return;
+	schedule_task(&tq); 
 }
 
 struct sysrq_key_op sysrq_acpi_poweroff_op = {
 
 
-Andi

Yes, it works perfectly with it, thanks.
Do you forward it to the acpi maintainer ?

Cheers,

Sylvain

#3 lore raw
In reply to Andi Kleen
Quoted 35 lines · Andi Kleen
Quoted 6 lines · Sylvain Pasche

Hi,

If I want to halt the system using sys-rq - o key, I get an oops instead of a power down.
Inside pm.c:159, there is:

Quoted 7 lines
	if (in_interrupt())
		BUG();

But if we look at the trace, we are in the interrupt of the keyboard handler.
One fix would be to comment out the BUG line, but there's certainly "a better way to do it".

Use this patch.

diff -u linux/drivers/acpi/system.c-o linux/drivers/acpi/system.c

drivers/acpi/system.c renamed from drivers/acpi/system.c-o +7 -0
@@ -1192,11 +1192,21 @@
 
 #if defined(CONFIG_MAGIC_SYSRQ) && defined(CONFIG_PM)
 
+static int po_cb_active; 
+
+static void acpi_po_tramp(void *x)
+{ 
+	acpi_power_off();	
+} 
+
 /* Simple wrapper calling power down function. */
 static void acpi_sysrq_power_off(int key, struct pt_regs *pt_regs,
 	struct kbd_struct *kbd, struct tty_struct *tty)

drivers/acpi/system.c line 1212

Quoted 10 lines
drivers/acpi/system.c renamed from drivers/acpi/system.c-o +5 -2
-{
-	acpi_power_off();
+{	
+	static struct tq_struct tq = { .routine = acpi_po_tramp };
+	if (po_cb_active++)
+		return;
+	schedule_task(&tq); 
 }
 
 struct sysrq_key_op sysrq_acpi_poweroff_op = {

Fix applied to 2.4 mainline.