From: Felipe Balbi <balbi@kernel.org>
To: Roger Quadros <rogerq@ti.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [2/2] usb: dwc3: drd: Fix lock-up on ID change during system suspend/resume
Date: Mon, 12 Feb 2018 10:54:56 +0200 [thread overview]
Message-ID: <87y3jya8pr.fsf@linux.intel.com> (raw)
Hi,
Roger Quadros <rogerq@ti.com> writes:
> Adding/removing host/gadget controller before .pm_complete()
> causes a lock-up. Let's prevent any dual-role state change
> between .pm_prepare() and .pm_complete() to fix this.
>
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> ---
> drivers/usb/dwc3/core.c | 31 +++++++++++++++++++++++++++++++
> drivers/usb/dwc3/core.h | 5 +++++
> drivers/usb/dwc3/drd.c | 10 ++++++----
> 3 files changed, 42 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 42379cc..85388dd 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1414,6 +1414,33 @@ static int dwc3_runtime_idle(struct device *dev)
> #endif /* CONFIG_PM */
>
> #ifdef CONFIG_PM_SLEEP
> +static int dwc3_prepare(struct device *dev)
> +{
> + struct dwc3 *dwc = dev_get_drvdata(dev);
> + unsigned long flags;
> +
> + if (dwc->dr_mode == USB_DR_MODE_OTG) {
> + spin_lock_irqsave(&dwc->lock, flags);
> + dwc->dr_keep_role = true;
> + spin_unlock_irqrestore(&dwc->lock, flags);
> + }
> +
> + return 0;
> +}
> +
> +static void dwc3_complete(struct device *dev)
> +{
> + struct dwc3 *dwc = dev_get_drvdata(dev);
> + unsigned long flags;
> +
> + if (dwc->dr_mode == USB_DR_MODE_OTG) {
> + spin_lock_irqsave(&dwc->lock, flags);
> + dwc->dr_keep_role = false;
> + spin_unlock_irqrestore(&dwc->lock, flags);
> + dwc3_drd_update(dwc);
> + }
> +}
wouldn't it be far easier to just disable OTG IRQ in prepare? and,
perhaps, also flush_work_sync() ?
next reply other threads:[~2018-02-12 8:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 8:54 Felipe Balbi [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-02-15 7:45 [2/2] usb: dwc3: drd: Fix lock-up on ID change during system suspend/resume Roger Quadros
2018-02-12 10:48 Roger Quadros
2018-01-25 16:11 Roger Quadros
2018-01-24 12:19 Roger Quadros
2018-01-23 12:41 Roger Quadros
2018-01-23 3:45 Manu Gautam
2018-01-22 13:01 Roger Quadros
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=87y3jya8pr.fsf@linux.intel.com \
--to=balbi@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rogerq@ti.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 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).