From: Mayuresh Kulkarni <mkulkarni@opensource.cirrus.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: <linux-usb@vger.kernel.org>
Subject: Re: About usb_new_device() API
Date: Mon, 5 Aug 2019 17:30:57 +0100 [thread overview]
Message-ID: <1565022657.10537.9.camel@opensource.cirrus.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1908051003420.1626-100000@iolanthe.rowland.org>
On Mon, 2019-08-05 at 10:07 -0400, Alan Stern wrote:
> On Mon, 5 Aug 2019, Mayuresh Kulkarni wrote:
>
> >
> > I think I found what is happening here:
> > - Looks like, the USB audio class driver is
> > calling usb_enable_autosuspend().
> The audio maintainers must have some good reason for doing that, but
> I
> don't know what it is. Normally kernel drivers are not supposed to
> enable autosuspend.
>
Thanks, please see my comment below.
> >
> > - Please check $KERNEL_SRC/sound/usb, card.c, usb_audio_probe().
> > - It is using interface_to_usbdev() to get the parent of its
> > interface
> > device, which is the USB device allocated by the hub driver.
> > And hence, in above use-case, I can see L2 when our device is in
> > composite USB-audio mode.
> >
Apologies, as I send the above response, without checking the latest
stable kernel tree.
In the kernel used on the platform I use (and also in Pixel-2 kernel),
the .probe() of USB-audio class driver calls usb_enable_autosuspend().
usb_enable_autosuspend() call is NOT present in latest stable kernel's
USB-audio class driver, which is in-sync with your comment.
> > Moreover, the HID-class driver doesn't seem to call
> > usb_enable_autosuspend() on its parent and hence I don't see L2 when
> > our
> > device operates as a vendor specific HID device.
> > So a simple fix would be to call usb_enable_autosuspend() from HID
> > class
> > driver as well.
> >
> > With that said, what would be your recommendation here, Alan -
> > 1. Is it OK for USB-class drivers to call usb_enable_autosuspend()
> > on
> > their parent device to ensure low power state is entered?
> Generally it is _not_ okay. Especially not for the HID class driver
> --
> there are far too many HID devices (like mice and keyboards) that
> don't
> work correctly when they go to low power.
>
> >
> > OR
> > 2. Is it recommended to call usb_enable_autosuspend() from user-
> > space by
> > writing "auto" to "cat /sys/bus/usb/devices/.../power/control"?
> That is the recommended approach.
>
This all makes sense now.
Thanks for all the comments and explainations.
> >
> > In my opinion, both should be fine.
> Alan Stern
>
prev parent reply other threads:[~2019-08-05 16:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-01 14:49 About usb_new_device() API Mayuresh Kulkarni
2019-08-01 17:51 ` Alan Stern
2019-08-02 15:43 ` Mayuresh Kulkarni
2019-08-02 16:27 ` Alan Stern
2019-08-05 8:43 ` Mayuresh Kulkarni
2019-08-05 14:07 ` Alan Stern
2019-08-05 16:30 ` Mayuresh Kulkarni [this message]
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=1565022657.10537.9.camel@opensource.cirrus.com \
--to=mkulkarni@opensource.cirrus.com \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/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;
as well as URLs for NNTP newsgroup(s).