All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Jun Li <lijun.kernel@gmail.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: port power is on again after turning off by user space
Date: Mon, 21 Dec 2020 05:37:29 +0000	[thread overview]
Message-ID: <20201221053659.GA26433@b29397-desktop> (raw)
In-Reply-To: <20201216155144.GA238371@rowland.harvard.edu>

On 20-12-16 10:51:44, Alan Stern wrote:
> On Wed, Dec 16, 2020 at 02:56:20AM +0000, Peter Chen wrote:
> > On 20-12-15 10:55:41, Alan Stern wrote:
> > > You've got the general idea.
> > > 
> > > Normally ports are owned by the hub driver.  If one of them loses power 
> > > for some reason (for example, the user turns it off), the hub driver 
> > > will turn the power back on.  This is because the hub driver wants 
> > > ports to be powered at all times unless they are in runtime suspend.
> > > 
> > > The way to prevent the hub driver from managing the port power is to 
> > > claim the port for the user, by issuing the USBDEVFS_CLAIM_PORT ioctl.  
> > > Also, when that is done, the kernel wno't try to manage a device 
> > > attached to the port -- that is, the kernel won't automatically install 
> > > a configuration for a new device and it won't try to probe drivers for 
> > > the device's interfaces if the user installs a config.
> > > 
> > 
> > Alan, we have several use cases for power switchable HUB, one of the use
> > cases is USB port is managed by kernel (eg, needs mass storage
> > class), but needs to toggle port power, is it reasonable we add a sysfs
> > entry to support it?
> 
> Can you give more information about your use cases?  After all, if the 
> port power is turned off then the port can't possibly handle 
> mass-storage devices -- or anything else.

Sorry, Alan. Due to holiday season, the U.S team doesn't reply me the
use case. I think the basic use cases are emulate the hot-plug test for
USB devices, the USB devices could be Flash Drive on market or DUT (Device
Under test) for the same controller works at device mode. Assume one
typical test case:

Plug in Flash Drive at port 1-1.1 during the boots up:

while (1) {
- Check Flash Drive is there (eg, cat /proc/partitions)
- Turn port 1 at 1-1 off
- Check Flash Drive is gone
- Turn port 1 at 1-1 on
}

> 
> On the other hand, if the port is managed by the kernel then the kernel 
> (not the user) should be responsible for deciding whether or not to 
> turn off the port's power.
> 
> If there's some real reason for turning the port power off for an 
> extended period of time, the user can claim the port and turn off the 
> power.  Then later on, the user can release the port and turn the power 
> back on.
> 

Yes, I think this is one of the use cases. We want power power control
at one application (A), but different with our test application(B), it means
if the user claims the port, and power off using A, then the A will end.
After the B finished running, A runs again for power on, but at this time,
the port owner has changed.

-- 

Thanks,
Peter Chen

  reply	other threads:[~2020-12-21  5:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-15  3:31 port power is on again after turning off by user space Peter Chen
2020-12-15  5:02 ` Jun Li
2020-12-15  5:14   ` Peter Chen
2020-12-15  9:57     ` Peter Chen
2020-12-15 15:55       ` Alan Stern
2020-12-16  2:56         ` Peter Chen
2020-12-16 15:51           ` Alan Stern
2020-12-21  5:37             ` Peter Chen [this message]
2020-12-21 16:25               ` Alan Stern
2020-12-22  2:02                 ` Peter Chen
2020-12-22  2:35                   ` 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=20201221053659.GA26433@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=lijun.kernel@gmail.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 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.