Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1547274 > unrolled thread

[PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

Started byBaolin Wang <baolin.wang@linaro.org>
First post2016-12-26 09:10 +0100
Last post2016-12-27 12:10 +0100
Articles 16 — 5 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1547274 — [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromBaolin Wang <baolin.wang@linaro.org>
Date2016-12-26 09:10 +0100
Subject[PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSyw1-28c-1@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1547470 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromLu Baolu <baolu.lu@linux.intel.com>
Date2016-12-27 03:50 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSPZT-4zE-1@gated-at.bofh.it>
In reply to#1547274
Hi,

On 12/26/2016 04:01 PM, Baolin Wang wrote:
> 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.

Why not spin_lock_irq ones? This lock seems to be used in both
normal and interrupt threads. Or, I missed anything?

Best regards,
Lu Baolu

>
> 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;
>  }

[toc] | [prev] | [next] | [standalone]


#1547474 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromBaolin Wang <baolin.wang@linaro.org>
Date2016-12-27 04:00 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSQ9z-4CO-5@gated-at.bofh.it>
In reply to#1547470
Hi,

On 27 December 2016 at 10:39, Lu Baolu <baolu.lu@linux.intel.com> wrote:
> Hi,
>
> On 12/26/2016 04:01 PM, Baolin Wang wrote:
>> 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.
>
> Why not spin_lock_irq ones? This lock seems to be used in both
> normal and interrupt threads. Or, I missed anything?

I assumed there are no nested interrupts, when one core is running at
interrupt context, then it can not respond any other interrupts, which
means we don't need to disable local IRQ now, right?

-- 
Baolin.wang
Best Regards

[toc] | [prev] | [next] | [standalone]


#1547492 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromLu Baolu <baolu.lu@linux.intel.com>
Date2016-12-27 05:50 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSRS2-5P2-1@gated-at.bofh.it>
In reply to#1547474
Hi,

On 12/27/2016 10:58 AM, Baolin Wang wrote:
> Hi,
>
> On 27 December 2016 at 10:39, Lu Baolu <baolu.lu@linux.intel.com> wrote:
>> Hi,
>>
>> On 12/26/2016 04:01 PM, Baolin Wang wrote:
>>> 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.
>> Why not spin_lock_irq ones? This lock seems to be used in both
>> normal and interrupt threads. Or, I missed anything?
> I assumed there are no nested interrupts, when one core is running at
> interrupt context, then it can not respond any other interrupts, which
> means we don't need to disable local IRQ now, right?
>

Fair enough. Thanks.

Best regards,
Lu Baolu

[toc] | [prev] | [next] | [standalone]


#1547558

FromFelipe Balbi <balbi@kernel.org>
Date2016-12-27 12:10 +0100
Message-ID<sSXNM-1f9-17@gated-at.bofh.it>
In reply to#1547470

[Multipart message — attachments visible in raw view] — view raw

Hi,

Lu Baolu <baolu.lu@linux.intel.com> writes:
> On 12/26/2016 04:01 PM, Baolin Wang wrote:
>> 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.
>
> Why not spin_lock_irq ones? This lock seems to be used in both
> normal and interrupt threads. Or, I missed anything?

this is top half handler. Interrupts are already disabled.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1547995 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromJanusz Dziedzic <janusz.dziedzic@gmail.com>
Date2016-12-28 16:30 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sTokW-1Dj-23@gated-at.bofh.it>
In reply to#1547558
2016-12-27 12:05 GMT+01:00 Felipe Balbi <balbi@kernel.org>:
> Hi,
>
> Lu Baolu <baolu.lu@linux.intel.com> writes:
>> On 12/26/2016 04:01 PM, Baolin Wang wrote:
>>> 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.
>>
>> Why not spin_lock_irq ones? This lock seems to be used in both
>> normal and interrupt threads. Or, I missed anything?
>
> this is top half handler. Interrupts are already disabled.
>
BTW,
We don't use spin_lock in top half handler.
Maybe we should/can switch all spin_lock_irqsave() to simple
spin_lock() in the thread/callbacks?
Or there is a reason to use irqsave() version?

BR
Janusz

> --
> balbi



-- 
Janusz Dziedzic

[toc] | [prev] | [next] | [standalone]


#1548016

FromFelipe Balbi <balbi@kernel.org>
Date2016-12-28 17:30 +0100
Message-ID<sTpgZ-2fa-1@gated-at.bofh.it>
In reply to#1547995
Hi,

Janusz Dziedzic <janusz.dziedzic@gmail.com> writes:
>>>> 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.
>>>
>>> Why not spin_lock_irq ones? This lock seems to be used in both
>>> normal and interrupt threads. Or, I missed anything?
>>
>> this is top half handler. Interrupts are already disabled.
>>
> BTW,
> We don't use spin_lock in top half handler.
> Maybe we should/can switch all spin_lock_irqsave() to simple
> spin_lock() in the thread/callbacks?

in theory, yes we've masked all interrupts from this controller for the
duration of the thread handler. However this breaks networking
gadgets. I can only guess network stack has a hard requirement to run
with IRQs disabled.

> Or there is a reason to use irqsave() version?

see above :-)

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1548168 — RE: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromJohn Youn <John.Youn@synopsys.com>
Date2016-12-29 02:40 +0100
SubjectRE: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sTxRf-8j3-5@gated-at.bofh.it>
In reply to#1548016

> -----Original Message-----
> From: linux-usb-owner@vger.kernel.org [mailto:linux-usb-
> owner@vger.kernel.org] On Behalf Of Felipe Balbi
> Sent: Wednesday, December 28, 2016 8:19 AM
> To: Janusz Dziedzic <janusz.dziedzic@gmail.com>
> Cc: Lu Baolu <baolu.lu@linux.intel.com>; Baolin Wang
> <baolin.wang@linaro.org>; Greg KH <gregkh@linuxfoundation.org>; USB
> <linux-usb@vger.kernel.org>; LKML <linux-kernel@vger.kernel.org>; Linaro
> Kernel Mailman List <linaro-kernel@lists.linaro.org>; Mark Brown
> <broonie@kernel.org>
> Subject: Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt
> handler and irq thread handler
> 
> 
> Hi,
> 
> Janusz Dziedzic <janusz.dziedzic@gmail.com> writes:
> >>>> 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.
> >>>
> >>> Why not spin_lock_irq ones? This lock seems to be used in both
> >>> normal and interrupt threads. Or, I missed anything?
> >>
> >> this is top half handler. Interrupts are already disabled.
> >>
> > BTW,
> > We don't use spin_lock in top half handler.
> > Maybe we should/can switch all spin_lock_irqsave() to simple
> > spin_lock() in the thread/callbacks?
> 
> in theory, yes we've masked all interrupts from this controller for the
> duration of the thread handler. However this breaks networking
> gadgets. I can only guess network stack has a hard requirement to run
> with IRQs disabled.
> 

Hi,

Is this version 3.00a of the core?

That version has a STAR where the interrupts cannot be masked. That results in similar symptoms to what you're seeing here.

Regards,
John

[toc] | [prev] | [next] | [standalone]


#1547552 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromJanusz Dziedzic <janusz.dziedzic@gmail.com>
Date2016-12-27 12:00 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSXE5-Wv-1@gated-at.bofh.it>
In reply to#1547274
2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
> 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.
>
Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
DWC3_GEVNTSIZ_INTMASK
And unmask interrupt when we end dwc3_thread_interrupt().

So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
or I miss something?
Do you have some traces that indicate this masking will not work correctly?

BTW, what value you get when problem occured, 0xFFFC?

BR
Janusz

> 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
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Janusz Dziedzic

[toc] | [prev] | [next] | [standalone]


#1547556 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromBaolin Wang <baolin.wang@linaro.org>
Date2016-12-27 12:10 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSXNL-1f9-1@gated-at.bofh.it>
In reply to#1547552
Hi,

On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>> 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.
>>
> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
> DWC3_GEVNTSIZ_INTMASK
> And unmask interrupt when we end dwc3_thread_interrupt().
>
> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
> or I miss something?
> Do you have some traces that indicate this masking will not work correctly?

Yes, but we just masked the interrupts described in DEVTEN register,
and we did not mask all the interrupts, like the endpoint command
complete event, transfer complete event and so on, so we can still get
interrupts.

>
> BTW, what value you get when problem occured, 0xFFFC?

Yes, something like this, the event count become huge.

>
> BR
> Janusz
>
>> 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
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>
> --
> Janusz Dziedzic



-- 
Baolin.wang
Best Regards

[toc] | [prev] | [next] | [standalone]


#1547559

FromFelipe Balbi <balbi@kernel.org>
Date2016-12-27 12:20 +0100
Message-ID<sSXXr-1k1-3@gated-at.bofh.it>
In reply to#1547556

[Multipart message — attachments visible in raw view] — view raw

Hi,

Baolin Wang <baolin.wang@linaro.org> writes:
> Hi,
>
> On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>> 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.
>>>
>> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
>> DWC3_GEVNTSIZ_INTMASK
>> And unmask interrupt when we end dwc3_thread_interrupt().
>>
>> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
>> or I miss something?
>> Do you have some traces that indicate this masking will not work correctly?
>
> Yes, but we just masked the interrupts described in DEVTEN register,
> and we did not mask all the interrupts, like the endpoint command
> complete event, transfer complete event and so on, so we can still get
> interrupts.

not true, we masked interrupts for the entire event buffer:

> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
> {
> 	struct dwc3 *dwc = evt->dwc;
> 	u32 count;
> 	u32 reg;
>
> 	if (pm_runtime_suspended(dwc->dev)) {
> 		pm_runtime_get(dwc->dev);
> 		disable_irq_nosync(dwc->irq_gadget);
> 		dwc->pending_events = true;
> 		return IRQ_HANDLED;
> 	}
>
> 	count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
> 	count &= DWC3_GEVNTCOUNT_MASK;
> 	if (!count)
> 		return IRQ_NONE;
>
> 	evt->count = count;
> 	evt->flags |= DWC3_EVENT_PENDING;
>
> 	/* Mask interrupt */
> 	reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
> 	reg |= DWC3_GEVNTSIZ_INTMASK;

See here ?!?

> 	dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>
> 	return IRQ_WAKE_THREAD;
> }

>> BTW, what value you get when problem occured, 0xFFFC?
>
> Yes, something like this, the event count become huge.

please send us tracepoint data. You probably need to compress
it. Something like 256k of trace data is probably enough, so:

# mkdir -p /t
# mount -t tracefs none /t
# cd /t
# echo 256 > buffer_size_kb
# echo 1 > events/dwc3/enable
# echo 0 > events/dwc3/dwc3_readl/enable
# echo 0 > events/dwc3/dwc3_writel/enable

(reproduce)

# cp /t/trace /path/to/non-volatile/media/trace.txt

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1547580 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromBaolin Wang <baolin.wang@linaro.org>
Date2016-12-27 13:20 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sSYTv-1VT-9@gated-at.bofh.it>
In reply to#1547559
Hi,

On 27 December 2016 at 19:11, Felipe Balbi <balbi@kernel.org> wrote:
>
> Hi,
>
> Baolin Wang <baolin.wang@linaro.org> writes:
>> Hi,
>>
>> On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>>> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>>> 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.
>>>>
>>> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
>>> DWC3_GEVNTSIZ_INTMASK
>>> And unmask interrupt when we end dwc3_thread_interrupt().
>>>
>>> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
>>> or I miss something?
>>> Do you have some traces that indicate this masking will not work correctly?
>>
>> Yes, but we just masked the interrupts described in DEVTEN register,
>> and we did not mask all the interrupts, like the endpoint command
>> complete event, transfer complete event and so on, so we can still get
>> interrupts.
>
> not true, we masked interrupts for the entire event buffer:

Yes, you are right and I missed that. I should reproduce this problem
and analyse the real reason.

>
>> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>> {
>>       struct dwc3 *dwc = evt->dwc;
>>       u32 count;
>>       u32 reg;
>>
>>       if (pm_runtime_suspended(dwc->dev)) {
>>               pm_runtime_get(dwc->dev);
>>               disable_irq_nosync(dwc->irq_gadget);
>>               dwc->pending_events = true;
>>               return IRQ_HANDLED;
>>       }
>>
>>       count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
>>       count &= DWC3_GEVNTCOUNT_MASK;
>>       if (!count)
>>               return IRQ_NONE;
>>
>>       evt->count = count;
>>       evt->flags |= DWC3_EVENT_PENDING;
>>
>>       /* Mask interrupt */
>>       reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
>>       reg |= DWC3_GEVNTSIZ_INTMASK;
>
> See here ?!?
>
>>       dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>>
>>       return IRQ_WAKE_THREAD;
>> }
>
>>> BTW, what value you get when problem occured, 0xFFFC?
>>
>> Yes, something like this, the event count become huge.
>
> please send us tracepoint data. You probably need to compress
> it. Something like 256k of trace data is probably enough, so:
>
> # mkdir -p /t
> # mount -t tracefs none /t
> # cd /t
> # echo 256 > buffer_size_kb
> # echo 1 > events/dwc3/enable
> # echo 0 > events/dwc3/dwc3_readl/enable
> # echo 0 > events/dwc3/dwc3_writel/enable
>
> (reproduce)
>
> # cp /t/trace /path/to/non-volatile/media/trace.txt

Okay, I try to do that. Thanks.

-- 
Baolin.wang
Best Regards

[toc] | [prev] | [next] | [standalone]


#1547942 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromJanusz Dziedzic <janusz.dziedzic@gmail.com>
Date2016-12-28 13:40 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sTlGq-8ds-19@gated-at.bofh.it>
In reply to#1547580
2016-12-27 13:16 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
> Hi,
>
> On 27 December 2016 at 19:11, Felipe Balbi <balbi@kernel.org> wrote:
>>
>> Hi,
>>
>> Baolin Wang <baolin.wang@linaro.org> writes:
>>> Hi,
>>>
>>> On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>>>> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>>>> 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.
>>>>>
>>>> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
>>>> DWC3_GEVNTSIZ_INTMASK
>>>> And unmask interrupt when we end dwc3_thread_interrupt().
>>>>
>>>> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
>>>> or I miss something?
>>>> Do you have some traces that indicate this masking will not work correctly?
>>>
>>> Yes, but we just masked the interrupts described in DEVTEN register,
>>> and we did not mask all the interrupts, like the endpoint command
>>> complete event, transfer complete event and so on, so we can still get
>>> interrupts.
>>
>> not true, we masked interrupts for the entire event buffer:
>
> Yes, you are right and I missed that. I should reproduce this problem
> and analyse the real reason.
>
>>
>>> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>>> {
>>>       struct dwc3 *dwc = evt->dwc;
>>>       u32 count;
>>>       u32 reg;
>>>
>>>       if (pm_runtime_suspended(dwc->dev)) {
>>>               pm_runtime_get(dwc->dev);
>>>               disable_irq_nosync(dwc->irq_gadget);
>>>               dwc->pending_events = true;
>>>               return IRQ_HANDLED;
>>>       }
>>>
>>>       count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
>>>       count &= DWC3_GEVNTCOUNT_MASK;
>>>       if (!count)
>>>               return IRQ_NONE;
>>>
>>>       evt->count = count;
>>>       evt->flags |= DWC3_EVENT_PENDING;
>>>
>>>       /* Mask interrupt */
>>>       reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
>>>       reg |= DWC3_GEVNTSIZ_INTMASK;
>>
>> See here ?!?
>>
>>>       dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>>>
>>>       return IRQ_WAKE_THREAD;
>>> }
>>
>>>> BTW, what value you get when problem occured, 0xFFFC?
>>>
>>> Yes, something like this, the event count become huge.
>>
Probably you have little bit different code than current community
version (depends how your PM works).

This is possible when we write:
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
And after that
dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4);

