All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: Mathias Nyman <mathias.nyman@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] usb: core: lpm: set lpm_capable for root hub device
Date: Fri, 12 Jun 2015 13:43:13 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.44L0.1506121334110.1505-100000@iolanthe.rowland.org> (raw)
In-Reply-To: <1434072625-7971-1-git-send-email-baolu.lu@linux.intel.com>

On Fri, 12 Jun 2015, Lu Baolu wrote:

> Commit 25cd2882e2fc ("usb/xhci: Change how we indicate a host supports
> Link PM.") removed the code to set lpm_capable for USB 3.0 super-speed
> root hub. The intention of that change was to avoid touching usb core
> internal field, a.k.a. lpm_capable, and let usb core to set it by
> checking U1 and U2 exit latency values in the descriptor.
> 
> Usb core checks and sets lpm_capable in hub_port_init(). Unfortunately,
> root hub is a special usb device as it has no parent. Hub_port_init()
> will never be called for a root hub device. That means lpm_capable will
> by no means be set for the root hub. As the result, lpm isn't functional
> at all in Linux kernel.
> 
> This patch add the code to check and set lpm_capable when registering a
> root hub device. It could be back-ported to kernels as old as v3.15,
> that contains the Commit 25cd2882e2fc ("usb/xhci: Change how we indicate
> a host supports Link PM.").
> 
> Cc: stable@vger.kernel.org # 3.15
> Reported-by: Kevin Strasser <kevin.strasser@linux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>  drivers/usb/core/hcd.c | 6 ++++++
>  drivers/usb/core/hub.c | 2 +-
>  drivers/usb/core/usb.h | 1 +
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 45a915c..48b208d 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1032,6 +1032,12 @@ static int register_root_hub(struct usb_hcd *hcd)
>  		}
>  	}
>  
> +	if (le16_to_cpu(usb_dev->descriptor.bcdUSB) >= 0x0201) {
> +		retval = usb_get_bos_descriptor(usb_dev);
> +		if (!retval)
> +			usb_dev->lpm_capable = usb_device_supports_lpm(usb_dev);
> +	}
> +

This should be integrated with the code immediately above it, which 
also calls usb_get_bos_descriptor().  In fact, maybe you should simply 
change the existing code to check bcdUSB >= 0x0201 instead of speed == 
USB_SPEED_SUPER.

>  	retval = usb_new_device (usb_dev);
>  	if (retval) {
>  		dev_err (parent_dev, "can't register root hub for %s, %d\n",
> diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
> index 3b71516..884d702 100644
> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -122,7 +122,7 @@ struct usb_hub *usb_hub_to_struct_hub(struct usb_device *hdev)
>  	return usb_get_intfdata(hdev->actconfig->interface[0]);
>  }
>  
> -static int usb_device_supports_lpm(struct usb_device *udev)
> +int usb_device_supports_lpm(struct usb_device *udev)
>  {
>  	/* USB 2.1 (and greater) devices indicate LPM support through
>  	 * their USB 2.0 Extended Capabilities BOS descriptor.
> diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h
> index 7eb1e26..d5668c4 100644
> --- a/drivers/usb/core/usb.h
> +++ b/drivers/usb/core/usb.h
> @@ -82,6 +82,7 @@ extern int usb_runtime_suspend(struct device *dev);
>  extern int usb_runtime_resume(struct device *dev);
>  extern int usb_runtime_idle(struct device *dev);
>  extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);
> +extern int usb_device_supports_lpm(struct usb_device *udev);
>  
>  #else

This will break if you build it with CONFIG_PM disabled.

Alan Stern


  parent reply	other threads:[~2015-06-12 17:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12  1:29 [PATCH 1/1] usb: core: lpm: set lpm_capable for root hub device Lu Baolu
2015-06-12  4:32 ` Greg Kroah-Hartman
2015-06-12  6:14   ` Lu, Baolu
2015-06-12 17:43 ` Alan Stern [this message]
2015-06-13  0:12   ` Lu, Baolu

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.1506121334110.1505-100000@iolanthe.rowland.org \
    --to=stern@rowland.harvard.edu \
    --cc=baolu.lu@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.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 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.