Linux CAN drivers development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Avi Weiss" <thnkslprpt@gmail.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Oliver Hartkopp" <socketcan@hartkopp.net>,
	linux-can@vger.kernel.org,
	"Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH net] can: ctucanfd: mark error-active controller status valid
Date: Fri, 24 Jul 2026 15:56:00 +0000	[thread overview]
Message-ID: <20260724155601.48C9A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723155543.318414-1-thnkslprpt@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] When Bus Error Reporting is enabled, the Bus Error Interrupt (BEI) is unhandled and uncleared, leading to an infinite interrupt loop and device lockup.
--

--- Patch [1]: [PATCH net] can: ctucanfd: mark error-active controller status valid ---
commit 5feac9571eb44c72dffa41f1990bff2ccac15e3e
Author: Avi Weiss <thnkslprpt@gmail.com>

can: ctucanfd: mark error-active controller status valid
    
In the CAN_STATE_ERROR_ACTIVE case, cf->data[1] is set to
CAN_ERR_CRTL_ACTIVE, but cf->can_id is not set with CAN_ERR_CRTL in
that path.

> diff --git a/drivers/net/can/ctucanfd/ctucanfd_base.c b/drivers/net/can/ctucanfd/ctucanfd_base.c
> index 0ea1ff28dfce8..8f8b1c097ec6d 100644
> --- a/drivers/net/can/ctucanfd/ctucanfd_base.c
> +++ b/drivers/net/can/ctucanfd/ctucanfd_base.c
> @@ -869,7 +869,7 @@ static void ctucan_err_interrupt(struct net_device *ndev, u32 isr)
>  			break;
>  		case CAN_STATE_ERROR_ACTIVE:
>  			if (skb) {
> -				cf->can_id |= CAN_ERR_CNT;
> +				cf->can_id |= CAN_ERR_CRTL | CAN_ERR_CNT;
>  				cf->data[1] = CAN_ERR_CRTL_ACTIVE;
>  				cf->data[6] = bec.txerr;
>  				cf->data[7] = bec.rxerr;

[Severity: High]
This isn't a bug introduced by this patch, but could there be an issue with
handling the Bus Error Interrupt (BEI) in ctucan_interrupt() when Bus Error
Reporting is enabled?

While ctucan_err_interrupt() has code to handle BEI, it appears it might never
be called if only the BEI interrupt is asserted:

drivers/net/can/ctucanfd/ctucanfd_base.c:ctucan_interrupt() {
        ...
        /* Error interrupts */
        if (FIELD_GET(REG_INT_STAT_EWLI, isr) ||
            FIELD_GET(REG_INT_STAT_FCSI, isr) ||
            FIELD_GET(REG_INT_STAT_ALI, isr)) {
                icr = isr & (REG_INT_STAT_EWLI | REG_INT_STAT_FCSI | REG_INT_STAT_ALI);

                ctucan_netdev_dbg(ndev, "some ERR interrupt: clearing 0x%08x\n", icr);
                ctucan_write32(priv, CTUCANFD_INT_STAT, icr);
                ctucan_err_interrupt(ndev, isr);
        }
        ...
}

Because REG_INT_STAT_BEI is omitted from both the if-condition and the icr mask,
does this leave the BEI status unhandled and uncleared?

If a bus error occurs, would this lead to an infinite interrupt loop and
ultimately lock up the device?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260723155543.318414-1-thnkslprpt@gmail.com?part=1

      reply	other threads:[~2026-07-24 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 15:55 [PATCH net] can: ctucanfd: mark error-active controller status valid Avi Weiss
2026-07-24 15:56 ` 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=20260724155601.48C9A1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    --cc=thnkslprpt@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox