linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
@ 2023-06-22  2:57 Guiting Shen
  2023-06-22 14:29 ` Alan Stern
  0 siblings, 1 reply; 6+ messages in thread
From: Guiting Shen @ 2023-06-22  2:57 UTC (permalink / raw)
  To: stern, gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea
  Cc: linux-usb, linux-arm-kernel, linux-kernel, Guiting Shen

The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when
suspend which will let the ohci_irq() skip the interrupt after resume. And
nobody to handle this interrupt.

Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when
suspend to fix it.

Signed-off-by: Guiting Shen <aarongt.shen@gmail.com>
---
 drivers/usb/host/ohci-at91.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index b9ce8d80f20b..7a970e573668 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
 	 * REVISIT: some boards will be able to turn VBUS off...
 	 */
 	if (!ohci_at91->wakeup) {
-		ohci->rh_state = OHCI_RH_HALTED;
+		ohci->rh_state = OHCI_RH_SUSPENDED;
 
 		/* flush the writes */
 		(void) ohci_readl (ohci, &ohci->regs->control);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
  2023-06-22  2:57 [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume Guiting Shen
@ 2023-06-22 14:29 ` Alan Stern
  2023-06-23  3:44   ` Guiting Shen
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2023-06-22 14:29 UTC (permalink / raw)
  To: Guiting Shen
  Cc: gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea,
	linux-usb, linux-arm-kernel, linux-kernel

On Thu, Jun 22, 2023 at 10:57:39AM +0800, Guiting Shen wrote:
> The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when
> suspend which will let the ohci_irq() skip the interrupt after resume. And
> nobody to handle this interrupt.
> 
> Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when
> suspend to fix it.
> 
> Signed-off-by: Guiting Shen <aarongt.shen@gmail.com>
> ---
>  drivers/usb/host/ohci-at91.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> index b9ce8d80f20b..7a970e573668 100644
> --- a/drivers/usb/host/ohci-at91.c
> +++ b/drivers/usb/host/ohci-at91.c
> @@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>  	 * REVISIT: some boards will be able to turn VBUS off...
>  	 */
>  	if (!ohci_at91->wakeup) {
> -		ohci->rh_state = OHCI_RH_HALTED;
> +		ohci->rh_state = OHCI_RH_SUSPENDED;

It looks like this change ignores the comment immediately above it 
(just before the start of this hunk).

If you want to find a way to handle IRQs better after the controller 
resumes, maybe you should change the resume routine instead of the 
suspend routine.

Alan Stern

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
  2023-06-22 14:29 ` Alan Stern
@ 2023-06-23  3:44   ` Guiting Shen
  2023-06-23 15:52     ` Alan Stern
  0 siblings, 1 reply; 6+ messages in thread
From: Guiting Shen @ 2023-06-23  3:44 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea,
	linux-usb, linux-arm-kernel, linux-kernel



