Re: [PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-03-28 Thread Thang Q. Nguyen
On Mon, Mar 5, 2018 at 5:22 PM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> On Mon, Jan 29, 2018 at 5:24 PM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
>> From: Tung Nguyen <tungu...@apm.com>
>>
>> Currently, hcd->shared_hcd always creates and registers to the usb-core.
>> If, for some reasons, USB3 downstream port is disabled, no roothub port for
>> USB3.0 is found. This causes kernel to display an error:
>> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
>> This patch checks and registers shared_hcd if USB3.0 downstream
>> port is available.
>>
>> Signed-off-by: Tung Nguyen <tungu...@apm.com>
>> ---
>>  drivers/usb/host/xhci-plat.c |  9 ++---
>>  drivers/usb/host/xhci.c  | 13 +
>>  2 files changed, 19 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> index 6f03830..bdb3975 100644
>> --- a/drivers/usb/host/xhci-plat.c
>> +++ b/drivers/usb/host/xhci-plat.c
>> @@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
>> if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
>> xhci->shared_hcd->can_do_streams = 1;
>>
>> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>> -   if (ret)
>> -   goto dealloc_usb2_hcd;
>> +   /* Just add the shared_hcd when USB3.0 downstream port is available 
>> */
>> +   if (xhci->num_usb3_ports > 0) {
>> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>> +   if (ret)
>> +   goto dealloc_usb2_hcd;
>> +   }
>>
>> device_enable_async_suspend(>dev);
>> pm_runtime_put_noidle(>dev);
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> index 1eeb339..9d3b1ab 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
>> @@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
>> if (ret)
>> xhci_free_command(xhci, command);
>> }
>> +   /*
>> +* In case that the USB3.0 downstream port is not available
>> +* No one triggers to start the xHC which should be done
>> +* before finishing xhci_run
>> +*/
>> +   if (xhci->num_usb3_ports == 0) {
>> +   if (xhci_start(xhci)) {
>> +   xhci_halt(xhci);
>> +   return -ENODEV;
>> +   }
>> +   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
>> +   }
>> +
>> xhci_dbg_trace(xhci, trace_xhci_dbg_init,
>> "Finished xhci_run for USB2 roothub");
>>
>> --
>> 1.8.3.1
>>
> Hi,
> Do you have any comment on the patch?
Hi,
Do you have any comment on the patch?


Re: [PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-03-28 Thread Thang Q. Nguyen
On Mon, Mar 5, 2018 at 5:22 PM, Thang Q. Nguyen  wrote:
> On Mon, Jan 29, 2018 at 5:24 PM, Thang Q. Nguyen  wrote:
>> From: Tung Nguyen 
>>
>> Currently, hcd->shared_hcd always creates and registers to the usb-core.
>> If, for some reasons, USB3 downstream port is disabled, no roothub port for
>> USB3.0 is found. This causes kernel to display an error:
>> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
>> This patch checks and registers shared_hcd if USB3.0 downstream
>> port is available.
>>
>> Signed-off-by: Tung Nguyen 
>> ---
>>  drivers/usb/host/xhci-plat.c |  9 ++---
>>  drivers/usb/host/xhci.c  | 13 +
>>  2 files changed, 19 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
>> index 6f03830..bdb3975 100644
>> --- a/drivers/usb/host/xhci-plat.c
>> +++ b/drivers/usb/host/xhci-plat.c
>> @@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
>> if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
>> xhci->shared_hcd->can_do_streams = 1;
>>
>> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>> -   if (ret)
>> -   goto dealloc_usb2_hcd;
>> +   /* Just add the shared_hcd when USB3.0 downstream port is available 
>> */
>> +   if (xhci->num_usb3_ports > 0) {
>> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
>> +   if (ret)
>> +   goto dealloc_usb2_hcd;
>> +   }
>>
>> device_enable_async_suspend(>dev);
>> pm_runtime_put_noidle(>dev);
>> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
>> index 1eeb339..9d3b1ab 100644
>> --- a/drivers/usb/host/xhci.c
>> +++ b/drivers/usb/host/xhci.c
>> @@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
>> if (ret)
>> xhci_free_command(xhci, command);
>> }
>> +   /*
>> +* In case that the USB3.0 downstream port is not available
>> +* No one triggers to start the xHC which should be done
>> +* before finishing xhci_run
>> +*/
>> +   if (xhci->num_usb3_ports == 0) {
>> +   if (xhci_start(xhci)) {
>> +   xhci_halt(xhci);
>> +   return -ENODEV;
>> +   }
>> +   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
>> +   }
>> +
>> xhci_dbg_trace(xhci, trace_xhci_dbg_init,
>> "Finished xhci_run for USB2 roothub");
>>
>> --
>> 1.8.3.1
>>
> Hi,
> Do you have any comment on the patch?
Hi,
Do you have any comment on the patch?


Re: [PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-03-05 Thread Thang Q. Nguyen
On Mon, Jan 29, 2018 at 5:24 PM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> From: Tung Nguyen <tungu...@apm.com>
>
> Currently, hcd->shared_hcd always creates and registers to the usb-core.
> If, for some reasons, USB3 downstream port is disabled, no roothub port for
> USB3.0 is found. This causes kernel to display an error:
> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
> This patch checks and registers shared_hcd if USB3.0 downstream
> port is available.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> ---
>  drivers/usb/host/xhci-plat.c |  9 ++---
>  drivers/usb/host/xhci.c  | 13 +
>  2 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6f03830..bdb3975 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
> if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> xhci->shared_hcd->can_do_streams = 1;
>
> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> -   if (ret)
> -   goto dealloc_usb2_hcd;
> +   /* Just add the shared_hcd when USB3.0 downstream port is available */
> +   if (xhci->num_usb3_ports > 0) {
> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> +   if (ret)
> +   goto dealloc_usb2_hcd;
> +   }
>
> device_enable_async_suspend(>dev);
> pm_runtime_put_noidle(>dev);
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 1eeb339..9d3b1ab 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
> if (ret)
> xhci_free_command(xhci, command);
> }
> +   /*
> +* In case that the USB3.0 downstream port is not available
> +* No one triggers to start the xHC which should be done
> +* before finishing xhci_run
> +*/
> +   if (xhci->num_usb3_ports == 0) {
> +   if (xhci_start(xhci)) {
> +   xhci_halt(xhci);
> +   return -ENODEV;
> +   }
> +   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
> +   }
> +
> xhci_dbg_trace(xhci, trace_xhci_dbg_init,
> "Finished xhci_run for USB2 roothub");
>
> --
> 1.8.3.1
>
Hi,
Do you have any comment on the patch?


Re: [PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-03-05 Thread Thang Q. Nguyen
On Mon, Jan 29, 2018 at 5:24 PM, Thang Q. Nguyen  wrote:
> From: Tung Nguyen 
>
> Currently, hcd->shared_hcd always creates and registers to the usb-core.
> If, for some reasons, USB3 downstream port is disabled, no roothub port for
> USB3.0 is found. This causes kernel to display an error:
> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
> This patch checks and registers shared_hcd if USB3.0 downstream
> port is available.
>
> Signed-off-by: Tung Nguyen 
> ---
>  drivers/usb/host/xhci-plat.c |  9 ++---
>  drivers/usb/host/xhci.c  | 13 +
>  2 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6f03830..bdb3975 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
> if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> xhci->shared_hcd->can_do_streams = 1;
>
> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> -   if (ret)
> -   goto dealloc_usb2_hcd;
> +   /* Just add the shared_hcd when USB3.0 downstream port is available */
> +   if (xhci->num_usb3_ports > 0) {
> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> +   if (ret)
> +   goto dealloc_usb2_hcd;
> +   }
>
> device_enable_async_suspend(>dev);
> pm_runtime_put_noidle(>dev);
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 1eeb339..9d3b1ab 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
> if (ret)
> xhci_free_command(xhci, command);
> }
> +   /*
> +* In case that the USB3.0 downstream port is not available
> +* No one triggers to start the xHC which should be done
> +* before finishing xhci_run
> +*/
> +   if (xhci->num_usb3_ports == 0) {
> +   if (xhci_start(xhci)) {
> +   xhci_halt(xhci);
> +   return -ENODEV;
> +   }
> +   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
> +   }
> +
> xhci_dbg_trace(xhci, trace_xhci_dbg_init,
> "Finished xhci_run for USB2 roothub");
>
> --
> 1.8.3.1
>
Hi,
Do you have any comment on the patch?


[PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-01-29 Thread Thang Q. Nguyen
From: Tung Nguyen 

Currently, hcd->shared_hcd always creates and registers to the usb-core.
If, for some reasons, USB3 downstream port is disabled, no roothub port for
USB3.0 is found. This causes kernel to display an error:
hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
This patch checks and registers shared_hcd if USB3.0 downstream
port is available.

Signed-off-by: Tung Nguyen 
---
 drivers/usb/host/xhci-plat.c |  9 ++---
 drivers/usb/host/xhci.c  | 13 +
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6f03830..bdb3975 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-   if (ret)
-   goto dealloc_usb2_hcd;
+   /* Just add the shared_hcd when USB3.0 downstream port is available */
+   if (xhci->num_usb3_ports > 0) {
+   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
+   if (ret)
+   goto dealloc_usb2_hcd;
+   }
 
device_enable_async_suspend(>dev);
pm_runtime_put_noidle(>dev);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1eeb339..9d3b1ab 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
if (ret)
xhci_free_command(xhci, command);
}
+   /*
+* In case that the USB3.0 downstream port is not available
+* No one triggers to start the xHC which should be done
+* before finishing xhci_run
+*/
+   if (xhci->num_usb3_ports == 0) {
+   if (xhci_start(xhci)) {
+   xhci_halt(xhci);
+   return -ENODEV;
+   }
+   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+   }
+
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB2 roothub");
 
-- 
1.8.3.1



[PATCH v2 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-01-29 Thread Thang Q. Nguyen
From: Tung Nguyen 

Currently, hcd->shared_hcd always creates and registers to the usb-core.
If, for some reasons, USB3 downstream port is disabled, no roothub port for
USB3.0 is found. This causes kernel to display an error:
hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
This patch checks and registers shared_hcd if USB3.0 downstream
port is available.

Signed-off-by: Tung Nguyen 
---
 drivers/usb/host/xhci-plat.c |  9 ++---
 drivers/usb/host/xhci.c  | 13 +
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6f03830..bdb3975 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -293,9 +293,12 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
xhci->shared_hcd->can_do_streams = 1;
 
-   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-   if (ret)
-   goto dealloc_usb2_hcd;
+   /* Just add the shared_hcd when USB3.0 downstream port is available */
+   if (xhci->num_usb3_ports > 0) {
+   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
+   if (ret)
+   goto dealloc_usb2_hcd;
+   }
 
device_enable_async_suspend(>dev);
pm_runtime_put_noidle(>dev);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1eeb339..9d3b1ab 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -611,6 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
if (ret)
xhci_free_command(xhci, command);
}
+   /*
+* In case that the USB3.0 downstream port is not available
+* No one triggers to start the xHC which should be done
+* before finishing xhci_run
+*/
+   if (xhci->num_usb3_ports == 0) {
+   if (xhci_start(xhci)) {
+   xhci_halt(xhci);
+   return -ENODEV;
+   }
+   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+   }
+
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB2 roothub");
 
-- 
1.8.3.1



