Skip to contentSkip to conversation

PM: Warn if interrupts are enabled during suspend-resume of sysdevs

RFC PATCH In review Rafael J. Wysocki 3 participants 9 messages Apr 4, 2009 – Apr 5, 2009 Driver core

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 PM: Warn if interrupts are enabled during suspend-resume of sysdevs

From: Rafael J. Wysocki <[email protected]>

Sysdev have to be suspended and resumed with interrupts disabled and things usually break in a way that's difficult to debug if one of sysdev drivers enables interrupts by mistake during suspend or resume. Add extra checks that will generate warnings in such cases.

---
 drivers/base/sys.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)
drivers/base/sys.c +16 -0
Index: linux-2.6/drivers/base/sys.c
===================================================================
@@ -343,11 +343,15 @@ static void __sysdev_resume(struct sys_d
 	/* First, call the class-specific one */
 	if (cls->resume)
 		cls->resume(dev);
+	WARN_ONCE(!irqs_disabled(),
+		"Interrupts enabled after %pF\n", cls->resume);
 
 	/* Call auxillary drivers next. */
 	list_for_each_entry(drv, &cls->drivers, entry) {
 		if (drv->resume)
 			drv->resume(dev);
+		WARN_ONCE(!irqs_disabled(),
+			"Interrupts enabled after %pF\n", drv->resume);
 	}
 }
 
@@ -377,6 +381,9 @@ int sysdev_suspend(pm_message_t state)
 	if (ret)
 		return ret;
 
+	WARN_ONCE(!irqs_disabled(),
+		"Interrupts enabled while suspending system devices");
+
 	pr_debug("Suspending System Devices\n");
 
 	list_for_each_entry_reverse(cls, &system_kset->list, kset.kobj.entry) {
@@ -393,6 +400,9 @@ int sysdev_suspend(pm_message_t state)
 					if (ret)
 						goto aux_driver;
 				}
+				WARN_ONCE(!irqs_disabled(),
+					"Interrupts enabled after %pF\n",
+					drv->suspend);
 			}
 
 			/* Now call the generic one */
@@ -400,6 +410,9 @@ int sysdev_suspend(pm_message_t state)
 				ret = cls->suspend(sysdev, state);
 				if (ret)
 					goto cls_driver;
+				WARN_ONCE(!irqs_disabled(),
+					"Interrupts enabled after %pF\n",
+					cls->suspend);
 			}
 		}
 	}
