From: sashiko-bot@kernel.org
To: "Shawn Guo" <shengchao.guo@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 2/2] usb: typec: Add onsemi FUSB15201 driver
Date: Wed, 16 Sep 2026 14:10:07 +0000 [thread overview]
Message-ID: <20260916141008.49BDB1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260916135918.1017527-3-shengchao.guo@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] usb: typec: fusb15201: unhandled interrupt bits cause interrupt storm
- [Medium] usb: typec: fusb15201: data race in probe allows spurious -ENOTCONN
--
commit d7feaab14acc6ee944a785f261bfb7dd837de605
Author: Shawn Guo <shengchao.guo@oss.qualcomm.com>
usb: typec: Add onsemi FUSB15201 driver
The FUSB15201 is a dual-port USB Type-C and Power Delivery controller. This
driver handles Type-C detection, registers a Type-C port for each connector,
and forwards role swaps to the controller.
> diff --git a/drivers/usb/typec/fusb15201.c b/drivers/usb/typec/fusb15201.c
> new file mode 100644
> index 0000000000000..ab3b07368bdf1
> --- /dev/null
> +++ b/drivers/usb/typec/fusb15201.c
[ ... ]
> +static irqreturn_t fusb15201_irq(int irq, void *data)
> +{
[ ... ]
> + for (i = 0; i < FUSB15201_NUM_PORTS; i++) {
> + struct fusb15201_port *port = &chip->ports[i];
> + unsigned int pending;
> +
> + if (!port->port)
> + continue;
> +
> + if (regmap_read(chip->regmap, FUSB15201_REG_INTERRUPT(i), &pending))
> + continue;
> +
> + pending &= FUSB15201_INT_ALL;
> + if (!pending)
> + continue;
> +
> + /* Write one to clear */
> + regmap_write(chip->regmap, FUSB15201_REG_INTERRUPT(i), pending);
[Severity: High]
Could masking the pending interrupts before writing back cause an interrupt
storm?
If the hardware asserts any bit outside of FUSB15201_INT_ALL (such as a
reserved bit or a new status bit in newer firmware), the driver masks it out
and writes 0 for that bit, failing to clear it.
If only unknown bits are asserted, pending becomes 0, and the handler returns
IRQ_NONE without clearing anything. The unhandled interrupt will then fire
continuously and lock up the CPU.
[ ... ]
> +static int fusb15201_hw_init(struct fusb15201 *chip)
> +{
[ ... ]
> + for (i = 0; i < FUSB15201_NUM_PORTS; i++) {
> + struct fusb15201_port *port = &chip->ports[i];
[ ... ]
> + /* Discard anything that happened before we got here */
> + ret = regmap_write(chip->regmap, FUSB15201_REG_INTERRUPT(i),
> + FUSB15201_INT_ALL);
[Severity: High]
Similar to the interrupt handler, this only clears known bits. Will any
pre-existing unhandled bits remain asserted and immediately trigger an
interrupt storm once the IRQ is requested?
Should this write a full mask to clear any unexpected bits during
initialization?
[ ... ]
> + /* Seed the Type-C class with the current state before arming the IRQ */
> + for (i = 0; i < FUSB15201_NUM_PORTS; i++) {
> + if (chip->ports[i].port)
> + fusb15201_hw_update(&chip->ports[i]);
> + }
> +
> + return 0;
> +}
[Severity: Medium]
Can this lockless initialization race with sysfs commands?
Because typec_register_port() is called before fusb15201_hw_init() in probe,
sysfs attributes and uevents are already active. When fusb15201_hw_update()
is called locklessly here, it invokes typec_register_partner(), which can
trigger additional uevents before port->status is updated.
If userspace reacts to these uevents and requests a data or power role swap,
fusb15201_command() will acquire chip->lock and read port->status. Since
this hardware update does not hold the lock, fusb15201_command() could observe
a stale port->status == 0 and spuriously reject the valid swap request with
-ENOTCONN.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916135918.1017527-1-shengchao.guo@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-09-16 14:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 13:59 [PATCH v3 0/2] usb: typec: Add onsemi FUSB15201 support Shawn Guo
2026-09-16 13:59 ` [PATCH v3 1/2] dt-bindings: usb: Add onsemi FUSB15201 Type-C and PD controller Shawn Guo
2026-09-16 13:59 ` [PATCH v3 2/2] usb: typec: Add onsemi FUSB15201 driver Shawn Guo
2026-09-16 14:10 ` sashiko-bot [this message]
2026-09-18 9:43 ` Heikki Krogerus
2026-10-03 4:22 ` [PATCH v3 0/2] usb: typec: Add onsemi FUSB15201 support Shawn Guo
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=20260916141008.49BDB1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shengchao.guo@oss.qualcomm.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.