agree your findings.

so it's better move the synchronize_irq() after the spin_unlock_irqrestore().
static int dwc3_suspend_common(struct dwc3 *dwc)
{
        unsigned long   flags;

        switch (dwc->dr_mode) {
        case USB_DR_MODE_PERIPHERAL:
        case USB_DR_MODE_OTG:
                spin_lock_irqsave(&dwc->lock, flags);
                dwc3_gadget_suspend(dwc);
                spin_unlock_irqrestore(&dwc->lock, flags);
                synchronize_irq()

-----Original Message-----
From: Marek Szyprowski <m.szyprow...@samsung.com> 
Sent: Monday, January 28, 2019 10:53 PM
To: Felipe Balbi <felipe.ba...@linux.intel.com>; Linux USB 
<linux-usb@vger.kernel.org>
Cc: He, Bo <bo...@intel.com>; Wang, Yu Y <yu.y.w...@intel.com>; 'Linux Samsung 
SOC' <linux-samsung-...@vger.kernel.org>
Subject: Re: [PATCH] usb: dwc3: gadget: synchronize_irq dwc irq in suspend

Hi Felipe,

On 2019-01-28 14:30, Felipe Balbi wrote:
> Marek Szyprowski <m.szyprow...@samsung.com> writes:
>> On 2019-01-14 09:30, Felipe Balbi wrote:
>>> From: Bo He <bo...@intel.com>
>>>
>>> We see dwc3 endpoint stopped by unwanted irq during suspend resume 
>>> test, which is caused dwc3 ep can't be started with error "No 
>>> Resource".
>>>
>>> Here, add synchronize_irq before suspend to sync the pending IRQ 
>>> handlers complete.
>>>
>>> Signed-off-by: Bo He <bo...@intel.com>
>>> Signed-off-by: Yu Wang <yu.y.w...@intel.com>
>>> Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
>> This patch causes following kernel BUG on Samsung Exynos based 
>> platforms during system suspend/resume cycle:
> are you calling ->suspend() from ->suspend_noirq() time? Are we not 
> allowed to call synchronize_irq() during ->suspend()?

dwc3_suspend_common() calls dwc3_gadget_suspend() with dwc->lock spinlock held. 
This is not the proper context for calling sleeping functions like 
synchronize_irq().

Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland

Reply via email to