Re: [PATCH 3/4] usb: Add usb port system pm support

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

 



On Thu, 28 Mar 2013, Lan Tianyu wrote:

> This patch is to add usb port system pm support. Add
> usb port's system suspend/resume callbacks and call
> usb_port_runtime_resume/suspend() to power off these
> ports whose pm qos NO_POWER_OFF flag is not set, system
> wakeup is disabled and persist is enalbed.
> 
> During system pm, usb port should be powered off after
> dev being suspended and powered on before dev being
> resumed. Since usb ports and devs enable async suspend,
> call device_pm_wait_for_dev() in the usb_port_system_suspend()
> and usb_port_resume() to keeping the order.
> 
> If usb port was already powered off by runtime pm with
> port_dev->power_is_on being false, usb_port_system_suspend()
> returns directly.
> 
> If usb port was not powered off during system suspend with
> port_dev->power_is_on being true, usb_port_system_resume()
> returns directly.
> 
> Signed-off-by: Lan Tianyu <tianyu.lan@xxxxxxxxx>

...

> +static int usb_port_system_suspend(struct device *dev)
> +{
> +	struct usb_port *port_dev = to_usb_port(dev);
> +
> +	if (!port_dev->power_is_on)
> +		return 0;
> +
> +	if (port_dev->child) {
> +		struct usb_device *udev = port_dev->child;
> +
> +		/*
> +		 * usb port can't be powered off when dev's system
> +		 * wakeup is enabled or persist is disabled.
> +		 */
> +		if (device_may_wakeup(&udev->dev)
> +				|| !udev->persist_enabled)
> +			return 0;
> +
> +		/*
> +		 * usb port should be powered off after usb dev
> +		 * being suspended.
> +		 */
> +		device_pm_wait_for_dev(dev, &port_dev->child->dev);
> +	}
> +
> +	usb_port_runtime_suspend(dev);
> +	return 0;
> +}

What happens if there's no device plugged in to the port, but the hub 
is enabled for remote wakeup?  How will the hub be able to detect a 
plug-in event if the port isn't powered?

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