After that we will get 0xFFFC (-4).

Possible races:
1) dwc3_event_buffers_setup/dwc3_event_buffers_cleanup - write 0
2) dwc3_thread - write 4

While [1] could be called in PM work or UM context (init in Android
case) spin_lock_irqsave() will only disable local irqs and still we
could get IRQ on different core, next update evt->count and run
thread...

So, seems your patch will solve this.

I am not sure this problem could be also visible in community current version.

Anyway, thanks for handling this.

BR
Janusz
>> please send us tracepoint data. You probably need to compress
>> it. Something like 256k of trace data is probably enough, so:
>>
>> # mkdir -p /t
>> # mount -t tracefs none /t
>> # cd /t
>> # echo 256 > buffer_size_kb
>> # echo 1 > events/dwc3/enable
>> # echo 0 > events/dwc3/dwc3_readl/enable
>> # echo 0 > events/dwc3/dwc3_writel/enable
>>
>> (reproduce)
>>
>> # cp /t/trace /path/to/non-volatile/media/trace.txt
>
> Okay, I try to do that. Thanks.
>
> --
> Baolin.wang
> Best Regards



-- 
Janusz Dziedzic

[toc] | [prev] | [next] | [standalone]


#1549741 — Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler

FromBaolin Wang <baolin.wang@linaro.org>
Date2017-01-03 13:30 +0100
SubjectRe: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Message-ID<sVwo2-64j-13@gated-at.bofh.it>
In reply to#1547942
On 28 December 2016 at 20:30, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
> 2016-12-27 13:16 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>> Hi,
>>
>> On 27 December 2016 at 19:11, Felipe Balbi <balbi@kernel.org> wrote:
>>>
>>> Hi,
>>>
>>> Baolin Wang <baolin.wang@linaro.org> writes:
>>>> Hi,
>>>>
>>>> On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>>>>> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>>>>> 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.
>>>>>>
>>>>> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
>>>>> DWC3_GEVNTSIZ_INTMASK
>>>>> And unmask interrupt when we end dwc3_thread_interrupt().
>>>>>
>>>>> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
>>>>> or I miss something?
>>>>> Do you have some traces that indicate this masking will not work correctly?
>>>>
>>>> Yes, but we just masked the interrupts described in DEVTEN register,
>>>> and we did not mask all the interrupts, like the endpoint command
>>>> complete event, transfer complete event and so on, so we can still get
>>>> interrupts.
>>>
>>> not true, we masked interrupts for the entire event buffer:
>>
>> Yes, you are right and I missed that. I should reproduce this problem
>> and analyse the real reason.
>>
>>>
>>>> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>>>> {
>>>>       struct dwc3 *dwc = evt->dwc;
>>>>       u32 count;
>>>>       u32 reg;
>>>>
>>>>       if (pm_runtime_suspended(dwc->dev)) {
>>>>               pm_runtime_get(dwc->dev);
>>>>               disable_irq_nosync(dwc->irq_gadget);
>>>>               dwc->pending_events = true;
>>>>               return IRQ_HANDLED;
>>>>       }
>>>>
>>>>       count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
>>>>       count &= DWC3_GEVNTCOUNT_MASK;
>>>>       if (!count)
>>>>               return IRQ_NONE;
>>>>
>>>>       evt->count = count;
>>>>       evt->flags |= DWC3_EVENT_PENDING;
>>>>
>>>>       /* Mask interrupt */
>>>>       reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
>>>>       reg |= DWC3_GEVNTSIZ_INTMASK;
>>>
>>> See here ?!?
>>>
>>>>       dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>>>>
>>>>       return IRQ_WAKE_THREAD;
>>>> }
>>>
>>>>> BTW, what value you get when problem occured, 0xFFFC?
>>>>
>>>> Yes, something like this, the event count become huge.
>>>
> Probably you have little bit different code than current community
> version (depends how your PM works).
>
> This is possible when we write:
> dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
> And after that
> dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4);
>
> After that we will get 0xFFFC (-4).
>
> Possible races:
> 1) dwc3_event_buffers_setup/dwc3_event_buffers_cleanup - write 0
> 2) dwc3_thread - write 4
>
> While [1] could be called in PM work or UM context (init in Android
> case) spin_lock_irqsave() will only disable local irqs and still we
> could get IRQ on different core, next update evt->count and run
> thread...

