From: Nigel Cunningham <nigel@nigel.suspend2.net>
To: Robert Hancock <hancockr@shaw.ca>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Jeff Garzik <jeff@garzik.org>
Subject: [PATCH] Re: NAK new drivers without proper power management?
Date: Sat, 10 Feb 2007 14:02:34 +1100 [thread overview]
Message-ID: <1171076554.10170.5.camel@nigel.suspend2.net> (raw)
In-Reply-To: <45CD24F6.8090107@shaw.ca>
Hi.
On Fri, 2007-02-09 at 19:50 -0600, Robert Hancock wrote:
> It also kind of bothers me that if a driver has no suspend/resume
> functions, and you suspend and resume the system, we don't complain
> about it even though there's a very good chance that device is not going
> to function properly. How about something in dmesg like:
>
> Warning: driver for device XXXX has no suspend or resume support.
> Device may not function properly after resume.
>
> so that users know who to complain to. Maybe there are some devices that
> truly don't need any handling for suspend, but if so I suspect the
> number of those is small enough that adding empty functions would be a
> good-enough solution.
Here's my current version of a patch to do this, if anyone wants to try
it out. It dumps stack with the warning to make it easier to see what
the source of the message is:
drivers/base/core.c | 25 +++++++++++++++++++++++++
drivers/pci/pci-driver.c | 6 ++++++
drivers/usb/core/driver.c | 5 +++++
include/linux/device.h | 1 +
4 files changed, 37 insertions(+)
diff -ruNp 920-report-no-pm-support.patch-old/drivers/base/core.c 920-report-no-pm-support.patch-new/drivers/base/core.c
--- 920-report-no-pm-support.patch-old/drivers/base/core.c 2007-02-06 14:48:31.000000000 +1100
+++ 920-report-no-pm-support.patch-new/drivers/base/core.c 2007-02-10 13:36:33.000000000 +1100
@@ -552,6 +552,30 @@ int device_add(struct device *dev)
class_intf->add_dev(dev, class_intf);
up(&dev->class->sem);
}
+
+#ifdef CONFIG_PM
+ {
+ int nosusp = 0, nores = 0;
+
+ if (!((dev->class && dev->class->suspend) ||
+ (dev->bus && (dev->bus->suspend || dev->bus->suspend_late))))
+ nosusp = 1;
+
+ if (!((dev->class && dev->class->resume) ||
+ (dev->bus && (dev->bus->resume || dev->bus->resume_early))))
+ nores = 1;
+
+ if ((nosusp || nores) && !dev->pm_safe) {
+ printk("Device driver %s lacks bus and class support for "
+ "being %s.\n",
+ kobject_name(&dev->kobj),
+ nosusp ? (nores ? "suspended or resumed" :
+ "resumed") : "suspended");
+ dump_stack();
+ }
+ }
+#endif
+
Done:
kfree(class_name);
put_device(dev);
@@ -851,6 +875,7 @@ struct device *device_create(struct clas
dev->class = class;
dev->parent = parent;
dev->release = device_create_release;
+ dev->pm_safe = 1;
va_start(args, fmt);
vsnprintf(dev->bus_id, BUS_ID_SIZE, fmt, args);
diff -ruNp 920-report-no-pm-support.patch-old/drivers/pci/pci-driver.c 920-report-no-pm-support.patch-new/drivers/pci/pci-driver.c
--- 920-report-no-pm-support.patch-old/drivers/pci/pci-driver.c 2007-02-06 14:48:44.000000000 +1100
+++ 920-report-no-pm-support.patch-new/drivers/pci/pci-driver.c 2007-02-10 14:00:39.000000000 +1100
@@ -449,6 +449,12 @@ int __pci_register_driver(struct pci_dri
if (error)
driver_unregister(&drv->driver);
+ if (!drv->suspend || !drv->resume)
+ printk("PCI driver %s lacks driver specific %s support.\n",
+ drv->name,
+ !drv->suspend ? (drv->resume ? "suspend" :
+ "suspend and resume") : "resume");
+
return error;
}
diff -ruNp 920-report-no-pm-support.patch-old/drivers/usb/core/driver.c 920-report-no-pm-support.patch-new/drivers/usb/core/driver.c
--- 920-report-no-pm-support.patch-old/drivers/usb/core/driver.c 2007-02-06 14:48:47.000000000 +1100
+++ 920-report-no-pm-support.patch-new/drivers/usb/core/driver.c 2007-02-10 12:32:57.000000000 +1100
@@ -709,6 +709,11 @@ int usb_register_device_driver(struct us
pr_info("%s: registered new device driver %s\n",
usbcore_name, new_udriver->name);
usbfs_update_special();
+ if (!new_udriver->suspend || !new_udriver->resume)
+ printk("USB driver %s lacks %s support.\n",
+ new_udriver->name, !new_udriver->suspend ?
+ (new_udriver->resume ? "suspend" :
+ "suspend and resume") : "resume");
} else {
printk(KERN_ERR "%s: error %d registering device "
" driver %s\n",
diff -ruNp 920-report-no-pm-support.patch-old/include/linux/device.h 920-report-no-pm-support.patch-new/include/linux/device.h
--- 920-report-no-pm-support.patch-old/include/linux/device.h 2007-02-06 14:48:56.000000000 +1100
+++ 920-report-no-pm-support.patch-new/include/linux/device.h 2007-02-10 13:36:01.000000000 +1100
@@ -356,6 +356,7 @@ struct device {
struct kobject kobj;
char bus_id[BUS_ID_SIZE]; /* position on parent bus */
unsigned is_registered:1;
+ unsigned pm_safe:1; /* No suspend/resume fns ok? */
struct device_attribute uevent_attr;
struct device_attribute *devt_attr;
My output:
nigel@nigel:~$ dmesg | grep lacks
[ 15.113674] Device driver platform lacks bus and class support for being suspended or resumed.
[ 15.131601] Device driver pci0000:00 lacks bus and class support for being suspended or resumed.
[ 15.179802] Device driver pnp0 lacks bus and class support for being suspended or resumed.
[ 15.972661] Device driver ide0 lacks bus and class support for being suspended or resumed.
[ 17.829746] Device driver ide1 lacks bus and class support for being suspended or resumed.
[ 17.830878] PCI driver ALI15x3_IDE lacks driver specific suspend and resume support.
[ 17.830963] PCI driver PIIX_IDE lacks driver specific suspend and resume support.
[ 17.878190] Device driver serio0 lacks bus and class support for being resumed.
[ 17.878442] Device driver serio1 lacks bus and class support for being resumed.
[ 17.878672] Device driver serio2 lacks bus and class support for being resumed.
[ 18.555856] Device driver serio3 lacks bus and class support for being resumed.
[ 18.558109] Device driver serio4 lacks bus and class support for being resumed.
[ 78.487717] Device driver usbdev1.1_ep00 lacks bus and class support for being suspended or resumed.
[ 78.595362] Device driver usbdev1.1_ep81 lacks bus and class support for being suspended or resumed.
[ 78.657382] Device driver usbdev2.1_ep00 lacks bus and class support for being suspended or resumed.
[ 78.765044] Device driver usbdev2.1_ep81 lacks bus and class support for being suspended or resumed.
[ 78.795324] Device driver usbdev3.1_ep00 lacks bus and class support for being suspended or resumed.
[ 78.904912] Device driver usbdev3.1_ep81 lacks bus and class support for being suspended or resumed.
[ 78.936997] PCI driver ali15x3_smbus lacks driver specific suspend and resume support.
[ 78.996318] PCI driver ali1535_smbus lacks driver specific suspend and resume support.
next prev parent reply other threads:[~2007-02-10 3:02 UTC|newest]
Thread overview: 64+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <fa.xSKPgY66Q+DPCZ1pszFFfdrJ0To@ifi.uio.no>
[not found] ` <fa.FzHdYYYH5Ru57c8/yRxLylpH0Kk@ifi.uio.no>
[not found] ` <fa.DuG12yQo+RR4jIjJTnoOwtKM0Ao@ifi.uio.no>
[not found] ` <fa.Jy0FJQtASvVEpsy8Q96uoHtyEVA@ifi.uio.no>
2007-02-10 1:50 ` NAK new drivers without proper power management? Robert Hancock
2007-02-10 1:59 ` Lee Revell
2007-02-10 2:09 ` Nigel Cunningham
2007-02-10 2:22 ` Lee Revell
2007-02-10 3:21 ` Kevin Fox
2007-02-10 20:40 ` Adrian Bunk
2007-02-10 4:35 ` Joseph Fannin
2007-02-13 21:08 ` Pavel Machek
2007-02-10 12:47 ` Stefan Richter
2007-02-10 2:05 ` Nigel Cunningham
2007-02-10 3:27 ` Dmitry Torokhov
2007-02-10 4:18 ` Nigel Cunningham
2007-02-10 3:02 ` Nigel Cunningham [this message]
2007-02-10 9:34 ` [PATCH] " Rafael J. Wysocki
2007-02-10 10:02 ` Nigel Cunningham
2007-02-10 10:30 ` Rafael J. Wysocki
2007-02-10 17:52 ` Daniel Barkalow
2007-02-10 19:50 ` Rafael J. Wysocki
2007-02-11 6:54 ` Willy Tarreau
2007-02-11 12:13 ` Matthew Garrett
2007-02-11 13:09 ` Willy Tarreau
2007-02-11 13:19 ` Matthew Garrett
2007-02-11 13:37 ` Willy Tarreau
2007-02-11 13:50 ` Rafael J. Wysocki
2007-02-11 13:57 ` Willy Tarreau
2007-02-11 14:36 ` Rafael J. Wysocki
2007-02-11 15:19 ` Pekka Enberg
2007-02-11 18:31 ` Rafael J. Wysocki
2007-02-11 17:27 ` Daniel Barkalow
2007-02-11 18:53 ` Rafael J. Wysocki
2007-02-11 23:06 ` Nigel Cunningham
2007-02-11 23:10 ` Rafael J. Wysocki
2007-02-11 21:04 ` Stefan Richter
2007-02-11 21:10 ` Pavel Machek
2007-02-11 17:36 ` Robert Hancock
2007-02-11 22:49 ` Nigel Cunningham
2007-02-11 19:37 ` Pavel Machek
[not found] ` <fa.DhkemAgVI60diqZy0t9GzpwyLmk@ifi.uio.no>
[not found] ` <fa.E/NjHlgg0HqDg5CgZjnCHFi2AMM@ifi.uio.no>
[not found] ` <fa.kop49l/7yexJoUGrzk6vVeIP934@ifi.uio.no>
2007-02-10 23:20 ` Robert Hancock
2007-02-11 0:44 ` Rafael J. Wysocki
2007-02-11 17:01 ` Pavel Machek
2007-02-11 22:40 ` Nigel Cunningham
2007-02-11 23:29 ` Rafael J. Wysocki
2007-02-11 23:40 ` Nigel Cunningham
[not found] ` <fa.EgQN5JpU6xrZSLyOY0kWjJ26hUM@ifi.uio.no>
2007-02-11 18:31 ` Robert Hancock
2007-02-11 21:52 ` Willy Tarreau
2007-02-11 22:26 ` Nigel Cunningham
2007-02-11 22:46 ` Willy Tarreau
2007-02-11 23:18 ` Nigel Cunningham
2007-02-11 23:38 ` Willy Tarreau
2007-02-11 23:45 ` Nigel Cunningham
2007-02-12 0:26 ` Alan
2007-02-12 5:19 ` Willy Tarreau
2007-02-12 20:20 ` Rafael J. Wysocki
2007-02-12 22:36 ` Nigel Cunningham
2007-02-11 23:23 ` Alan
2007-02-11 23:38 ` Rafael J. Wysocki
2007-02-11 23:41 ` Rafael J. Wysocki
2007-02-11 23:47 ` Nigel Cunningham
2007-02-11 23:50 ` Rafael J. Wysocki
2007-02-11 23:55 ` Nigel Cunningham
2007-02-12 0:09 ` Rafael J. Wysocki
2007-02-12 0:15 ` Nigel Cunningham
2007-02-12 12:19 ` Pavel Machek
[not found] ` <fa.O1YH4k5KtBGCNs5i2yB17bPvPGw@ifi.uio.no>
[not found] ` <fa.RfzClbTP/7B79AoEbQLNj3ABfIk@ifi.uio.no>
[not found] ` <fa.AaJ/ugmiUmPO8uC+y1rS9JLuuMc@ifi.uio.no>
2007-02-12 0:59 ` Robert Hancock
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1171076554.10170.5.camel@nigel.suspend2.net \
--to=nigel@nigel.suspend2.net \
--cc=hancockr@shaw.ca \
--cc=jeff@garzik.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox