diff mbox series

usb: host: xhci-plat: add XHCI_MISSING_CAS quirk

Message ID 20200219173727.9882-1-martin.kepplinger@puri.sm (mailing list archive)
State New, archived
Headers show
Series usb: host: xhci-plat: add XHCI_MISSING_CAS quirk | expand

Commit Message

Martin Kepplinger Feb. 19, 2020, 5:37 p.m. UTC
From: Li Jun <jun.li@nxp.com>

i.MX8MQ USB3 host needs XHCI_MISSING_CAS quirk to warm reset the port to
enum the USB3 device plugged in while system sleep, as the port state is
stuck in polling mode after resume.

Signed-off-by: Li Jun <jun.li@nxp.com>
Acked-by: Peter Chen <peter.chen@nxp.com>
---

Hi,

Because resume from S3 suspend is broken for me on imx8mq, I stumbled
upon this patch in NXP's linux tree. (Please note that I'm not the
author and I've not yet put my SoB tag under it). This is just a
question:

This patch (and the docs) clearly is missing in mainline Linux because
the imx8mq devicetree description includes it (which does nothing now).

I've tested this and this particular addition doesn't fix my problem:

[   84.257538] imx8mq-usb-phy 381f0040.usb-phy: bus resume
[   84.263195] imx8mq-usb-phy 382f0040.usb-phy: bus resume
[   84.268898] dwc3 38100000.usb: driver resume

during resume from S3 suspend, here it still hangs.

What else could be missing here? I'm using mainline Linux only of course.

thanks,

                            martin



 drivers/usb/host/xhci-plat.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jun Li Feb. 20, 2020, 6:31 a.m. UTC | #1
> -----Original Message-----
> From: Martin Kepplinger <martin.kepplinger@puri.sm>
> Sent: 2020年2月20日 1:37
> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
> mathias.nyman@intel.com
> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; Anson Huang
> <anson.huang@nxp.com>; shawnguo@kernel.org; kernel@pengutronix.de
> Subject: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
> 
> From: Li Jun <jun.li@nxp.com>
> 
> i.MX8MQ USB3 host needs XHCI_MISSING_CAS quirk to warm reset the port to enum the
> USB3 device plugged in while system sleep, as the port state is stuck in polling
> mode after resume.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> Acked-by: Peter Chen <peter.chen@nxp.com>
> ---
> 
> Hi,
> 
> Because resume from S3 suspend is broken for me on imx8mq, I stumbled upon this
> patch in NXP's linux tree. (Please note that I'm not the author and I've not yet
> put my SoB tag under it). This is just a
> question:
> 
> This patch (and the docs) clearly is missing in mainline Linux because the imx8mq
> devicetree description includes it (which does nothing now).
> 
> I've tested this and this particular addition doesn't fix my problem:
> 
> [   84.257538] imx8mq-usb-phy 381f0040.usb-phy: bus resume
> [   84.263195] imx8mq-usb-phy 382f0040.usb-phy: bus resume
> [   84.268898] dwc3 38100000.usb: driver resume
> 
> during resume from S3 suspend, here it still hangs.

Is your problem a system hang? If yes, this may another issue,
where the hang happens? dwc3_resume_common()?

The question patch is to give a warm reset for connected USB
device if the link state is not connect/CAS after system resume,
otherwise host will wait 2s for device appear:

[   44.834831] usb 2-1: Waited 2000ms for CONNECT
...
[   45.055718] PM: resume devices took 3.132 seconds

I will post this patch and doc(to be updated) to upstream later.

