Skip to content

Commit 0583bc7

Browse files
oneukumgregkh
authored andcommitted
USB: dwc2: write HCINT with INTMASK applied
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. Signed-off-by: Oliver Neukum <[email protected]> Tested-by: Ivan Ivanov <[email protected]> Tested-by: Andrea della Porta <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: stable <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 30ce1c0 commit 0583bc7

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

drivers/usb/dwc2/hcd_intr.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,15 +2015,17 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
20152015
{
20162016
struct dwc2_qtd *qtd;
20172017
struct dwc2_host_chan *chan;
2018-
u32 hcint, hcintmsk;
2018+
u32 hcint, hcintraw, hcintmsk;
20192019

20202020
chan = hsotg->hc_ptr_array[chnum];
20212021

2022-
hcint = dwc2_readl(hsotg, HCINT(chnum));
2022+
hcintraw = dwc2_readl(hsotg, HCINT(chnum));
20232023
hcintmsk = dwc2_readl(hsotg, HCINTMSK(chnum));
2024+
hcint = hcintraw & hcintmsk;
2025+
dwc2_writel(hsotg, hcint, HCINT(chnum));
2026+
20242027
if (!chan) {
20252028
dev_err(hsotg->dev, "## hc_ptr_array for channel is NULL ##\n");
2026-
dwc2_writel(hsotg, hcint, HCINT(chnum));
20272029
return;
20282030
}
20292031

@@ -2032,11 +2034,9 @@ static void dwc2_hc_n_intr(struct dwc2_hsotg *hsotg, int chnum)
20322034
chnum);
20332035
dev_vdbg(hsotg->dev,
20342036
" hcint 0x%08x, hcintmsk 0x%08x, hcint&hcintmsk 0x%08x\n",
2035-
hcint, hcintmsk, hcint & hcintmsk);
2037+
hcintraw, hcintmsk, hcint);
20362038
}
20372039

2038-
dwc2_writel(hsotg, hcint, HCINT(chnum));
2039-
20402040
/*
20412041
* If we got an interrupt after someone called
20422042
* 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)
20462046
return;
20472047
}
20482048

2049-
chan->hcint = hcint;
2050-
hcint &= hcintmsk;
2049+
chan->hcint = hcintraw;
20512050

20522051
/*
20532052
* If the channel was halted due to a dequeue, the qtd list might

0 commit comments

Comments
 (0)