Re: [PATCH v1 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-01-03 Thread Thang Q. Nguyen
Hi,

On Sat, Dec 16, 2017 at 10:45 AM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> From: Tung Nguyen <tungu...@apm.com>
>
> Currently, hcd->shared_hcd always creates and registers to the usb-core.
> If, for some reasons, USB3 downstream port is disabled, no roothub port for
> USB3.0 is found. This causes kernel to display an error:
> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
> This patch checks, creates and registers shared_hcd if USB3.0 downstream
> port is available.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
> ---
>  drivers/usb/host/xhci-mem.c  |  2 +-
>  drivers/usb/host/xhci-plat.c | 26 +++--
>  drivers/usb/host/xhci.c  | 54 
> 
>  3 files changed, 54 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 554a8a5..157d1e7 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1067,7 +1067,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd 
> *xhci,
> struct usb_device *top_dev;
> struct usb_hcd *hcd;
>
> -   if (udev->speed >= USB_SPEED_SUPER)
> +   if (udev->speed >= USB_SPEED_SUPER && xhci->shared_hcd)
> hcd = xhci->shared_hcd;
> else
> hcd = xhci->main_hcd;
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6f03830..e812e3d 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -253,12 +253,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
>
> xhci->clk = clk;
> xhci->main_hcd = hcd;
> -   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
> -   dev_name(>dev), hcd);
> -   if (!xhci->shared_hcd) {
> -   ret = -ENOMEM;
> -   goto disable_clk;
> -   }
>
> if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
> xhci->quirks |= XHCI_HW_LPM_DISABLE;
> @@ -290,12 +284,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
> if (ret)
> goto disable_usb_phy;
>
> -   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> -   xhci->shared_hcd->can_do_streams = 1;
> -
> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> -   if (ret)
> -   goto dealloc_usb2_hcd;
> +   if (xhci->num_usb3_ports > 0) {
> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, 
> >dev,
> +   dev_name(>dev), hcd);
> +   if (!xhci->shared_hcd) {
> +   ret = -ENOMEM;
> +   goto disable_clk;
> +   }
> +   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> +   xhci->shared_hcd->can_do_streams = 1;
> +
> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> +   if (ret)
> +   goto dealloc_usb2_hcd;
> +   }
>
> device_enable_async_suspend(>dev);
> pm_runtime_put_noidle(>dev);
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 05104bd..4824bf6 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -417,12 +417,14 @@ static void compliance_mode_recovery(struct timer_list 
> *t)
> i + 1);
> xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
> "Attempting compliance mode 
> recovery");
> -   hcd = xhci->shared_hcd;
> +   if (xhci->shared_hcd) {
> +   hcd = xhci->shared_hcd;
>
> -   if (hcd->state == HC_STATE_SUSPENDED)
> -   usb_hcd_resume_root_hub(hcd);
> +   if (hcd->state == HC_STATE_SUSPENDED)
> +   usb_hcd_resume_root_hub(hcd);
>
> -   usb_hcd_poll_rh_status(hcd);
> +   usb_hcd_poll_rh_status(hcd);
> +   }
> }
> }
>
> @@ -611,6 +613,18 @@ int xhci_run(struct usb_hcd *hcd)
> if (ret)
> xhci_free_command(xhci, command);
> }
> +   /*
> +* Execute xhci_start() in case xhci->shared_hcd is not registered.
> +* If the xhci->shared_hcd

Re: [PATCH v1 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2018-01-03 Thread Thang Q. Nguyen
Hi,

On Sat, Dec 16, 2017 at 10:45 AM, Thang Q. Nguyen  wrote:
> From: Tung Nguyen 
>
> Currently, hcd->shared_hcd always creates and registers to the usb-core.
> If, for some reasons, USB3 downstream port is disabled, no roothub port for
> USB3.0 is found. This causes kernel to display an error:
> hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
> This patch checks, creates and registers shared_hcd if USB3.0 downstream
> port is available.
>
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
>  drivers/usb/host/xhci-mem.c  |  2 +-
>  drivers/usb/host/xhci-plat.c | 26 +++--
>  drivers/usb/host/xhci.c  | 54 
> 
>  3 files changed, 54 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> index 554a8a5..157d1e7 100644
> --- a/drivers/usb/host/xhci-mem.c
> +++ b/drivers/usb/host/xhci-mem.c
> @@ -1067,7 +1067,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd 
> *xhci,
> struct usb_device *top_dev;
> struct usb_hcd *hcd;
>
> -   if (udev->speed >= USB_SPEED_SUPER)
> +   if (udev->speed >= USB_SPEED_SUPER && xhci->shared_hcd)
> hcd = xhci->shared_hcd;
> else
> hcd = xhci->main_hcd;
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index 6f03830..e812e3d 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -253,12 +253,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
>
> xhci->clk = clk;
> xhci->main_hcd = hcd;
> -   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
> -   dev_name(>dev), hcd);
> -   if (!xhci->shared_hcd) {
> -   ret = -ENOMEM;
> -   goto disable_clk;
> -   }
>
> if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
> xhci->quirks |= XHCI_HW_LPM_DISABLE;
> @@ -290,12 +284,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
> if (ret)
> goto disable_usb_phy;
>
> -   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> -   xhci->shared_hcd->can_do_streams = 1;
> -
> -   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> -   if (ret)
> -   goto dealloc_usb2_hcd;
> +   if (xhci->num_usb3_ports > 0) {
> +   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, 
> >dev,
> +   dev_name(>dev), hcd);
> +   if (!xhci->shared_hcd) {
> +   ret = -ENOMEM;
> +   goto disable_clk;
> +   }
> +   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> +   xhci->shared_hcd->can_do_streams = 1;
> +
> +   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> +   if (ret)
> +   goto dealloc_usb2_hcd;
> +   }
>
> device_enable_async_suspend(>dev);
> pm_runtime_put_noidle(>dev);
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 05104bd..4824bf6 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -417,12 +417,14 @@ static void compliance_mode_recovery(struct timer_list 
> *t)
> i + 1);
> xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
> "Attempting compliance mode 
> recovery");
> -   hcd = xhci->shared_hcd;
> +   if (xhci->shared_hcd) {
> +   hcd = xhci->shared_hcd;
>
> -   if (hcd->state == HC_STATE_SUSPENDED)
> -   usb_hcd_resume_root_hub(hcd);
> +   if (hcd->state == HC_STATE_SUSPENDED)
> +   usb_hcd_resume_root_hub(hcd);
>
> -   usb_hcd_poll_rh_status(hcd);
> +   usb_hcd_poll_rh_status(hcd);
> +   }
> }
> }
>
> @@ -611,6 +613,18 @@ int xhci_run(struct usb_hcd *hcd)
> if (ret)
> xhci_free_command(xhci, command);
> }
> +   /*
> +* Execute xhci_start() in case xhci->shared_hcd is not registered.
> +* If the xhci->shared_hcd doesn't exist, no one triggers to start
> +* the xhci which should be done before ex

[PATCH v1 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2017-12-15 Thread Thang Q. Nguyen
From: Tung Nguyen <tungu...@apm.com>

Currently, hcd->shared_hcd always creates and registers to the usb-core.
If, for some reasons, USB3 downstream port is disabled, no roothub port for
USB3.0 is found. This causes kernel to display an error:
hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
This patch checks, creates and registers shared_hcd if USB3.0 downstream
port is available.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
 drivers/usb/host/xhci-mem.c  |  2 +-
 drivers/usb/host/xhci-plat.c | 26 +++--
 drivers/usb/host/xhci.c  | 54 
 3 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 554a8a5..157d1e7 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1067,7 +1067,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd 
*xhci,
struct usb_device *top_dev;
struct usb_hcd *hcd;
 
-   if (udev->speed >= USB_SPEED_SUPER)
+   if (udev->speed >= USB_SPEED_SUPER && xhci->shared_hcd)
hcd = xhci->shared_hcd;
else
hcd = xhci->main_hcd;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6f03830..e812e3d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -253,12 +253,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
xhci->clk = clk;
xhci->main_hcd = hcd;
-   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
-   dev_name(>dev), hcd);
-   if (!xhci->shared_hcd) {
-   ret = -ENOMEM;
-   goto disable_clk;
-   }
 
if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
xhci->quirks |= XHCI_HW_LPM_DISABLE;
@@ -290,12 +284,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (ret)
goto disable_usb_phy;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
-   xhci->shared_hcd->can_do_streams = 1;
-
-   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-   if (ret)
-   goto dealloc_usb2_hcd;
+   if (xhci->num_usb3_ports > 0) {
+   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
+   dev_name(>dev), hcd);
+   if (!xhci->shared_hcd) {
+   ret = -ENOMEM;
+   goto disable_clk;
+   }
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   xhci->shared_hcd->can_do_streams = 1;
+
+   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
+   if (ret)
+   goto dealloc_usb2_hcd;
+   }
 
device_enable_async_suspend(>dev);
pm_runtime_put_noidle(>dev);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..4824bf6 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -417,12 +417,14 @@ static void compliance_mode_recovery(struct timer_list *t)
i + 1);
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
"Attempting compliance mode recovery");
-   hcd = xhci->shared_hcd;
+   if (xhci->shared_hcd) {
+   hcd = xhci->shared_hcd;
 
-   if (hcd->state == HC_STATE_SUSPENDED)
-   usb_hcd_resume_root_hub(hcd);
+   if (hcd->state == HC_STATE_SUSPENDED)
+   usb_hcd_resume_root_hub(hcd);
 
-   usb_hcd_poll_rh_status(hcd);
+   usb_hcd_poll_rh_status(hcd);
+   }
}
}
 
@@ -611,6 +613,18 @@ int xhci_run(struct usb_hcd *hcd)
if (ret)
xhci_free_command(xhci, command);
}
+   /*
+* Execute xhci_start() in case xhci->shared_hcd is not registered.
+* If the xhci->shared_hcd doesn't exist, no one triggers to start
+* the xhci which should be done before exitting run function
+*/
+   if (!xhci->shared_hcd) {
+   if (xhci_start(xhci)) {
+   xhci_halt(xhci);
+   return -ENODEV;
+   }
+   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+   }
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB2 roothub");
 
@@ -861,8 +875,8 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
if (!hcd->state)
   

[PATCH v1 1/1] usb: xhci: do not create and register shared_hcd when USB3.0 is disabled

2017-12-15 Thread Thang Q. Nguyen
From: Tung Nguyen 

Currently, hcd->shared_hcd always creates and registers to the usb-core.
If, for some reasons, USB3 downstream port is disabled, no roothub port for
USB3.0 is found. This causes kernel to display an error:
hub 2-0:1.0: config failed, hub doesn't have any ports! (err -19)
This patch checks, creates and registers shared_hcd if USB3.0 downstream
port is available.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
 drivers/usb/host/xhci-mem.c  |  2 +-
 drivers/usb/host/xhci-plat.c | 26 +++--
 drivers/usb/host/xhci.c  | 54 
 3 files changed, 54 insertions(+), 28 deletions(-)

diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 554a8a5..157d1e7 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1067,7 +1067,7 @@ static u32 xhci_find_real_port_number(struct xhci_hcd 
*xhci,
struct usb_device *top_dev;
struct usb_hcd *hcd;
 
-   if (udev->speed >= USB_SPEED_SUPER)
+   if (udev->speed >= USB_SPEED_SUPER && xhci->shared_hcd)
hcd = xhci->shared_hcd;
else
hcd = xhci->main_hcd;
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index 6f03830..e812e3d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -253,12 +253,6 @@ static int xhci_plat_probe(struct platform_device *pdev)
 
xhci->clk = clk;
xhci->main_hcd = hcd;
-   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
-   dev_name(>dev), hcd);
-   if (!xhci->shared_hcd) {
-   ret = -ENOMEM;
-   goto disable_clk;
-   }
 
if (device_property_read_bool(sysdev, "usb2-lpm-disable"))
xhci->quirks |= XHCI_HW_LPM_DISABLE;
@@ -290,12 +284,20 @@ static int xhci_plat_probe(struct platform_device *pdev)
if (ret)
goto disable_usb_phy;
 
-   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
-   xhci->shared_hcd->can_do_streams = 1;
-
-   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
-   if (ret)
-   goto dealloc_usb2_hcd;
+   if (xhci->num_usb3_ports > 0) {
+   xhci->shared_hcd = __usb_create_hcd(driver, sysdev, >dev,
+   dev_name(>dev), hcd);
+   if (!xhci->shared_hcd) {
+   ret = -ENOMEM;
+   goto disable_clk;
+   }
+   if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
+   xhci->shared_hcd->can_do_streams = 1;
+
+   ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
+   if (ret)
+   goto dealloc_usb2_hcd;
+   }
 
device_enable_async_suspend(>dev);
pm_runtime_put_noidle(>dev);
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 05104bd..4824bf6 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -417,12 +417,14 @@ static void compliance_mode_recovery(struct timer_list *t)
i + 1);
xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
"Attempting compliance mode recovery");
-   hcd = xhci->shared_hcd;
+   if (xhci->shared_hcd) {
+   hcd = xhci->shared_hcd;
 
-   if (hcd->state == HC_STATE_SUSPENDED)
-   usb_hcd_resume_root_hub(hcd);
+   if (hcd->state == HC_STATE_SUSPENDED)
+   usb_hcd_resume_root_hub(hcd);
 
-   usb_hcd_poll_rh_status(hcd);
+   usb_hcd_poll_rh_status(hcd);
+   }
}
}
 
@@ -611,6 +613,18 @@ int xhci_run(struct usb_hcd *hcd)
if (ret)
xhci_free_command(xhci, command);
}
+   /*
+* Execute xhci_start() in case xhci->shared_hcd is not registered.
+* If the xhci->shared_hcd doesn't exist, no one triggers to start
+* the xhci which should be done before exitting run function
+*/
+   if (!xhci->shared_hcd) {
+   if (xhci_start(xhci)) {
+   xhci_halt(xhci);
+   return -ENODEV;
+   }
+   xhci->cmd_ring_state = CMD_RING_STATE_RUNNING;
+   }
xhci_dbg_trace(xhci, trace_xhci_dbg_init,
"Finished xhci_run for USB2 roothub");
 
@@ -861,8 +875,8 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup)
if (!hcd->state)
return 0;
 