Li Jun
> 
> What else could be missing here? I'm using mainline Linux only of course.
> 
> thanks,
> 
>                             martin
> 
> 
> 
>  drivers/usb/host/xhci-plat.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index
> d90cd5ec09cf..4655016eaf45 100644
> --- a/drivers/usb/host/xhci-plat.c
> +++ b/drivers/usb/host/xhci-plat.c
> @@ -291,6 +291,10 @@ static int xhci_plat_probe(struct platform_device *pdev)
> 
>  		device_property_read_u32(tmpdev, "imod-interval-ns",
>  					 &xhci->imod_interval);
> +
> +		if (device_property_read_bool(tmpdev,
> +					      "usb3-resume-missing-cas"))
> +			xhci->quirks |= XHCI_MISSING_CAS;
>  	}
> 
>  	hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);
> --
> 2.20.1
Martin Kepplinger Feb. 20, 2020, 11:43 a.m. UTC | #2
On 20.02.20 07:31, Jun Li wrote:
>> -----Original Message-----
>> From: Martin Kepplinger <martin.kepplinger@puri.sm>
>> Sent: 2020年2月20日 1:37
>> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
>> mathias.nyman@intel.com
>> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; Anson Huang
>> <anson.huang@nxp.com>; shawnguo@kernel.org; kernel@pengutronix.de
>> Subject: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
>>
>> From: Li Jun <jun.li@nxp.com>
>>
>> i.MX8MQ USB3 host needs XHCI_MISSING_CAS quirk to warm reset the port to enum the
>> USB3 device plugged in while system sleep, as the port state is stuck in polling
>> mode after resume.
>>
>> Signed-off-by: Li Jun <jun.li@nxp.com>
>> Acked-by: Peter Chen <peter.chen@nxp.com>
>> ---
>>
>> Hi,
>>
>> Because resume from S3 suspend is broken for me on imx8mq, I stumbled upon this
>> patch in NXP's linux tree. (Please note that I'm not the author and I've not yet
>> put my SoB tag under it). This is just a
>> question:
>>
>> This patch (and the docs) clearly is missing in mainline Linux because the imx8mq
>> devicetree description includes it (which does nothing now).
>>
>> I've tested this and this particular addition doesn't fix my problem:
>>
>> [   84.257538] imx8mq-usb-phy 381f0040.usb-phy: bus resume
>> [   84.263195] imx8mq-usb-phy 382f0040.usb-phy: bus resume
>> [   84.268898] dwc3 38100000.usb: driver resume
>>
>> during resume from S3 suspend, here it still hangs.
> 
> Is your problem a system hang? If yes, this may another issue,
> where the hang happens? dwc3_resume_common()?

exactly! I followed to the point it hangs once again and it's

dwc3_core_init() called from dwc3_resume_common()'s "OTG" case.

Specifically, dwc3_writel() is what I don't get past:
https://elixir.bootlin.com/linux/v5.6-rc2/source/drivers/usb/dwc3/core.c#L934

do you have an idea why this writel() hangs?

> 
> The question patch is to give a warm reset for connected USB
> device if the link state is not connect/CAS after system resume,
> otherwise host will wait 2s for device appear:
> 
> [   44.834831] usb 2-1: Waited 2000ms for CONNECT
> ...
> [   45.055718] PM: resume devices took 3.132 seconds
> 
> I will post this patch and doc(to be updated) to upstream later.
> 

ok, good, thanks,

                                 martin
