Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1268088

Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node

From Alan Stern <stern@rowland.harvard.edu>
Newsgroups linux.kernel
Subject Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node
Date 2015-11-12 17:30 +0100
Message-ID <qu2V5-2MB-41@gated-at.bofh.it> (permalink)
References <qtPEu-2Lj-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 12 Nov 2015, Lu Baolu wrote:

> Commit 655fe4effe0f ("usbcore: add sysfs support to xHCI usb3
> hardware LPM") introduced usb3_hardware_lpm sysfs node. This
> doesn't show the correct status of USB3 U1 and U2 LPM status.
> 
> This patch fixes this by replacing usb3_hardware_lpm with two
> nodes, usb3_hardware_lpm_u1 (for U1) and usb3_hardware_lpm_u2
> (for U2), and recording the U1/U2 LPM status in right places.
> 
> This patch should be back-ported to kernels as old as 4.3,
> that contains Commit 655fe4effe0f ("usbcore: add sysfs support
> to xHCI usb3 hardware LPM").
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>

...

> --- a/drivers/usb/core/hub.c
> +++ b/drivers/usb/core/hub.c
> @@ -3875,17 +3875,23 @@ static void usb_enable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
>  		return;
>  	}
>  
> -	if (usb_set_lpm_timeout(udev, state, timeout))
> +	ret = usb_set_lpm_timeout(udev, state, timeout);
> +	if (ret)
>  		/* If we can't set the parent hub U1/U2 timeout,
>  		 * device-initiated LPM won't be allowed either, so let the xHCI
>  		 * host know that this link state won't be enabled.
>  		 */
>  		hcd->driver->disable_usb3_lpm_timeout(hcd, udev, state);
> -
>  	/* Only a configured device will accept the Set Feature U1/U2_ENABLE */
>  	else if (udev->actconfig)
>  		usb_set_device_initiated_lpm(udev, state, true);
>  
> +	if (!ret) {
> +		if (state == USB3_LPM_U1)
> +			udev->usb3_lpm_u1_enabled = 1;
> +		else if (state == USB3_LPM_U2)
> +			udev->usb3_lpm_u2_enabled = 1;
> +	}

This doesn't look right at all.  What happens if ret is 0 but the
device isn't configured?  You'll set the usb3_lpm_u*_enabled flag even
though LPM isn't really enabled.

Don't you want to set these flags inside the
usb_set_device_initiated_lpm() function, where you know whether the
action succeeded?  And leave this routine unchanged?

> @@ -3925,6 +3931,12 @@ static int usb_disable_link_state(struct usb_hcd *hcd, struct usb_device *udev,
>  		dev_warn(&udev->dev, "Could not disable xHCI %s timeout, "
>  				"bus schedule bandwidth may be impacted.\n",
>  				usb3_lpm_names[state]);
> +
> +	if (state == USB3_LPM_U1)
> +		udev->usb3_lpm_u1_enabled = 0;
> +	else if (state == USB3_LPM_U2)
> +		udev->usb3_lpm_u2_enabled = 0;
> +
>  	return 0;
>  }

And then this won't be necessary.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/3] usb: core: lpm: add sysfs node for usb3 lpm permit Lu Baolu <baolu.lu@linux.intel.com> - 2015-11-12 03:20 +0100
  [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node Lu Baolu <baolu.lu@linux.intel.com> - 2015-11-12 03:20 +0100
    Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node Alan Stern <stern@rowland.harvard.edu> - 2015-11-12 17:30 +0100
      Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node "Lu, Baolu" <baolu.lu@linux.intel.com> - 2015-11-13 07:00 +0100
        Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node Alan Stern <stern@rowland.harvard.edu> - 2015-11-13 16:30 +0100
          Re: [PATCH v2 1/3] usb: core: lpm: fix usb3_hardware_lpm sysfs node Lu Baolu <baolu.lu@linux.intel.com> - 2015-11-14 08:20 +0100
  [PATCH v2 3/3] usb: core: lpm: remove usb3_lpm_enabled in usb_device Lu Baolu <baolu.lu@linux.intel.com> - 2015-11-12 03:30 +0100
    Re: [PATCH v2 3/3] usb: core: lpm: remove usb3_lpm_enabled in  usb_device Alan Stern <stern@rowland.harvard.edu> - 2015-11-12 17:30 +0100
      Re: [PATCH v2 3/3] usb: core: lpm: remove usb3_lpm_enabled in  usb_device "Lu, Baolu" <baolu.lu@linux.intel.com> - 2015-11-13 02:40 +0100
  [PATCH v2 2/3] usb: core: lpm: add sysfs node for usb3 lpm permit Lu Baolu <baolu.lu@linux.intel.com> - 2015-11-12 03:30 +0100

csiph-web