-   if (hcd->state != HC_STATE_SUSPENDED ||
- 

Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-08-23 Thread Thang Q. Nguyen
On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> From: "Thang Q. Nguyen" <tqngu...@apm.com>
>
> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
> configuration"), sysdev points to devices known to the system firmware
> or hardware for DMA parameters.
> However, the parent of the system firmware/hardware device checking
> logic does not work in ACPI boot mode. This patch updates the formulation
> to check this case in both DT and ACPI.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
> ---
> Change since v1:
>  - Update codes to work with kernel 4.13-rc5
> ---
>  drivers/usb/host/xhci-plat.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c04144b..1bb9729 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>  */
> sysdev = >dev;
> -   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> +   if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
> +   !is_acpi_device_node(sysdev->fwnode) &&
> +   (is_of_node(sysdev->parent->fwnode) ||
> +is_acpi_device_node(sysdev->parent->fwnode)))
> sysdev = sysdev->parent;
>  #ifdef CONFIG_PCI
> else if (sysdev->parent && sysdev->parent->parent &&
> --
> 1.8.3.1
>
Is there any comment about the patch?
With current kernel (4.13.0-rc6), booting the Linux using ACPI boot,
kernel is crashed right after probing the USB DWC3 driver with the
following messages:

[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.211272] Modules linked in:
[   10.211272] Modules linked in:
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.252464] task: 8001f3c78000 task.stack: 8001f3c74000
[   10.252464] task: 8001f3c78000 task.stack: 8001f3c74000
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.282906] pc : [] lr : []
pstate: 0145
[   10.282906] pc : [] lr : []
pstate: 0145
[   10.297909] sp : 8001f3c77c00
[   10.297909] sp : 8001f3c77c00
[   10.304608] x29: 8001f3c77c00 x28: 
[   10.304608] x29: 8001f3c77c00 x28: 
[   10.315360] x27: 08eac808 x26: 08db0454
[   10.315360] x27: 08eac808 x26: 08db0454
[   10.326113] x25: 001c x24: 
[   10.326113] x25: 001c x24: 
[   10.336814] x23: 08fa32d0 x22: 8001f2bd1010
[   10.336814] x23: 08fa32d0 x22: 8001f2bd1010
[   10.347532] x21: 8001f2bd1000 x20: 8001f2bd1010
[   10.347532] x21: 8001f2bd1000 x20: 8001f2bd1010
[   10.358215] x19: ffed x18: 
[   10.358215] x19: ffed x18: 
[   10.368950] x17: 00030004 x16: 0003
[   10.368950] x17: 00030004 x16: 0003
[   10.379642] x15: 8001f3f50400 x14: 0004
[   10.379642] x15: 8001f3f50400 x14: 0004
[   10.390403] x13: 0404 x12: 0003
[   10.390403] x13: 0404 x12: 0003
[   10.401173] x11: 00030004 x10: 8001f3f50400
[   10.401173] x11: 00030004 x10: 8001f3f50400
[   10.411864] x9 :  x8 : 001c
[   10.411864] x9 :  x8 : 001c
[   10.422616] x7 : 8001f3f50400 x6 : 8001f3f50400
[   10.422616] x7 : 8001f3f50400 x6 : 8001f3f50400
[   10.433360] x5 :  x4 : 
[   10.433360] x5 :  x4 : 
[   10.444103] x3 : 08f245b8 x2 : 08f24000
[   10.444103] x3 : 08f245b8 x2 : 08f24000
[   10.454864] x1 :  x0 : 
[   10.454864] x1 : 00

Re: [PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-08-23 Thread Thang Q. Nguyen
On Sat, Aug 19, 2017 at 10:43 AM, Thang Q. Nguyen  wrote:
> From: "Thang Q. Nguyen" 
>
> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
> configuration"), sysdev points to devices known to the system firmware
> or hardware for DMA parameters.
> However, the parent of the system firmware/hardware device checking
> logic does not work in ACPI boot mode. This patch updates the formulation
> to check this case in both DT and ACPI.
>
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
> Change since v1:
>  - Update codes to work with kernel 4.13-rc5
> ---
>  drivers/usb/host/xhci-plat.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c04144b..1bb9729 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>  */
> sysdev = >dev;
> -   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> +   if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
> +   !is_acpi_device_node(sysdev->fwnode) &&
> +   (is_of_node(sysdev->parent->fwnode) ||
> +is_acpi_device_node(sysdev->parent->fwnode)))
> sysdev = sysdev->parent;
>  #ifdef CONFIG_PCI
> else if (sysdev->parent && sysdev->parent->parent &&
> --
> 1.8.3.1
>
Is there any comment about the patch?
With current kernel (4.13.0-rc6), booting the Linux using ACPI boot,
kernel is crashed right after probing the USB DWC3 driver with the
following messages:

[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.193176] WARNING: CPU: 0 PID: 1 at
drivers/usb/host/xhci-plat.c:199 xhci_plat_probe+0x2f0/0x700
[   10.211272] Modules linked in:
[   10.211272] Modules linked in:
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.217457] CPU: 0 PID: 1 Comm: swapper/0 Not tainted
4.13.0-rc6-00066-g143c97c #4
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.232727] Hardware name: AppliedMicro X-Gene Mustang Board/X-Gene
Mustang Board, BIOS 3.07.09 Feb 28 2017
[   10.252464] task: 8001f3c78000 task.stack: 8001f3c74000
[   10.252464] task: 8001f3c78000 task.stack: 8001f3c74000
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.264383] PC is at xhci_plat_probe+0x2f0/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.273727] LR is at xhci_plat_probe+0x34/0x700
[   10.282906] pc : [] lr : []
pstate: 0145
[   10.282906] pc : [] lr : []
pstate: 0145
[   10.297909] sp : 8001f3c77c00
[   10.297909] sp : 8001f3c77c00
[   10.304608] x29: 8001f3c77c00 x28: 
[   10.304608] x29: 8001f3c77c00 x28: 
[   10.315360] x27: 08eac808 x26: 08db0454
[   10.315360] x27: 08eac808 x26: 08db0454
[   10.326113] x25: 001c x24: 
[   10.326113] x25: 001c x24: 
[   10.336814] x23: 08fa32d0 x22: 8001f2bd1010
[   10.336814] x23: 08fa32d0 x22: 8001f2bd1010
[   10.347532] x21: 8001f2bd1000 x20: 8001f2bd1010
[   10.347532] x21: 8001f2bd1000 x20: 8001f2bd1010
[   10.358215] x19: ffed x18: 
[   10.358215] x19: ffed x18: 
[   10.368950] x17: 00030004 x16: 0003
[   10.368950] x17: 00030004 x16: 0003
[   10.379642] x15: 8001f3f50400 x14: 0004
[   10.379642] x15: 8001f3f50400 x14: 0004
[   10.390403] x13: 0404 x12: 0003
[   10.390403] x13: 0404 x12: 0003
[   10.401173] x11: 00030004 x10: 8001f3f50400
[   10.401173] x11: 00030004 x10: 8001f3f50400
[   10.411864] x9 :  x8 : 001c
[   10.411864] x9 :  x8 : 001c
[   10.422616] x7 : 8001f3f50400 x6 : 8001f3f50400
[   10.422616] x7 : 8001f3f50400 x6 : 8001f3f50400
[   10.433360] x5 :  x4 : 
[   10.433360] x5 :  x4 : 
[   10.444103] x3 : 08f245b8 x2 : 08f24000
[   10.444103] x3 : 08f245b8 x2 : 08f24000
[   10.454864] x1 :  x0 : 
[   10.454864] x1 :  x0 : 
[   10.465600] Call trace:
[   10.465600] Call trace:
[   10.470546] Ex

[PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-08-18 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" <tqngu...@apm.com>

For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
configuration"), sysdev points to devices known to the system firmware
or hardware for DMA parameters.
However, the parent of the system firmware/hardware device checking
logic does not work in ACPI boot mode. This patch updates the formulation
to check this case in both DT and ACPI.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Change since v1:
 - Update codes to work with kernel 4.13-rc5
---
 drivers/usb/host/xhci-plat.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c04144b..1bb9729 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
 */
sysdev = >dev;
-   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
+   !is_acpi_device_node(sysdev->fwnode) &&
+   (is_of_node(sysdev->parent->fwnode) ||
+is_acpi_device_node(sysdev->parent->fwnode)))
sysdev = sysdev->parent;
 #ifdef CONFIG_PCI