Jun Li Feb. 20, 2020, 3:37 p.m. UTC | #3
> -----Original Message-----
> From: Martin Kepplinger <martin.kepplinger@puri.sm>
> Sent: 2020年2月20日 19:44
> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
> mathias.nyman@intel.com
> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; Anson Huang
> <anson.huang@nxp.com>; shawnguo@kernel.org; kernel@pengutronix.de
> Subject: Re: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
> 
> On 20.02.20 07:31, Jun Li wrote:
> >> -----Original Message-----
> >> From: Martin Kepplinger <martin.kepplinger@puri.sm>
> >> Sent: 2020年2月20日 1:37
> >> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
> >> mathias.nyman@intel.com
> >> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
> >> Anson Huang <anson.huang@nxp.com>; shawnguo@kernel.org;
> >> kernel@pengutronix.de
> >> Subject: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
> >>
> >> From: Li Jun <jun.li@nxp.com>
> >>
> >> i.MX8MQ USB3 host needs XHCI_MISSING_CAS quirk to warm reset the port
> >> to enum the
> >> USB3 device plugged in while system sleep, as the port state is stuck
> >> in polling mode after resume.
> >>
> >> Signed-off-by: Li Jun <jun.li@nxp.com>
> >> Acked-by: Peter Chen <peter.chen@nxp.com>
> >> ---
> >>
> >> Hi,
> >>
> >> Because resume from S3 suspend is broken for me on imx8mq, I stumbled
> >> upon this patch in NXP's linux tree. (Please note that I'm not the
> >> author and I've not yet put my SoB tag under it). This is just a
> >> question:
> >>
> >> This patch (and the docs) clearly is missing in mainline Linux
> >> because the imx8mq devicetree description includes it (which does nothing now).
> >>
> >> I've tested this and this particular addition doesn't fix my problem:
> >>
> >> [   84.257538] imx8mq-usb-phy 381f0040.usb-phy: bus resume
> >> [   84.263195] imx8mq-usb-phy 382f0040.usb-phy: bus resume
> >> [   84.268898] dwc3 38100000.usb: driver resume
> >>
> >> during resume from S3 suspend, here it still hangs.
> >
> > Is your problem a system hang? If yes, this may another issue, where
> > the hang happens? dwc3_resume_common()?
> 
> exactly! I followed to the point it hangs once again and it's
> 
> dwc3_core_init() called from dwc3_resume_common()'s "OTG" case.
> 
> Specifically, dwc3_writel() is what I don't get past:
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootl
> in.com%2Flinux%2Fv5.6-rc2%2Fsource%2Fdrivers%2Fusb%2Fdwc3%2Fcore.c%23L934&amp;
> data=02%7C01%7Cjun.li%40nxp.com%7C130cd29875c44792d1a908d7b5fa2516%7C686ea1d3b
> c2b4c6fa92cd99c5c301635%7C0%7C0%7C637177958284696041&amp;sdata=mqh9MH6ESLVxKvW
> vvMq4vwt2dcTuvNopgGVdXEbbMwk%3D&amp;reserved=0

So while dwc3 resume, the first register access cause hang.
Looks like some required clocks or power domain of USB0 is not on.
 
> 
> do you have an idea why this writel() hangs?

I never encounter such hang on my iMX8MQ EVK board
using upstream kernel(5.x) + changes of enable USB0 port,
but I didn't try latest 5.6 kernel.
I will enable the first port based on Linux-next to give a
try on my NXP iMX8MQ EVK board, do you think I can reproduce
your problem?