Yeah, that's the possible races.

>
> So, seems your patch will solve this.
>
> I am not sure this problem could be also visible in community current version.
>
> Anyway, thanks for handling this.
>
> BR
> Janusz
>>> please send us tracepoint data. You probably need to compress
>>> it. Something like 256k of trace data is probably enough, so:
>>>
>>> # mkdir -p /t
>>> # mount -t tracefs none /t
>>> # cd /t
>>> # echo 256 > buffer_size_kb
>>> # echo 1 > events/dwc3/enable
>>> # echo 0 > events/dwc3/dwc3_readl/enable
>>> # echo 0 > events/dwc3/dwc3_writel/enable
>>>
>>> (reproduce)
>>>
>>> # cp /t/trace /path/to/non-volatile/media/trace.txt
>>
>> Okay, I try to do that. Thanks.
>>
>> --
>> Baolin.wang
>> Best Regards
>
>
>
> --
> Janusz Dziedzic



-- 
Baolin.wang
Best Regards

[toc] | [prev] | [next] | [standalone]


#1549772

FromFelipe Balbi <balbi@kernel.org>
Date2017-01-03 13:40 +0100
Message-ID<sVwxH-67Q-23@gated-at.bofh.it>
In reply to#1549741

[Multipart message — attachments visible in raw view] — view raw

