From: Mayuresh Kulkarni <mkulkarni@opensource.cirrus.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Greg KH <gregkh@linuxfoundation.org>, <linux-usb@vger.kernel.org>,
<patches@opensource.cirrus.com>, <oneukum@suse.com>
Subject: Re: [PATCH] usb: core: devio: add ioctls for suspend and resume
Date: Tue, 18 Jun 2019 15:00:41 +0100 [thread overview]
Message-ID: <1560866441.8425.8.camel@opensource.cirrus.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1906171119130.1738-100000@iolanthe.rowland.org>
On Mon, 2019-06-17 at 11:55 -0400, Alan Stern wrote:
> On Mon, 17 Jun 2019, Mayuresh Kulkarni wrote:
>
> >
> > >
> > > (Note: I imagine you might run into trouble because devices
> > > generally
> > > do not get put into runtime suspend immediately. So if you call
> > > the
> > > USBDEVFS_SUSPEND ioctl and then the USBDEVFS_WAIT_FOR_RESUME
> > > ioctl,
> > > the
> > > wait will return immediately because the device hasn't yet been
> > > suspended.)
> > >
> > Hi Alan,
> >
> > For this particular comment, how about we add suspend-waiter similar
> > to
> > resume-waiter?
> > As per the below changes, usbfs_notify_suspend() can wake the
> > suspend-
> > waiter, if generic_suspend() is called. So, the suspend ioctl will
> > be
> > partial blocking i.e.: it will wait till suspend happens and will
> > return
> > when it is safe to do resume.
> >
> > Will this work?
> Probably not. Just think about it: Your program stops communicating
> with the device and tells the kernel that it's ready for the device to
> be suspended. But the device doesn't go into suspend for several
> seconds (or longer!) and during that time your program has no idea
> what's happening to it. I'm pretty sure that's not what you want.
>
Right, sounds good. Thanks.
> You're right that the program needs to know when the device is about
> to
> be suspended. But waiting for an ioctl to return isn't a good way
> to do it; this needs to be a callback of some sort. That is, the
> kernel also needs to know when the program is ready for the suspend.
>
> I don't know what is the best approach.
This is becoming tricky now.
>
> >
> > The reason for asking this is - I think the suspend ioctl should
> > return
> > appropriate status to user-space indicating weather to wait-for-
> > resume
> > or not.
> >
> > Or are you suggesting to always have a delay in suspend/resume in
> > user-
> > space?
> >
> > Please do review my comment below in this context too.
> >
> > In a typical SoC based system (XHCI compliant USB host controller
> > with
> > one port exposed out on PCB), wouldn't this
> > call usbfs_notify_suspend()
> > twice - first for udev of connected device and then for udev of
> > root-
> > hub?
> Yes, it would. This wouldn't make any difference to your program,
> since your program would have an open file reference only for the
> connected device, not for the root hub.
>
> >
> > If yes, how about we call usbfs_notify_*() for root-hubs only? That
> > would be a good indication of suspend/resume since root-hubs will be
> > suspended last while resumed first.
> >
> > Will that work?
> No. Remember, this mechanism has to work on non-SoC systems
> too. And
> even on an SoC, it's possible that your device is just one of several
> plugged into an external hub. So your device might be suspended
> while
> the others remain active; then the root hub would not be suspended.
>
I think my point is - usbfs driver is actually doing nothing w.r.t USB-
2.0 L2 state, right? The root-hub's suspend will invoke the USB-2.0 L2
transitions. This will happen when all the USB devices on that port
report idle to USB-core.
I agree that usually driver's suspend/resume call-back will put the
device in its low power state. But that is not applicable to udev of
usbfs driver, right?
So, doesn't it makes sense to tell user-space about actual USB-2.0 L2
state transitions rather than suspend/resume entry call-backs of device-
driver model of kernel (which are stub in this context)?
> Alan Stern
>
next prev parent reply other threads:[~2019-06-18 14:00 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-10 10:01 [PATCH] usb: core: devio: add ioctls for suspend and resume Mayuresh Kulkarni
2019-06-05 9:41 ` Greg KH
2019-06-05 21:02 ` Alan Stern
2019-06-13 14:00 ` Mayuresh Kulkarni
2019-06-13 20:54 ` Alan Stern
2019-06-17 11:38 ` Mayuresh Kulkarni
2019-06-17 15:55 ` Alan Stern
2019-06-18 14:00 ` Mayuresh Kulkarni [this message]
2019-06-18 15:50 ` Alan Stern
2019-06-19 9:19 ` Oliver Neukum
2019-06-19 14:40 ` Alan Stern
2019-06-19 15:12 ` Oliver Neukum
2019-06-19 16:07 ` Alan Stern
2019-06-20 15:11 ` Mayuresh Kulkarni
2019-06-20 15:49 ` Alan Stern
2019-06-21 16:16 ` Mayuresh Kulkarni
2019-06-21 19:28 ` Alan Stern
2019-06-24 16:02 ` Mayuresh Kulkarni
2019-06-24 17:48 ` Alan Stern
2019-06-25 10:41 ` Mayuresh Kulkarni
2019-06-25 14:08 ` Alan Stern
2019-06-26 7:42 ` Oliver Neukum
2019-06-26 14:35 ` Alan Stern
2019-06-26 14:15 ` Mayuresh Kulkarni
2019-06-26 15:07 ` Alan Stern
2019-06-27 13:20 ` Mayuresh Kulkarni
2019-06-27 13:52 ` Alan Stern
2019-07-01 9:18 ` Oliver Neukum
2019-07-01 14:17 ` Alan Stern
2019-07-02 9:21 ` Oliver Neukum
2019-07-02 14:29 ` Alan Stern
2019-07-03 14:44 ` Mayuresh Kulkarni
2019-07-05 18:51 ` [RFC] usbfs: Add ioctls for runtime " Alan Stern
2019-07-11 9:16 ` Mayuresh Kulkarni
2019-07-11 14:20 ` Alan Stern
2019-07-11 14:36 ` Greg KH
2019-07-25 9:10 ` Mayuresh Kulkarni
2019-07-25 9:18 ` Greg KH
2019-07-25 15:18 ` Alan Stern
2019-07-25 16:05 ` Greg KH
2019-06-20 14:34 ` [PATCH] usb: core: devio: add ioctls for " Mayuresh Kulkarni
2019-06-20 14:43 ` Alan Stern
2019-06-13 13:32 ` Mayuresh Kulkarni
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=1560866441.8425.8.camel@opensource.cirrus.com \
--to=mkulkarni@opensource.cirrus.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=oneukum@suse.com \
--cc=patches@opensource.cirrus.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.