lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230109190914.3blihjfjdcszazdd@synopsys.com>
Date:   Mon, 9 Jan 2023 19:09:18 +0000
From:   Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To:     Thinh Nguyen <Thinh.Nguyen@...opsys.com>
CC:     JaeHun Jung <jh0801.jung@...sung.com>,
        Felipe Balbi <balbi@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "open list:USB XHCI DRIVER" <linux-usb@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        Seungchull Suh <sc.suh@...sung.com>,
        Daehwan Jung <dh10.jung@...sung.com>
Subject: Re: [PATCH] usb: dwc3: Clear DWC3_EVENT_PENDING when count is 0

On Mon, Jan 09, 2023, Thinh Nguyen wrote:
> Hi,
> 
> On Mon, Jan 02, 2023, JaeHun Jung wrote:
> > Sometimes very rarely, The count is 0 and the DWC3 flag is set has status.
> > It must not have these status. Because, It can make happen interrupt storming
> > status.
> > So, It have to clean up DWC3_EVENT_PENDING flags set when count is 0.
> > It means "There are no interrupts to handle.".
> 
> Can you reword to include the explanation from my response [*] and add a
> fixes tag to 7441b273388b ("usb: dwc3: gadget: Fix event pending check")
> 

Actually, the old problem that the commit 7441b273388b fixes may
resurface because of this change.

Can you try this instead?

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 65500246323b..3c36dfdb88f0 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -5515,8 +5515,15 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
         * irq event handler completes before caching new event to prevent
         * losing events.
         */
-       if (evt->flags & DWC3_EVENT_PENDING)
+       if (evt->flags & DWC3_EVENT_PENDING) {
+               if (!evt->count) {
+                       u32 reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
+
+                       if (!(reg & DWC3_GEVNTSIZ_INTMASK))
+                               evt->flags &= ~DWC3_EVENT_PENDING;
+               }
                return IRQ_HANDLED;
+       }


This is a quick solution at the moment. Let me know if you have have a
better option. Note that reading a register may take some time, albeit
short. That's why we may want to keep the evt->count check to help with
performance.

Thanks,
Thinh


> 
> 
> > 
> > (struct dwc3_event_buffer *) ev_buf = 0xFFFFFF883DBF1180 (
> > 	(void *) buf = 0xFFFFFFC00DBDD000 = end+0x337D000,
> > 	(void *) cache = 0xFFFFFF8839F54080,
> > 	(unsigned int) length = 0x1000,
> > 	(unsigned int) lpos = 0x0,
> > 	(unsigned int) count = 0x0,
> > 	(unsigned int) flags = 0x00000001,
> > 	(dma_addr_t) dma = 0x00000008BD7D7000,
> > 	(struct dwc3 *) dwc = 0xFFFFFF8839CBC880,
> > 	(u64) android_kabi_reserved1 = 0x0),
> > 
> > (time = 47557628930999, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628931268, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628932383, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628932652, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628933768, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628934037, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628935152, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628935460, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628936575, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628936845, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628937960, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628938229, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628939345, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628939652, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628940768, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628941037, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628942152, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628942422, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628943537, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628943806, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628944922, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628945229, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628946345, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628946614, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > (time = 47557628947729, irq = 165, fn = dwc3_interrupt, latency = 0, en = 1),
> > (time = 47557628947999, irq = 165, fn = dwc3_interrupt, latency = 0, en = 3),
> > 
> > Signed-off-by: JaeHun Jung <jh0801.jung@...sung.com>
> > ---
> >  drivers/usb/dwc3/gadget.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
> > index 789976567f9f..5d2d5a9b9915 100644
> > --- a/drivers/usb/dwc3/gadget.c
> > +++ b/drivers/usb/dwc3/gadget.c
> > @@ -4355,8 +4355,11 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
> >  	 * irq event handler completes before caching new event to prevent
> >  	 * losing events.
> >  	 */
> > -	if (evt->flags & DWC3_EVENT_PENDING)
> > +	if (evt->flags & DWC3_EVENT_PENDING) {
> > +		if (!evt->count)
> > +			evt->flags &= ~DWC3_EVENT_PENDING;
> >  		return IRQ_HANDLED;
> > +	}
> >  
> >  	count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
> >  	count &= DWC3_GEVNTCOUNT_MASK;
> > -- 
> > 2.31.1
> > 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