From: sashiko-bot@kernel.org
To: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org
Subject: Re: [PATCH 05/19] usb: cdns3: switch the role unlocked on resume
Date: Tue, 27 Oct 2026 15:27:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-186835@kernel.org> (raw)
In-Reply-To: <20261027-llm-usb-v1-5-b9751ddb9c7c@linuxfoundation.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] usb: cdns3: role switched in cdns3_controller_resume() while in_lpm is true
--
commit 4cc15afc73e105403285c3f1673e0d0dcaa8187a
Author: Josef Bacik <josef@toxicpanda.com>
usb: cdns3: switch the role unlocked on resume
This commit moves the OTG role switch during system resume out of
cdns_resume() into a new cdns_resume_role() helper called before acquiring
cdns->lock. This avoids calling sleeping functions from atomic context when
the controller loses power during suspend and the role changes while asleep.
> diff --git a/drivers/usb/cdns3/cdns3-plat.c b/drivers/usb/cdns3/cdns3-plat.c
> index e3f32c3e95352..674625cdd4d48 100644
> --- a/drivers/usb/cdns3/cdns3-plat.c
> +++ b/drivers/usb/cdns3/cdns3-plat.c
> @@ -268,7 +268,7 @@ static int cdns3_controller_suspend(struct device *dev, pm_message_t msg)
> static int cdns3_controller_resume(struct device *dev, pm_message_t msg)
> {
> struct cdns *cdns = dev_get_drvdata(dev);
> - int ret;
> + int ret, role_changed;
> unsigned long flags;
>
> if (!cdns->in_lpm)
> @@ -292,8 +292,12 @@ static int cdns3_controller_resume(struct device *dev, pm_message_t msg)
>
> cdns3_set_platform_suspend(cdns->dev, false, false);
>
> + /* It resumes the device, which cannot be done from runtime resume */
> + role_changed = PMSG_IS_AUTO(msg) ? 0 : cdns_resume_role(cdns);
> +
> spin_lock_irqsave(&cdns->lock, flags);
> - cdns_resume(cdns);
> + if (!role_changed)
> + cdns_resume(cdns);
> cdns->in_lpm = false;
> spin_unlock_irqrestore(&cdns->lock, flags);
> cdns_set_active(cdns, !PMSG_IS_AUTO(msg));
[Severity: High]
Can calling cdns_resume_role() with interrupts enabled while cdns->in_lpm is
still true cause an unhandled interrupt storm?
When the controller loses power during system suspend and transitions to
USB_ROLE_DEVICE on resume (for example, because a peripheral cable was
connected while asleep), cdns_resume_role() invokes the following call chain
before cdns->in_lpm is cleared:
cdns_resume_role()
cdns_hw_role_switch()
cdns_role_start()
__cdns3_gadget_init()
In drivers/usb/cdns3/cdns3-gadget.c, __cdns3_gadget_init() enables the gadget
block, starts the gadget (which binds the gadget driver and enables
USB_IEN_INIT and USB_CONF_DEVEN), and requests cdns->dev_irq:
cdns_drd_gadget_on(cdns);
pm_runtime_get_sync(cdns->dev);
ret = cdns3_gadget_start(cdns);
...
ret = devm_request_threaded_irq(cdns->dev, cdns->dev_irq,
cdns3_device_irq_handler,
cdns3_device_thread_irq_handler,
IRQF_SHARED, dev_name(cdns->dev),
cdns->gadget_dev);
Because VBUS is present and device interrupts are enabled in hardware, the
level-triggered cdns->dev_irq can fire immediately while cdns_resume_role()
is still running.
However, cdns3_device_irq_handler() in drivers/usb/cdns3/cdns3-gadget.c (as
well as cdns_drd_irq() in drivers/usb/cdns3/drd.c) checks cdns->in_lpm at the
entry of the handler:
if (cdns->in_lpm)
return ret;
Since cdns->in_lpm is not set to false until after cdns_resume_role() returns
and cdns->lock is acquired, the handler returns IRQ_NONE without masking or
acknowledging the pending hardware interrupt, which can cause the kernel to
disable the IRQ line or trigger spurious wakeup handling on shared IRQ
platforms.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027-llm-usb-v1-0-b9751ddb9c7c@linuxfoundation.org?part=5
next prev parent reply other threads:[~2026-10-27 15:27 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:57 [PATCH 00/19] USB: a bunch of llm-found fixes Greg Kroah-Hartman
2026-10-27 14:57 ` [PATCH 01/19] usb: core: sysfs: take the port lock to read the BOS Greg Kroah-Hartman
2026-10-27 15:10 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 02/19] USB: core: signal the end of an sg request last Greg Kroah-Hartman
2026-10-27 15:04 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 03/19] usbip: vudc: free the unlink item if the send fails Greg Kroah-Hartman
2026-10-27 15:09 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 04/19] usb: host: oxu210hp-hcd: fix oxu_qh_alloc() deadlock Greg Kroah-Hartman
2026-10-27 15:06 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 05/19] usb: cdns3: switch the role unlocked on resume Greg Kroah-Hartman
2026-10-27 15:27 ` sashiko-bot [this message]
2026-10-27 14:57 ` [PATCH 06/19] usb: gadget: snps_udc_plat: lock out the interrupt Greg Kroah-Hartman
2026-10-27 15:05 ` sashiko-bot
2026-10-27 18:17 ` Herve Codina
2026-10-27 14:57 ` [PATCH 07/19] usb: gadget: bdc: the resume callback is optional Greg Kroah-Hartman
2026-10-27 15:06 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 08/19] usb: gadget: uvc: fix oops on a premature STREAMON Greg Kroah-Hartman
2026-10-27 15:22 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 09/19] usb: gadget: f_fs: let the request keep its fence Greg Kroah-Hartman
2026-10-27 15:15 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 10/19] usb: host: ehci-orion: fix the probe without DT Greg Kroah-Hartman
2026-10-27 15:09 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 11/19] usb: typec: tcpm: don't wait for the VDM discovery work Greg Kroah-Hartman
2026-10-27 15:18 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 12/19] usb: typec: tcpci: don't act on unread alerts Greg Kroah-Hartman
2026-10-27 15:12 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 13/19] usb: typec: anx7411: zero on-stack alt mode descriptors Greg Kroah-Hartman
2026-10-27 15:10 ` sashiko-bot
2026-10-28 16:20 ` Benson Leung
2026-10-27 14:57 ` [PATCH 14/19] usb: typec: mux: it5205: fix oops on accessory modes Greg Kroah-Hartman
2026-10-27 15:13 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 15/19] usb: typec: mux: tusb1046: " Greg Kroah-Hartman
2026-10-27 15:13 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 16/19] usb: renesas_usbhs: link URBs with interrupts disabled Greg Kroah-Hartman
2026-10-27 15:23 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 17/19] usb: renesas_usbhs: unlink the URB if it is not queued Greg Kroah-Hartman
2026-10-27 15:27 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 18/19] usb: isp1760: wait for the TT clear in endpoint_disable Greg Kroah-Hartman
2026-10-27 15:21 ` Rui Miguel Silva
2026-10-27 15:28 ` sashiko-bot
2026-10-27 14:57 ` [PATCH 19/19] usb: dwc2: " Greg Kroah-Hartman
2026-10-27 15:37 ` sashiko-bot
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=sashiko-outbox-186835@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.