From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Alexey Charkov <alchark@flipper.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Guenter Roeck <linux@roeck-us.net>,
Sebastian Reichel <sebastian.reichel@collabora.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] usb: typec: fusb302: Keep interrupt flags across a failed register read
Date: Wed, 25 Nov 2026 10:51:13 +0100 [thread overview]
Message-ID: <awavkaJN9zbouVvU@black.igk.intel.com> (raw)
In-Reply-To: <20261123-fusb302-irq-read-error-v2-1-5539a09127d8@flipper.net>
On Mon, Nov 23, 2026 at 02:34:10PM +0400, Alexey Charkov wrote:
> Reading INTERRUPT, INTERRUPTA or INTERRUPTB clears its flags in the chip,
> so bailing out on an I2C error in a later read loses the flags already
> read. On Flipper One, a NACK on INTERRUPTB just as a source raised VBUS
> lost VBUSOK. The driver kept treating VBUS as off, so TCPM never attached
> as a sink and left every Source_Capabilities unanswered.
>
> Keep the flags pending until they are handled, and retry the reads a few
> times, as such errors pass. Otherwise a flag left pending waits for the
> next interrupt.
>
> Fixes: c034a43e72dd ("staging: typec: Fairchild FUSB302 Type-c chip driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alexey Charkov <alchark@flipper.net>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> Changes in v2:
> - Added stable
> - Rebased onto current linux-next
> - Link to v1: https://patch.msgid.link/20261117-fusb302-irq-read-error-v1-1-a85d45b91912@flipper.net
> ---
> drivers/usb/typec/tcpm/fusb302.c | 62 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 51 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/usb/typec/tcpm/fusb302.c b/drivers/usb/typec/tcpm/fusb302.c
> index 83bd287dadc7..9fb76fdd3b7b 100644
> --- a/drivers/usb/typec/tcpm/fusb302.c
> +++ b/drivers/usb/typec/tcpm/fusb302.c
> @@ -100,6 +100,10 @@ struct fusb302_chip {
> bool intr_togdone;
> bool intr_bc_lvl;
> bool intr_comp_chng;
> + /* interrupt flags read from the chip, but not handled yet */
> + u8 pending_interrupt;
> + u8 pending_interrupta;
> + u8 pending_interruptb;
>
> /* port status */
> bool vconn_on;
> @@ -1499,6 +1503,43 @@ static irqreturn_t fusb302_irq_intn(int irq, void *dev_id)
> return IRQ_HANDLED;
> }
>
> +/*
> + * Reading an interrupt register clears its flags in the chip, so keep them
> + * pending until handled: a bus error on a later read would otherwise lose
> + * them. Such errors pass, so retry a few times.
> + */
> +static int fusb302_read_interrupts(struct fusb302_chip *chip, u8 *status0)
> +{
> + int ret, tries;
> + u8 flags;
> +
> + for (tries = 0; tries < 3; tries++) {
> + if (tries)
> + usleep_range(1000, 2000);
> +
> + ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPT, &flags);
> + if (ret < 0)
> + continue;
> + chip->pending_interrupt |= flags;
> +
> + ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPTA, &flags);
> + if (ret < 0)
> + continue;
> + chip->pending_interrupta |= flags;
> +
> + ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPTB, &flags);
> + if (ret < 0)
> + continue;
> + chip->pending_interruptb |= flags;
> +
> + ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, status0);
> + if (ret >= 0)
> + return 0;
> + }
> +
> + return ret;
> +}
> +
> static void fusb302_irq_work(struct work_struct *work)
> {
> struct fusb302_chip *chip = container_of(work, struct fusb302_chip,
> @@ -1521,18 +1562,17 @@ static void fusb302_irq_work(struct work_struct *work)
> intr_bc_lvl = chip->intr_bc_lvl;
> intr_comp_chng = chip->intr_comp_chng;
>
> - ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPT, &interrupt);
> - if (ret < 0)
> - goto done;
> - ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPTA, &interrupta);
> - if (ret < 0)
> - goto done;
> - ret = fusb302_i2c_read(chip, FUSB_REG_INTERRUPTB, &interruptb);
> - if (ret < 0)
> - goto done;
> - ret = fusb302_i2c_read(chip, FUSB_REG_STATUS0, &status0);
> - if (ret < 0)
> + ret = fusb302_read_interrupts(chip, &status0);
> + if (ret < 0) {
> + fusb302_log(chip, "interrupts left pending, ret=%d", ret);
> goto done;
> + }
> + interrupt = chip->pending_interrupt;
> + interrupta = chip->pending_interrupta;
> + interruptb = chip->pending_interruptb;
> + chip->pending_interrupt = 0;
> + chip->pending_interrupta = 0;
> + chip->pending_interruptb = 0;
> fusb302_log(chip,
> "IRQ: 0x%02x, a: 0x%02x, b: 0x%02x, status0: 0x%02x",
> interrupt, interrupta, interruptb, status0);
>
> ---
> base-commit: 909ef7a9a30fa139e69e555e3606680f5cca7726
> change-id: 20261116-fusb302-irq-read-error-8a3ca5ef9ebc
>
> Best regards,
> --
> Alexey Charkov <alchark@flipper.net>
--
heikki
prev parent reply other threads:[~2026-11-25 9:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 10:34 [PATCH v2] usb: typec: fusb302: Keep interrupt flags across a failed register read Alexey Charkov
2026-11-23 10:37 ` sashiko-bot
2026-11-25 9:51 ` Heikki Krogerus [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=awavkaJN9zbouVvU@black.igk.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=alchark@flipper.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=sebastian.reichel@collabora.com \
--cc=stable@vger.kernel.org \
/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.