Re: [v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-18 Thread Thang Q. Nguyen
On Fri, May 19, 2017 at 5:30 AM, Rob Herring  wrote:
> On Sat, May 13, 2017 at 07:13:14AM +0700, Thang Q. Nguyen wrote:
>> XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
>> to always enable hardware USB2 LPM.
>> However, the current xHCI driver always enable it by setting HLE=1 when
>> seeing HLC=1. This makes certain xHCI controllers that have broken USB2
>> HW LPM fail to work as there is no way to disable this feature.
>> This patch adds support to control disabling USB2 Hardware LPM via
>> DT/ACPI attribute.
>>
>> Signed-off-by: Tung Nguyen 
>> Signed-off-by: Thang Q. Nguyen 
>> ---
>>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>>  drivers/usb/host/xhci-plat.c   |3 +++
>>  drivers/usb/host/xhci.c|7 ++-
>>  drivers/usb/host/xhci.h|1 +
>>  4 files changed, 11 insertions(+), 1 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> index 2d80b60..b5da569 100644
>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> @@ -26,6 +26,7 @@ Required properties:
>>
>>  Optional properties:
>>- clocks: reference to a clock
>> +  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
>>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>
> Can we have some consistency in the naming of these 2 properties? At
> least use 'lpm' rather than 'hle'. I don't recall why the 2nd one is not
> default enabled, but that would make more sense.
Thanks. I will update the attribute to "usb2-lpm-disable" in the next
patch revision.
>
>>- quirk-broken-port-ped: set if the controller has broken port disable 
>> mechanism
>>


Re: [v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-18 Thread Thang Q. Nguyen
On Fri, May 19, 2017 at 5:30 AM, Rob Herring  wrote:
> On Sat, May 13, 2017 at 07:13:14AM +0700, Thang Q. Nguyen wrote:
>> XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
>> to always enable hardware USB2 LPM.
>> However, the current xHCI driver always enable it by setting HLE=1 when
>> seeing HLC=1. This makes certain xHCI controllers that have broken USB2
>> HW LPM fail to work as there is no way to disable this feature.
>> This patch adds support to control disabling USB2 Hardware LPM via
>> DT/ACPI attribute.
>>
>> Signed-off-by: Tung Nguyen 
>> Signed-off-by: Thang Q. Nguyen 
>> ---
>>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>>  drivers/usb/host/xhci-plat.c   |3 +++
>>  drivers/usb/host/xhci.c|7 ++-
>>  drivers/usb/host/xhci.h|1 +
>>  4 files changed, 11 insertions(+), 1 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> index 2d80b60..b5da569 100644
>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> @@ -26,6 +26,7 @@ Required properties:
>>
>>  Optional properties:
>>- clocks: reference to a clock
>> +  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
>>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>
> Can we have some consistency in the naming of these 2 properties? At
> least use 'lpm' rather than 'hle'. I don't recall why the 2nd one is not
> default enabled, but that would make more sense.
Thanks. I will update the attribute to "usb2-lpm-disable" in the next
patch revision.
>
>>- quirk-broken-port-ped: set if the controller has broken port disable 
>> mechanism
>>


Re: [v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-18 Thread Rob Herring
On Sat, May 13, 2017 at 07:13:14AM +0700, Thang Q. Nguyen wrote:
> XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
> to always enable hardware USB2 LPM.
> However, the current xHCI driver always enable it by setting HLE=1 when
> seeing HLC=1. This makes certain xHCI controllers that have broken USB2
> HW LPM fail to work as there is no way to disable this feature.
> This patch adds support to control disabling USB2 Hardware LPM via
> DT/ACPI attribute.
> 
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|7 ++-
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..b5da569 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> @@ -26,6 +26,7 @@ Required properties:
>  
>  Optional properties:
>- clocks: reference to a clock
> +  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
>- usb3-lpm-capable: determines if platform is USB3 LPM capable

Can we have some consistency in the naming of these 2 properties? At 
least use 'lpm' rather than 'hle'. I don't recall why the 2nd one is not 
default enabled, but that would make more sense.

>- quirk-broken-port-ped: set if the controller has broken port disable 
> mechanism
>  


Re: [v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-18 Thread Rob Herring
On Sat, May 13, 2017 at 07:13:14AM +0700, Thang Q. Nguyen wrote:
> XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
> to always enable hardware USB2 LPM.
> However, the current xHCI driver always enable it by setting HLE=1 when
> seeing HLC=1. This makes certain xHCI controllers that have broken USB2
> HW LPM fail to work as there is no way to disable this feature.
> This patch adds support to control disabling USB2 Hardware LPM via
> DT/ACPI attribute.
> 
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|7 ++-
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 11 insertions(+), 1 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..b5da569 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> @@ -26,6 +26,7 @@ Required properties:
>  
>  Optional properties:
>- clocks: reference to a clock
> +  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
>- usb3-lpm-capable: determines if platform is USB3 LPM capable

Can we have some consistency in the naming of these 2 properties? At 
least use 'lpm' rather than 'hle'. I don't recall why the 2nd one is not 
default enabled, but that would make more sense.

>- quirk-broken-port-ped: set if the controller has broken port disable 
> mechanism
>  


[v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-12 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
to always enable hardware USB2 LPM.
However, the current xHCI driver always enable it by setting HLE=1 when
seeing HLC=1. This makes certain xHCI controllers that have broken USB2
HW LPM fail to work as there is no way to disable this feature.
This patch adds support to control disabling USB2 Hardware LPM via
DT/ACPI attribute.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|7 ++-
 drivers/usb/host/xhci.h|1 +
 4 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..b5da569 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,7 @@ Required properties:
 
 Optional properties:
   - clocks: reference to a clock
+  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
   - quirk-broken-port-ped: set if the controller has broken port disable 
mechanism
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 7c2a9e7..7d316bc 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -267,6 +267,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}
 
+   if (device_property_read_bool(>dev, "usb2-hle-disable"))
+   xhci->quirks |= XHCI_HLE_DISABLE;
+
if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
xhci->quirks |= XHCI_LPM_SUPPORT;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d13102..4ad243a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4055,6 +4055,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
unsigned long   flags;
int hird, exit_latency;
int ret;
+   int disable_hle = 0;
 
if (hcd->speed >= HCD_USB3 || !xhci->hw_lpm_support ||
!udev->lpm_capable)
@@ -4079,7 +4080,11 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd 
*hcd,
xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
enable ? "enable" : "disable", port_num + 1);
 
-   if (enable) {
+   /* Check for optional disable HLE if XHCI 1.0 */
+   if ((xhci->quirks & XHCI_HLE_DISABLE) && (xhci->hci_version == 0x100))
+   disable_hle = 1;
+
+   if (enable && !disable_hle) {
/* Host supports BESL timeout instead of HIRD */
if (udev->usb2_hw_lpm_besl_capable) {
/* if device doesn't have a preferred BESL value use a
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 73a28a9..44ca323 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1819,6 +1819,7 @@ struct xhci_hcd {
 /* For controller with a broken Port Disable implementation */
 #define XHCI_BROKEN_PORT_PED   (1 << 25)
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
+#define XHCI_HLE_DISABLE   (1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



[v1 1/1] usb:host:xhci support option to disable xHCI 1.0 USB2 HW LPM

2017-05-12 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI 1.0 compliant controllers
to always enable hardware USB2 LPM.
However, the current xHCI driver always enable it by setting HLE=1 when
seeing HLC=1. This makes certain xHCI controllers that have broken USB2
HW LPM fail to work as there is no way to disable this feature.
This patch adds support to control disabling USB2 Hardware LPM via
DT/ACPI attribute.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|7 ++-
 drivers/usb/host/xhci.h|1 +
 4 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..b5da569 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -26,6 +26,7 @@ Required properties:
 
 Optional properties:
   - clocks: reference to a clock
+  - usb2-hle-disable: disable USB2 LPM for hardware does not support it
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
   - quirk-broken-port-ped: set if the controller has broken port disable 
mechanism
 
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 7c2a9e7..7d316bc 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -267,6 +267,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}
 
+   if (device_property_read_bool(>dev, "usb2-hle-disable"))
+   xhci->quirks |= XHCI_HLE_DISABLE;
+
if (device_property_read_bool(sysdev, "usb3-lpm-capable"))
xhci->quirks |= XHCI_LPM_SUPPORT;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 2d13102..4ad243a 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4055,6 +4055,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
unsigned long   flags;
int hird, exit_latency;
int ret;
+   int disable_hle = 0;
 
if (hcd->speed >= HCD_USB3 || !xhci->hw_lpm_support ||
!udev->lpm_capable)
@@ -4079,7 +4080,11 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd 
*hcd,
xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
enable ? "enable" : "disable", port_num + 1);
 
-   if (enable) {
+   /* Check for optional disable HLE if XHCI 1.0 */
+   if ((xhci->quirks & XHCI_HLE_DISABLE) && (xhci->hci_version == 0x100))
+   disable_hle = 1;
+
+   if (enable && !disable_hle) {
/* Host supports BESL timeout instead of HIRD */
if (udev->usb2_hw_lpm_besl_capable) {
/* if device doesn't have a preferred BESL value use a
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 73a28a9..44ca323 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1819,6 +1819,7 @@ struct xhci_hcd {
 /* For controller with a broken Port Disable implementation */
 #define XHCI_BROKEN_PORT_PED   (1 << 25)
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
+#define XHCI_HLE_DISABLE   (1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1