Re: [PATCH v3 7/9] usb: add usb port auto power off mechanism

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

 



On Sun, 6 Jan 2013, Lan Tianyu wrote:

> This patch is to add usb port auto power off mechanism.
> When usb device is suspending, usb core will suspend usb port and
> usb port runtime pm callback will clear PORT_POWER feature to
> power off port if all conditions were met. These conditions are
> remote wakeup disable, pm qos NO_POWER_OFF flag clear and persist
> enable. When it resumes, power on port again. Add did_runtime_put
> in the struct usb_port in order to call pm_runtime_get/put(portdev)
> paired during suspending and resuming.

> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c

> @@ -1509,7 +1525,6 @@ static void hub_disconnect(struct usb_interface *intf)
>  	kfree(hub->status);
>  	kfree(hub->buffer);
>  
> -	pm_suspend_ignore_children(&intf->dev, false);
>  	kref_put(&hub->kref, hub_release);
>  }

This looks like a mistake.  Either that line shouldn't have been added 
in the first place or else it shouldn't be removed here.

> @@ -1940,7 +1955,8 @@ void usb_disconnect(struct usb_device **pdev)
>  		sysfs_remove_link(&udev->dev.kobj, "port");
>  		sysfs_remove_link(&port_dev->dev.kobj, "device");
>  
> -		pm_runtime_put(&port_dev->dev);
> +		if (!port_dev->did_runtime_put)
> +			pm_runtime_put(&port_dev->dev);
>  	}

You need to set port_dev->did_runtime_put to false here, so that it 
will have the correct value the next time a device is plugged into the 
port.

> --- a/drivers/usb/core/hub.h
> +++ b/drivers/usb/core/hub.h
> @@ -80,6 +80,8 @@ struct usb_hub {
>   * @port_owner: port's owner
>   * @connect_type: port's connect type
>   * @portnum: port index num based one
> + * @power_is_on: port's power state
> + * @did_runtime_put: port has done pm_runtime_put().
>   */
>  struct usb_port {
>  	struct usb_device *child;
> @@ -87,6 +89,8 @@ struct usb_port {
>  	struct dev_state *port_owner;
>  	enum usb_port_connect_type connect_type;
>  	u8 portnum;
> +	bool power_is_on;
> +	bool did_runtime_put;
>  };

Should these be power_is_on:1 and did_runtime_put:1?

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