public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
To: Oliver Neukum <oneukum@suse.com>,
	Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: Ivan Ivanov <ivan.ivanov@suse.com>,
	Andrea della Porta <andrea.porta@suse.com>
Subject: Re: [PATCH] USB: dwc2: write HCINT with INTMASK applied
Date: Wed, 22 Nov 2023 12:35:40 +0000	[thread overview]
Message-ID: <f0bd323a-8384-e303-907f-5d533af6d71e@synopsys.com> (raw)
In-Reply-To: <20231115144514.15248-1-oneukum@suse.com>

Hi Oliver,

On 11/15/23 18:45, Oliver Neukum wrote:
> dwc2_hc_n_intr() writes back INTMASK as read but evaluates it
> with intmask applied. In stress testing this causes spurious
> interrupts like this:
> 
> [Mon Aug 14 10:51:07 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 7 - ChHltd set, but reason is unknown
> [Mon Aug 14 10:51:07 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001
> [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 0 - ChHltd set, but reason is unknown
> [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001
> [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_hc_chhltd_intr_dma: Channel 4 - ChHltd set, but reason is unknown
> [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: hcint 0x00000002, intsts 0x04600001
> [Mon Aug 14 10:51:08 2023] dwc2 3f980000.usb: dwc2_update_urb_state_abn(): trimming xfer length
> 
> Applying INTMASK prevents this. The issue exists in all versions of the
> driver.

I'm Ok with this patch, just need some elaboration.
So, channel halted interrupt asserted due to some other interrupt (AHB 
Error, Excessive transaction errors, Babble, Stall) which was masked. 
Can you check which of masked interrupts is cause of channel halt interrupt?

Thanks,
Minas

> 
> Signed-off-by: Oliver Neukum <oneukum@suse.com>
> Tested-by: Ivan Ivanov <ivan.ivanov@suse.com>
> Tested-by: Andrea della Porta <andrea.porta@suse.com>
> ---
>   drivers/usb/dwc2/hcd_intr.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c
> index 0144ca8350c3..5c7538d498dd 100644
> --- a/drivers/usb/dwc2/hcd_intr.c
> +++ b/drivers/usb/dwc2/hcd_intr.c
> @@ -2015,15 +2015,17 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
>   {
>   	struct dwc2_qtd *qtd;
>   	struct dwc2_host_chan *chan;
> -	u32 hcint, hcintmsk;
> +	u32 hcint, hcintraw, hcintmsk;
>   
>   	chan = hsotg->hc_ptr_array[chnum];
>   
> -	hcint = dwc2_readl(hsotg, HCINT(chnum));
> +	hcintraw = dwc2_readl(hsotg, HCINT(chnum));
>   	hcintmsk = dwc2_readl(hsotg, HCINTMSK(chnum));
> +	hcint = hcintraw & hcintmsk;
> +	dwc2_writel(hsotg, hcint, HCINT(chnum));
> +
>   	if (!chan) {
>   		dev_err(hsotg->dev, "## hc_ptr_array for channel is NULL ##\n");
> -		dwc2_writel(hsotg, hcint, HCINT(chnum));
>   		return;
>   	}
>   
> @@ -2032,11 +2034,9 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
>   			 chnum);
>   		dev_vdbg(hsotg->dev,
>   			 "  hcint 0x%08x, hcintmsk 0x%08x, hcint&hcintmsk 0x%08x\n",
> -			 hcint, hcintmsk, hcint & hcintmsk);
> +			 hcintraw, hcintmsk, hcint);
>   	}
>   
> -	dwc2_writel(hsotg, hcint, HCINT(chnum));
> -
>   	/*
>   	 * If we got an interrupt after someone called
>   	 * dwc2_hcd_endpoint_disable() we don't want to crash below
> @@ -2046,8 +2046,7 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
>   		return;
>   	}
>   
> -	chan->hcint = hcint;
> -	hcint &= hcintmsk;
> +	chan->hcint = hcintraw;
>   
>   	/*
>   	 * If the channel was halted due to a dequeue, the qtd list might

  reply	other threads:[~2023-11-22 12:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-15 14:45 [PATCH] USB: dwc2: write HCINT with INTMASK applied Oliver Neukum
2023-11-22 12:35 ` Minas Harutyunyan [this message]
2023-11-27  9:04   ` Andrea della Porta
2023-11-27 10:46     ` Minas Harutyunyan
2023-11-28  9:00       ` Andrea della Porta
2023-11-28 11:48         ` Minas Harutyunyan
2023-11-28 14:43           ` Ivan Ivanov
2023-12-01 10:26             ` Minas Harutyunyan
2023-12-03  6:52               ` Andrea della Porta
2023-12-14 12:23                 ` Minas Harutyunyan
2023-12-18 14:36                   ` Andrea della Porta
2023-12-19 10:19                     ` Minas Harutyunyan
2023-12-19 10:18 ` Minas Harutyunyan

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=f0bd323a-8384-e303-907f-5d533af6d71e@synopsys.com \
    --to=minas.harutyunyan@synopsys.com \
    --cc=andrea.porta@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ivan.ivanov@suse.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=oneukum@suse.com \
    /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