else if (sysdev->parent && sysdev->parent->parent &&
-- 
1.8.3.1



[PATCH v2 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-08-18 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" 

For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
configuration"), sysdev points to devices known to the system firmware
or hardware for DMA parameters.
However, the parent of the system firmware/hardware device checking
logic does not work in ACPI boot mode. This patch updates the formulation
to check this case in both DT and ACPI.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
Change since v1:
 - Update codes to work with kernel 4.13-rc5
---
 drivers/usb/host/xhci-plat.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c04144b..1bb9729 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -187,7 +187,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
 */
sysdev = >dev;
-   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   if (sysdev->parent && !is_of_node(sysdev->fwnode) &&
+   !is_acpi_device_node(sysdev->fwnode) &&
+   (is_of_node(sysdev->parent->fwnode) ||
+is_acpi_device_node(sysdev->parent->fwnode)))
sysdev = sysdev->parent;
 #ifdef CONFIG_PCI
else if (sysdev->parent && sysdev->parent->parent &&
-- 
1.8.3.1



Re: [PATCH v5 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-08-16 Thread Thang Q. Nguyen
On Tue, Aug 8, 2017 at 11:27 AM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> XHCI specification 1.1 does not require xHCI-compliant controllers
> to always enable hardware USB2 LPM. However, the current xHCI
> driver always enable it when seeing HLC=1.
> This patch supports an option for users to control disabling
> USB2 Hardware LPM via DT/ACPI attribute.
> This option is needed in case user would like to disable this
> feature. For example, their xHCI controller has its USB2 HW LPM
> broken.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
> Acked-by: Rob Herring <r...@kernel.org>
> ---
> Changes since v4:
>  - When HW LPM is optionally disabled, explicitly disable HLE, RWE, ...
>  - Update codes to work with kernel 4.13-rc4
>  - Add Acked-By from Rob Herring <r...@kernel.org>
> Changes since v3:
>  - Bypass updating LPM parameters when HW LPM is optionally disabled.
> Changes since v2:
>  - Change code to disable HW LPM as an option for user which
>is set via ACPI/DT.
> Changes since v1:
>  - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>be consistent with other attribute names.
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|2 +-
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
>- 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
> +   xhci->quirks |= XHCI_HW_LPM_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 b2ff1ff..3a8e75f 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4087,7 +4087,7 @@ 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) {
> +   if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
> /* 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 e3e9352..5d89c51 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1821,6 +1821,7 @@ struct xhci_hcd {
>  #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
>  #define XHCI_U2_DISABLE_WAKE   (1 << 27)
>  #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL(1 << 28)
> +#define XHCI_HW_LPM_DISABLE(1 << 29)
>
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> --
> 1.7.1
>

Do you have any comments about this patch? Thanks.


Re: [PATCH v5 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-08-16 Thread Thang Q. Nguyen
On Tue, Aug 8, 2017 at 11:27 AM, Thang Q. Nguyen  wrote:
> XHCI specification 1.1 does not require xHCI-compliant controllers
> to always enable hardware USB2 LPM. However, the current xHCI
> driver always enable it when seeing HLC=1.
> This patch supports an option for users to control disabling
> USB2 Hardware LPM via DT/ACPI attribute.
> This option is needed in case user would like to disable this
> feature. For example, their xHCI controller has its USB2 HW LPM
> broken.
>
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> Acked-by: Rob Herring 
> ---
> Changes since v4:
>  - When HW LPM is optionally disabled, explicitly disable HLE, RWE, ...
>  - Update codes to work with kernel 4.13-rc4
>  - Add Acked-By from Rob Herring 
> Changes since v3:
>  - Bypass updating LPM parameters when HW LPM is optionally disabled.
> Changes since v2:
>  - Change code to disable HW LPM as an option for user which
>is set via ACPI/DT.
> Changes since v1:
>  - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>be consistent with other attribute names.
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|2 +-
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
>- 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
> +   xhci->quirks |= XHCI_HW_LPM_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 b2ff1ff..3a8e75f 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4087,7 +4087,7 @@ 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) {
> +   if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
> /* 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 e3e9352..5d89c51 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1821,6 +1821,7 @@ struct xhci_hcd {
>  #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
>  #define XHCI_U2_DISABLE_WAKE   (1 << 27)
>  #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL(1 << 28)
> +#define XHCI_HW_LPM_DISABLE(1 << 29)
>
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> --
> 1.7.1
>

Do you have any comments about this patch? Thanks.


[PATCH v5 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-08-07 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
Acked-by: Rob Herring <r...@kernel.org>
---
Changes since v4:
 - When HW LPM is optionally disabled, explicitly disable HLE, RWE, ...
 - Update codes to work with kernel 4.13-rc4
 - Add Acked-By from Rob Herring <r...@kernel.org>
Changes since v3:
 - Bypass updating LPM parameters when HW LPM is optionally disabled.
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|2 +-
 drivers/usb/host/xhci.h|1 +
 4 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 b2ff1ff..3a8e75f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4087,7 +4087,7 @@ 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) {
+   if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
/* 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 e3e9352..5d89c51 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1821,6 +1821,7 @@ struct xhci_hcd {
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
 #define XHCI_U2_DISABLE_WAKE   (1 << 27)
 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL(1 << 28)
+#define XHCI_HW_LPM_DISABLE(1 << 29)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



[PATCH v5 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-08-07 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
Acked-by: Rob Herring 
---
Changes since v4:
 - When HW LPM is optionally disabled, explicitly disable HLE, RWE, ...
 - Update codes to work with kernel 4.13-rc4
 - Add Acked-By from Rob Herring 
Changes since v3:
 - Bypass updating LPM parameters when HW LPM is optionally disabled.
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|2 +-
 drivers/usb/host/xhci.h|1 +
 4 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 b2ff1ff..3a8e75f 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4087,7 +4087,7 @@ 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) {
+   if (enable && !(xhci->quirks & XHCI_HW_LPM_DISABLE)) {
/* 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 e3e9352..5d89c51 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1821,6 +1821,7 @@ struct xhci_hcd {
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
 #define XHCI_U2_DISABLE_WAKE   (1 << 27)
 #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL(1 << 28)
+#define XHCI_HW_LPM_DISABLE(1 << 29)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



[PATCH v4 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-07-12 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes since v3:
 - Bypass updating LPM parameters when HW LPM is optionally disabled.
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|6 ++
 drivers/usb/host/xhci.h|1 +
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 56f85df..73b24bc 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4060,6 +4060,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
!udev->lpm_capable)
return -EPERM;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return -EPERM;
+
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
return -EPERM;
@@ -4177,6 +4180,9 @@ static int xhci_update_device(struct usb_hcd *hcd, struct 
usb_device *udev)
!udev->lpm_capable)
return 0;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return 0;
+
/* we only support lpm for non-hub device connected to root hub yet */
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3c6da1f..3cbf4a9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1820,6 +1820,7 @@ struct xhci_hcd {
 #define XHCI_BROKEN_PORT_PED   (1 << 25)
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
 #define XHCI_U2_DISABLE_WAKE   (1 << 27)
+#define XHCI_HW_LPM_DISABLE(1 << 28)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



[PATCH v4 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-07-12 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
Changes since v3:
 - Bypass updating LPM parameters when HW LPM is optionally disabled.
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|6 ++
 drivers/usb/host/xhci.h|1 +
 4 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 56f85df..73b24bc 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4060,6 +4060,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
!udev->lpm_capable)
return -EPERM;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return -EPERM;
+
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
return -EPERM;
@@ -4177,6 +4180,9 @@ static int xhci_update_device(struct usb_hcd *hcd, struct 
usb_device *udev)
!udev->lpm_capable)
return 0;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return 0;
+
/* we only support lpm for non-hub device connected to root hub yet */
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 3c6da1f..3cbf4a9 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1820,6 +1820,7 @@ struct xhci_hcd {
 #define XHCI_BROKEN_PORT_PED   (1 << 25)
 #define XHCI_LIMIT_ENDPOINT_INTERVAL_7 (1 << 26)
 #define XHCI_U2_DISABLE_WAKE   (1 << 27)
+#define XHCI_HW_LPM_DISABLE(1 << 28)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



Re: [PATCH v3 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-07-08 Thread Thang Q. Nguyen
On Fri, Jun 23, 2017 at 10:02 AM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> XHCI specification 1.1 does not require xHCI-compliant controllers
> to always enable hardware USB2 LPM. However, the current xHCI
> driver always enable it when seeing HLC=1.
> This patch supports an option for users to control disabling
> USB2 Hardware LPM via DT/ACPI attribute.
> This option is needed in case user would like to disable this
> feature. For example, their xHCI controller has its USB2 HW LPM
> broken.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
> ---
> Changes since v2:
>  - Change code to disable HW LPM as an option for user which
>is set via ACPI/DT.
> Changes since v1:
>  - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>be consistent with other attribute names.
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|3 +++
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
>- 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
> +   xhci->quirks |= XHCI_HW_LPM_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 30f47d9..49d05c7 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4061,6 +4061,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd 
> *hcd,
> !udev->lpm_capable)
> return -EPERM;
>
> +   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
> +   return -EPERM;
> +
> if (!udev->parent || udev->parent->parent ||
> udev->descriptor.bDeviceClass == USB_CLASS_HUB)
> return -EPERM;
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 73a28a9..03d50e8 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_HW_LPM_DISABLE(1 << 27)
>
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> --
> 1.7.1
>
Hi,
Is there any other comment on the patch?

Regards,
Thang Q. Nguyen


Re: [PATCH v3 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-07-08 Thread Thang Q. Nguyen
On Fri, Jun 23, 2017 at 10:02 AM, Thang Q. Nguyen  wrote:
> XHCI specification 1.1 does not require xHCI-compliant controllers
> to always enable hardware USB2 LPM. However, the current xHCI
> driver always enable it when seeing HLC=1.
> This patch supports an option for users to control disabling
> USB2 Hardware LPM via DT/ACPI attribute.
> This option is needed in case user would like to disable this
> feature. For example, their xHCI controller has its USB2 HW LPM
> broken.
>
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
> Changes since v2:
>  - Change code to disable HW LPM as an option for user which
>is set via ACPI/DT.
> Changes since v1:
>  - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>be consistent with other attribute names.
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
>  drivers/usb/host/xhci-plat.c   |3 +++
>  drivers/usb/host/xhci.c|3 +++
>  drivers/usb/host/xhci.h|1 +
>  4 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
>- 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
> +   xhci->quirks |= XHCI_HW_LPM_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 30f47d9..49d05c7 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4061,6 +4061,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd 
> *hcd,
> !udev->lpm_capable)
> return -EPERM;
>
> +   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
> +   return -EPERM;
> +
> if (!udev->parent || udev->parent->parent ||
> udev->descriptor.bDeviceClass == USB_CLASS_HUB)
> return -EPERM;
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index 73a28a9..03d50e8 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_HW_LPM_DISABLE(1 << 27)
>
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> --
> 1.7.1
>
Hi,
Is there any other comment on the patch?

Regards,
Thang Q. Nguyen


Re: [PATCH v1 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-07-03 Thread Thang Q. Nguyen
On Tue, Jun 6, 2017 at 2:11 PM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
> configuration"), sysdev points to devices known to the system firmware
> or hardware for DMA parameters.
> However, the parent of the system firmware/hardware device checking
> logic does not work in ACPI boot mode. This patch updates the formulation
> to check this case in both DT and ACPI.
>
> Signed-off-by: Tung Nguyen <tungu...@apm.com>
> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
> ---
>  drivers/usb/host/xhci-plat.c |4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c04144b..e3e342a 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -187,7 +187,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>  */
> sysdev = >dev;
> -   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> +   if (sysdev->parent && (sysdev->fwnode->type == FWNODE_PDATA) &&
> +   (is_of_node(sysdev->parent->fwnode) ||
> +   is_acpi_device_node(sysdev->parent->fwnode)))
> sysdev = sysdev->parent;
>  #ifdef CONFIG_PCI
> else if (sysdev->parent && sysdev->parent->parent &&
> --
> 1.7.1
>
Hi,
Do you have any comment on this patch?

Regards,
Thang Q. Nguyen


Re: [PATCH v1 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-07-03 Thread Thang Q. Nguyen
On Tue, Jun 6, 2017 at 2:11 PM, Thang Q. Nguyen  wrote:
> For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
> configuration"), sysdev points to devices known to the system firmware
> or hardware for DMA parameters.
> However, the parent of the system firmware/hardware device checking
> logic does not work in ACPI boot mode. This patch updates the formulation
> to check this case in both DT and ACPI.
>
> Signed-off-by: Tung Nguyen 
> Signed-off-by: Thang Q. Nguyen 
> ---
>  drivers/usb/host/xhci-plat.c |4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index c04144b..e3e342a 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -187,7 +187,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
>  * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
>  */
> sysdev = >dev;
> -   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
> +   if (sysdev->parent && (sysdev->fwnode->type == FWNODE_PDATA) &&
> +   (is_of_node(sysdev->parent->fwnode) ||
> +   is_acpi_device_node(sysdev->parent->fwnode)))
> sysdev = sysdev->parent;
>  #ifdef CONFIG_PCI
> else if (sysdev->parent && sysdev->parent->parent &&
> --
> 1.7.1
>
Hi,
Do you have any comment on this patch?

Regards,
Thang Q. Nguyen


[PATCH v3 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-06-22 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|3 +++
 drivers/usb/host/xhci.h|1 +
 4 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 30f47d9..49d05c7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4061,6 +4061,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
!udev->lpm_capable)
return -EPERM;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return -EPERM;
+
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
return -EPERM;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 73a28a9..03d50e8 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_HW_LPM_DISABLE(1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



[PATCH v3 1/1] usb:host:xhci support option to disable the xHCI USB2 HW LPM

2017-06-22 Thread Thang Q. Nguyen
XHCI specification 1.1 does not require xHCI-compliant controllers
to always enable hardware USB2 LPM. However, the current xHCI
driver always enable it when seeing HLC=1.
This patch supports an option for users to control disabling
USB2 Hardware LPM via DT/ACPI attribute.
This option is needed in case user would like to disable this
feature. For example, their xHCI controller has its USB2 HW LPM
broken.

Signed-off-by: Tung Nguyen 
Signed-off-by: Thang Q. Nguyen 
---
Changes since v2:
 - Change code to disable HW LPM as an option for user which
   is set via ACPI/DT.
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
   be consistent with other attribute names.
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt |1 +
 drivers/usb/host/xhci-plat.c   |3 +++
 drivers/usb/host/xhci.c|3 +++
 drivers/usb/host/xhci.h|1 +
 4 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 2d80b60..ae6e484 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-lpm-disable: indicate if we don't want to enable USB2 HW LPM
   - 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 c04144b..9028fb5 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(sysdev, "usb2-lpm-disable"))
+   xhci->quirks |= XHCI_HW_LPM_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 30f47d9..49d05c7 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4061,6 +4061,9 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
!udev->lpm_capable)
return -EPERM;
 
+   if (xhci->quirks & XHCI_HW_LPM_DISABLE)
+   return -EPERM;
+
if (!udev->parent || udev->parent->parent ||
udev->descriptor.bDeviceClass == USB_CLASS_HUB)
return -EPERM;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 73a28a9..03d50e8 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_HW_LPM_DISABLE(1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



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

2017-06-14 Thread Thang Q. Nguyen
On Tue, Jun 13, 2017 at 8:12 PM, Mathias Nyman
<mathias.ny...@linux.intel.com> wrote:
> On 06.06.2017 09:33, Thang Q. Nguyen wrote:
>>
>> On Mon, Jun 5, 2017 at 9:33 PM, Mathias Nyman <mathias.ny...@intel.com>
>> wrote:
>>>
>>> On 05.06.2017 15:57, Thang Q. Nguyen wrote:
>>>>
>>>>
>>>> On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
>>>> <mathias.ny...@linux.intel.com> wrote:
>>>>>
>>>>>
>>>>> On 20.05.2017 10:24, 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.
>>>>>>
>>>>>
>>>>>Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the
>>>>> host
>>>>> doesn't support Hardware LPM Capability, (HLC)?
>>>>>
>>>>> This should prevent all those extra steps getting here just to do
>>>>> nothing.
>>>>
>>>>
>>>> No, HLC = 0 means the host doesn't support Hardware LPM.
>>>> The problem here is the host support Hardware LPM but there is a bug
>>>> in host controller that make the LPM fail to work.
>>>>
>>>
>>> So the host support hw LPM, and has its HLC capability bit set,
>>> but in the end it just doesn't work at all, and should be prevented.
>>>
>>>> When debugging the host controller, we detect there are some holes in
>>>> the current usb specifications which can can result in inter-operating
>>>> problems between USB Host Controller and USB PHY. To be more specific,
>>>> the specs have not clarified the resume recovery timing after the port
>>>> has just waken up from L1. This can lead to different interpretations
>>>> of the specs by Host Controller and PHY. What happened in our case is
>>>> that a Host controller cannot work with a PHY right after resuming
>>>> from L1 because these two Vendors have different views of the specs
>>>> regarding LPM timing after L1. These views are contradictory and
>>>> cannot work together.
>>>>
>>>> If Host Controller and PHY are from the same vendor, they might have
>>>> some "internal handshake mechanisms" to avoid these holes of the USB
>>>> specs. However, these mechanisms are not standardized in USB specs;
>>>> and not all vendors follow these mechanisms. In fact, we have observed
>>>> this kind of "internal handshake mechanism" in HOST Controller and PHY
>>>> from SYNOPSYS DWC. So, we can say that if users use Host Controller
>>>> and PHY from different Vendors, the inteopering problems after waking
>>>> up from L1 are more likely to occur.
>>>
>>>
>>>
>>> Can you explain the reason why you prefer preventing hw lpm inside the
>>> xhci_set_usb2_hardware_lpm() function instead of preventing hw lpm usage
>>> all together for this platform -i.e. by not setting xhci->hw_lpm_support
>>
>> The reason I don't change in the xhci_add_in_port() function inside
>> xhci-mem.c is because of the description for xhci->hw_lpm_support in
>> the drivers/usb/host/xhci.h header file: support xHCI 1.0 spec USB2
>> hardware LPM. Per my understanding, this attribute is used to indicate
>> if the host supports HW LPM and this can be checked via HLC.
>> My intension is to support an option for user to disable the HW LPM
>> because of some reasons (in my case because HW LPM is broken).
>
>
> I think we should keep supporting new options separate from workarounds
> for broken HW.
So, I will continue to use usb2-lpm-disable to let kernel know that we
want to disable USB2 HW LPM.
>
>>>
>>>
>>> Again, something like:
>>> if (temp & XHCI_HLC && !(xhci->quirks & XHCI_HW_LPM_BROKEN))
>>>  xhci->hw_lpm_support = 1;
>>
>> This should work too. But the DT/ACPI attribute should change to
>> "usb2-lpm-broken".
>
>
> This would be more clear for future developers and prevent them from
> enabling hw lpm for this host to gain some powersaving.
>
> A new feature allowing optional host hw lpm disabling can then be written
> separately,
> preferable without using the quirk bits.
How's about adding a new attribute such as sw_lpm_disable to the
xhci_hcd struct to indicate that we will disable USB2 HW LPM by
software?
>
> -Mathias


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

2017-06-14 Thread Thang Q. Nguyen
On Tue, Jun 13, 2017 at 8:12 PM, Mathias Nyman
 wrote:
> On 06.06.2017 09:33, Thang Q. Nguyen wrote:
>>
>> On Mon, Jun 5, 2017 at 9:33 PM, Mathias Nyman 
>> wrote:
>>>
>>> On 05.06.2017 15:57, Thang Q. Nguyen wrote:
>>>>
>>>>
>>>> On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
>>>>  wrote:
>>>>>
>>>>>
>>>>> On 20.05.2017 10:24, 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.
>>>>>>
>>>>>
>>>>>Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the
>>>>> host
>>>>> doesn't support Hardware LPM Capability, (HLC)?
>>>>>
>>>>> This should prevent all those extra steps getting here just to do
>>>>> nothing.
>>>>
>>>>
>>>> No, HLC = 0 means the host doesn't support Hardware LPM.
>>>> The problem here is the host support Hardware LPM but there is a bug
>>>> in host controller that make the LPM fail to work.
>>>>
>>>
>>> So the host support hw LPM, and has its HLC capability bit set,
>>> but in the end it just doesn't work at all, and should be prevented.
>>>
>>>> When debugging the host controller, we detect there are some holes in
>>>> the current usb specifications which can can result in inter-operating
>>>> problems between USB Host Controller and USB PHY. To be more specific,
>>>> the specs have not clarified the resume recovery timing after the port
>>>> has just waken up from L1. This can lead to different interpretations
>>>> of the specs by Host Controller and PHY. What happened in our case is
>>>> that a Host controller cannot work with a PHY right after resuming
>>>> from L1 because these two Vendors have different views of the specs
>>>> regarding LPM timing after L1. These views are contradictory and
>>>> cannot work together.
>>>>
>>>> If Host Controller and PHY are from the same vendor, they might have
>>>> some "internal handshake mechanisms" to avoid these holes of the USB
>>>> specs. However, these mechanisms are not standardized in USB specs;
>>>> and not all vendors follow these mechanisms. In fact, we have observed
>>>> this kind of "internal handshake mechanism" in HOST Controller and PHY
>>>> from SYNOPSYS DWC. So, we can say that if users use Host Controller
>>>> and PHY from different Vendors, the inteopering problems after waking
>>>> up from L1 are more likely to occur.
>>>
>>>
>>>
>>> Can you explain the reason why you prefer preventing hw lpm inside the
>>> xhci_set_usb2_hardware_lpm() function instead of preventing hw lpm usage
>>> all together for this platform -i.e. by not setting xhci->hw_lpm_support
>>
>> The reason I don't change in the xhci_add_in_port() function inside
>> xhci-mem.c is because of the description for xhci->hw_lpm_support in
>> the drivers/usb/host/xhci.h header file: support xHCI 1.0 spec USB2
>> hardware LPM. Per my understanding, this attribute is used to indicate
>> if the host supports HW LPM and this can be checked via HLC.
>> My intension is to support an option for user to disable the HW LPM
>> because of some reasons (in my case because HW LPM is broken).
>
>
> I think we should keep supporting new options separate from workarounds
> for broken HW.
So, I will continue to use usb2-lpm-disable to let kernel know that we
want to disable USB2 HW LPM.
>
>>>
>>>
>>> Again, something like:
>>> if (temp & XHCI_HLC && !(xhci->quirks & XHCI_HW_LPM_BROKEN))
>>>  xhci->hw_lpm_support = 1;
>>
>> This should work too. But the DT/ACPI attribute should change to
>> "usb2-lpm-broken".
>
>
> This would be more clear for future developers and prevent them from
> enabling hw lpm for this host to gain some powersaving.
>
> A new feature allowing optional host hw lpm disabling can then be written
> separately,
> preferable without using the quirk bits.
How's about adding a new attribute such as sw_lpm_disable to the
xhci_hcd struct to indicate that we will disable USB2 HW LPM by
software?
>
> -Mathias


[PATCH v1 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-06-06 Thread Thang Q. Nguyen
For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
configuration"), sysdev points to devices known to the system firmware
or hardware for DMA parameters.
However, the parent of the system firmware/hardware device checking
logic does not work in ACPI boot mode. This patch updates the formulation
to check this case in both DT and ACPI.

Signed-off-by: Tung Nguyen <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
 drivers/usb/host/xhci-plat.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c04144b..e3e342a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -187,7 +187,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
 */
sysdev = >dev;
-   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   if (sysdev->parent && (sysdev->fwnode->type == FWNODE_PDATA) &&
+   (is_of_node(sysdev->parent->fwnode) ||
+   is_acpi_device_node(sysdev->parent->fwnode)))
sysdev = sysdev->parent;
 #ifdef CONFIG_PCI
else if (sysdev->parent && sysdev->parent->parent &&
-- 
1.7.1



[PATCH v1 1/1] usb:xhci: update condition to select bus->sysdev from parent device

2017-06-06 Thread Thang Q. Nguyen
For commit 4c39d4b949d3 ("usb: xhci: use bus->sysdev for DMA
configuration"), sysdev points to devices known to the system firmware
or hardware for DMA parameters.
However, the parent of the system firmware/hardware device checking
logic does not work in ACPI boot mode. This patch updates the formulation
to check this case in both DT and ACPI.

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

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index c04144b..e3e342a 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -187,7 +187,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
 * 3. xhci_plat is grandchild of a pci device (dwc3-pci)
 */
sysdev = >dev;
-   if (sysdev->parent && !sysdev->of_node && sysdev->parent->of_node)
+   if (sysdev->parent && (sysdev->fwnode->type == FWNODE_PDATA) &&
+   (is_of_node(sysdev->parent->fwnode) ||
+   is_acpi_device_node(sysdev->parent->fwnode)))
sysdev = sysdev->parent;
 #ifdef CONFIG_PCI
else if (sysdev->parent && sysdev->parent->parent &&
-- 
1.7.1



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

2017-06-06 Thread Thang Q. Nguyen
On Mon, Jun 5, 2017 at 9:33 PM, Mathias Nyman <mathias.ny...@intel.com> wrote:
> On 05.06.2017 15:57, Thang Q. Nguyen wrote:
>>
>> On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
>> <mathias.ny...@linux.intel.com> wrote:
>>>
>>> On 20.05.2017 10:24, 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.
>>>>
>>>
>>>   Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the
>>> host
>>> doesn't support Hardware LPM Capability, (HLC)?
>>>
>>> This should prevent all those extra steps getting here just to do
>>> nothing.
>>
>> No, HLC = 0 means the host doesn't support Hardware LPM.
>> The problem here is the host support Hardware LPM but there is a bug
>> in host controller that make the LPM fail to work.
>>
>
> So the host support hw LPM, and has its HLC capability bit set,
> but in the end it just doesn't work at all, and should be prevented.
>
>> When debugging the host controller, we detect there are some holes in
>> the current usb specifications which can can result in inter-operating
>> problems between USB Host Controller and USB PHY. To be more specific,
>> the specs have not clarified the resume recovery timing after the port
>> has just waken up from L1. This can lead to different interpretations
>> of the specs by Host Controller and PHY. What happened in our case is
>> that a Host controller cannot work with a PHY right after resuming
>> from L1 because these two Vendors have different views of the specs
>> regarding LPM timing after L1. These views are contradictory and
>> cannot work together.
>>
>> If Host Controller and PHY are from the same vendor, they might have
>> some "internal handshake mechanisms" to avoid these holes of the USB
>> specs. However, these mechanisms are not standardized in USB specs;
>> and not all vendors follow these mechanisms. In fact, we have observed
>> this kind of "internal handshake mechanism" in HOST Controller and PHY
>> from SYNOPSYS DWC. So, we can say that if users use Host Controller
>> and PHY from different Vendors, the inteopering problems after waking
>> up from L1 are more likely to occur.
>
>
> Can you explain the reason why you prefer preventing hw lpm inside the
> xhci_set_usb2_hardware_lpm() function instead of preventing hw lpm usage
> all together for this platform -i.e. by not setting xhci->hw_lpm_support
The reason I don't change in the xhci_add_in_port() function inside
xhci-mem.c is because of the description for xhci->hw_lpm_support in
the drivers/usb/host/xhci.h header file: support xHCI 1.0 spec USB2
hardware LPM. Per my understanding, this attribute is used to indicate
if the host supports HW LPM and this can be checked via HLC.
My intension is to support an option for user to disable the HW LPM
because of some reasons (in my case because HW LPM is broken).
>
>
> Again, something like:
> if (temp & XHCI_HLC && !(xhci->quirks & XHCI_HW_LPM_BROKEN))
> xhci->hw_lpm_support = 1;
This should work too. But the DT/ACPI attribute should change to
"usb2-lpm-broken".
>
>>> The HW LPM can also be disabled (per device) in sysfs if needed.
>>
>> This does not work. When the issue happens, the USB device is fail to
>> probe so no /sys interface created. Messages displayed when issue
>> happen is similar to:
>>
>> [ 2846.677903] usb 1-1: reset high-speed USB device number 2 using
>> xhci-hcd
>> [ 2882.037125] usb usb1-port1: Cannot enable. Maybe the USB cable is bad?
>> or
>> usb usb3-port1: disabled by hub (EMI?), re-enabling...
>> [   57.840237] usb 3-1: USB disconnect, device number 5
>
>
> Ok, the sysfs entry is not useful in this case.
>
> -Mathias
>
>


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

2017-06-06 Thread Thang Q. Nguyen
On Mon, Jun 5, 2017 at 9:33 PM, Mathias Nyman  wrote:
> On 05.06.2017 15:57, Thang Q. Nguyen wrote:
>>
>> On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
>>  wrote:
>>>
>>> On 20.05.2017 10:24, 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.
>>>>
>>>
>>>   Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the
>>> host
>>> doesn't support Hardware LPM Capability, (HLC)?
>>>
>>> This should prevent all those extra steps getting here just to do
>>> nothing.
>>
>> No, HLC = 0 means the host doesn't support Hardware LPM.
>> The problem here is the host support Hardware LPM but there is a bug
>> in host controller that make the LPM fail to work.
>>
>
> So the host support hw LPM, and has its HLC capability bit set,
> but in the end it just doesn't work at all, and should be prevented.
>
>> When debugging the host controller, we detect there are some holes in
>> the current usb specifications which can can result in inter-operating
>> problems between USB Host Controller and USB PHY. To be more specific,
>> the specs have not clarified the resume recovery timing after the port
>> has just waken up from L1. This can lead to different interpretations
>> of the specs by Host Controller and PHY. What happened in our case is
>> that a Host controller cannot work with a PHY right after resuming
>> from L1 because these two Vendors have different views of the specs
>> regarding LPM timing after L1. These views are contradictory and
>> cannot work together.
>>
>> If Host Controller and PHY are from the same vendor, they might have
>> some "internal handshake mechanisms" to avoid these holes of the USB
>> specs. However, these mechanisms are not standardized in USB specs;
>> and not all vendors follow these mechanisms. In fact, we have observed
>> this kind of "internal handshake mechanism" in HOST Controller and PHY
>> from SYNOPSYS DWC. So, we can say that if users use Host Controller
>> and PHY from different Vendors, the inteopering problems after waking
>> up from L1 are more likely to occur.
>
>
> Can you explain the reason why you prefer preventing hw lpm inside the
> xhci_set_usb2_hardware_lpm() function instead of preventing hw lpm usage
> all together for this platform -i.e. by not setting xhci->hw_lpm_support
The reason I don't change in the xhci_add_in_port() function inside
xhci-mem.c is because of the description for xhci->hw_lpm_support in
the drivers/usb/host/xhci.h header file: support xHCI 1.0 spec USB2
hardware LPM. Per my understanding, this attribute is used to indicate
if the host supports HW LPM and this can be checked via HLC.
My intension is to support an option for user to disable the HW LPM
because of some reasons (in my case because HW LPM is broken).
>
>
> Again, something like:
> if (temp & XHCI_HLC && !(xhci->quirks & XHCI_HW_LPM_BROKEN))
> xhci->hw_lpm_support = 1;
This should work too. But the DT/ACPI attribute should change to
"usb2-lpm-broken".
>
>>> The HW LPM can also be disabled (per device) in sysfs if needed.
>>
>> This does not work. When the issue happens, the USB device is fail to
>> probe so no /sys interface created. Messages displayed when issue
>> happen is similar to:
>>
>> [ 2846.677903] usb 1-1: reset high-speed USB device number 2 using
>> xhci-hcd
>> [ 2882.037125] usb usb1-port1: Cannot enable. Maybe the USB cable is bad?
>> or
>> usb usb3-port1: disabled by hub (EMI?), re-enabling...
>> [   57.840237] usb 3-1: USB disconnect, device number 5
>
>
> Ok, the sysfs entry is not useful in this case.
>
> -Mathias
>
>


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

2017-06-05 Thread Thang Q. Nguyen
On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
<mathias.ny...@linux.intel.com> wrote:
> On 20.05.2017 10:24, 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 <tungu...@apm.com>
>> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
>> ---
>> Changes since v1:
>>   - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>>be consistent with other attribute names.
>> ---
>>   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..96f1ac0 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-lpm-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..950eaf0 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-lpm-disable"))
>> +   xhci->quirks |= XHCI_USB2_LPM_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..47d51d4 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 usb2_lpm_disable = 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 USB2 LPM if XHCI 1.0 */
>> +   if ((xhci->quirks & XHCI_USB2_LPM_DISABLE) && (xhci->hci_version
>> == 0x100))
>> +   usb2_lpm_disable = 1;
>> +
>> +   if (enable && !usb2_lpm_disable) {
>
>  Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the host
> doesn't support Hardware LPM Capability, (HLC)?
>
> This should prevent all those extra steps getting here just to do nothing.
No, HLC = 0 means the host doesn't support Hardware LPM.
The problem here is the host support Hardware LPM but there is a bug
in host controller that make the LPM fail to work.

When debugging the host controller, we detect there are some holes in
the current usb specifications which can can result in inter-operating
problems between USB Host Controller and USB PHY. To be more specific,
the specs have not clarified the resume recovery timing after the port
has just waken up from L1. This can lead to different interpretations
of the specs by Host Controller and PHY. What happened in our case is
that a Host controller cannot work with a PHY right after resuming
from L1 because these two Vendors have different views of the specs
regarding LPM timing after L1. These views are contradictory and
cannot work together.

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

2017-06-05 Thread Thang Q. Nguyen
On Mon, Jun 5, 2017 at 6:14 PM, Mathias Nyman
 wrote:
> On 20.05.2017 10:24, 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 
>> ---
>> Changes since v1:
>>   - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
>>be consistent with other attribute names.
>> ---
>>   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..96f1ac0 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-lpm-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..950eaf0 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-lpm-disable"))
>> +   xhci->quirks |= XHCI_USB2_LPM_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..47d51d4 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 usb2_lpm_disable = 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 USB2 LPM if XHCI 1.0 */
>> +   if ((xhci->quirks & XHCI_USB2_LPM_DISABLE) && (xhci->hci_version
>> == 0x100))
>> +   usb2_lpm_disable = 1;
>> +
>> +   if (enable && !usb2_lpm_disable) {
>
>  Wouldn't it be better to just keep  xhci->hw_lpm_support = 0 if the host
> doesn't support Hardware LPM Capability, (HLC)?
>
> This should prevent all those extra steps getting here just to do nothing.
No, HLC = 0 means the host doesn't support Hardware LPM.
The problem here is the host support Hardware LPM but there is a bug
in host controller that make the LPM fail to work.

When debugging the host controller, we detect there are some holes in
the current usb specifications which can can result in inter-operating
problems between USB Host Controller and USB PHY. To be more specific,
the specs have not clarified the resume recovery timing after the port
has just waken up from L1. This can lead to different interpretations
of the specs by Host Controller and PHY. What happened in our case is
that a Host controller cannot work with a PHY right after resuming
from L1 because these two Vendors have different views of the specs
regarding LPM timing after L1. These views are contradictory and
cannot work together.

If Host Controller and PHY are from the same vendor, they might have
some &quo

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

2017-05-20 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 <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
  be consistent with other attribute names.
---
 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..96f1ac0 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-lpm-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..950eaf0 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-lpm-disable"))
+   xhci->quirks |= XHCI_USB2_LPM_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..47d51d4 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 usb2_lpm_disable = 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 USB2 LPM if XHCI 1.0 */
+   if ((xhci->quirks & XHCI_USB2_LPM_DISABLE) && (xhci->hci_version == 
0x100))
+   usb2_lpm_disable = 1;
+
+   if (enable && !usb2_lpm_disable) {
/* 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..cfb9f5d 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_USB2_LPM_DISABLE  (1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



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

2017-05-20 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 
---
Changes since v1:
 - Update DT/ACPI attribute and corresponding codes from HLE to LPM to
  be consistent with other attribute names.
---
 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..96f1ac0 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-lpm-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..950eaf0 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-lpm-disable"))
+   xhci->quirks |= XHCI_USB2_LPM_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..47d51d4 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 usb2_lpm_disable = 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 USB2 LPM if XHCI 1.0 */
+   if ((xhci->quirks & XHCI_USB2_LPM_DISABLE) && (xhci->hci_version == 
0x100))
+   usb2_lpm_disable = 1;
+
+   if (enable && !usb2_lpm_disable) {
/* 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..cfb9f5d 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_USB2_LPM_DISABLE  (1 << 27)
 
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
-- 
1.7.1



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 <r...@kernel.org> 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 <tungu...@apm.com>
>> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
>> ---
>>  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
>>


[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 <tungu...@apm.com>
Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
 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



Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2017-01-09 Thread Thang Q. Nguyen
On Mon, Dec 12, 2016 at 8:00 PM, Mathias Nyman
<mathias.ny...@linux.intel.com> wrote:
> On 12.12.2016 06:00, Thang Q. Nguyen wrote:
>>
>> On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring <r...@kernel.org> wrote:
>>>
>>> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>>>>
>>>> From: Thang Nguyen <tqngu...@apm.com>
>>>>
>>>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>>>> device or host initiated via resume signaling; device-initiated resumes
>>>> can be optionally enabled/disabled by software. This patch adds support
>>>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>>>
>>>> Signed-off-by: Vu Nguyen <vngu...@apm.com>
>>>> Signed-off-by: Thang Nguyen <tqngu...@apm.com>
>>>> ---
>>>>   Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>>>   drivers/usb/host/xhci-plat.c   | 3 +++
>>>>   drivers/usb/host/xhci.c| 5 -
>>>>   drivers/usb/host/xhci.h| 1 +
>>>>   4 files changed, 9 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> index 966885c..9b4cd14 100644
>>>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> @@ -25,6 +25,7 @@ Required properties:
>>>>
>>>>   Optional properties:
>>>> - clocks: reference to a clock
>>>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>>>
>>>
>>> Remote wakeup has been around since USB 1.0 days. Does this need to be
>>> USB2 or XHCI specific?
>>
>> This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
>> optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
>> ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
>
> I think I understand what's going on.
>
> USB:
>   The good old USB2 suspend is called L2. Device enters it after 3ms if
> there is no link activity.
> If a device can remote wakeup (RWE) it's stated in the descriptor. RWE can
> be turned on
> of off using standard SET/CLEAR Fature requests
>
> The LPM L1 USB2 state again is entered with a LPM extended transaction to
> avoid the
> 3ms wait before powersaving. L1 state is exit can be done with a simialr RWE
> as L2 resume.
> The RWE from L1 can turned on/off using a bit in the LPM extended
> transaction.
>
> XHCI:
>
> Specs say that if the device supports RWE we should enable it for LPM L1
> exit as well.
> This is done by setting the RWE (LPM L1) bit in PORTPMSC register. This bit
> only affect LPM L1 remote
> wake. see 4.23.5.1.1.1
>
> The issue might be that xhci driver never check if the device actually
> supports RWE, we always
> set the PORTPMSC RWE  (for LPM L1) bit.
Yes, we should check if device support Remote Wakeup to enable or
disable RWE as noted in cases 1 (page 265) and 2 (page 266) from
4.23.5.1.1.1.
>
> How about checking something like udev->do_remote_wakeup and setting and
> setting the bit
> based on that.
>
> The function that you are changing,  xhci_set_usb2_hardware_lpm() should
> only be used if
> host has Hardware LPM Cabaility bit (HLC) set for that USB2 port in the
> USB 2.0 xHCI Supported Protocol Capability.
> Host that don't supprt LPM won't have that set. See xhci 7.2.2.1.3.2
When hosts support Hardware LPM (HLC), any problem if we add a DT/ACPI
attribute to support disable it (HLE=0)?
>  -Mathias
>
>
>
>
>
>
>


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2017-01-09 Thread Thang Q. Nguyen
On Mon, Dec 12, 2016 at 8:00 PM, Mathias Nyman
 wrote:
> On 12.12.2016 06:00, Thang Q. Nguyen wrote:
>>
>> On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring  wrote:
>>>
>>> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>>>>
>>>> From: Thang Nguyen 
>>>>
>>>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>>>> device or host initiated via resume signaling; device-initiated resumes
>>>> can be optionally enabled/disabled by software. This patch adds support
>>>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>>>
>>>> Signed-off-by: Vu Nguyen 
>>>> Signed-off-by: Thang Nguyen 
>>>> ---
>>>>   Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>>>   drivers/usb/host/xhci-plat.c   | 3 +++
>>>>   drivers/usb/host/xhci.c| 5 -
>>>>   drivers/usb/host/xhci.h| 1 +
>>>>   4 files changed, 9 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> index 966885c..9b4cd14 100644
>>>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> @@ -25,6 +25,7 @@ Required properties:
>>>>
>>>>   Optional properties:
>>>> - clocks: reference to a clock
>>>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>>>
>>>
>>> Remote wakeup has been around since USB 1.0 days. Does this need to be
>>> USB2 or XHCI specific?
>>
>> This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
>> optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
>> ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
>
> I think I understand what's going on.
>
> USB:
>   The good old USB2 suspend is called L2. Device enters it after 3ms if
> there is no link activity.
> If a device can remote wakeup (RWE) it's stated in the descriptor. RWE can
> be turned on
> of off using standard SET/CLEAR Fature requests
>
> The LPM L1 USB2 state again is entered with a LPM extended transaction to
> avoid the
> 3ms wait before powersaving. L1 state is exit can be done with a simialr RWE
> as L2 resume.
> The RWE from L1 can turned on/off using a bit in the LPM extended
> transaction.
>
> XHCI:
>
> Specs say that if the device supports RWE we should enable it for LPM L1
> exit as well.
> This is done by setting the RWE (LPM L1) bit in PORTPMSC register. This bit
> only affect LPM L1 remote
> wake. see 4.23.5.1.1.1
>
> The issue might be that xhci driver never check if the device actually
> supports RWE, we always
> set the PORTPMSC RWE  (for LPM L1) bit.
Yes, we should check if device support Remote Wakeup to enable or
disable RWE as noted in cases 1 (page 265) and 2 (page 266) from
4.23.5.1.1.1.
>
> How about checking something like udev->do_remote_wakeup and setting and
> setting the bit
> based on that.
>
> The function that you are changing,  xhci_set_usb2_hardware_lpm() should
> only be used if
> host has Hardware LPM Cabaility bit (HLC) set for that USB2 port in the
> USB 2.0 xHCI Supported Protocol Capability.
> Host that don't supprt LPM won't have that set. See xhci 7.2.2.1.3.2
When hosts support Hardware LPM (HLC), any problem if we add a DT/ACPI
attribute to support disable it (HLE=0)?
>  -Mathias
>
>
>
>
>
>
>


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-12 Thread Thang Q. Nguyen
Hi,

On Mon, Dec 12, 2016 at 3:37 PM, Felipe Balbi
<felipe.ba...@linux.intel.com> wrote:
>
> Hi,
>
> "Thang Q. Nguyen" <tqngu...@apm.com> writes:
>> On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring <r...@kernel.org> wrote:
>>> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>>>> From: Thang Nguyen <tqngu...@apm.com>
>>>>
>>>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>>>> device or host initiated via resume signaling; device-initiated resumes
>>>> can be optionally enabled/disabled by software. This patch adds support
>>>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>>>
>>>> Signed-off-by: Vu Nguyen <vngu...@apm.com>
>>>> Signed-off-by: Thang Nguyen <tqngu...@apm.com>
>>>> ---
>>>>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>>>  drivers/usb/host/xhci-plat.c   | 3 +++
>>>>  drivers/usb/host/xhci.c| 5 -
>>>>  drivers/usb/host/xhci.h| 1 +
>>>>  4 files changed, 9 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>>>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> index 966885c..9b4cd14 100644
>>>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> @@ -25,6 +25,7 @@ Required properties:
>>>>
>>>>  Optional properties:
>>>>- clocks: reference to a clock
>>>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>>>
>>> Remote wakeup has been around since USB 1.0 days. Does this need to be
>>> USB2 or XHCI specific?
>> This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
>> optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
>> ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
> is there no way of detecting this in runtime?
Current driver always enable remote wakeup when the controller and USB
support this feature. However, per the Errata, software can optionally
enable/disable this.
Some XHCI-1.0-compatible controller does not implement features such
as HIRD, BESL which are optional for XHCI 1.1 will be fail to work
with USB2.0 device that require long time to resume from suspend.
Disabling remote wakeup by software will make this case not happen.
>
> --
> balbi



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-12 Thread Thang Q. Nguyen
Hi,

On Mon, Dec 12, 2016 at 3:37 PM, Felipe Balbi
 wrote:
>
> Hi,
>
> "Thang Q. Nguyen"  writes:
>> On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring  wrote:
>>> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>>>> From: Thang Nguyen 
>>>>
>>>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>>>> device or host initiated via resume signaling; device-initiated resumes
>>>> can be optionally enabled/disabled by software. This patch adds support
>>>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>>>
>>>> Signed-off-by: Vu Nguyen 
>>>> Signed-off-by: Thang Nguyen 
>>>> ---
>>>>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>>>  drivers/usb/host/xhci-plat.c   | 3 +++
>>>>  drivers/usb/host/xhci.c| 5 -
>>>>  drivers/usb/host/xhci.h| 1 +
>>>>  4 files changed, 9 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>>>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> index 966885c..9b4cd14 100644
>>>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>>>> @@ -25,6 +25,7 @@ Required properties:
>>>>
>>>>  Optional properties:
>>>>- clocks: reference to a clock
>>>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>>>
>>> Remote wakeup has been around since USB 1.0 days. Does this need to be
>>> USB2 or XHCI specific?
>> This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
>> optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
>> ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
> is there no way of detecting this in runtime?
Current driver always enable remote wakeup when the controller and USB
support this feature. However, per the Errata, software can optionally
enable/disable this.
Some XHCI-1.0-compatible controller does not implement features such
as HIRD, BESL which are optional for XHCI 1.1 will be fail to work
with USB2.0 device that require long time to resume from suspend.
Disabling remote wakeup by software will make this case not happen.
>
> --
> balbi



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-11 Thread Thang Q. Nguyen
On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring <r...@kernel.org> wrote:
> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>> From: Thang Nguyen <tqngu...@apm.com>
>>
>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>> device or host initiated via resume signaling; device-initiated resumes
>> can be optionally enabled/disabled by software. This patch adds support
>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>
>> Signed-off-by: Vu Nguyen <vngu...@apm.com>
>> Signed-off-by: Thang Nguyen <tqngu...@apm.com>
>> ---
>>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>  drivers/usb/host/xhci-plat.c   | 3 +++
>>  drivers/usb/host/xhci.c| 5 -
>>  drivers/usb/host/xhci.h| 1 +
>>  4 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> index 966885c..9b4cd14 100644
>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> @@ -25,6 +25,7 @@ Required properties:
>>
>>  Optional properties:
>>- clocks: reference to a clock
>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>
> Remote wakeup has been around since USB 1.0 days. Does this need to be
> USB2 or XHCI specific?
This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
>>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>>
>>  Example:



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-11 Thread Thang Q. Nguyen
On Sat, Dec 10, 2016 at 4:36 AM, Rob Herring  wrote:
> On Sun, Dec 04, 2016 at 07:42:01PM +0700, Thang Q. Nguyen wrote:
>> From: Thang Nguyen 
>>
>> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
>> device or host initiated via resume signaling; device-initiated resumes
>> can be optionally enabled/disabled by software. This patch adds support
>> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>>
>> Signed-off-by: Vu Nguyen 
>> Signed-off-by: Thang Nguyen 
>> ---
>>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>>  drivers/usb/host/xhci-plat.c   | 3 +++
>>  drivers/usb/host/xhci.c| 5 -
>>  drivers/usb/host/xhci.h| 1 +
>>  4 files changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
>> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> index 966885c..9b4cd14 100644
>> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
>> @@ -25,6 +25,7 @@ Required properties:
>>
>>  Optional properties:
>>- clocks: reference to a clock
>> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>
> Remote wakeup has been around since USB 1.0 days. Does this need to be
> USB2 or XHCI specific?
This is XHCI specific. Per XHCI specification 1.1, remote wakeup is
optional for XHCI 1.0 and required for XHCI 1.1. This patch provides
ability for software to disable RWE for USB2 in XHCI1.0 controller.
>
>>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>>
>>  Example:



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-05 Thread Thang Q. Nguyen
Hi,
Do you have any feedback on this?

Thanks,
Thang Q. Nguyen

On Sun, Dec 4, 2016 at 7:42 PM, Thang Q. Nguyen <tqngu...@apm.com> wrote:
> From: Thang Nguyen <tqngu...@apm.com>
>
> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
> device or host initiated via resume signaling; device-initiated resumes
> can be optionally enabled/disabled by software. This patch adds support
> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>
> Signed-off-by: Vu Nguyen <vngu...@apm.com>
> Signed-off-by: Thang Nguyen <tqngu...@apm.com>
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>  drivers/usb/host/xhci-plat.c   | 3 +++
>  drivers/usb/host/xhci.c| 5 -
>  drivers/usb/host/xhci.h| 1 +
>  4 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 966885c..9b4cd14 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> @@ -25,6 +25,7 @@ Required properties:
>
>  Optional properties:
>- clocks: reference to a clock
> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>
>  Example:
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index ed56bf9..15c540d 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -220,6 +220,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
> goto disable_clk;
> }
>
> +   if (device_property_read_bool(>dev, "usb2-rwe-disable"))
> +   xhci->quirks |= XHCI_RWE_DISABLE;
> +
> if (device_property_read_bool(>dev, "usb3-lpm-capable"))
> xhci->quirks |= XHCI_LPM_SUPPORT;
>
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 1a4ca02..f804868 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4183,7 +4183,10 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
> }
>
> pm_val &= ~PORT_HIRD_MASK;
> -   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
> PORT_L1DS(udev->slot_id);
> +   if ((xhci->quirks & XHCI_RWE_DISABLE) && (xhci->hci_version 
> <= 0x100))
> +   pm_val |= PORT_HIRD(hird) | PORT_L1DS(udev->slot_id);
> +   else
> +   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
> PORT_L1DS(udev->slot_id);
> writel(pm_val, pm_addr);
> pm_val = readl(pm_addr);
> pm_val |= PORT_HLE;
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index f945380..2b9bc33 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1656,6 +1656,7 @@ struct xhci_hcd {
>  #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
>  #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
>  #define XHCI_MISSING_CAS   (1 << 24)
> +#define XHCI_RWE_DISABLE   (1 << 25)
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> /* There are two roothubs to keep track of bus suspend info for */
> --
> 2.7.4
>



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-05 Thread Thang Q. Nguyen
Hi,
Do you have any feedback on this?

Thanks,
Thang Q. Nguyen

On Sun, Dec 4, 2016 at 7:42 PM, Thang Q. Nguyen  wrote:
> From: Thang Nguyen 
>
> As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
> device or host initiated via resume signaling; device-initiated resumes
> can be optionally enabled/disabled by software. This patch adds support
> to control enabling the USB2 RWE feature via DT/ACPI attribute.
>
> Signed-off-by: Vu Nguyen 
> Signed-off-by: Thang Nguyen 
> ---
>  Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
>  drivers/usb/host/xhci-plat.c   | 3 +++
>  drivers/usb/host/xhci.c| 5 -
>  drivers/usb/host/xhci.h| 1 +
>  4 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
> b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> index 966885c..9b4cd14 100644
> --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
> +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
> @@ -25,6 +25,7 @@ Required properties:
>
>  Optional properties:
>- clocks: reference to a clock
> +  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
>- usb3-lpm-capable: determines if platform is USB3 LPM capable
>
>  Example:
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
> index ed56bf9..15c540d 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -220,6 +220,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
> goto disable_clk;
> }
>
> +   if (device_property_read_bool(>dev, "usb2-rwe-disable"))
> +   xhci->quirks |= XHCI_RWE_DISABLE;
> +
> if (device_property_read_bool(>dev, "usb3-lpm-capable"))
> xhci->quirks |= XHCI_LPM_SUPPORT;
>
> diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
> index 1a4ca02..f804868 100644
> --- a/drivers/usb/host/xhci.c
> +++ b/drivers/usb/host/xhci.c
> @@ -4183,7 +4183,10 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
> }
>
> pm_val &= ~PORT_HIRD_MASK;
> -   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
> PORT_L1DS(udev->slot_id);
> +   if ((xhci->quirks & XHCI_RWE_DISABLE) && (xhci->hci_version 
> <= 0x100))
> +   pm_val |= PORT_HIRD(hird) | PORT_L1DS(udev->slot_id);
> +   else
> +   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
> PORT_L1DS(udev->slot_id);
> writel(pm_val, pm_addr);
> pm_val = readl(pm_addr);
> pm_val |= PORT_HLE;
> diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
> index f945380..2b9bc33 100644
> --- a/drivers/usb/host/xhci.h
> +++ b/drivers/usb/host/xhci.h
> @@ -1656,6 +1656,7 @@ struct xhci_hcd {
>  #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
>  #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
>  #define XHCI_MISSING_CAS   (1 << 24)
> +#define XHCI_RWE_DISABLE   (1 << 25)
> unsigned intnum_active_eps;
> unsigned intlimit_active_eps;
> /* There are two roothubs to keep track of bus suspend info for */
> --
> 2.7.4
>



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-04 Thread Thang Q. Nguyen
From: Thang Nguyen 

As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
device or host initiated via resume signaling; device-initiated resumes
can be optionally enabled/disabled by software. This patch adds support
to control enabling the USB2 RWE feature via DT/ACPI attribute.

Signed-off-by: Vu Nguyen 
Signed-off-by: Thang Nguyen 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
 drivers/usb/host/xhci-plat.c   | 3 +++
 drivers/usb/host/xhci.c| 5 -
 drivers/usb/host/xhci.h| 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..9b4cd14 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -25,6 +25,7 @@ Required properties:
 
 Optional properties:
   - clocks: reference to a clock
+  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
 
 Example:
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..15c540d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -220,6 +220,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}
 
+   if (device_property_read_bool(>dev, "usb2-rwe-disable"))
+   xhci->quirks |= XHCI_RWE_DISABLE;
+
if (device_property_read_bool(>dev, "usb3-lpm-capable"))
xhci->quirks |= XHCI_LPM_SUPPORT;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..f804868 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4183,7 +4183,10 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
}
 
pm_val &= ~PORT_HIRD_MASK;
-   pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
+   if ((xhci->quirks & XHCI_RWE_DISABLE) && (xhci->hci_version <= 
0x100))
+   pm_val |= PORT_HIRD(hird) | PORT_L1DS(udev->slot_id);
+   else
+   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
PORT_L1DS(udev->slot_id);
writel(pm_val, pm_addr);
pm_val = readl(pm_addr);
pm_val |= PORT_HLE;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f945380..2b9bc33 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1656,6 +1656,7 @@ struct xhci_hcd {
 #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
 #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
 #define XHCI_MISSING_CAS   (1 << 24)
+#define XHCI_RWE_DISABLE   (1 << 25)
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
-- 
2.7.4



usb:xhci: support disable usb2 LPM Remote Wakeup

2016-12-04 Thread Thang Q. Nguyen
From: Thang Nguyen 

As per USB 2.0 link power management addendum ECN, table 1-2, page 4,
device or host initiated via resume signaling; device-initiated resumes
can be optionally enabled/disabled by software. This patch adds support
to control enabling the USB2 RWE feature via DT/ACPI attribute.

Signed-off-by: Vu Nguyen 
Signed-off-by: Thang Nguyen 
---
 Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 +
 drivers/usb/host/xhci-plat.c   | 3 +++
 drivers/usb/host/xhci.c| 5 -
 drivers/usb/host/xhci.h| 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt 
b/Documentation/devicetree/bindings/usb/usb-xhci.txt
index 966885c..9b4cd14 100644
--- a/Documentation/devicetree/bindings/usb/usb-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt
@@ -25,6 +25,7 @@ Required properties:
 
 Optional properties:
   - clocks: reference to a clock
+  - usb2-rwe-disable: disable USB2 LPM Remote Wakeup capable
   - usb3-lpm-capable: determines if platform is USB3 LPM capable
 
 Example:
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index ed56bf9..15c540d 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -220,6 +220,9 @@ static int xhci_plat_probe(struct platform_device *pdev)
goto disable_clk;
}
 
+   if (device_property_read_bool(>dev, "usb2-rwe-disable"))
+   xhci->quirks |= XHCI_RWE_DISABLE;
+
if (device_property_read_bool(>dev, "usb3-lpm-capable"))
xhci->quirks |= XHCI_LPM_SUPPORT;
 
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1a4ca02..f804868 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4183,7 +4183,10 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
}
 
pm_val &= ~PORT_HIRD_MASK;
-   pm_val |= PORT_HIRD(hird) | PORT_RWE | PORT_L1DS(udev->slot_id);
+   if ((xhci->quirks & XHCI_RWE_DISABLE) && (xhci->hci_version <= 
0x100))
+   pm_val |= PORT_HIRD(hird) | PORT_L1DS(udev->slot_id);
+   else
+   pm_val |= PORT_HIRD(hird) | PORT_RWE | 
PORT_L1DS(udev->slot_id);
writel(pm_val, pm_addr);
pm_val = readl(pm_addr);
pm_val |= PORT_HLE;
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index f945380..2b9bc33 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1656,6 +1656,7 @@ struct xhci_hcd {
 #define XHCI_SSIC_PORT_UNUSED  (1 << 22)
 #define XHCI_NO_64BIT_SUPPORT  (1 << 23)
 #define XHCI_MISSING_CAS   (1 << 24)
+#define XHCI_RWE_DISABLE   (1 << 25)
unsigned intnum_active_eps;
unsigned intlimit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
-- 
2.7.4



Re: [PATCH v3 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-31 Thread Thang Q. Nguyen
Thanks Grygorii for information.
I checked but do not see dma_init_dev_from_parent is used in
linux-next repository. Can you give me more information for what
branch I can checkout to use it for USB DWC3?

Thanks,
Thang --


Re: [PATCH v3 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-31 Thread Thang Q. Nguyen
Thanks Grygorii for information.
I checked but do not see dma_init_dev_from_parent is used in
linux-next repository. Can you give me more information for what
branch I can checkout to use it for USB DWC3?

Thanks,
Thang --


Re: [PATCH v3 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-31 Thread Thang Q. Nguyen
Hi Balbi,
If CONFIG_DMA_CMA=y, dma mask is set properly. The issue just happen
when CONFIG_DMA_CMA is not set. In this case, dma mask is not set and
we need this code to check if dma mask should be manually set to 32 or
64.


Thang

On Wed, Mar 30, 2016 at 8:09 PM, Felipe Balbi
<felipe.ba...@linux.intel.com> wrote:
>
> Hi,
>
> "Thang Q. Nguyen" <tqngu...@apm.com> writes:
>> From: "Thang Q. Nguyen" <tqngu...@apm.com>
>>
>> Add 64-bit DMA operation support to the USB DWC3 driver.
>> First attempt to set the coherent DMA mask for 64-bit DMA.
>> If that failed, attempt again with 32-bit DMA.
>>
>> Changes from v2:
>>   - None.
>>
>> Changes from v1:
>>   - Remove WARN_ON if dma_mask is NULL
>
> these changes lines should be between the tearline (---) and diffstat
> below.
>
>> Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
>> ---
>>  drivers/usb/dwc3/core.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index de5e01f..2479c24 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
>>   dwc->mem = mem;
>>   dwc->dev = dev;
>>
>> + /* Try to set 64-bit DMA first */
>> + if (!pdev->dev.dma_mask)
>> + /* Platform did not initialize dma_mask */
>> + ret = dma_coerce_mask_and_coherent(>dev,
>> +DMA_BIT_MASK(64));
>> + else
>> + ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
>> +
>> + /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
>> + if (ret) {
>> + ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
>> + if (ret)
>> +     return ret;
>> + }
>
> Also, why is it so that you need this now ? glue layers are copying dma
> mask from parent device and that should be set properly. This really
> shouldn't be necessary in dwc3-core; it would mean that glue layer
> didn't set this device up properly.
>
> --
> balbi



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


Re: [PATCH v3 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-31 Thread Thang Q. Nguyen
Hi Balbi,
If CONFIG_DMA_CMA=y, dma mask is set properly. The issue just happen
when CONFIG_DMA_CMA is not set. In this case, dma mask is not set and
we need this code to check if dma mask should be manually set to 32 or
64.


Thang

On Wed, Mar 30, 2016 at 8:09 PM, Felipe Balbi
 wrote:
>
> Hi,
>
> "Thang Q. Nguyen"  writes:
>> From: "Thang Q. Nguyen" 
>>
>> Add 64-bit DMA operation support to the USB DWC3 driver.
>> First attempt to set the coherent DMA mask for 64-bit DMA.
>> If that failed, attempt again with 32-bit DMA.
>>
>> Changes from v2:
>>   - None.
>>
>> Changes from v1:
>>   - Remove WARN_ON if dma_mask is NULL
>
> these changes lines should be between the tearline (---) and diffstat
> below.
>
>> Signed-off-by: Thang Q. Nguyen 
>> ---
>>  drivers/usb/dwc3/core.c | 15 +++
>>  1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
>> index de5e01f..2479c24 100644
>> --- a/drivers/usb/dwc3/core.c
>> +++ b/drivers/usb/dwc3/core.c
>> @@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
>>   dwc->mem = mem;
>>   dwc->dev = dev;
>>
>> + /* Try to set 64-bit DMA first */
>> + if (!pdev->dev.dma_mask)
>> + /* Platform did not initialize dma_mask */
>> + ret = dma_coerce_mask_and_coherent(>dev,
>> +DMA_BIT_MASK(64));
>> + else
>> + ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
>> +
>> + /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
>> + if (ret) {
>> + ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
>> + if (ret)
>> + return ret;
>> +     }
>
> Also, why is it so that you need this now ? glue layers are copying dma
> mask from parent device and that should be set properly. This really
> shouldn't be necessary in dwc3-core; it would mean that glue layer
> didn't set this device up properly.
>
> --
> balbi



-- 

Thang Q. Nguyen| Staff SW Eng.

C: +849.7684.7606 | O: +848.3770.0640

F: +848.3770.0641  | tqngu...@apm.com


[PATCH v3 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" <tqngu...@apm.com>

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Changes from v2:
- None.

Changes from v1:
- Remove WARN_ON if dma_mask is NULL

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;
 
+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
-- 
2.2.0



[PATCH v3 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" 

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Changes from v2:
- None.

Changes from v1:
- Remove WARN_ON if dma_mask is NULL

Signed-off-by: Thang Q. Nguyen 
---
 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;
 
+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
-- 
2.2.0



[PATCH v3 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" <tqngu...@apm.com>

The xhci-hcd child node needs to inherit archdata attribute to use
dma_ops functions and attributes. This patch enables the USB DWC3
driver to pass archdata attributes to its xhci-hcd child node.

Changes from v2:
- None

Changes from v1:
- None

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;
 
dwc->xhci = xhci;
 
-- 
2.2.0



[PATCH v3 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" 

The xhci-hcd child node needs to inherit archdata attribute to use
dma_ops functions and attributes. This patch enables the USB DWC3
driver to pass archdata attributes to its xhci-hcd child node.

Changes from v2:
- None

Changes from v1:
- None

Signed-off-by: Thang Q. Nguyen 
---

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;
 
dwc->xhci = xhci;
 
-- 
2.2.0



[PATCH v3 0/2] usb:dwc3: Enable USB DWC3 support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" <tqngu...@apm.com>

When CONFIG_DMA_CMA is not set, the coherent mask is not set.
These patches enable the USB DWC3 driver to set the coherent mask
correctly by first set coherent DMA mask to 64-bit. If this
failed, attempt again with 32-bit.
In addition, pass the archdata to the xhci-hcd child so that
xhci-hcd can configure DMA operations correctly.

Thang Q. Nguyen (2):
  usb:dwc3: Enable support for 64-bit system
  usb:dwc3: pass arch data to xhci-hcd child

 drivers/usb/dwc3/core.c | 15 +++
 drivers/usb/dwc3/host.c |  1 +
 2 files changed, 16 insertions(+)

-- 
2.2.0



[PATCH v3 0/2] usb:dwc3: Enable USB DWC3 support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
From: "Thang Q. Nguyen" 

When CONFIG_DMA_CMA is not set, the coherent mask is not set.
These patches enable the USB DWC3 driver to set the coherent mask
correctly by first set coherent DMA mask to 64-bit. If this
failed, attempt again with 32-bit.
In addition, pass the archdata to the xhci-hcd child so that
xhci-hcd can configure DMA operations correctly.

Thang Q. Nguyen (2):
  usb:dwc3: Enable support for 64-bit system
  usb:dwc3: pass arch data to xhci-hcd child

 drivers/usb/dwc3/core.c | 15 +++
 drivers/usb/dwc3/host.c |  1 +
 2 files changed, 16 insertions(+)

-- 
2.2.0



RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
Thanks Felipe for your feedback.
I will re-generate patches and resend.

Regards,
Thang Q. Nguyen -
-Original Message-
From: Felipe Balbi [mailto:felipe.ba...@linux.intel.com]
Sent: Thursday, March 10, 2016 3:15 PM
To: Thang Q. Nguyen; Thang Q. Nguyen; Felipe Balbi; Greg Kroah-Hartman;
linux-...@vger.kernel.org; linux-o...@vger.kernel.org;
linux-kernel@vger.kernel.org; linux-...@lists.infradead.org
Cc: Phong Vo; Loc Ho; patches
Subject: RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system


Hi,

"Thang Q. Nguyen" <tqngu...@apm.com> writes:
> [ text/plain ]
> Hi,
> I would like to ask if I need to update anything else for this change?

seems like I don't have original patch in my inbox. Please resend.

-- 
balbi


RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-10 Thread Thang Q. Nguyen
Thanks Felipe for your feedback.
I will re-generate patches and resend.

Regards,
Thang Q. Nguyen -
-Original Message-
From: Felipe Balbi [mailto:felipe.ba...@linux.intel.com]
Sent: Thursday, March 10, 2016 3:15 PM
To: Thang Q. Nguyen; Thang Q. Nguyen; Felipe Balbi; Greg Kroah-Hartman;
linux-...@vger.kernel.org; linux-o...@vger.kernel.org;
linux-kernel@vger.kernel.org; linux-...@lists.infradead.org
Cc: Phong Vo; Loc Ho; patches
Subject: RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system


Hi,

"Thang Q. Nguyen"  writes:
> [ text/plain ]
> Hi,
> I would like to ask if I need to update anything else for this change?

seems like I don't have original patch in my inbox. Please resend.

-- 
balbi


RE: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-09 Thread Thang Q. Nguyen
Hi,
I would like to ask if I need to update anything else for this change?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

The xhci-hcd child node needs to inherit archdata attribute to use dma_ops
functions and attributes. This patch enables the USB DWC3 driver to pass
archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index
c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;

dwc->xhci = xhci;

--
2.2.0


RE: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-03-09 Thread Thang Q. Nguyen
Hi,
I would like to ask if I need to update anything else for this change?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

The xhci-hcd child node needs to inherit archdata attribute to use dma_ops
functions and attributes. This patch enables the USB DWC3 driver to pass
archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index
c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;

dwc->xhci = xhci;

--
2.2.0


RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-09 Thread Thang Q. Nguyen
Hi,
I would like to ask if I need to update anything else for this change?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;

+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask
*/
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
--
2.2.0


RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-03-09 Thread Thang Q. Nguyen
Hi,
I would like to ask if I need to update anything else for this change?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;

+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask
*/
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
--
2.2.0


RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-02-16 Thread Thang Q. Nguyen
Hi,
Do you have any more feedback on this patch?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;

+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask
*/
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
--
2.2.0


RE: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-02-16 Thread Thang Q. Nguyen
Hi,
Do you have any more feedback on this patch?

Thanks,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index
de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;

+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask
*/
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev,
DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
--
2.2.0


RE: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-02-16 Thread Thang Q. Nguyen
Hi,
Do you have any feedback on this change?

Regards,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

The xhci-hcd child node needs to inherit archdata attribute to use dma_ops
functions and attributes. This patch enables the USB DWC3 driver to pass
archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index
c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;

dwc->xhci = xhci;

--
2.2.0


RE: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-02-16 Thread Thang Q. Nguyen
Hi,
Do you have any feedback on this change?

Regards,
Thang Q. Nguyen -
-Original Message-
From: Thang Q. Nguyen [mailto:tqngu...@apm.com]
Sent: Monday, January 25, 2016 9:26 PM
To: Felipe Balbi; Greg Kroah-Hartman; linux-...@vger.kernel.org;
linux-o...@vger.kernel.org; linux-kernel@vger.kernel.org;
linux-...@lists.infradead.org
Cc: Thang Nguyen; Phong Vo; Loc Ho; patc...@apm.com
Subject: [PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

The xhci-hcd child node needs to inherit archdata attribute to use dma_ops
functions and attributes. This patch enables the USB DWC3 driver to pass
archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c index
c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;

dwc->xhci = xhci;

--
2.2.0


[PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-01-25 Thread Thang Q. Nguyen
Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;
 
+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
-- 
2.2.0



[PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-01-25 Thread Thang Q. Nguyen
The xhci-hcd child node needs to inherit archdata attribute to use
dma_ops functions and attributes. This patch enables the USB DWC3
driver to pass archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen 
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;
 
dwc->xhci = xhci;
 
-- 
2.2.0



[PATCH v2 1/2] usb:dwc3: Enable support for 64-bit system

2016-01-25 Thread Thang Q. Nguyen
Add 64-bit DMA operation support to the USB DWC3 driver.
First attempt to set the coherent DMA mask for 64-bit DMA.
If that failed, attempt again with 32-bit DMA.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- Remove WARN_ON if dma_mask is NULL

 drivers/usb/dwc3/core.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index de5e01f..2479c24 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -831,6 +831,21 @@ static int dwc3_probe(struct platform_device *pdev)
dwc->mem = mem;
dwc->dev = dev;
 
+   /* Try to set 64-bit DMA first */
+   if (!pdev->dev.dma_mask)
+   /* Platform did not initialize dma_mask */
+   ret = dma_coerce_mask_and_coherent(>dev,
+  DMA_BIT_MASK(64));
+   else
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(64));
+
+   /* If seting 64-bit DMA mask fails, fall back to 32-bit DMA mask */
+   if (ret) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(32));
+   if (ret)
+   return ret;
+   }
+
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (!res) {
dev_err(dev, "missing IRQ\n");
-- 
2.2.0



[PATCH v2 2/2] usb:dwc3: pass arch data to xhci-hcd child

2016-01-25 Thread Thang Q. Nguyen
The xhci-hcd child node needs to inherit archdata attribute to use
dma_ops functions and attributes. This patch enables the USB DWC3
driver to pass archdata attributes to its xhci-hcd child node.

Signed-off-by: Thang Q. Nguyen <tqngu...@apm.com>
---
Changes from v1:
- None

 drivers/usb/dwc3/host.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/dwc3/host.c b/drivers/usb/dwc3/host.c
index c679f63..661fbae 100644
--- a/drivers/usb/dwc3/host.c
+++ b/drivers/usb/dwc3/host.c
@@ -37,6 +37,7 @@ int dwc3_host_init(struct dwc3 *dwc)
xhci->dev.parent= dwc->dev;
xhci->dev.dma_mask  = dwc->dev->dma_mask;
xhci->dev.dma_parms = dwc->dev->dma_parms;
+   xhci->dev.archdata  = dwc->dev->archdata;
 
dwc->xhci = xhci;
 
-- 
2.2.0