Hi,

Baolin Wang <baolin.wang@linaro.org> writes:
> On 28 December 2016 at 20:30, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>> 2016-12-27 13:16 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>> Hi,
>>>
>>> On 27 December 2016 at 19:11, Felipe Balbi <balbi@kernel.org> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Baolin Wang <baolin.wang@linaro.org> writes:
>>>>> Hi,
>>>>>
>>>>> On 27 December 2016 at 18:52, Janusz Dziedzic <janusz.dziedzic@gmail.com> wrote:
>>>>>> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>>>>>>> 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.
>>>>>>>
>>>>>> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
>>>>>> DWC3_GEVNTSIZ_INTMASK
>>>>>> And unmask interrupt when we end dwc3_thread_interrupt().
>>>>>>
>>>>>> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
>>>>>> or I miss something?
>>>>>> Do you have some traces that indicate this masking will not work correctly?
>>>>>
>>>>> Yes, but we just masked the interrupts described in DEVTEN register,
>>>>> and we did not mask all the interrupts, like the endpoint command
>>>>> complete event, transfer complete event and so on, so we can still get
>>>>> interrupts.
>>>>
>>>> not true, we masked interrupts for the entire event buffer:
>>>
>>> Yes, you are right and I missed that. I should reproduce this problem
>>> and analyse the real reason.
>>>
>>>>
>>>>> static irqreturn_t dwc3_check_event_buf(struct dwc3_event_buffer *evt)
>>>>> {
>>>>>       struct dwc3 *dwc = evt->dwc;
>>>>>       u32 count;
>>>>>       u32 reg;
>>>>>
>>>>>       if (pm_runtime_suspended(dwc->dev)) {
>>>>>               pm_runtime_get(dwc->dev);
>>>>>               disable_irq_nosync(dwc->irq_gadget);
>>>>>               dwc->pending_events = true;
>>>>>               return IRQ_HANDLED;
>>>>>       }
>>>>>
>>>>>       count = dwc3_readl(dwc->regs, DWC3_GEVNTCOUNT(0));
>>>>>       count &= DWC3_GEVNTCOUNT_MASK;
>>>>>       if (!count)
>>>>>               return IRQ_NONE;
>>>>>
>>>>>       evt->count = count;
>>>>>       evt->flags |= DWC3_EVENT_PENDING;
>>>>>
>>>>>       /* Mask interrupt */
>>>>>       reg = dwc3_readl(dwc->regs, DWC3_GEVNTSIZ(0));
>>>>>       reg |= DWC3_GEVNTSIZ_INTMASK;
>>>>
>>>> See here ?!?
>>>>
>>>>>       dwc3_writel(dwc->regs, DWC3_GEVNTSIZ(0), reg);
>>>>>
>>>>>       return IRQ_WAKE_THREAD;
>>>>> }
>>>>
>>>>>> BTW, what value you get when problem occured, 0xFFFC?
>>>>>
>>>>> Yes, something like this, the event count become huge.
>>>>
>> Probably you have little bit different code than current community
>> version (depends how your PM works).
>>
>> This is possible when we write:
>> dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 0);
>> And after that
>> dwc3_writel(dwc->regs, DWC3_GEVNTCOUNT(0), 4);
>>
>> After that we will get 0xFFFC (-4).
>>
>> Possible races:
>> 1) dwc3_event_buffers_setup/dwc3_event_buffers_cleanup - write 0
>> 2) dwc3_thread - write 4
>>
>> While [1] could be called in PM work or UM context (init in Android
>> case) spin_lock_irqsave() will only disable local irqs and still we
>> could get IRQ on different core, next update evt->count and run
>> thread...
>
> Yeah, that's the possible races.

