linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Oliver Neukum <oneukum@suse.com>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	Mayuresh Kulkarni <mkulkarni@opensource.cirrus.com>,
	<patches@opensource.cirrus.com>, <linux-usb@vger.kernel.org>
Subject: Re: [PATCH] usb: core: devio: add ioctls for suspend and resume
Date: Wed, 19 Jun 2019 12:07:28 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1906191153310.1596-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <1560957124.4587.20.camel@suse.com>

On Wed, 19 Jun 2019, Oliver Neukum wrote:

> Am Mittwoch, den 19.06.2019, 10:40 -0400 schrieb Alan Stern:
> > On Wed, 19 Jun 2019, Oliver Neukum wrote:
> 
> > > It would be easiest to export the usb_autopm_* API to user space.
> > 
> > But ->suspend and ->resume callbacks are part of that API, and as you 
> > say, it is not feasible to have these callbacks run in userspace.
> 
> We can notify user space about resume(). There will be a delay, but
> there will always be a delay, even in kernel space.
> 
> > The only solution I can think of is for the userspace program to first
> > set the device's autosuspend delay to 0.  Then whenever the
> > WAIT_FOR_RESUME ioctl returns -- even if it returns immediately -- the
> > program should assume the suspend is over or is not going to happen.  
> > Then the program can run normally for a short while (10 seconds,
> > perhaps) before making another attempt to suspend.
> 
> That is ugly. Quite ugly actually.
> 
> Why actually do we care about suspend()? Would the user space
> task do anything else but cease IO? We can do that in usbfs,
> assuming we do not care about the order of killing.
> User space will learn from an appropriate error code the device
> went to power save. And if it does not do IO, why care?
> I have never seen a driver that actually saves device state in
> suspend().

Learning from error codes is problematic.  According to the current
design, any usbfs interaction (except for the specific suspend/resume
ioctls) will cause usbfs to do a usb_autoresume_device(), thus
preventing a suspend from occurring.

Evidently we need to rethink this.  In fact, the userspace program
needs to be able to interact with the device right up until the point
where it actually gets suspended.  And of course, this implies that the
program needs to be able to reap URBs even after the device is
suspended.

That sort of approach ought to be workable.  Once the program sees that 
its URBs are failing with the appropriate error codes, it can call the 
WAIT_FOR_RESUME ioctl.

Alan Stern


  reply	other threads:[~2019-06-19 16:07 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
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 [this message]
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=Pine.LNX.4.44L0.1906191153310.1596-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mkulkarni@opensource.cirrus.com \
    --cc=oneukum@suse.com \
    --cc=patches@opensource.cirrus.com \
    /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).