diff mbox series

[v10,6/6] usb: dwc3: qcom: Enable the interrupts during probe

Message ID 1642398248-21753-7-git-send-email-quic_c_sanm@quicinc.com (mailing list archive)
State Superseded
Headers show
Series USB DWC3 host wake up support from system suspend | expand

Commit Message

Sandeep Maheswaram Jan. 17, 2022, 5:44 a.m. UTC
Enable the interrupts during probe and remove the disable interrupts
function.

Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
---
 drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

Comments

Steev Klimaszewski Jan. 18, 2022, 6:12 a.m. UTC | #1
On 1/16/22 11:44 PM, Sandeep Maheswaram wrote:
> Enable the interrupts during probe and remove the disable interrupts
> function.
>
> Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
> ---
>   drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
>   1 file changed, 4 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> index 54dc3d3..7c5e636 100644
> --- a/drivers/usb/dwc3/dwc3-qcom.c
> +++ b/drivers/usb/dwc3/dwc3-qcom.c
> @@ -306,25 +306,7 @@ static void dwc3_qcom_enable_wakeup_irq(int irq)
>   	enable_irq_wake(irq);
>   }
>   
> -static void dwc3_qcom_disable_wakeup_irq(int irq)
> -{
> -	if (!irq)
> -		return;
> -
> -	disable_irq_wake(irq);
> -	disable_irq_nosync(irq);
> -}
>   
> -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> -{
> -	dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
> -
> -	dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
> -
> -	dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
> -
> -	dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
> -}
>   
>   static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
>   {
> @@ -356,9 +338,6 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
>   	if (ret)
>   		dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
>   
> -	if (device_may_wakeup(qcom->dev))
> -		dwc3_qcom_enable_interrupts(qcom);
> -
>   	qcom->is_suspended = true;
>   
>   	return 0;
> @@ -372,9 +351,6 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
>   	if (!qcom->is_suspended)
>   		return 0;
>   
> -	if (device_may_wakeup(qcom->dev))
> -		dwc3_qcom_disable_interrupts(qcom);
> -
>   	for (i = 0; i < qcom->num_clocks; i++) {
>   		ret = clk_prepare_enable(qcom->clks[i]);
>   		if (ret < 0) {
> @@ -832,6 +808,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>   	genpd->flags |= GENPD_FLAG_ALWAYS_ON;
>   
>   	device_init_wakeup(&pdev->dev, 1);
> +
> +	if (device_may_wakeup(qcom->dev))
> +		dwc3_qcom_enable_interrupts(qcom);
> +
>   	qcom->is_suspended = false;
>   	pm_runtime_set_active(dev);
>   	pm_runtime_enable(dev);

Hi Sandeep,

I was testing this series on my Lenovo Yoga C630, and with this patch in 
particular applied, my system will no longer boot. Unfortunately I don't 
get any sort of good output at all, I just get hung tasks when trying to 
probe things it would seem.


With the other 5 patches in the series applied, the system still boots 
and works correctly.


-- Steev
Sandeep Maheswaram Jan. 18, 2022, 6:30 a.m. UTC | #2
Hi Steev,

On 1/18/2022 11:42 AM, Steev Klimaszewski wrote:
>
> On 1/16/22 11:44 PM, Sandeep Maheswaram wrote:
>> Enable the interrupts during probe and remove the disable interrupts
>> function.
>>
>> Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
>> ---
>>   drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
>>   1 file changed, 4 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
>> index 54dc3d3..7c5e636 100644
>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>> @@ -306,25 +306,7 @@ static void dwc3_qcom_enable_wakeup_irq(int irq)
>>       enable_irq_wake(irq);
>>   }
>>   -static void dwc3_qcom_disable_wakeup_irq(int irq)
>> -{
>> -    if (!irq)
>> -        return;
>> -
>> -    disable_irq_wake(irq);
>> -    disable_irq_nosync(irq);
>> -}
>>   -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
>> -{
>> -    dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
>> -
>> -    dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
>> -
>> -    dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
>> -
>> -    dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
>> -}
>>     static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
>>   {
>> @@ -356,9 +338,6 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
>>       if (ret)
>>           dev_warn(qcom->dev, "failed to disable interconnect: %d\n", 
>> ret);
>>   -    if (device_may_wakeup(qcom->dev))
>> -        dwc3_qcom_enable_interrupts(qcom);
>> -
>>       qcom->is_suspended = true;
>>         return 0;
>> @@ -372,9 +351,6 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
>>       if (!qcom->is_suspended)
>>           return 0;
>>   -    if (device_may_wakeup(qcom->dev))
>> -        dwc3_qcom_disable_interrupts(qcom);
>> -
>>       for (i = 0; i < qcom->num_clocks; i++) {
>>           ret = clk_prepare_enable(qcom->clks[i]);
>>           if (ret < 0) {
>> @@ -832,6 +808,10 @@ static int dwc3_qcom_probe(struct 
>> platform_device *pdev)
>>       genpd->flags |= GENPD_FLAG_ALWAYS_ON;
>>         device_init_wakeup(&pdev->dev, 1);
>> +
>> +    if (device_may_wakeup(qcom->dev))
>> +        dwc3_qcom_enable_interrupts(qcom);
>> +
>>       qcom->is_suspended = false;
>>       pm_runtime_set_active(dev);
>>       pm_runtime_enable(dev);
>
> Hi Sandeep,
>
> I was testing this series on my Lenovo Yoga C630, and with this patch 
> in particular applied, my system will no longer boot. Unfortunately I 
> don't get any sort of good output at all, I just get hung tasks when 
> trying to probe things it would seem.
>
>
> With the other 5 patches in the series applied, the system still boots 
> and works correctly.
>
>
> -- Steev
>
Will check this. Is your controller in host mode or device mode?

Regards

Sandeep
Steev Klimaszewski Jan. 18, 2022, 8:46 a.m. UTC | #3
On 1/18/22 12:30 AM, Sandeep Maheswaram wrote:
> Hi Steev,
<snip>
>> Hi Sandeep,
>>
>> I was testing this series on my Lenovo Yoga C630, and with this patch 
>> in particular applied, my system will no longer boot. Unfortunately I 
>> don't get any sort of good output at all, I just get hung tasks when 
>> trying to probe things it would seem.
>>
>>
>> With the other 5 patches in the series applied, the system still 
>> boots and works correctly.
>>
>>
>> -- Steev
>>
> Will check this. Is your controller in host mode or device mode?
>
> Regards
>
> Sandeep
>
Both usb_1_dwc3 and usb_2_dwc3 are in host mode

-- Steev
Pavan Kondeti Jan. 18, 2022, 9:52 a.m. UTC | #4
On Tue, Jan 18, 2022 at 12:12:30AM -0600, Steev Klimaszewski wrote:
> 
> On 1/16/22 11:44 PM, Sandeep Maheswaram wrote:
> >Enable the interrupts during probe and remove the disable interrupts
> >function.
> >
> >Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
> >---
> >  drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
> >  1 file changed, 4 insertions(+), 24 deletions(-)
> >
> >diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
> >index 54dc3d3..7c5e636 100644
> >--- a/drivers/usb/dwc3/dwc3-qcom.c
> >+++ b/drivers/usb/dwc3/dwc3-qcom.c
> >@@ -306,25 +306,7 @@ static void dwc3_qcom_enable_wakeup_irq(int irq)
> >  	enable_irq_wake(irq);
> >  }
> >-static void dwc3_qcom_disable_wakeup_irq(int irq)
> >-{
> >-	if (!irq)
> >-		return;
> >-
> >-	disable_irq_wake(irq);
> >-	disable_irq_nosync(irq);
> >-}
> >-static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
> >-{
> >-	dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
> >-
> >-	dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
> >-
> >-	dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
> >-
> >-	dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
> >-}
> >  static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
> >  {
> >@@ -356,9 +338,6 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
> >  	if (ret)
> >  		dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
> >-	if (device_may_wakeup(qcom->dev))
> >-		dwc3_qcom_enable_interrupts(qcom);
> >-
> >  	qcom->is_suspended = true;
> >  	return 0;
> >@@ -372,9 +351,6 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
> >  	if (!qcom->is_suspended)
> >  		return 0;
> >-	if (device_may_wakeup(qcom->dev))
> >-		dwc3_qcom_disable_interrupts(qcom);
> >-
> >  	for (i = 0; i < qcom->num_clocks; i++) {
> >  		ret = clk_prepare_enable(qcom->clks[i]);
> >  		if (ret < 0) {
> >@@ -832,6 +808,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
> >  	genpd->flags |= GENPD_FLAG_ALWAYS_ON;
> >  	device_init_wakeup(&pdev->dev, 1);
> >+
> >+	if (device_may_wakeup(qcom->dev))
> >+		dwc3_qcom_enable_interrupts(qcom);
> >+
> >  	qcom->is_suspended = false;
> >  	pm_runtime_set_active(dev);
> >  	pm_runtime_enable(dev);
> 
> Hi Sandeep,
> 
> I was testing this series on my Lenovo Yoga C630, and with this patch in
> particular applied, my system will no longer boot. Unfortunately I don't get
> any sort of good output at all, I just get hung tasks when trying to probe
> things it would seem.
> 
> 
> With the other 5 patches in the series applied, the system still boots and
> works correctly.
> 
> 

Sandeep,

Enable DP/DM interrupts all the time might be creating a storm of interrupts.
calling enable_irq_wake() during probe is okay, but not the enable_irq().

Did you verify your change with a Highspeed/Fullspeed device connected?

Thanks,
Pavan
Sandeep Maheswaram Jan. 20, 2022, 5:22 a.m. UTC | #5
Hi Pavan,

On 1/18/2022 3:22 PM, Pavan Kondeti wrote:
> On Tue, Jan 18, 2022 at 12:12:30AM -0600, Steev Klimaszewski wrote:
>> On 1/16/22 11:44 PM, Sandeep Maheswaram wrote:
>>> Enable the interrupts during probe and remove the disable interrupts
>>> function.
>>>
>>> Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
>>> ---
>>>   drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
>>>   1 file changed, 4 insertions(+), 24 deletions(-)
>>>
>>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
>>> index 54dc3d3..7c5e636 100644
>>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>>> @@ -306,25 +306,7 @@ static void dwc3_qcom_enable_wakeup_irq(int irq)
>>>   	enable_irq_wake(irq);
>>>   }
>>> -static void dwc3_qcom_disable_wakeup_irq(int irq)
>>> -{
>>> -	if (!irq)
>>> -		return;
>>> -
>>> -	disable_irq_wake(irq);
>>> -	disable_irq_nosync(irq);
>>> -}
>>> -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
>>> -{
>>> -	dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
>>> -
>>> -	dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
>>> -
>>> -	dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
>>> -
>>> -	dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
>>> -}
>>>   static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
>>>   {
>>> @@ -356,9 +338,6 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
>>>   	if (ret)
>>>   		dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
>>> -	if (device_may_wakeup(qcom->dev))
>>> -		dwc3_qcom_enable_interrupts(qcom);
>>> -
>>>   	qcom->is_suspended = true;
>>>   	return 0;
>>> @@ -372,9 +351,6 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
>>>   	if (!qcom->is_suspended)
>>>   		return 0;
>>> -	if (device_may_wakeup(qcom->dev))
>>> -		dwc3_qcom_disable_interrupts(qcom);
>>> -
>>>   	for (i = 0; i < qcom->num_clocks; i++) {
>>>   		ret = clk_prepare_enable(qcom->clks[i]);
>>>   		if (ret < 0) {
>>> @@ -832,6 +808,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)
>>>   	genpd->flags |= GENPD_FLAG_ALWAYS_ON;
>>>   	device_init_wakeup(&pdev->dev, 1);
>>> +
>>> +	if (device_may_wakeup(qcom->dev))
>>> +		dwc3_qcom_enable_interrupts(qcom);
>>> +
>>>   	qcom->is_suspended = false;
>>>   	pm_runtime_set_active(dev);
>>>   	pm_runtime_enable(dev);
>> Hi Sandeep,
>>
>> I was testing this series on my Lenovo Yoga C630, and with this patch in
>> particular applied, my system will no longer boot. Unfortunately I don't get
>> any sort of good output at all, I just get hung tasks when trying to probe
>> things it would seem.
>>
>>
>> With the other 5 patches in the series applied, the system still boots and
>> works correctly.
>>
>>
> Sandeep,
>
> Enable DP/DM interrupts all the time might be creating a storm of interrupts.
> calling enable_irq_wake() during probe is okay, but not the enable_irq().
>
> Did you verify your change with a Highspeed/Fullspeed device connected?
>
> Thanks,
> Pavan

I didn't face any such issue with devices connected.

I think this is because I used IRQ_TYPE_EDGE_BOTH in device tree and 
Steev has IRQ_TYPE_LEVEL_HIGH in his device tree.

When i changed to IRQ_TYPE_LEVEL_HIGH I also observed a storm of 
interrupts in my device though it booted .

Regards

Sandeep
Sandeep Maheswaram Jan. 25, 2022, 9:17 a.m. UTC | #6
Hi Steev,

On 1/20/2022 10:52 AM, Sandeep Maheswaram wrote:
> Hi Pavan,
>
> On 1/18/2022 3:22 PM, Pavan Kondeti wrote:
>> On Tue, Jan 18, 2022 at 12:12:30AM -0600, Steev Klimaszewski wrote:
>>> On 1/16/22 11:44 PM, Sandeep Maheswaram wrote:
>>>> Enable the interrupts during probe and remove the disable interrupts
>>>> function.
>>>>
>>>> Signed-off-by: Sandeep Maheswaram <quic_c_sanm@quicinc.com>
>>>> ---
>>>>   drivers/usb/dwc3/dwc3-qcom.c | 28 ++++------------------------
>>>>   1 file changed, 4 insertions(+), 24 deletions(-)
>>>>
>>>> diff --git a/drivers/usb/dwc3/dwc3-qcom.c 
>>>> b/drivers/usb/dwc3/dwc3-qcom.c
>>>> index 54dc3d3..7c5e636 100644
>>>> --- a/drivers/usb/dwc3/dwc3-qcom.c
>>>> +++ b/drivers/usb/dwc3/dwc3-qcom.c
>>>> @@ -306,25 +306,7 @@ static void dwc3_qcom_enable_wakeup_irq(int irq)
>>>>       enable_irq_wake(irq);
>>>>   }
>>>> -static void dwc3_qcom_disable_wakeup_irq(int irq)
>>>> -{
>>>> -    if (!irq)
>>>> -        return;
>>>> -
>>>> -    disable_irq_wake(irq);
>>>> -    disable_irq_nosync(irq);
>>>> -}
>>>> -static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
>>>> -{
>>>> -    dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
>>>> -
>>>> -    dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
>>>> -
>>>> -    dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
>>>> -
>>>> -    dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
>>>> -}
>>>>   static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
>>>>   {
>>>> @@ -356,9 +338,6 @@ static int dwc3_qcom_suspend(struct dwc3_qcom 
>>>> *qcom)
>>>>       if (ret)
>>>>           dev_warn(qcom->dev, "failed to disable interconnect: 
>>>> %d\n", ret);
>>>> -    if (device_may_wakeup(qcom->dev))
>>>> -        dwc3_qcom_enable_interrupts(qcom);
>>>> -
>>>>       qcom->is_suspended = true;
>>>>       return 0;
>>>> @@ -372,9 +351,6 @@ static int dwc3_qcom_resume(struct dwc3_qcom 
>>>> *qcom)
>>>>       if (!qcom->is_suspended)
>>>>           return 0;
>>>> -    if (device_may_wakeup(qcom->dev))
>>>> -        dwc3_qcom_disable_interrupts(qcom);
>>>> -
>>>>       for (i = 0; i < qcom->num_clocks; i++) {
>>>>           ret = clk_prepare_enable(qcom->clks[i]);
>>>>           if (ret < 0) {
>>>> @@ -832,6 +808,10 @@ static int dwc3_qcom_probe(struct 
>>>> platform_device *pdev)
>>>>       genpd->flags |= GENPD_FLAG_ALWAYS_ON;
>>>>       device_init_wakeup(&pdev->dev, 1);
>>>> +
>>>> +    if (device_may_wakeup(qcom->dev))
>>>> +        dwc3_qcom_enable_interrupts(qcom);
>>>> +
>>>>       qcom->is_suspended = false;
>>>>       pm_runtime_set_active(dev);
>>>>       pm_runtime_enable(dev);
>>> Hi Sandeep,
>>>
>>> I was testing this series on my Lenovo Yoga C630, and with this 
>>> patch in
>>> particular applied, my system will no longer boot. Unfortunately I 
>>> don't get
>>> any sort of good output at all, I just get hung tasks when trying to 
>>> probe
>>> things it would seem.
>>>
>>>
>>> With the other 5 patches in the series applied, the system still 
>>> boots and
>>> works correctly.
>>>
>>>
>> Sandeep,
>>
>> Enable DP/DM interrupts all the time might be creating a storm of 
>> interrupts.
>> calling enable_irq_wake() during probe is okay, but not the 
>> enable_irq().
>>
>> Did you verify your change with a Highspeed/Fullspeed device connected?
>>
>> Thanks,
>> Pavan
>
> I didn't face any such issue with devices connected.
>
> I think this is because I used IRQ_TYPE_EDGE_BOTH in device tree and 
> Steev has IRQ_TYPE_LEVEL_HIGH in his device tree.
>
> When i changed to IRQ_TYPE_LEVEL_HIGH I also observed a storm of 
> interrupts in my device though it booted .
>
> Regards
>
> Sandeep
>
Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if you 
are getting the issue.

Regards

Sandeep
Steev Klimaszewski Jan. 28, 2022, 8:36 a.m. UTC | #7
Hi Sandeep,

On 1/25/22 3:17 AM, Sandeep Maheswaram wrote:
> Hi Steev,
>
>> I didn't face any such issue with devices connected.
>>
>> I think this is because I used IRQ_TYPE_EDGE_BOTH in device tree and 
>> Steev has IRQ_TYPE_LEVEL_HIGH in his device tree.
>>
>> When i changed to IRQ_TYPE_LEVEL_HIGH I also observed a storm of 
>> interrupts in my device though it booted .
>>
>> Regards
>>
>> Sandeep
>>
> Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if you 
> are getting the issue.
>
> Regards
>
> Sandeep
>
I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the 
yoga's dts to EDGE_BOTH and I still do not get a booting system.

-- Steev
Pavan Kondeti Jan. 28, 2022, 9 a.m. UTC | #8
On Fri, Jan 28, 2022 at 02:36:38AM -0600, Steev Klimaszewski wrote:
> Hi Sandeep,
> 
> On 1/25/22 3:17 AM, Sandeep Maheswaram wrote:
> >Hi Steev,
> >
> >>I didn't face any such issue with devices connected.
> >>
> >>I think this is because I used IRQ_TYPE_EDGE_BOTH in device tree and
> >>Steev has IRQ_TYPE_LEVEL_HIGH in his device tree.
> >>
> >>When i changed to IRQ_TYPE_LEVEL_HIGH I also observed a storm of
> >>interrupts in my device though it booted .
> >>
> >>Regards
> >>
> >>Sandeep
> >>
> >Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if you are
> >getting the issue.
> >
> >Regards
> >
> >Sandeep
> >
> I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the yoga's
> dts to EDGE_BOTH and I still do not get a booting system.
> 

Sandeep,

For whatever reason, if the interrupt comes immediately after enabling it in
the probe, are we ready to call pm_runtime_resume(&dwc->xhci->dev); ? 

I am not sure if Steev is facing an interrupt storm issue or some kind of
incorrect access and device is crashing. In any case, can you simulate this
and see if we can call the above runtime PM API in dwc->xhci->dev immediately
after enabling the IRQs.

Thanks,
Pavan
Sandeep Maheswaram Feb. 15, 2022, 9:40 a.m. UTC | #9
Hi Steev,

On 1/28/2022 2:06 PM, Steev Klimaszewski wrote:
> Hi Sandeep,
>
> On 1/25/22 3:17 AM, Sandeep Maheswaram wrote:
>> Hi Steev,
>>
>>> I didn't face any such issue with devices connected.
>>>
>>> I think this is because I used IRQ_TYPE_EDGE_BOTH in device tree and 
>>> Steev has IRQ_TYPE_LEVEL_HIGH in his device tree.
>>>
>>> When i changed to IRQ_TYPE_LEVEL_HIGH I also observed a storm of 
>>> interrupts in my device though it booted .
>>>
>>> Regards
>>>
>>> Sandeep
>>>
>> Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if 
>> you are getting the issue.
>>
>> Regards
>>
>> Sandeep
>>
> I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the 
> yoga's dts to EDGE_BOTH and I still do not get a booting system.
>
> -- Steev
>
Please let us know what devices are connected to your setup and share 
the device tree file you are using.

Please share the failure logs also,

Regards

Sandeep
Steev Klimaszewski Feb. 16, 2022, 3:22 a.m. UTC | #10
Hi Sandeep,

On 2/15/22 3:40 AM, Sandeep Maheswaram wrote:
> Hi Steev,
>
>>>>
>>> Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if 
>>> you are getting the issue.
>>>
>>> Regards
>>>
>>> Sandeep
>>>
>> I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the 
>> yoga's dts to EDGE_BOTH and I still do not get a booting system.
>>
>> -- Steev
>>
> Please let us know what devices are connected to your setup and share 
> the device tree file you are using.
>
> Please share the failure logs also,
>
> Regards
>
> Sandeep
>
The setup is a Lenovo Yoga C630 (Windows on ARM laptop).  I do not have 
any sort of serial console access to the device, unfortunately.  Even 
when taking it apart, it seems to have some sort of 26pin debug adapter 
port that I've never seen before which you can see on the far right in 
this picture of the motherboard at 
https://i.ebayimg.com/images/g/a2EAAOSwwzZiCxPM/s-l1600.jpg

I do not have anything plugged in to the USB ports (sometimes the power 
adapter, but I have tried both on mains as well as off.)

I am using this diff


diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
index eab3f00c603235..c54042b9e21df2 100644
--- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
@@ -370,7 +370,7 @@
  		reg = <0x15>;
  		hid-descr-addr = <0x1>;
  
-		interrupts-extended = <&tlmm 37 IRQ_TYPE_LEVEL_HIGH>;
+		interrupts-extended = <&tlmm 37 IRQ_TYPE_EDGE_BOTH>;
  	};
  
  	tsc2: hid@2c {
@@ -378,7 +378,7 @@
  		reg = <0x2c>;
  		hid-descr-addr = <0x20>;
  
-		interrupts-extended = <&tlmm 37 IRQ_TYPE_LEVEL_HIGH>;
+		interrupts-extended = <&tlmm 37 IRQ_TYPE_EDGE_BOTH>;
  	};
  };

Which I added as a commit to my kernel tree, and pushed so you can see 
the full dts here: 
https://github.com/steev/linux/blob/c8234e664491e35e3edcd211f3b78c04436402b0/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts

I am booting with the command line arguments of

clk_ignore_unused verbose module_blacklist=msm video=efifb 
earlyconsole=efifb

I can't provide a boot log, because I'm not actually getting anything.  
Booting a different kernel, and it doesn't appear that anything is 
logged at all.


-- steev
Sandeep Maheswaram Feb. 16, 2022, 6:27 a.m. UTC | #11
Hi Steev

On 2/16/2022 8:52 AM, Steev Klimaszewski wrote:
> Hi Sandeep,
>
> On 2/15/22 3:40 AM, Sandeep Maheswaram wrote:
>> Hi Steev,
>>
>>>>>
>>>> Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if 
>>>> you are getting the issue.
>>>>
>>>> Regards
>>>>
>>>> Sandeep
>>>>
>>> I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the 
>>> yoga's dts to EDGE_BOTH and I still do not get a booting system.
>>>
>>> -- Steev
>>>
>> Please let us know what devices are connected to your setup and share 
>> the device tree file you are using.
>>
>> Please share the failure logs also,
>>
>> Regards
>>
>> Sandeep
>>
> The setup is a Lenovo Yoga C630 (Windows on ARM laptop).  I do not 
> have any sort of serial console access to the device, unfortunately.  
> Even when taking it apart, it seems to have some sort of 26pin debug 
> adapter port that I've never seen before which you can see on the far 
> right in this picture of the motherboard at 
> https://i.ebayimg.com/images/g/a2EAAOSwwzZiCxPM/s-l1600.jpg
>
> I do not have anything plugged in to the USB ports (sometimes the 
> power adapter, but I have tried both on mains as well as off.)
>
> I am using this diff
>
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts 
> b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> index eab3f00c603235..c54042b9e21df2 100644
> --- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> +++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
> @@ -370,7 +370,7 @@
>          reg = <0x15>;
>          hid-descr-addr = <0x1>;
>
> -        interrupts-extended = <&tlmm 37 IRQ_TYPE_LEVEL_HIGH>;
> +        interrupts-extended = <&tlmm 37 IRQ_TYPE_EDGE_BOTH>;
>      };
>
>      tsc2: hid@2c {
> @@ -378,7 +378,7 @@
>          reg = <0x2c>;
>          hid-descr-addr = <0x20>;
>
> -        interrupts-extended = <&tlmm 37 IRQ_TYPE_LEVEL_HIGH>;
> +        interrupts-extended = <&tlmm 37 IRQ_TYPE_EDGE_BOTH>;
>      };
>  };
>
> Which I added as a commit to my kernel tree, and pushed so you can see 
> the full dts here: 
> https://github.com/steev/linux/blob/c8234e664491e35e3edcd211f3b78c04436402b0/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
>
> I am booting with the command line arguments of
>
> clk_ignore_unused verbose module_blacklist=msm video=efifb 
> earlyconsole=efifb
>
> I can't provide a boot log, because I'm not actually getting 
> anything.  Booting a different kernel, and it doesn't appear that 
> anything is logged at all.
>
>
> -- steev
>
Can you try with below change

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 0d6286d..0a9c0f7 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -3796,8 +3796,8 @@

                         interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>,
                                      <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 488 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 489 IRQ_TYPE_LEVEL_HIGH>;
+                                    <GIC_SPI 488 IRQ_TYPE_EDGE_BOTH>,
+                                    <GIC_SPI 489 IRQ_TYPE_EDGE_BOTH>;
                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
                                           "dm_hs_phy_irq", "dp_hs_phy_irq";

@@ -3844,8 +3844,8 @@

                         interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
                                      <GIC_SPI 487 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 490 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 491 IRQ_TYPE_LEVEL_HIGH>;
+                                    <GIC_SPI 490 IRQ_TYPE_EDGE_BOTH>,
+                                    <GIC_SPI 491 IRQ_TYPE_EDGE_BOTH>;
                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
                                           "dm_hs_phy_irq", "dp_hs_phy_irq";

Regards

Sandeep
Steev Klimaszewski Feb. 16, 2022, 9:51 a.m. UTC | #12
Hi Sandeep,

On 2/16/22 12:27 AM, Sandeep Maheswaram wrote:
> Hi Steev
>
> On 2/16/2022 8:52 AM, Steev Klimaszewski wrote:
>> Hi Sandeep,
>>
>> On 2/15/22 3:40 AM, Sandeep Maheswaram wrote:
>>> Hi Steev,
>>>
>>>>>>
>>>>> Can you try with IRQ_TYPE_EDGE_BOTH in your device tree and see if 
>>>>> you are getting the issue.
>>>>>
>>>>> Regards
>>>>>
>>>>> Sandeep
>>>>>
>>>> I just tested here, changing both of the IRQ_TYPE_LEVEL_HIGH in the 
>>>> yoga's dts to EDGE_BOTH and I still do not get a booting system.
>>>>
>>>> -- Steev
>>>>
>>> Please let us know what devices are connected to your setup and 
>>> share the device tree file you are using.
>>>
>>> Please share the failure logs also,
>>>
>>> Regards
>>>
>>> Sandeep
>>>
>> The setup is a Lenovo Yoga C630 (Windows on ARM laptop).  I do not 
>> have any sort of serial console access to the device, unfortunately.  
>> Even when taking it apart, it seems to have some sort of 26pin debug 
>> adapter port that I've never seen before which you can see on the far 
>> right in this picture of the motherboard at 
>> https://i.ebayimg.com/images/g/a2EAAOSwwzZiCxPM/s-l1600.jpg
>>
>> I do not have anything plugged in to the USB ports (sometimes the 
>> power adapter, but I have tried both on mains as well as off.)
>>
>> Which I added as a commit to my kernel tree, and pushed so you can 
>> see the full dts here: 
>> https://github.com/steev/linux/blob/c8234e664491e35e3edcd211f3b78c04436402b0/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts
>>
>> I am booting with the command line arguments of
>>
>> clk_ignore_unused verbose module_blacklist=msm video=efifb 
>> earlyconsole=efifb
>>
>> I can't provide a boot log, because I'm not actually getting 
>> anything.  Booting a different kernel, and it doesn't appear that 
>> anything is logged at all.
>>
>>
>> -- steev
>>
> Can you try with below change
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
> b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> index 0d6286d..0a9c0f7 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> @@ -3796,8 +3796,8 @@
>
>                         interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>,
>                                      <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 488 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 489 IRQ_TYPE_LEVEL_HIGH>;
> +                                    <GIC_SPI 488 IRQ_TYPE_EDGE_BOTH>,
> +                                    <GIC_SPI 489 IRQ_TYPE_EDGE_BOTH>;
>                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
>                                           "dm_hs_phy_irq", 
> "dp_hs_phy_irq";
>
> @@ -3844,8 +3844,8 @@
>
>                         interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
>                                      <GIC_SPI 487 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 490 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 491 IRQ_TYPE_LEVEL_HIGH>;
> +                                    <GIC_SPI 490 IRQ_TYPE_EDGE_BOTH>,
> +                                    <GIC_SPI 491 IRQ_TYPE_EDGE_BOTH>;
>                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
>                                           "dm_hs_phy_irq", 
> "dp_hs_phy_irq";
>
> Regards
>
> Sandeep

That does allow it to boot, however.... it breaks USB.

[    2.013325] genirq: Setting trigger mode 3 for irq 35 failed 
(gic_set_type+0x0/0x1b0)
[    2.014063] dwc3-qcom a6f8800.usb: dp_hs_phy_irq failed: -22
[    2.014134] dwc3-qcom a6f8800.usb: failed to setup IRQs, err=-22
[    2.014351] dwc3-qcom: probe of a6f8800.usb failed with error -22
[    2.018496] genirq: Setting trigger mode 3 for irq 39 failed 
(gic_set_type+0x0/0x1b0)
[    2.019124] dwc3-qcom a8f8800.usb: dp_hs_phy_irq failed: -22
[    2.019193] dwc3-qcom a8f8800.usb: failed to setup IRQs, err=-22
[    2.019372] dwc3-qcom: probe of a8f8800.usb failed with error -22

steev@limitless:~$ lsusb
steev@limitless:~$


-- steev
Steev Klimaszewski Feb. 17, 2022, 10:16 p.m. UTC | #13
Hi Sandeep,

On 2/17/22 12:05 AM, Sandeep Maheswaram wrote:
>
> Hi Steev,
>
> On 2/16/2022 3:21 PM, Steev Klimaszewski wrote:
>> That does allow it to boot, however.... it breaks USB.
>>
>> [    2.013325] genirq: Setting trigger mode 3 for irq 35 failed 
>> (gic_set_type+0x0/0x1b0)
>> [    2.014063] dwc3-qcom a6f8800.usb: dp_hs_phy_irq failed: -22
>> [    2.014134] dwc3-qcom a6f8800.usb: failed to setup IRQs, err=-22
>> [    2.014351] dwc3-qcom: probe of a6f8800.usb failed with error -22
>> [    2.018496] genirq: Setting trigger mode 3 for irq 39 failed 
>> (gic_set_type+0x0/0x1b0)
>> [    2.019124] dwc3-qcom a8f8800.usb: dp_hs_phy_irq failed: -22
>> [    2.019193] dwc3-qcom a8f8800.usb: failed to setup IRQs, err=-22
>> [    2.019372] dwc3-qcom: probe of a8f8800.usb failed with error -22
>>
>> steev@limitless:~$ lsusb
>> steev@limitless:~$
>>
>>
>> -- steev
>>
> Can you try with only IRQ_TYPE_EDGE_RISING as you are using GIC 
> interrupts  where IRQ_TYPE_EDGE_FALLING may not be supported
>
> diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi 
> b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> index 0d6286d..ee3b031 100644
> --- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
> +++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
> @@ -3796,8 +3796,8 @@
>
>                         interrupts = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>,
>                                      <GIC_SPI 486 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 488 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 489 IRQ_TYPE_LEVEL_HIGH>;
> +                                    <GIC_SPI 488 IRQ_TYPE_EDGE_RISING>,
> +                                    <GIC_SPI 489 IRQ_TYPE_EDGE_RISING>;
>                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
>                                           "dm_hs_phy_irq", 
> "dp_hs_phy_irq";
>
> @@ -3844,8 +3844,8 @@
>
>                         interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
>                                      <GIC_SPI 487 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 490 IRQ_TYPE_LEVEL_HIGH>,
> -                                    <GIC_SPI 491 IRQ_TYPE_LEVEL_HIGH>;
> +                                    <GIC_SPI 490 IRQ_TYPE_EDGE_RISING>,
> +                                    <GIC_SPI 491 IRQ_TYPE_EDGE_RISING>;
>                         interrupt-names = "hs_phy_irq", "ss_phy_irq",
>                                           "dm_hs_phy_irq", 
> "dp_hs_phy_irq";
> Regards
>
> Sandeep
>
With this change, and with either EDGE_RISING or EDGE_BOTH in the lenovo 
yoga c630 dts, it does indeed boot.  Leaving LEVEL_HIGH in the c630, it 
does also boot, but there is a delay of about 30 seconds (I'm assuming 
interrupt storm?) during the boot.

-- steev
diff mbox series

Patch

diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c
index 54dc3d3..7c5e636 100644
--- a/drivers/usb/dwc3/dwc3-qcom.c
+++ b/drivers/usb/dwc3/dwc3-qcom.c
@@ -306,25 +306,7 @@  static void dwc3_qcom_enable_wakeup_irq(int irq)
 	enable_irq_wake(irq);
 }
 
-static void dwc3_qcom_disable_wakeup_irq(int irq)
-{
-	if (!irq)
-		return;
-
-	disable_irq_wake(irq);
-	disable_irq_nosync(irq);
-}
 
-static void dwc3_qcom_disable_interrupts(struct dwc3_qcom *qcom)
-{
-	dwc3_qcom_disable_wakeup_irq(qcom->hs_phy_irq);
-
-	dwc3_qcom_disable_wakeup_irq(qcom->dp_hs_phy_irq);
-
-	dwc3_qcom_disable_wakeup_irq(qcom->dm_hs_phy_irq);
-
-	dwc3_qcom_disable_wakeup_irq(qcom->ss_phy_irq);
-}
 
 static void dwc3_qcom_enable_interrupts(struct dwc3_qcom *qcom)
 {
@@ -356,9 +338,6 @@  static int dwc3_qcom_suspend(struct dwc3_qcom *qcom)
 	if (ret)
 		dev_warn(qcom->dev, "failed to disable interconnect: %d\n", ret);
 
-	if (device_may_wakeup(qcom->dev))
-		dwc3_qcom_enable_interrupts(qcom);
-
 	qcom->is_suspended = true;
 
 	return 0;
@@ -372,9 +351,6 @@  static int dwc3_qcom_resume(struct dwc3_qcom *qcom)
 	if (!qcom->is_suspended)
 		return 0;
 
-	if (device_may_wakeup(qcom->dev))
-		dwc3_qcom_disable_interrupts(qcom);
-
 	for (i = 0; i < qcom->num_clocks; i++) {
 		ret = clk_prepare_enable(qcom->clks[i]);
 		if (ret < 0) {
@@ -832,6 +808,10 @@  static int dwc3_qcom_probe(struct platform_device *pdev)
 	genpd->flags |= GENPD_FLAG_ALWAYS_ON;
 
 	device_init_wakeup(&pdev->dev, 1);
+
+	if (device_may_wakeup(qcom->dev))
+		dwc3_qcom_enable_interrupts(qcom);
+
 	qcom->is_suspended = false;
 	pm_runtime_set_active(dev);
 	pm_runtime_enable(dev);