Skip to contentSkip to conversation

s2ram: warn when interrupts should be disabled but are not

PATCH Pavel Machek 4 participants 5 messages Apr 12, 2008 – Apr 15, 2008 Driver core

lore
Share & tools
lore
#0 lore raw

sysdevs should be suspended/resumed with IRQs disabled; if something reenables them by mistake, we want to know early.

---
commit fc3bccaf69e6c05464e7154369639bd5c96ccdc1
tree bf960093ddb840242a00b4ec456ec79472b1c2ad
parent 308e9d5309f378209e931f63f729806ec0a4d9f1
author Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200 committer Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200

 drivers/ata/ahci.c |    2 +-
 drivers/base/sys.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)
drivers/base/sys.c +3 -0
index 8e13fd9..e214467 100644
@@ -22,6 +22,7 @@ #include <linux/string.h>
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
+#include <linux/hardirq.h>
 
 #include "base.h"
 
@@ -367,6 +368,7 @@ int sysdev_suspend(pm_message_t state)
 			/* Call auxillary drivers first */
 			list_for_each_entry(drv, &cls->drivers, entry) {
 				if (drv->suspend) {
+					WARN_ON(!irqs_disabled());
 					ret = drv->suspend(sysdev, state);
 					if (ret)
 						goto aux_driver;
@@ -442,6 +444,7 @@ int sysdev_resume(void)
 		list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
 			pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
+			WARN_ON(!irqs_disabled());
 			__sysdev_resume(sysdev);
 		}
 	}
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw
Quoted 10 lines · Pavel Machek

---
commit fc3bccaf69e6c05464e7154369639bd5c96ccdc1
tree bf960093ddb840242a00b4ec456ec79472b1c2ad
parent 308e9d5309f378209e931f63f729806ec0a4d9f1
author Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200 committer Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200

 drivers/ata/ahci.c |    2 +-
 drivers/base/sys.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

What happened to the drivers/ata/ahci.c part of the patch?

Quoted 21 lines
drivers/base/sys.c +2 -0
index 8e13fd9..e214467 100644
@@ -22,6 +22,7 @@ #include <linux/string.h>
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
+#include <linux/hardirq.h>
 
 #include "base.h"
 
@@ -367,6 +368,7 @@ int sysdev_suspend(pm_message_t state)
 			/* Call auxillary drivers first */
 			list_for_each_entry(drv, &cls->drivers, entry) {
 				if (drv->suspend) {
+					WARN_ON(!irqs_disabled());
 					ret = drv->suspend(sysdev, state);
 					if (ret)
 						goto aux_driver;

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

Quoted 7 lines
drivers/base/sys.c +1 -0
@@ -442,6 +444,7 @@ int sysdev_resume(void)
 		list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
 			pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
+			WARN_ON(!irqs_disabled());
 			__sysdev_resume(sysdev);
 		}
 	}

Alan Stern

#2 lore raw
Quoted 9 lines · Alan Stern
Quoted 7 lines · Pavel Machek

---
commit fc3bccaf69e6c05464e7154369639bd5c96ccdc1
tree bf960093ddb840242a00b4ec456ec79472b1c2ad
parent 308e9d5309f378209e931f63f729806ec0a4d9f1
author Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200 committer Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200

Quoted 5 lines
Quoted 3 lines
 drivers/ata/ahci.c |    2 +-
 drivers/base/sys.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)

What happened to the drivers/ata/ahci.c part of the patch?

Sorry, bad diffstat (but correct patch).

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw
In reply to Pavel Machek
Quoted 2 lines · Pavel Machek

+                                       WARN_ON(!irqs_disabled()); ret = drv->suspend(sysdev, state);

Wouldn't it be better to assert the warning AFTER the driver had a chance to screw it up? (On the resume side of things too.)

We know IRQs were disabled on entry to the loop. If something went wrong it was some goofy driver. Best warn about it ASAP instead of *maybe* getting a warning before the next driver (if there is one).

And if you're concerned about such issues, I'd think similar warnings would be done in suspend_late() and resume_early() support...

- Dave

#4 lore raw
In reply to Pavel Machek
Quoted 30 lines · On Sat, 12 Apr 2008 11:53:11 +0200 Pavel Machek <[email protected]> wrote:

sysdevs should be suspended/resumed with IRQs disabled; if something reenables them by mistake, we want to know early.

---
commit fc3bccaf69e6c05464e7154369639bd5c96ccdc1
tree bf960093ddb840242a00b4ec456ec79472b1c2ad
parent 308e9d5309f378209e931f63f729806ec0a4d9f1
author Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200 committer Pavel <[email protected]> Sat, 12 Apr 2008 11:52:05 +0200

 drivers/ata/ahci.c |    2 +-
 drivers/base/sys.c |    3 +++
 2 files changed, 4 insertions(+), 1 deletions(-)
drivers/base/sys.c +1 -0
index 8e13fd9..e214467 100644
@@ -22,6 +22,7 @@ #include <linux/string.h>
 #include <linux/pm.h>
 #include <linux/device.h>
 #include <linux/mutex.h>
+#include <linux/hardirq.h>
 
 #include "base.h"
 

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

Quoted 7 lines
drivers/base/sys.c +1 -0
@@ -367,6 +368,7 @@ int sysdev_suspend(pm_message_t state)
 			/* Call auxillary drivers first */
 			list_for_each_entry(drv, &cls->drivers, entry) {
 				if (drv->suspend) {
+					WARN_ON(!irqs_disabled());
 					ret = drv->suspend(sysdev, state);
 					if (ret)
 						goto aux_driver;

Is this warning ever triggers I expect we'll really really wish that we'd done the check _after_ calling drv->suspend, and that we had also done a print_symbol(drv->suspend). No?

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

Quoted 8 lines
drivers/base/sys.c +1 -0
@@ -442,6 +444,7 @@ int sysdev_resume(void)
 		list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
 			pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
+			WARN_ON(!irqs_disabled());
 			__sysdev_resume(sysdev);
 		}
 	}

Perhaps here too.