public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@kernel.org>
To: Wesley Cheng <wcheng@codeaurora.org>, gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	jackp@codeaurora.org, Wesley Cheng <wcheng@codeaurora.org>
Subject: Re: [PATCH] usb: dwc3: gadget: Disable gadget IRQ during pullup disable
Date: Thu, 10 Jun 2021 14:09:19 +0300	[thread overview]
Message-ID: <87h7i60ye8.fsf@kernel.org> (raw)
In-Reply-To: <1621571037-1424-1-git-send-email-wcheng@codeaurora.org>

[-- Attachment #1: Type: text/plain, Size: 1791 bytes --]

Wesley Cheng <wcheng@codeaurora.org> writes:

> Current sequence utilizes dwc3_gadget_disable_irq() alongside
> synchronize_irq() to ensure that no further DWC3 events are generated.
> However, the dwc3_gadget_disable_irq() API only disables device
> specific events.  Endpoint events can still be generated.  Briefly
> disable the interrupt line, so that the cleanup code can run to
> prevent device and endpoint events. (i.e. __dwc3_gadget_stop() and
> dwc3_stop_active_transfers() respectively)
>
> Without doing so, it can lead to both the interrupt handler and the
> pullup disable routine both writing to the GEVNTCOUNT register, which
> will cause an incorrect count being read from future interrupts.
>
> Fixes: ae7e86108b12 ("usb: dwc3: Stop active transfers before halting the controller")
> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
> ---
>  drivers/usb/dwc3/gadget.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> index 49ca5da..89aa9ac 100644
> --- a/drivers/usb/dwc3/gadget.c
> +++ b/drivers/usb/dwc3/gadget.c
> @@ -2260,13 +2260,10 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on)
>  	}
>  
>  	/*
> -	 * Synchronize any pending event handling before executing the controller
> -	 * halt routine.
> +	 * Synchronize and disable any further event handling while controller
> +	 * is being enabled/disabled.
>  	 */
> -	if (!is_on) {
> -		dwc3_gadget_disable_irq(dwc);
> -		synchronize_irq(dwc->irq_gadget);
> -	}
> +	disable_irq(dwc->irq_gadget);
>  
>  	spin_lock_irqsave(&dwc->lock, flags);

spin_lock_irqsave() is already disabling interrupt, right? Why do we
need another call to disable_irq()?

-- 
balbi

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

  reply	other threads:[~2021-06-10 11:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  4:23 [PATCH] usb: dwc3: gadget: Disable gadget IRQ during pullup disable Wesley Cheng
2021-06-10 11:09 ` Felipe Balbi [this message]
2021-06-10 18:21   ` Wesley Cheng
2021-06-10 20:27     ` Wesley Cheng
2021-06-11  7:23       ` Felipe Balbi
2021-06-14  7:39         ` Jack Pham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7i60ye8.fsf@kernel.org \
    --to=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=wcheng@codeaurora.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox