RE: USB port power-off and system suspend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 23 Mar 2013, Lan, Tianyu wrote:

> On 2013/3/23 1:35, Alan Stern wrote:> Tianyu:
> > 
> > Did you ever test the port power-off mechanism with system suspend?
> > Right now it doesn't seem like it would work, because it relies on
> > runtime PM to turn off the port power, and runtime PM doesn't operate
> > normally during a system suspend.
> > 
> > Alan Stern
> > 
> 
> Hi Alan:
> 	You are right. Current the port power-off can't work during
> system suspend. I have already worked on a patch of adding usb
> port system pm support. But there is a still problem that how to
> control power off mechanism from kernel side. Before, we have a solution
> for runtime pm that increase/decrease port dev's usage count.
> 	http://marc.info/?l=linux-usb&m=135772122031446&w=2
> But now, we have another user, System pm. So I think we should find
> a solution to cover these two cases. Maybe add a new pm qos request
> for NO_POWER_OFF flag? I'd like to see your opinion. 

Yes, I think you need to copy the test that's in usb_port_suspend.  
Better yet, move that test to a separate function in port.c and call it 
from both places.

> I have a patch that can work and it still needs to add some condition
> checks in the usb_port_system_suspend(). Dev's system wakeup disable
> and persist enable.

...

> +static int usb_port_system_suspend(struct device *dev)
> +{
> +	struct usb_port *port_dev = to_usb_port(dev);
> +	int retval;
> +
> +	if (port_dev->child)
> +		device_pm_wait_for_dev(dev, &port_dev->child->dev);
> +
> +	retval = usb_port_runtime_suspend(dev);
> +	if (retval < 0 && retval != -EAGAIN)
> +		return retval;
> +
> +	return 0;

This should always return 0.  Ignore any errors from 
usb_port_runtime_suspend.

> +}
> +
> +static int usb_port_system_resume(struct device *dev)
> +{
> +	return usb_port_runtime_resume(dev);
> +}
> +

These new functions should be protected by #ifdef CONFIG_PM_SLEEP.

>  static const struct dev_pm_ops usb_port_pm_ops = {
> +	.suspend =	usb_port_system_suspend,
> +	.resume =	usb_port_system_resume,

And the same goes for these entries.  The runtime routines now need to 
be protected by CONFIG_PM, since they can be used if either PM_RUNTIME 
or PM_SLEEP is enabled.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux