* [RFC] Wakeup for PNP
[not found] <20100223214920.GA14313@core.coreip.homeip.net>
@ 2010-03-02 20:13 ` Alan Stern
2010-03-02 20:41 ` Bjorn Helgaas
2010-03-02 21:31 ` Dmitry Torokhov
0 siblings, 2 replies; 6+ messages in thread
From: Alan Stern @ 2010-03-02 20:13 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: Linux-pm mailing list, linux-input
On Tue, 23 Feb 2010, Dmitry Torokhov wrote:
> Yes, I agree, we need a genric mechanism for PNP to emable wakups. It
> was discussed a bit here:
>
> http://bugzilla.kernel.org/show_bug.cgi?id=8286
>
> but David was too hung up on the fact that number of devices in ACPI
> does not map directly onto number of serio ports when i8042 is in active
> multiplexing mode that it id not go anywhere.
Does this look reasonable? I don't know anything about PNPBIOS or
ISAPNP, so it handles only PNPACPI. But at least it's a starting
point -- and it does enable my system to wake up in response to
hitting a key.
(This combines changes to the PNP core with changes to the i8042
drivers. For submission they can be broken out into separate patches.)
Alan Stern
Index: usb-2.6/drivers/input/serio/i8042-x86ia64io.h
===================================================================
--- usb-2.6.orig/drivers/input/serio/i8042-x86ia64io.h
+++ usb-2.6/drivers/input/serio/i8042-x86ia64io.h
@@ -625,6 +625,7 @@ static int i8042_pnp_kbd_probe(struct pn
}
i8042_pnp_kbd_devices++;
+ device_set_wakeup_enable(&dev->dev, true);
return 0;
}
@@ -646,6 +647,7 @@ static int i8042_pnp_aux_probe(struct pn
}
i8042_pnp_aux_devices++;
+ device_set_wakeup_enable(&dev->dev, true);
return 0;
}
@@ -656,7 +658,7 @@ static struct pnp_device_id pnp_kbd_devi
};
static struct pnp_driver i8042_pnp_kbd_driver = {
- .name = "i8042 kbd",
+ .name = "i8042-kbd",
.id_table = pnp_kbd_devids,
.probe = i8042_pnp_kbd_probe,
};
@@ -676,7 +678,7 @@ static struct pnp_device_id pnp_aux_devi
};
static struct pnp_driver i8042_pnp_aux_driver = {
- .name = "i8042 aux",
+ .name = "i8042-aux",
.id_table = pnp_aux_devids,
.probe = i8042_pnp_aux_probe,
};
Index: usb-2.6/drivers/pnp/core.c
===================================================================
--- usb-2.6.orig/drivers/pnp/core.c
+++ usb-2.6/drivers/pnp/core.c
@@ -164,6 +164,9 @@ int __pnp_add_device(struct pnp_dev *dev
list_add_tail(&dev->global_list, &pnp_global);
list_add_tail(&dev->protocol_list, &dev->protocol->devices);
spin_unlock(&pnp_lock);
+ device_set_wakeup_capable(&dev->dev,
+ dev->protocol->can_wakeup &&
+ dev->protocol->can_wakeup(dev));
return device_register(&dev->dev);
}
Index: usb-2.6/drivers/pnp/pnpacpi/core.c
===================================================================
--- usb-2.6.orig/drivers/pnp/pnpacpi/core.c
+++ usb-2.6/drivers/pnp/pnpacpi/core.c
@@ -121,12 +121,27 @@ static int pnpacpi_disable_resources(str
}
#ifdef CONFIG_ACPI_SLEEP
+static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
+{
+ acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
+
+ return handle && acpi_bus_can_wakeup(handle);
+}
+
static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
{
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;
int power_state;
+ if (device_can_wakeup(&dev->dev)) {
+ int ret;
+
+ ret = acpi_pm_device_sleep_wake(&dev->dev,
+ device_may_wakeup(&dev->dev));
+ if (ret)
+ return ret;
+ }
power_state = acpi_pm_device_sleep_state(&dev->dev, NULL);
if (power_state < 0)
power_state = (state.event == PM_EVENT_ON) ?
@@ -140,6 +155,8 @@ static int pnpacpi_resume(struct pnp_dev
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;
+ if (device_can_wakeup(&dev->dev))
+ acpi_pm_device_sleep_wake(&dev->dev, false);
return acpi_bus_set_power(handle, ACPI_STATE_D0);
}
#endif
@@ -150,6 +167,7 @@ struct pnp_protocol pnpacpi_protocol = {
.set = pnpacpi_set_resources,
.disable = pnpacpi_disable_resources,
#ifdef CONFIG_ACPI_SLEEP
+ .can_wakeup = pnpacpi_can_wakeup,
.suspend = pnpacpi_suspend,
.resume = pnpacpi_resume,
#endif
Index: usb-2.6/include/linux/pnp.h
===================================================================
--- usb-2.6.orig/include/linux/pnp.h
+++ usb-2.6/include/linux/pnp.h
@@ -414,6 +414,7 @@ struct pnp_protocol {
int (*disable) (struct pnp_dev *dev);
/* protocol specific suspend/resume */
+ bool (*can_wakeup) (struct pnp_dev *dev);
int (*suspend) (struct pnp_dev * dev, pm_message_t state);
int (*resume) (struct pnp_dev * dev);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Wakeup for PNP
2010-03-02 20:13 ` [RFC] Wakeup for PNP Alan Stern
@ 2010-03-02 20:41 ` Bjorn Helgaas
2010-03-02 21:08 ` Alan Stern
2010-03-02 21:31 ` Dmitry Torokhov
1 sibling, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2010-03-02 20:41 UTC (permalink / raw)
To: Alan Stern
Cc: Dmitry Torokhov, Li Shaohua, Linux-pm mailing list, linux-input
On Tuesday 02 March 2010 01:13:30 pm Alan Stern wrote:
> On Tue, 23 Feb 2010, Dmitry Torokhov wrote:
>
> > Yes, I agree, we need a genric mechanism for PNP to emable wakups. It
> > was discussed a bit here:
> >
> > http://bugzilla.kernel.org/show_bug.cgi?id=8286
> >
> > but David was too hung up on the fact that number of devices in ACPI
> > does not map directly onto number of serio ports when i8042 is in active
> > multiplexing mode that it id not go anywhere.
>
> Does this look reasonable? I don't know anything about PNPBIOS or
> ISAPNP, so it handles only PNPACPI. But at least it's a starting
> point -- and it does enable my system to wake up in response to
> hitting a key.
I don't know much about power management, but your patch looks
reasonable to me.
> --- usb-2.6.orig/drivers/pnp/pnpacpi/core.c
> +++ usb-2.6/drivers/pnp/pnpacpi/core.c
> @@ -121,12 +121,27 @@ static int pnpacpi_disable_resources(str
> }
>
> #ifdef CONFIG_ACPI_SLEEP
> +static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
> +{
> + acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
I would have used:
struct acpi_device *acpi_dev = dev->data;
acpi_handle handle = acpi_dev->handle;
here because that's what the rest of the PNPACPI code does.
Bjorn
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Wakeup for PNP
2010-03-02 20:41 ` Bjorn Helgaas
@ 2010-03-02 21:08 ` Alan Stern
0 siblings, 0 replies; 6+ messages in thread
From: Alan Stern @ 2010-03-02 21:08 UTC (permalink / raw)
To: Bjorn Helgaas
Cc: Dmitry Torokhov, Li Shaohua, Linux-pm mailing list, linux-input
On Tue, 2 Mar 2010, Bjorn Helgaas wrote:
> > Does this look reasonable? I don't know anything about PNPBIOS or
> > ISAPNP, so it handles only PNPACPI. But at least it's a starting
> > point -- and it does enable my system to wake up in response to
> > hitting a key.
>
> I don't know much about power management, but your patch looks
> reasonable to me.
Thanks.
> > --- usb-2.6.orig/drivers/pnp/pnpacpi/core.c
> > +++ usb-2.6/drivers/pnp/pnpacpi/core.c
> > @@ -121,12 +121,27 @@ static int pnpacpi_disable_resources(str
> > }
> >
> > #ifdef CONFIG_ACPI_SLEEP
> > +static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
> > +{
> > + acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
>
> I would have used:
>
> struct acpi_device *acpi_dev = dev->data;
> acpi_handle handle = acpi_dev->handle;
>
> here because that's what the rest of the PNPACPI code does.
Ah yes. I just copied the code from the corresponding PCI function
without thinking about it very much. I'll update the patch and wait to
hear from other people.
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Wakeup for PNP
2010-03-02 20:13 ` [RFC] Wakeup for PNP Alan Stern
2010-03-02 20:41 ` Bjorn Helgaas
@ 2010-03-02 21:31 ` Dmitry Torokhov
2010-03-03 15:29 ` Alan Stern
1 sibling, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2010-03-02 21:31 UTC (permalink / raw)
To: Alan Stern; +Cc: Bjorn Helgaas, Li Shaohua, Linux-pm mailing list, linux-input
On Tue, Mar 02, 2010 at 03:13:30PM -0500, Alan Stern wrote:
> On Tue, 23 Feb 2010, Dmitry Torokhov wrote:
>
> > Yes, I agree, we need a genric mechanism for PNP to emable wakups. It
> > was discussed a bit here:
> >
> > http://bugzilla.kernel.org/show_bug.cgi?id=8286
> >
> > but David was too hung up on the fact that number of devices in ACPI
> > does not map directly onto number of serio ports when i8042 is in active
> > multiplexing mode that it id not go anywhere.
>
> Does this look reasonable? I don't know anything about PNPBIOS or
> ISAPNP, so it handles only PNPACPI. But at least it's a starting
> point -- and it does enable my system to wake up in response to
> hitting a key.
>
> (This combines changes to the PNP core with changes to the i8042
> drivers. For submission they can be broken out into separate patches.)
>
> Alan Stern
>
>
> Index: usb-2.6/drivers/input/serio/i8042-x86ia64io.h
> ===================================================================
> --- usb-2.6.orig/drivers/input/serio/i8042-x86ia64io.h
> +++ usb-2.6/drivers/input/serio/i8042-x86ia64io.h
> @@ -625,6 +625,7 @@ static int i8042_pnp_kbd_probe(struct pn
> }
>
> i8042_pnp_kbd_devices++;
> + device_set_wakeup_enable(&dev->dev, true);
> return 0;
> }
>
> @@ -646,6 +647,7 @@ static int i8042_pnp_aux_probe(struct pn
> }
>
> i8042_pnp_aux_devices++;
> + device_set_wakeup_enable(&dev->dev, true);
> return 0;
> }
>
> @@ -656,7 +658,7 @@ static struct pnp_device_id pnp_kbd_devi
> };
>
> static struct pnp_driver i8042_pnp_kbd_driver = {
> - .name = "i8042 kbd",
> + .name = "i8042-kbd",
Why is this needed? I don't think spaces are more dangerous than a colon
which we do use...
Other than that - looks reasonable to me...
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Wakeup for PNP
2010-03-02 21:31 ` Dmitry Torokhov
@ 2010-03-03 15:29 ` Alan Stern
2010-03-09 7:45 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2010-03-03 15:29 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Bjorn Helgaas, Li Shaohua, Linux-pm mailing list, linux-input
On Tue, 2 Mar 2010, Dmitry Torokhov wrote:
> > @@ -656,7 +658,7 @@ static struct pnp_device_id pnp_kbd_devi
> > };
> >
> > static struct pnp_driver i8042_pnp_kbd_driver = {
> > - .name = "i8042 kbd",
> > + .name = "i8042-kbd",
>
> Why is this needed? I don't think spaces are more dangerous than a colon
> which we do use...
This string becomes the name of a directory in sysfs. Having a ' '
character in a directory name just doesn't seem like a good idea; at
the very least it's likely to confuse shell scripts. (A ':' character
is a lot less subject to misinterpretation.) I could change the '-' to
':' if you prefer.
> Other than that - looks reasonable to me...
Thanks. I'll separate out the driver name change from the rest of the
patch.
There are a couple of questions remaining. The patch enables wakeup on
the i8042-aux device -- is this a good idea? I haven't tested that
part of it yet, but we wouldn't want suspended systems waking up just
because somebody moves the mouse around. On the other hand, on some
machines (like mine!) it may not be possible to enable keyboard-wakeup
without also enabling mouse-wakeup, since they use the same GPE.
Also, the patch effectively tells the kernel that ISAPNP and PNPBIOS
devices are incapable of issuing wakeup requests. Is that going to
cause trouble for people? Would it be better to change the patch so
that it doesn't call device_set_wakeup_capable() if
dev->protocol->can_wakeup isn't defined?
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC] Wakeup for PNP
2010-03-03 15:29 ` Alan Stern
@ 2010-03-09 7:45 ` Dmitry Torokhov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2010-03-09 7:45 UTC (permalink / raw)
To: Alan Stern; +Cc: Bjorn Helgaas, Li Shaohua, Linux-pm mailing list, linux-input
Hi Alan,
On Wed, Mar 03, 2010 at 10:29:09AM -0500, Alan Stern wrote:
> On Tue, 2 Mar 2010, Dmitry Torokhov wrote:
>
> > > @@ -656,7 +658,7 @@ static struct pnp_device_id pnp_kbd_devi
> > > };
> > >
> > > static struct pnp_driver i8042_pnp_kbd_driver = {
> > > - .name = "i8042 kbd",
> > > + .name = "i8042-kbd",
> >
> > Why is this needed? I don't think spaces are more dangerous than a colon
> > which we do use...
>
> This string becomes the name of a directory in sysfs. Having a ' '
> character in a directory name just doesn't seem like a good idea; at
> the very least it's likely to confuse shell scripts. (A ':' character
> is a lot less subject to misinterpretation.) I could change the '-' to
> ':' if you prefer.
>
We have not heard complains about this causing trouble ever since PNP
support was added (so what 5 years at least?). At this point I'd be more
worried about breaking existing users...
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-09 7:45 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20100223214920.GA14313@core.coreip.homeip.net>
2010-03-02 20:13 ` [RFC] Wakeup for PNP Alan Stern
2010-03-02 20:41 ` Bjorn Helgaas
2010-03-02 21:08 ` Alan Stern
2010-03-02 21:31 ` Dmitry Torokhov
2010-03-03 15:29 ` Alan Stern
2010-03-09 7:45 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).