Li Jun
> 
> >
> > The question patch is to give a warm reset for connected USB device if
> > the link state is not connect/CAS after system resume, otherwise host
> > will wait 2s for device appear:
> >
> > [   44.834831] usb 2-1: Waited 2000ms for CONNECT
> > ...
> > [   45.055718] PM: resume devices took 3.132 seconds
> >
> > I will post this patch and doc(to be updated) to upstream later.
> >
> 
> ok, good, thanks,
> 
>                                  martin
Martin Kepplinger Feb. 21, 2020, 8:16 a.m. UTC | #4
On 20.02.20 16:37, Jun Li wrote:
> 
> 
>> -----Original Message-----
>> From: Martin Kepplinger <martin.kepplinger@puri.sm>
>> Sent: 2020年2月20日 19:44
>> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
>> mathias.nyman@intel.com
>> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>; Anson Huang
>> <anson.huang@nxp.com>; shawnguo@kernel.org; kernel@pengutronix.de
>> Subject: Re: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
>>
>> On 20.02.20 07:31, Jun Li wrote:
>>>> -----Original Message-----
>>>> From: Martin Kepplinger <martin.kepplinger@puri.sm>
>>>> Sent: 2020年2月20日 1:37
>>>> To: Jun Li <jun.li@nxp.com>; Peter Chen <peter.chen@nxp.com>;
>>>> mathias.nyman@intel.com
>>>> Cc: linux-usb@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>;
>>>> Anson Huang <anson.huang@nxp.com>; shawnguo@kernel.org;
>>>> kernel@pengutronix.de
>>>> Subject: [PATCH] usb: host: xhci-plat: add XHCI_MISSING_CAS quirk
>>>>
>>>> From: Li Jun <jun.li@nxp.com>
>>>>
>>>> i.MX8MQ USB3 host needs XHCI_MISSING_CAS quirk to warm reset the port
>>>> to enum the
>>>> USB3 device plugged in while system sleep, as the port state is stuck
>>>> in polling mode after resume.
>>>>
>>>> Signed-off-by: Li Jun <jun.li@nxp.com>
>>>> Acked-by: Peter Chen <peter.chen@nxp.com>
>>>> ---
>>>>
>>>> Hi,
>>>>
>>>> Because resume from S3 suspend is broken for me on imx8mq, I stumbled
>>>> upon this patch in NXP's linux tree. (Please note that I'm not the
>>>> author and I've not yet put my SoB tag under it). This is just a
>>>> question:
>>>>
>>>> This patch (and the docs) clearly is missing in mainline Linux
>>>> because the imx8mq devicetree description includes it (which does nothing now).
>>>>
>>>> I've tested this and this particular addition doesn't fix my problem:
>>>>
>>>> [   84.257538] imx8mq-usb-phy 381f0040.usb-phy: bus resume
>>>> [   84.263195] imx8mq-usb-phy 382f0040.usb-phy: bus resume
>>>> [   84.268898] dwc3 38100000.usb: driver resume
>>>>
>>>> during resume from S3 suspend, here it still hangs.
>>>
>>> Is your problem a system hang? If yes, this may another issue, where
>>> the hang happens? dwc3_resume_common()?
>>
>> exactly! I followed to the point it hangs once again and it's
>>
>> dwc3_core_init() called from dwc3_resume_common()'s "OTG" case.
>>
>> Specifically, dwc3_writel() is what I don't get past:
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootl
>> in.com%2Flinux%2Fv5.6-rc2%2Fsource%2Fdrivers%2Fusb%2Fdwc3%2Fcore.c%23L934&amp;
>> data=02%7C01%7Cjun.li%40nxp.com%7C130cd29875c44792d1a908d7b5fa2516%7C686ea1d3b
>> c2b4c6fa92cd99c5c301635%7C0%7C0%7C637177958284696041&amp;sdata=mqh9MH6ESLVxKvW
>> vvMq4vwt2dcTuvNopgGVdXEbbMwk%3D&amp;reserved=0
> 
> So while dwc3 resume, the first register access cause hang.
> Looks like some required clocks or power domain of USB0 is not on.

which would these be in imx8mq.dtsi ?

>  
>>
>> do you have an idea why this writel() hangs?
> 
> I never encounter such hang on my iMX8MQ EVK board
> using upstream kernel(5.x) + changes of enable USB0 port,
> but I didn't try latest 5.6 kernel.
> I will enable the first port based on Linux-next to give a
> try on my NXP iMX8MQ EVK board, do you think I can reproduce
> your problem?
> 
> Li Jun

Hi Li, thanks for taking a look. I would think that you can reproduce
that, yes. I'm running v5.6-rc2 with no changes to usb or any relevant
changes to clk (I think), but in case you're curious, this is the whole
tree:
https://source.puri.sm/Librem5/linux-next/tree/imx8-linux-next-librem5

What "changes of enable USB0 port" do you mean?

thanks,

                       martin

>>
>>>
>>> The question patch is to give a warm reset for connected USB device if
>>> the link state is not connect/CAS after system resume, otherwise host
>>> will wait 2s for device appear:
>>>
>>> [   44.834831] usb 2-1: Waited 2000ms for CONNECT
>>> ...
>>> [   45.055718] PM: resume devices took 3.132 seconds
>>>
>>> I will post this patch and doc(to be updated) to upstream later.
>>>
>>
>> ok, good, thanks,
>>
>>                                  martin
>
diff mbox series

Patch

diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c
index d90cd5ec09cf..4655016eaf45 100644
--- a/drivers/usb/host/xhci-plat.c
+++ b/drivers/usb/host/xhci-plat.c
@@ -291,6 +291,10 @@  static int xhci_plat_probe(struct platform_device *pdev)
 
 		device_property_read_u32(tmpdev, "imod-interval-ns",
 					 &xhci->imod_interval);
+
+		if (device_property_read_bool(tmpdev,
+					      "usb3-resume-missing-cas"))
+			xhci->quirks |= XHCI_MISSING_CAS;
 	}
 
 	hcd->usb_phy = devm_usb_get_phy_by_phandle(sysdev, "usb-phy", 0);