diff mbox series

[RFT] xhci: Prevent device initiated U1/U2 link pm if exit latency is too long

Message ID 1568732029-11186-1-git-send-email-mathias.nyman@linux.intel.com (mailing list archive)
State Mainlined
Commit cd9d9491e835a845c1a98b8471f88d26285e0bb9
Headers show
Series [RFT] xhci: Prevent device initiated U1/U2 link pm if exit latency is too long | expand

Commit Message

Mathias Nyman Sept. 17, 2019, 2:53 p.m. UTC
If host/hub initiated link pm is prevented by a driver flag we still must
ensure that periodic endpoints have longer service intervals than link pm
exit latency before allowing device initiated link pm.

Fix this by continue walking and checking endpoint service interval if
xhci_get_timeout_no_hub_lpm() returns anything else than USB3_LPM_DISABLED

While at it fix the split line error message

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
---
 drivers/usb/host/xhci.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Jan Schmidt Sept. 17, 2019, 3:56 p.m. UTC | #1
On 18/9/19 12:53 am, Mathias Nyman wrote:
> If host/hub initiated link pm is prevented by a driver flag we still must
> ensure that periodic endpoints have longer service intervals than link pm
> exit latency before allowing device initiated link pm.
> 
> Fix this by continue walking and checking endpoint service interval if
> xhci_get_timeout_no_hub_lpm() returns anything else than USB3_LPM_DISABLED
> 
> While at it fix the split line error message
> 
> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>

I tested by forcing the driver->disable_hub_initiated_lpm check and
confirm a) Other USB devices still work as I expect them to b) without
this patch, I'm back to only 1 working Oculus Rift Sensor. With it, I
can capture 3 simultaneously.

Tested-by: Jan Schmidt <jan@centricular.com>

- Jan

> ---
>  drivers/usb/host/xhci.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 447c29bbad48..8892dfbb2af7 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4809,10 +4809,12 @@ static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd,
>  		if (intf->dev.driver) {
>  			driver = to_usb_driver(intf->dev.driver);
>  			if (driver && driver->disable_hub_initiated_lpm) {
> -				dev_dbg(&udev->dev, "Hub-initiated %s disabled "
> -						"at request of driver %s\n",
> -						state_name, driver->name);
> -				return xhci_get_timeout_no_hub_lpm(udev, state);
> +				dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
> +					state_name, driver->name);
> +				timeout = xhci_get_timeout_no_hub_lpm(udev,
> +								      state);
> +				if (timeout == USB3_LPM_DISABLED)
> +					return timeout;
>  			}
>  		}
>  
>
Mathias Nyman Sept. 18, 2019, 12:46 p.m. UTC | #2
On 17.9.2019 18.56, Jan Schmidt wrote:
> 
> 
> On 18/9/19 12:53 am, Mathias Nyman wrote:
>> If host/hub initiated link pm is prevented by a driver flag we still must
>> ensure that periodic endpoints have longer service intervals than link pm
>> exit latency before allowing device initiated link pm.
>>
>> Fix this by continue walking and checking endpoint service interval if
>> xhci_get_timeout_no_hub_lpm() returns anything else than USB3_LPM_DISABLED
>>
>> While at it fix the split line error message
>>
>> Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
> 
> I tested by forcing the driver->disable_hub_initiated_lpm check and
> confirm a) Other USB devices still work as I expect them to b) without
> this patch, I'm back to only 1 working Oculus Rift Sensor. With it, I
> can capture 3 simultaneously.
> 
> Tested-by: Jan Schmidt <jan@centricular.com>
> 

Great, thanks, I'll queue up that patch as well with your Tested-by tag

-Mathias
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 447c29bbad48..8892dfbb2af7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4809,10 +4809,12 @@  static u16 xhci_calculate_lpm_timeout(struct usb_hcd *hcd,
 		if (intf->dev.driver) {
 			driver = to_usb_driver(intf->dev.driver);
 			if (driver && driver->disable_hub_initiated_lpm) {
-				dev_dbg(&udev->dev, "Hub-initiated %s disabled "
-						"at request of driver %s\n",
-						state_name, driver->name);
-				return xhci_get_timeout_no_hub_lpm(udev, state);
+				dev_dbg(&udev->dev, "Hub-initiated %s disabled at request of driver %s\n",
+					state_name, driver->name);
+				timeout = xhci_get_timeout_no_hub_lpm(udev,
+								      state);
+				if (timeout == USB3_LPM_DISABLED)
+					return timeout;
 			}
 		}