From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Tom Gundersen <teg@jklm.no>,
linux-usb@vger.kernel.org, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, Jiri Kosina <jkosina@suse.cz>
Subject: Re: [PATCH][RFC] usbhid: enable autosuspend for internal devices
Date: Fri, 26 Jun 2015 15:15:17 -0700 [thread overview]
Message-ID: <20150626221517.GB2761@kroah.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1506261549310.1566-100000@iolanthe.rowland.org>
On Fri, Jun 26, 2015 at 04:08:20PM -0400, Alan Stern wrote:
> On Fri, 26 Jun 2015, Tom Gundersen wrote:
>
> > This policy used to be unconditionally applied by udev, but there
> > is no reason to make userspace be involved in this and in the future
> > udev will not be doing it by default.
> >
> > See: <https://github.com/systemd/systemd/pull/353>.
> >
> > Signed-off-by: Tom Gundersen <teg@jklm.no>
> > Cc: Jiri Kosina <jkosina@suse.cz>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >
> > Hi,
> >
> > I don't have the right hardware for this, so it has only been compile-tested.
> > I'm therefore sending it as an RFC only. Mainly I want to bring it to people's
> > attention that it would be great to get this feature into the kernel as we want
> > to drop it from udev.
> >
> > Cheers,
> >
> > Tom
> >
> > drivers/hid/usbhid/hid-core.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
> > index bfbe1be..af80700 100644
> > --- a/drivers/hid/usbhid/hid-core.c
> > +++ b/drivers/hid/usbhid/hid-core.c
> > @@ -1358,6 +1358,9 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id *
> > setup_timer(&usbhid->io_retry, hid_retry_timeout, (unsigned long) hid);
> > spin_lock_init(&usbhid->lock);
> >
> > + if (dev->removable == USB_DEVICE_FIXED)
> > + usb_enable_autosuspend(dev);
>
> This doesn't do what the patch title says. USB_DEVICE_FIXED means that
> the device can't be unplugged from its upstream port. It doesn't mean
> the device is internal to the computer.
>
> As an example, consider a composite Apple keyboard, which has an
> internal 3-port USB hub where two of the hub's ports are exposed on the
> edge of the keyboard case and the keyboard controller is permanently
> attached to the third hub port. Then the controller device would be
> marked USB_DEVICE_FIXED, even though the whole thing is external to
> the computer and can be unplugged.
>
Is that really how those devices are marked? I can't find any of my
keyboard with hubs that mark things that way.
> A reasonable compromise might be
>
> /*
> * Enable autosuspend for devices permanently attached
> * to the root hub.
> */
> if (!dev->parent->parent && dev->removable == USB_DEVICE_FIXED)
> usb_enable_autosuspend(dev);
>
> But this doesn't work if there's a permanently attached hub and a
> device permanently attached to that hub. To do this thoroughly, you
> have to iterate up the dev->parent chain, making sure at each step that
> the ->removable value is USB_DEVICE_FIXED.
>
> Also, are you really certain this is safe? Aren't there a number of
> built-in keyboards that will work badly if you allow them to
> autosuspend?
udev has been doing this for a while now by default, with no reports of
problems, so I think we should be safe.
thanks,
greg k-h
next prev parent reply other threads:[~2015-06-26 22:15 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 19:24 [PATCH][RFC] usbhid: enable autosuspend for internal devices Tom Gundersen
2015-06-26 19:32 ` Greg Kroah-Hartman
2015-06-26 20:08 ` Alan Stern
2015-06-26 20:28 ` Alan Stern
2015-06-26 22:15 ` Greg Kroah-Hartman [this message]
2015-06-27 1:20 ` Alan Stern
2015-06-27 1:29 ` Greg Kroah-Hartman
2015-06-27 6:29 ` Jiri Kosina
2015-06-27 15:31 ` Greg Kroah-Hartman
2015-06-30 15:21 ` Alan Stern
2015-06-29 9:48 ` Oliver Neukum
2015-06-29 11:16 ` Jiri Kosina
2015-06-29 11:37 ` Oliver Neukum
2015-06-29 12:00 ` Jiri Kosina
-- strict thread matches above, loose matches on Subject: below --
2015-07-02 7:18 Andreas Mohr
2015-07-02 14:08 ` Alan Stern
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=20150626221517.GB2761@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=teg@jklm.no \
/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