On Thu,Jun 22,2023 at 22:29:43PM GMT+8, Alan Stern wrote:
> On Thu, Jun 22, 2023 at 10:57:39AM +0800, Guiting Shen wrote:
>> The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when
>> suspend which will let the ohci_irq() skip the interrupt after resume. And
>> nobody to handle this interrupt.
>>
>> Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when
>> suspend to fix it.
>>
>> Signed-off-by: Guiting Shen <aarongt.shen@gmail.com>
>> ---
>>   drivers/usb/host/ohci-at91.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
>> index b9ce8d80f20b..7a970e573668 100644
>> --- a/drivers/usb/host/ohci-at91.c
>> +++ b/drivers/usb/host/ohci-at91.c
>> @@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>>   	 * REVISIT: some boards will be able to turn VBUS off...
>>   	 */
>>   	if (!ohci_at91->wakeup) {
>> -		ohci->rh_state = OHCI_RH_HALTED;
>> +		ohci->rh_state = OHCI_RH_SUSPENDED;
> 
> It looks like this change ignores the comment immediately above it
> (just before the start of this hunk).
> 
> If you want to find a way to handle IRQs better after the controller
> resumes, maybe you should change the resume routine instead of the
> suspend routine.
>
> Alan Stern

The comment which was added with commit-id 0365ee0a8f745 may be outdated
because ohci_suspend() and ohci_at91_port_suspend() is used to suspend 
instead of setting ohci->rh_state to OHCI_RH_HALTED.

What's more, I found that only ohci-at91 driver to set the 
ohci->rh_state which may be unnessory because the ohci_suspend() disable 
irq emission and mark HW unaccessible and ohci_at91_port_suspend() 
suspend the controller.

Is it really need to set ohci->rh_state in ohci_hcd_at91_drv_suspend()?

It maybe confused to set ohci->rh_state to OHCI_RH_SUSPEND in resume 
routine.

-- 
Best regards,
Guiting Shen

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
  2023-06-23  3:44   ` Guiting Shen
@ 2023-06-23 15:52     ` Alan Stern
  2023-06-25  4:01       ` Guiting Shen
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2023-06-23 15:52 UTC (permalink / raw)
  To: Guiting Shen
  Cc: gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea,
	linux-usb, linux-arm-kernel, linux-kernel

On Fri, Jun 23, 2023 at 11:44:04AM +0800, Guiting Shen wrote:
> 
> 
> On Thu,Jun 22,2023 at 22:29:43PM GMT+8, Alan Stern wrote:
> > On Thu, Jun 22, 2023 at 10:57:39AM +0800, Guiting Shen wrote:
> > > The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when
> > > suspend which will let the ohci_irq() skip the interrupt after resume. And
> > > nobody to handle this interrupt.
> > > 
> > > Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when
> > > suspend to fix it.
> > > 
> > > Signed-off-by: Guiting Shen <aarongt.shen@gmail.com>
> > > ---
> > >   drivers/usb/host/ohci-at91.c | 2 +-
> > >   1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
> > > index b9ce8d80f20b..7a970e573668 100644
> > > --- a/drivers/usb/host/ohci-at91.c
> > > +++ b/drivers/usb/host/ohci-at91.c
> > > @@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
> > >   	 * REVISIT: some boards will be able to turn VBUS off...
> > >   	 */
> > >   	if (!ohci_at91->wakeup) {
> > > -		ohci->rh_state = OHCI_RH_HALTED;
> > > +		ohci->rh_state = OHCI_RH_SUSPENDED;
> > 
> > It looks like this change ignores the comment immediately above it
> > (just before the start of this hunk).
> > 
> > If you want to find a way to handle IRQs better after the controller
> > resumes, maybe you should change the resume routine instead of the
> > suspend routine.
> > 
> > Alan Stern
> 
> The comment which was added with commit-id 0365ee0a8f745 may be outdated
> because ohci_suspend() and ohci_at91_port_suspend() is used to suspend
> instead of setting ohci->rh_state to OHCI_RH_HALTED.

The comment says nothing about ohci->rh_state; it talks about the 
integrated transceivers and the 48 MHz clock.  I don't see why you would 
think the comment is outdated.

> What's more, I found that only ohci-at91 driver to set the ohci->rh_state
> which may be unnessory because the ohci_suspend() disable irq emission and
> mark HW unaccessible and ohci_at91_port_suspend() suspend the controller.
> 
> Is it really need to set ohci->rh_state in ohci_hcd_at91_drv_suspend()?
> 
> It maybe confused to set ohci->rh_state to OHCI_RH_SUSPEND in resume
> routine.

I'm not really sure what that assignment was intended to accomplish, but 
maybe it was meant to force a reset when the controller resumes.

You could get the same result by leaving ohci->rh_state set to 
OHCI_RH_SUSPENDED but changing ohci_hcd_at91_drv_resume().  Instead of 
calling ohci_resume(hcd, false), have it call:

	ohci_resume(hcd, !ohci_at91->wakeup);

That way, if the wakeup flag is clear and the clock was stopped, 
ohci_resume() will call ohci_usb_reset().  You should also add a comment 
explaining the reason.

I can't test this because I don't have the AT91 hardware.

Alan Stern

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
  2023-06-23 15:52     ` Alan Stern
@ 2023-06-25  4:01       ` Guiting Shen
  2023-06-25 13:57         ` Alan Stern
  0 siblings, 1 reply; 6+ messages in thread
From: Guiting Shen @ 2023-06-25  4:01 UTC (permalink / raw)
  To: Alan Stern
  Cc: gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea,
	linux-usb, linux-arm-kernel, linux-kernel

On Fri, Jun 23, 2023 at 23:52:53PM GMT+8, Alan Stern wrote:
> On Fri, Jun 23, 2023 at 11:44:04AM +0800, Guiting Shen wrote:
>>
>>
>> On Thu,Jun 22,2023 at 22:29:43PM GMT+8, Alan Stern wrote:
>>> On Thu, Jun 22, 2023 at 10:57:39AM +0800, Guiting Shen wrote:
>>>> The ohci_hcd_at91_drv_suspend() sets ohci->rh_state to OHCI_RH_HALTED when
>>>> suspend which will let the ohci_irq() skip the interrupt after resume. And
>>>> nobody to handle this interrupt.
>>>>
>>>> Set the ohci->rh_state to OHCI_RH_SUSPEND instead of OHCI_RH_HALTED when
>>>> suspend to fix it.
>>>>
>>>> Signed-off-by: Guiting Shen <aarongt.shen@gmail.com>
>>>> ---
>>>>   drivers/usb/host/ohci-at91.c | 2 +-
>>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
>>>> index b9ce8d80f20b..7a970e573668 100644
>>>> --- a/drivers/usb/host/ohci-at91.c
>>>> +++ b/drivers/usb/host/ohci-at91.c
>>>> @@ -645,7 +645,7 @@ ohci_hcd_at91_drv_suspend(struct device *dev)
>>>>   	 * REVISIT: some boards will be able to turn VBUS off...
>>>>   	 */
>>>>   	if (!ohci_at91->wakeup) {
>>>> -		ohci->rh_state = OHCI_RH_HALTED;
>>>> +		ohci->rh_state = OHCI_RH_SUSPENDED;
>>>
>>> It looks like this change ignores the comment immediately above it
>>> (just before the start of this hunk).
>>>
>>> If you want to find a way to handle IRQs better after the controller
>>> resumes, maybe you should change the resume routine instead of the
>>> suspend routine.
>>>
>>> Alan Stern
>>
>> The comment which was added with commit-id 0365ee0a8f745 may be outdated
>> because ohci_suspend() and ohci_at91_port_suspend() is used to suspend
>> instead of setting ohci->rh_state to OHCI_RH_HALTED.
> 
> The comment says nothing about ohci->rh_state; it talks about the 
> integrated transceivers and the 48 MHz clock.  I don't see why you would 
> think the comment is outdated.
> 

The comment says the reason to discard connection state by reset, but I
don't see any reset operation at ohci-at91 suspend/resume routine in
source code.And ohci_suspend() disable irq emission and mark HW
unaccessible  maybe do the same effect as set ohci->rh_state to
OHCI_RH_HALTED to discard connection state which I think the comment is
outdated.

>> What's more, I found that only ohci-at91 driver to set the ohci->rh_state
>> which may be unnessory because the ohci_suspend() disable irq emission and
>> mark HW unaccessible and ohci_at91_port_suspend() suspend the controller.
>>
>> Is it really need to set ohci->rh_state in ohci_hcd_at91_drv_suspend()?
>>
>> It maybe confused to set ohci->rh_state to OHCI_RH_SUSPEND in resume
>> routine.
> 
> I'm not really sure what that assignment was intended to accomplish, but 
> maybe it was meant to force a reset when the controller resumes.
> 
> You could get the same result by leaving ohci->rh_state set to 
> OHCI_RH_SUSPENDED but changing ohci_hcd_at91_drv_resume().  Instead of 
> calling ohci_resume(hcd, false), have it call:
> 
> 	ohci_resume(hcd, !ohci_at91->wakeup);
> 
> That way, if the wakeup flag is clear and the clock was stopped, 
> ohci_resume() will call ohci_usb_reset().  You should also add a comment 
> explaining the reason.
> 
> I can't test this because I don't have the AT91 hardware.
> 

It works by your methods to force a reset in my sama5d3 soc hardware.
And I found that the ohci->rh_state was already OHCI_RH_SUSPEND before
set it OHCI_RH_HALTED in suspend.So the question is whether to set it
OHCI_RH_HALETED in ohci-at91 suspend routine.

It also works by comment the ohci->rh_state = OHCI_RH_HALTED in suspend
routine.But I think it is safer to use your methods.

Do you have any suggestion on it before I send v2 patch latter.

-- 
Regards,
Guiting Shen


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume
  2023-06-25  4:01       ` Guiting Shen
@ 2023-06-25 13:57         ` Alan Stern
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Stern @ 2023-06-25 13:57 UTC (permalink / raw)
  To: Guiting Shen
  Cc: gregkh, nicolas.ferre, alexandre.belloni, claudiu.beznea,
	linux-usb, linux-arm-kernel, linux-kernel

On Sun, Jun 25, 2023 at 12:01:12PM +0800, Guiting Shen wrote:
> On Fri, Jun 23, 2023 at 23:52:53PM GMT+8, Alan Stern wrote:
> >> The comment which was added with commit-id 0365ee0a8f745 may be outdated
> >> because ohci_suspend() and ohci_at91_port_suspend() is used to suspend
> >> instead of setting ohci->rh_state to OHCI_RH_HALTED.
> > 
> > The comment says nothing about ohci->rh_state; it talks about the 
> > integrated transceivers and the 48 MHz clock.  I don't see why you would 
> > think the comment is outdated.
> > 
> 
> The comment says the reason to discard connection state by reset, but I
> don't see any reset operation at ohci-at91 suspend/resume routine in
> source code.And ohci_suspend() disable irq emission and mark HW
> unaccessible  maybe do the same effect as set ohci->rh_state to
> OHCI_RH_HALTED to discard connection state which I think the comment is
> outdated.

No, it doesn't do the same.  An actual reset is needed.

> >> What's more, I found that only ohci-at91 driver to set the ohci->rh_state
> >> which may be unnessory because the ohci_suspend() disable irq emission and
> >> mark HW unaccessible and ohci_at91_port_suspend() suspend the controller.
> >>
> >> Is it really need to set ohci->rh_state in ohci_hcd_at91_drv_suspend()?
> >>
> >> It maybe confused to set ohci->rh_state to OHCI_RH_SUSPEND in resume
> >> routine.
> > 
> > I'm not really sure what that assignment was intended to accomplish, but 
> > maybe it was meant to force a reset when the controller resumes.
> > 
> > You could get the same result by leaving ohci->rh_state set to 
> > OHCI_RH_SUSPENDED but changing ohci_hcd_at91_drv_resume().  Instead of 
> > calling ohci_resume(hcd, false), have it call:
> > 
> > 	ohci_resume(hcd, !ohci_at91->wakeup);
> > 
> > That way, if the wakeup flag is clear and the clock was stopped, 
> > ohci_resume() will call ohci_usb_reset().  You should also add a comment 
> > explaining the reason.
> > 
> > I can't test this because I don't have the AT91 hardware.
> > 
> 
> It works by your methods to force a reset in my sama5d3 soc hardware.
> And I found that the ohci->rh_state was already OHCI_RH_SUSPEND before
> set it OHCI_RH_HALTED in suspend.So the question is whether to set it
> OHCI_RH_HALETED in ohci-at91 suspend routine.
> 
> It also works by comment the ohci->rh_state = OHCI_RH_HALTED in suspend
> routine.But I think it is safer to use your methods.
> 
> Do you have any suggestion on it before I send v2 patch latter.

No suggestions now.  Submit your v2 patch and then maybe I'll have 
something more to say.

Alan Stern

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-06-25 13:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-22  2:57 [PATCH] usb: ohci-at91: Fix the unhandle interrupt when resume Guiting Shen
2023-06-22 14:29 ` Alan Stern
2023-06-23  3:44   ` Guiting Shen
2023-06-23 15:52     ` Alan Stern
2023-06-25  4:01       ` Guiting Shen
2023-06-25 13:57         ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).