Hi, Janusz Dziedzic <janusz.dziedzic@xxxxxxxxx> writes: > On 15 November 2016 at 12:23, Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> wrote: >> From: John Youn <johnyoun@xxxxxxxxxxxx> >> >> Let's start copying events from evt->buf to >> evt->cache and use evt->cache for processing events. >> >> A follow-up patch will be added to clear events in >> the top-half handler in order to bring IRQ line low >> as soon as possible. >> >> Signed-off-by: John Youn <johnyoun@xxxxxxxxxxxx> >> Signed-off-by: Felipe Balbi <felipe.balbi@xxxxxxxxxxxxxxx> >> --- >> drivers/usb/dwc3/gadget.c | 9 ++++++++- >> 1 file changed, 8 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c >> index 304653fd9223..0481cb7d7142 100644 >> --- a/drivers/usb/dwc3/gadget.c >> +++ b/drivers/usb/dwc3/gadget.c >> @@ -2821,7 +2821,7 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3_event_buffer *evt) >> while (left > 0) { >> union dwc3_event event; >> >> - event.raw = *(u32 *) (evt->buf + evt->lpos); >> + event.raw = *(u32 *) (evt->cache + evt->lpos); >> >> dwc3_process_event_entry(dwc, &event); >> >> @@ -2869,6 +2869,7 @@ static irqreturn_t dwc3_thread_interrupt(int irq, void *_evt) >> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt) >> { >> struct dwc3 *dwc = evt->dwc; >> + u32 amount; >> u32 count; >> u32 reg; >> >> @@ -2892,6 +2893,12 @@ static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt) >> reg |= DWC3_GEVNTSIZ_INTMASK; >> dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg); >> >> + amount = min(count, evt->length - evt->lpos); >> + memcpy(evt->cache + evt->lpos, evt->buf + evt->lpos, amount); >> + > Why not just: > memcpy(evt->cache, evt->buf + evt->lpos, count) > And always handle evt->cache[0 ... count] in thread_interrupt. This won't always work. evt->buf is treated by HW as a ring buffer, so if count + lpos > length, then we would copy from outside our event buffer. -- balbi
Attachment:
signature.asc
Description: PGP signature