All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Shawn Guo" <shengchao.guo@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 2/2] usb: typec: Add onsemi FUSB15201 driver
Date: Thu, 10 Sep 2026 09:28:35 +0000	[thread overview]
Message-ID: <20260910092836.616891F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910091751.819264-3-shengchao.guo@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Unrecoverable interrupt storm due to masked write-1-to-clear operations.
--

commit f97eba3512034404133da1fbd6a5cac5d95da491
Author: Shawn Guo <shengchao.guo@oss.qualcomm.com>

usb: typec: Add onsemi FUSB15201 driver

This commit adds the driver for the onsemi FUSB15201 dual-port USB Type-C 
and Power Delivery controller.

Link: https://lore.kernel.org/r/20260902045938.184221-3-shengchao.guo@oss.qualcomm.com

> diff --git a/drivers/usb/typec/fusb15201.c b/drivers/usb/typec/fusb15201.c
> new file mode 100644
> index 0000000000000..897b2fabc449e
> --- /dev/null
> +++ b/drivers/usb/typec/fusb15201.c

[ ... ]

> +static irqreturn_t fusb15201_irq(int irq, void *data)
> +{
> +	struct fusb15201 *chip = data;
> +	irqreturn_t ret = IRQ_NONE;
> +	unsigned int i;
> +
> +	guard(mutex)(&chip->lock);
> +
> +	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]
Can this lead to an unrecoverable interrupt loop if the hardware sets an
unexpected bit?

By applying a bitmask (pending &= FUSB15201_INT_ALL) before writing back to
the W1C register, any interrupt bit outside this mask will never be cleared.

[ ... ]

> +static int fusb15201_hw_init(struct fusb15201 *chip)
> +{
> +	bool source_only = true;
> +	unsigned int i;
> +	int ret;
> +
> +	for (i = 0; i < FUSB15201_NUM_PORTS; i++) {
> +		struct fusb15201_port *port = &chip->ports[i];
> +
> +		if (!port->port) {
> +			/* Nothing describes this port, keep it quiet. */
> +			ret = regmap_write(chip->regmap,
> +					   FUSB15201_REG_INT_MASK(i),
> +					   FUSB15201_INT_ALL);

[Severity: High]
Does this leave bits 3-7 unmasked on unused ports?

Since FUSB15201_INT_ALL is 0x07, writing it to the mask register might
keep bits 0-2 masked, but leaves the upper bits completely unmasked.

> +			if (ret)
> +				return ret;
> +
> +			continue;
> +		}
> +
> +		if (port->cap.type != TYPEC_PORT_SRC)
> +			source_only = false;
> +
> +		ret = regmap_write(chip->regmap, FUSB15201_REG_INT_MASK(i), 0);

[Severity: High]
Does writing 0 here unmask all interrupt bits on the port, including ones
not covered by FUSB15201_INT_ALL?

Combined with the clearing logic in fusb15201_irq() that only clears bits
defined in FUSB15201_INT_ALL, if any of the upper bits trigger an
interrupt, they won't be cleared. This would cause the IRQ handler to
immediately re-trigger in a continuous storm.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910091751.819264-1-shengchao.guo@oss.qualcomm.com?part=2

      reply	other threads:[~2026-09-10  9:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10  9:17 [PATCH v2 0/2] usb: typec: Add onsemi FUSB15201 support Shawn Guo
2026-09-10  9:17 ` [PATCH v2 1/2] dt-bindings: usb: Add onsemi FUSB15201 Type-C and PD controller Shawn Guo
2026-09-11  7:26   ` Shawn Guo
2026-09-10  9:17 ` [PATCH v2 2/2] usb: typec: Add onsemi FUSB15201 driver Shawn Guo
2026-09-10  9:28   ` sashiko-bot [this message]

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=20260910092836.616891F000FF@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.