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


Groups > linux.kernel > #1548016

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

From Felipe Balbi <balbi@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler
Date 2016-12-28 17:30 +0100
Message-ID <sTpgZ-2fa-1@gated-at.bofh.it> (permalink)
References <sSyw1-28c-1@gated-at.bofh.it> <sSPZT-4zE-1@gated-at.bofh.it> <sSXNM-1f9-17@gated-at.bofh.it> <sTokW-1Dj-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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