Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1547274
| From | Baolin Wang <baolin.wang@linaro.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler |
| Date | 2016-12-26 09:10 +0100 |
| Message-ID | <sSyw1-28c-1@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
On some platfroms(like x86 platform), when one core is running the USB gadget
irq thread handler by dwc3_thread_interrupt(), meanwhile another core also can
respond other interrupts from dwc3 controller and modify the event buffer by
dwc3_interrupt() function, that will cause getting the wrong event count in
irq thread handler to make the USB function abnormal.
We should add spin_lock/unlock() in dwc3_check_event_buf() to avoid this race.
Signed-off-by: Baolin Wang <baolin.wang@linaro.org>
---
drivers/usb/dwc3/gadget.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index 6785595..1a1e1f4 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -2894,10 +2894,13 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
return IRQ_HANDLED;
}
+ spin_lock(&dwc->lock);
count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
count &= DWC3_GEVNTCOUNT_MASK;
- if (!count)
+ if (!count) {
+ spin_unlock(&dwc->lock);
return IRQ_NONE;
+ }
evt->count = count;
evt->flags |= DWC3_EVENT_PENDING;
@@ -2914,6 +2917,7 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
memcpy(evt->cache, evt->buf, count - amount);
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), count);
+ spin_unlock(&dwc->lock);
return IRQ_WAKE_THREAD;
}
--
1.7.9.5
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang <baolin.wang@linaro.org> - 2016-12-26 09:10 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Lu Baolu <baolu.lu@linux.intel.com> - 2016-12-27 03:50 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang <baolin.wang@linaro.org> - 2016-12-27 04:00 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Lu Baolu <baolu.lu@linux.intel.com> - 2016-12-27 05:50 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Felipe Balbi <balbi@kernel.org> - 2016-12-27 12:10 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Janusz Dziedzic <janusz.dziedzic@gmail.com> - 2016-12-28 16:30 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Felipe Balbi <balbi@kernel.org> - 2016-12-28 17:30 +0100
RE: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler John Youn <John.Youn@synopsys.com> - 2016-12-29 02:40 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Janusz Dziedzic <janusz.dziedzic@gmail.com> - 2016-12-27 12:00 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang <baolin.wang@linaro.org> - 2016-12-27 12:10 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Felipe Balbi <balbi@kernel.org> - 2016-12-27 12:20 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang <baolin.wang@linaro.org> - 2016-12-27 13:20 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Janusz Dziedzic <janusz.dziedzic@gmail.com> - 2016-12-28 13:40 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang <baolin.wang@linaro.org> - 2017-01-03 13:30 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Felipe Balbi <balbi@kernel.org> - 2017-01-03 13:40 +0100
Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Felipe Balbi <balbi@kernel.org> - 2016-12-27 12:10 +0100
csiph-web