All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <felipe.balbi@linux.intel.com>
To: "Wang, Yu1" <yu1.wang@intel.com>
Cc: "He, Bo" <bo.he@intel.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Linux USB <linux-usb@vger.kernel.org>,
	"Wang, Yu Y" <yu.y.wang@intel.com>,
	'Linux Samsung SOC' <linux-samsung-soc@vger.kernel.org>
Subject: usb: dwc3: gadget: synchronize_irq dwc irq in suspend
Date: Wed, 30 Jan 2019 08:53:06 +0200	[thread overview]
Message-ID: <87pnsefxgt.fsf@linux.intel.com> (raw)

Hi,

"Wang, Yu1" <yu1.wang@intel.com> writes:
>> > 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()
>> 
>> indeed, I missed that when I first reviewed the patch. Care to send a fix?
> With this new change, the dwc3 irq thread will be sync after dwc3
> stopped, is this irq thread can be handled correctly for this case?

how about this?

modified   drivers/usb/dwc3/gadget.c
@@ -3373,6 +3373,8 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
 }
 
 int dwc3_gadget_suspend(struct dwc3 *dwc)
+	__releases(dwc->lock)
+	__acquires(dwc->lock)
 {
 	if (!dwc->gadget_driver)
 		return 0;
@@ -3381,7 +3383,9 @@ int dwc3_gadget_suspend(struct dwc3 *dwc)
 	dwc3_disconnect_gadget(dwc);
 	__dwc3_gadget_stop(dwc);
 
+	spin_unlock_irq(dwc->lock);
 	synchronize_irq(dwc->irq_gadget);
+	spin_lock_irq(dwc->lock);
 
 	return 0;
 }

Not the most elegant solution. I'm open to other suggestions.

             reply	other threads:[~2019-01-30  6:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30  6:53 Felipe Balbi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-02-08 11:00 usb: dwc3: gadget: synchronize_irq dwc irq in suspend Marek Szyprowski
2019-01-30  8:11 Marek Szyprowski
2019-01-29 10:44 Felipe Balbi
2019-01-28 22:58 He, Bo
2019-01-28 14:53 Marek Szyprowski
2019-01-28 13:30 Felipe Balbi
2019-01-22 14:04 Marek Szyprowski
2019-01-14  8:30 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=87pnsefxgt.fsf@linux.intel.com \
    --to=felipe.balbi@linux.intel.com \
    --cc=bo.he@intel.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=yu.y.wang@intel.com \
    --cc=yu1.wang@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.