and you have triggered this with mailine? How? We don't write to GEVNT*
registers from PM code and we only allow runtime_suspend with cable
dettached.

-- 
balbi

[toc] | [prev] | [next] | [standalone]


#1547557

FromFelipe Balbi <balbi@kernel.org>
Date2016-12-27 12:10 +0100
Message-ID<sSXNL-1f9-7@gated-at.bofh.it>
In reply to#1547552

[Multipart message — attachments visible in raw view] — view raw

Hi,

Janusz Dziedzic <janusz.dziedzic@gmail.com> writes:
> 2016-12-26 9:01 GMT+01:00 Baolin Wang <baolin.wang@linaro.org>:
>> 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.
>>
> Interesting, I always think we mask interrupt in dwc3_interrupt() by setting
> DWC3_GEVNTSIZ_INTMASK
> And unmask interrupt when we end dwc3_thread_interrupt().
>
> So, we shouldn't get any IRQ from HW during dwc3_thread_interrupt(),
> or I miss something?
> Do you have some traces that indicate this masking will not work correctly?

that's the very question I have. We are already masking interrupts from
this controller. The only thing this could race with is usb_ep_queue(),
but that gets nowhere close to anything we're doing in the top half
handler, so there's really no danger of anything bad happening.

I'd like to see traces as well.

-- 
balbi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web