From: John Youn <John.Youn@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
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
Date: Thu, 5 Jan 2017 11:08:32 -0800 [thread overview]
Message-ID: <0ac76b9b-c12b-866b-f76e-99380b7126fd@synopsys.com> (raw)
In-Reply-To: <2B3535C5ECE8B5419E3ECBE300772909021B3DECCC@US01WEMBX2.internal.synopsys.com>
On 12/28/2016 5:29 PM, John Youn wrote:
>
>
>> 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
>
Didn't see any response to this. Just want to make sure this
possibility is addressed as there is a workaround for it on mainline.
See the following commits for details:
d9fa4c63f766 ("usb: dwc3: core: add a event buffer cache")
ebbb2d59398f ("usb: dwc3: gadget: use evt->cache for processing events")
65aca3205046 ("usb: dwc3: gadget: clear events in top-half handler")
cf40b86b6ef6 ("usb: dwc3: Implement interrupt moderation")
28632b44d129 ("usb: dwc3: Workaround for irq mask issue")
Regards,
John
next prev parent reply other threads:[~2017-01-05 19:09 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-26 8:01 [PATCH] usb: dwc3: gadget: Avoid race between dwc3 interrupt handler and irq thread handler Baolin Wang
2016-12-27 2:39 ` Lu Baolu
2016-12-27 2:58 ` Baolin Wang
2016-12-27 4:45 ` Lu Baolu
2016-12-27 11:05 ` Felipe Balbi
2016-12-28 15:27 ` Janusz Dziedzic
2016-12-28 16:19 ` Felipe Balbi
2016-12-29 1:29 ` John Youn
2017-01-05 19:08 ` John Youn [this message]
2017-01-06 2:44 ` Baolin Wang
2016-12-27 10:52 ` Janusz Dziedzic
2016-12-27 11:06 ` Baolin Wang
2016-12-27 11:11 ` Felipe Balbi
2016-12-27 12:16 ` Baolin Wang
2016-12-28 12:30 ` Janusz Dziedzic
2017-01-03 12:21 ` Baolin Wang
2017-01-03 12:33 ` Felipe Balbi
2017-01-05 2:07 ` Baolin Wang
2017-01-05 9:26 ` Felipe Balbi
2017-01-05 9:43 ` Baolin Wang
2017-01-05 11:19 ` Felipe Balbi
2017-01-05 12:03 ` Baolin Wang
2016-12-27 11:07 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ac76b9b-c12b-866b-f76e-99380b7126fd@synopsys.com \
--to=john.youn@synopsys.com \
--cc=balbi@kernel.org \
--cc=baolin.wang@linaro.org \
--cc=baolu.lu@linux.intel.com \
--cc=broonie@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=janusz.dziedzic@gmail.com \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).