Re: [PATCH 12/19] usb: typec: tcpci: don't act on unread alerts

From: Greg Kroah-Hartman

Date: Tue Dec 01 2026 - 05:44:35 EST


On Mon, Nov 02, 2026 at 02:23:57PM -0800, Amit Sunil Dhamne wrote:
> Hi,
>
> On 10/27/26 7:57 AM, Greg Kroah-Hartman wrote:
> > From: Josef Bacik <josef@xxxxxxxxxxxxxx>
> >
> > tcpci_irq() ignores the result of nearly all its register reads.
> >
> > If the first read of TCPC_ALERT fails, "status" is an unwritten variable,
> > and its bits decide which events are reported to the port manager: among
> > them a hard reset, which drops VBUS. If the read at the end of the function
> > fails, "status" keeps the alerts which have just been handled: they are
> > handled again, for as long as the read fails.
> >
> > In the receive branch the byte count, the header and the payload are not
> > checked: a count made of stack content trips the WARN_ON(), and a message
> > made of stack content is handed to tcpm_pd_receive(). A failed read of the
> > frame type returns a negative errno as irqreturn_t, with RX_STATUS still
> > set.
> >
> > The handler must not simply return in these cases. Nine in-tree boards
> > connect ALERT# to an edge triggered interrupt: as long as an alert is
> > pending the line stays low, and there is no further edge. That is what the
> > read at the end is for.
> >
> > So read the alert register through a helper which tries three times and
> > reports "no alert" if that fails: after a failed first read the function
> > falls through to the read at the end. Drop a message which cannot be read,
> > but clear RX_STATUS, to release the line. Don't take an unread power status
> > mask for a reset of the TCPC. Return IRQ_HANDLED if any round has found an
> > alert, not only the first one.
> >
>
> nit: This commit is quite verbose. It would be better if it were more
> succinct and to the point. For example, the last paragraph narrates the code
> rather than stating the intent.

Yeah, LLMs love to be chatty, I'll go clean this up to be more concise,
thanks for the review.

greg k-h