On Fri, 2019-08-02 at 12:27 -0400, Alan Stern wrote: > On Fri, 2 Aug 2019, Mayuresh Kulkarni wrote: > > > > > Hi Alan, > > > > Thanks a lot for clearing out the confusion. > > > > Our USB device can operate in 2 mutually exclusive modes: one is > > normal > > composite USB audio mode and other is vendor specific HID device > > mode. > > > > On the same platform (Android based): > > - When the device is in normal composite USB audio mode, > > "cat /sys/bus/usb/devices/.../power/control" show "auto". > > - When the device is in vendor specific HID device mode, > > "cat /sys/bus/usb/devices/.../power/control" show "on". > > > > And hence as per your comment, I am unable to see USB-2.0 L2 for > > vendor > > specific HID device mode. > > > > I guess I need to find out "who" is setting the /power/control = > > "auto" > > when composite USB audio device is detected. And explore if it could > > be > > moved to a more generic place. > I'm pretty sure this is done by some program, not automatically done > by > the kernel. I think I found what is happening here: - Looks like, the USB audio class driver is calling usb_enable_autosuspend(). - 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. 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? OR 2. Is it recommended to call usb_enable_autosuspend() from user-space by writing "auto" to "cat /sys/bus/usb/devices/.../power/control"? In my opinion, both should be fine. Thanks, > > > > > Is there any module parameter (or some other means) by which, > > power/control (or deprecated power/level) will always be "auto", by > > default? > No, there isn't. The power/control (or power/level) attribute has to > be set by the user or a program. > > Alan Stern >