Kernel Newbies archive mirror
 help / color / mirror / Atom feed
From: Muni Sekhar <munisekharrms@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org,
	kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: Seeking Assistance: Implementing USB Device Suspend/Resume in User Space Driver
Date: Tue, 7 May 2024 17:14:25 +0530	[thread overview]
Message-ID: <CAHhAz+i9TLCb3hKpzWAL2DkH9Y25XszJO5kgbRGzsut1zCzrJw@mail.gmail.com> (raw)
In-Reply-To: <c309b037-50db-4ca1-8f86-60131cb84564@rowland.harvard.edu>

On Tue, May 7, 2024 at 1:20 AM Alan Stern <stern@rowland.harvard.edu> wrote:
>
> On Mon, May 06, 2024 at 09:44:52PM +0530, Muni Sekhar wrote:
> > On Mon, May 6, 2024 at 7:59 PM Alan Stern <stern@rowland.harvard.edu> wrote:
> > >
> > > On Mon, May 06, 2024 at 04:44:30PM +0530, Muni Sekhar wrote:
> > > > While we have successfully converted most of the USB device driver
> > > > functionality from kernel space to user space using libusb, we are now
> > > > seeking guidance on how to implement USB device suspend/resume in user
> > > > space. Specifically, we would like to know if libusb provides support
> > > > for achieving the suspend/resume functionality mentioned above.
> > > > Additionally, any insights or suggestions on how to accomplish this
> > > > task would be greatly appreciated.
> > >
> > > Your question is about libusb, right?  So you'll get better answers if
> > > you post it on the libusb mailing list rather than the linux-usb mailing
> > > list.
> > Can USB device suspend\resume  be implemented in user space driver
> > using software other than libusb?
>
> Yes, a userspace driver can use the usbfs interface and can employ the
> ioctl commands listed in /usr/include/linux/usbdevfs.h.  It's possible
> that libusb also provides facilities for controlling suspend and resume;
> I don't know whether it does.
>
> > If so, what are those methods or techniques to achieve USB device
> > suspend\resume , can you please provide clarity on this.
>
> As far as I know, these usbfs ioctl commands are not documented
> anywhere.
>
> The USBDEVFS_FORBID_SUSPEND ioctl prevents the device from being
> suspended, and wakes it up if it is currently suspended.
>
> The USBDEVFS_ALLOW_SUSPEND ioctl allows the device to be suspended.  The
> suspend may not happen immediately; it is controlled by the settings in
> the device's power/control and power/autosuspend (or
> power/autosuspend_delay_ms) sysfs attribute files.
>
> The USBDEVFS_WAIT_FOR_RESUME ioctl waits until the device resumes,
> whether because of a remote wakeup or because another process has
> resumed it, and then forbids the device from suspending again until
> you perform another USBDEVFS_ALLOW_SUSPEND ioctl.
>
Thank you, it is very helpful.

To verify the USB device suspend\resume functionality, I configured
the USB Power Management variables as follows:

# cat /sys/bus/usb/devices/2-1.7/power/wakeup
enabled

# cat /sys/bus/usb/devices/2-1.7/power/control
on

# cat /sys/bus/usb/devices/2-1.7/power/autosuspend_delay_ms
0

# cat /sys/module/usbcore/parameters/autosuspend
2


So, I configured the system to autosuspend the USB device as soon as
it becomes idle, with no transactions running through the USB device.
Now, how can I verify that the USB device has entered suspend mode
from user space? When checking /var/log/kern.log, there are no
relevant print statements. Are there any other log files related to
power management or USB subsystems?
Please correct me if anything in the test procedure mentioned above is
incorrect.

> Alan Stern



-- 
Thanks,
Sekhar

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  reply	other threads:[~2024-05-07 11:46 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 11:14 Seeking Assistance: Implementing USB Device Suspend/Resume in User Space Driver Muni Sekhar
2024-05-06 14:29 ` Alan Stern
2024-05-06 16:03   ` Muni Sekhar
2024-05-06 16:14   ` Muni Sekhar
2024-05-06 19:50     ` Alan Stern
2024-05-07 11:44       ` Muni Sekhar [this message]
2024-05-07 14:20         ` Alan Stern
2024-05-07 16:38           ` Muni Sekhar
2024-05-07 17:51             ` Alan Stern
2024-05-08  5:38               ` Muni Sekhar
2024-05-08 13:58                 ` Alan Stern
2024-05-13 17:44         ` Muni Sekhar
2024-05-13 18:09           ` 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=CAHhAz+i9TLCb3hKpzWAL2DkH9Y25XszJO5kgbRGzsut1zCzrJw@mail.gmail.com \
    --to=munisekharrms@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --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 read-only IMAP folder(s) and NNTP newsgroup(s).