@@ -452,6 +465,9 @@ int sysdev_resume(void)
 {
 	struct sysdev_class *cls;
 
+	WARN_ONCE(!irqs_disabled(),
+		"Interrupts enabled while resuming system devices");
+
 	pr_debug("Resuming System Devices\n");
 
 	list_for_each_entry(cls, &system_kset->list, kset.kobj.entry) {
#1 lore raw
Quoted 7 lines
drivers/base/sys.c +0 -0
@@ -377,6 +381,9 @@ int sysdev_suspend(pm_message_t state)
         if (ret)
                 return ret;


+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while suspending system devices"); +

Missing \n ?

Quoted 7 lines
drivers/base/sys.c +0 -0
@@ -452,6 +465,9 @@ int sysdev_resume(void)
  {
         struct sysdev_class *cls;


+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while resuming system devices"); +

Again.

Cheers,
FJP

#2 lore raw
In reply to Rafael J. Wysocki

Review int sysdev_suspend(pm_message_t state)>         if (ret)>                 return ret;>  > +       WARN_ONCE(!irqs_disabled(),> +               "Interrupts enabled while suspending system devices");> +

Quoted 1 line
(quoted diff) +0 -0
@@ -377,6 +381,9 @@ int sysdev_suspend(pm_message_t state)>         if (ret)>                 return ret;>  > +       WARN_ONCE(!irqs_disabled(),> +               "Interrupts enabled while suspending system devices");> +

Missing \n ?

Review int sysdev_resume(void)>  {>         struct sysdev_class *cls;>  > +       WARN_ONCE(!irqs_disabled(),> +               "Interrupts enabled while resuming system devices");> +

Quoted 1 line
(quoted diff) +0 -0
@@ -452,6 +465,9 @@ int sysdev_resume(void)>  {>         struct sysdev_class *cls;>  > +       WARN_ONCE(!irqs_disabled(),> +               "Interrupts enabled while resuming system devices");> +

Again. Cheers,FJPÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºʇڙë,j­¢f£¢·hš�ï�êÿ‘êçz_è®(­éšŽŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨è­Ú&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿà ÿ¶ìÿ¢¸?–I¥

#3 lore raw
Quoted 14 lines · Frans Pop

drivers/base/sys.c int sysdev_suspend(pm_message_t state) · line 386

Quoted 7 lines
drivers/base/sys.c +3 -0
@@ -377,6 +381,9 @@ int sysdev_suspend(pm_message_t state)
        if (ret)
                return ret;
 
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while suspending system devices");
+

Missing \n ?

Quoted 4 lines
drivers/base/sys.c +0 -0
@@ -452,6 +465,9 @@ int sysdev_resume(void)
 {
        struct sysdev_class *cls;
 
Quoted 5 lines

drivers/base/sys.c int sysdev_resume(void) · line 470

Quoted 3 lines
drivers/base/sys.c +3 -0
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while resuming system devices");
+

Again.

Yes, thank.

Rafael

#4 lore raw
In reply to Frans Pop
Quoted 14 lines · Frans Pop

drivers/base/sys.c int sysdev_suspend(pm_message_t state) · line 386

Quoted 7 lines
drivers/base/sys.c +3 -0
@@ -377,6 +381,9 @@ int sysdev_suspend(pm_message_t state)
        if (ret)
                return ret;
 
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while suspending system devices");
+

Missing \n ?

Quoted 4 lines
drivers/base/sys.c +0 -0
@@ -452,6 +465,9 @@ int sysdev_resume(void)
 {
        struct sysdev_class *cls;
 
Quoted 5 lines

drivers/base/sys.c int sysdev_resume(void) · line 470

Quoted 3 lines
drivers/base/sys.c +3 -0
+       WARN_ONCE(!irqs_disabled(),
+               "Interrupts enabled while resuming system devices");
+

Again.

Yes, thank.

Rafael

#5 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Sysdev have to be suspended and resumed with interrupts disabled and things usually break in a way that's difficult to debug if one of sysdev drivers enables interrupts by mistake during suspend or resume. Add extra checks that will generate warnings in such cases.

no objections - but obviously the real solution would be to finish PeterZ's "detect assymetric kernel functions" patch:

That patch (Peter posted an initial version of it already on lkml) works the following way:

the ftrace function-graph-tracer plugin is utilized to instrument every function call in the kernel. That is extended with the following check: every function except __lockfunc and __sched functions must be 'balanced' - i.e. they must enter and exit with the same IRQ flags, preempt count and lock depth counter.

Ingo

#6 lore raw
In reply to Rafael J. Wysocki
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Sysdev have to be suspended and resumed with interrupts disabled and things usually break in a way that's difficult to debug if one of sysdev drivers enables interrupts by mistake during suspend or resume. Add extra checks that will generate warnings in such cases.

no objections - but obviously the real solution would be to finish PeterZ's "detect assymetric kernel functions" patch:

That patch (Peter posted an initial version of it already on lkml) works the following way:

the ftrace function-graph-tracer plugin is utilized to instrument every function call in the kernel. That is extended with the following check: every function except __lockfunc and __sched functions must be 'balanced' - i.e. they must enter and exit with the same IRQ flags, preempt count and lock depth counter.

Ingo

#7 lore raw
Quoted 14 lines · Ingo Molnar
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Sysdev have to be suspended and resumed with interrupts disabled and things usually break in a way that's difficult to debug if one of sysdev drivers enables interrupts by mistake during suspend or resume. Add extra checks that will generate warnings in such cases.

no objections - but obviously the real solution would be to finish PeterZ's "detect assymetric kernel functions" patch:

Quoted 8 lines

That patch (Peter posted an initial version of it already on lkml) works the following way:

the ftrace function-graph-tracer plugin is utilized to instrument every function call in the kernel. That is extended with the following check: every function except __lockfunc and __sched functions must be 'balanced' - i.e. they must enter and exit with the same IRQ flags, preempt count and lock depth counter.

Nothing wrong with that, but I'd also like to have checks that don't depend on ftrace. :-)

Thanks,
Rafael

#8 lore raw
In reply to Ingo Molnar
Quoted 14 lines · Ingo Molnar
Quoted 7 lines · Rafael J. Wysocki

From: Rafael J. Wysocki <[email protected]>

Sysdev have to be suspended and resumed with interrupts disabled and things usually break in a way that's difficult to debug if one of sysdev drivers enables interrupts by mistake during suspend or resume. Add extra checks that will generate warnings in such cases.

no objections - but obviously the real solution would be to finish PeterZ's "detect assymetric kernel functions" patch:

Quoted 8 lines

That patch (Peter posted an initial version of it already on lkml) works the following way:

the ftrace function-graph-tracer plugin is utilized to instrument every function call in the kernel. That is extended with the following check: every function except __lockfunc and __sched functions must be 'balanced' - i.e. they must enter and exit with the same IRQ flags, preempt count and lock depth counter.

Nothing wrong with that, but I'd also like to have checks that don't depend on ftrace. :-)

Thanks,
Rafael