All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
To: sashiko-reviews@lists.linux.dev
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	Marc Kleine-Budde <mkl@pengutronix.de>,
	Oliver Hartkopp <socketcan@hartkopp.net>,
	linux-can@vger.kernel.org, Vincent Mailhol <mailhol@kernel.org>,
	imx@lists.linux.dev, Frank.Li@kernel.org,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	s32@nxp.com, imx@lists.linux.dev
Subject: Re: [PATCH v7 1/6] can: flexcan: use dedicated IRQ handlers for multi-IRQ platforms
Date: Tue, 1 Sep 2026 17:44:14 +0300	[thread overview]
Message-ID: <cc806640-bb65-486e-a574-1d6e615e6df8@oss.nxp.com> (raw)
In-Reply-To: <20260831180131.B55E61F00ACA@smtp.kernel.org>

On 8/31/2026 9:01 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> 
> Pre-existing issues:
> - [High] The split IRQ handlers fail to resolve multi-IRQ concurrency for device state processing, leading to lockless list corruption.
> --
> 
> commit f3f261bafd25e44254ad99cda953074bc68ed987
> Author: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
> 
> can: flexcan: use dedicated IRQ handlers for multi-IRQ platforms
> 
> This commit splits the monolithic flexcan_irq handler into dedicated
> functions for mailbox, device state, and bus error processing. The split
> handlers are then registered to specific multi-IRQ lines depending on the
> platform quirks.
> 
>> diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c
>> index f5d22c61503fa..2e9df2d14b341 100644
>> --- a/drivers/net/can/flexcan/flexcan-core.c
>> +++ b/drivers/net/can/flexcan/flexcan-core.c
> [ ... ]
>> +/* Process device state change events */
>> +static irqreturn_t flexcan_do_state(struct net_device *dev)
>> +{
> [ ... ]
>> +	/* state change interrupt or broken error state quirk fix is enabled */
>> +	if ((reg_esr & FLEXCAN_ESR_ERR_STATE) ||
>> +	    (priv->devtype_data.quirks &
>> +	    (FLEXCAN_QUIRK_BROKEN_WERR_STATE | FLEXCAN_QUIRK_BROKEN_PERR_STATE)))
>> +		flexcan_irq_state(dev, reg_esr);
> 
> [Severity: High]
> This is a pre-existing issue, but does calling flexcan_irq_state()
> concurrently corrupt the lockless SKB queue?
> 
> If the boff and err handlers execute flexcan_do_state() concurrently,
> they will both allocate error SKBs and insert them into
> offload->skb_irq_queue using the lockless __skb_queue_add_sort().
> 
> Can this concurrent insertion corrupt the list pointers (skb->next and
> skb->prev), potentially causing infinite loops or use-after-free
> conditions?
> 
> [ ... ]
>> +/* Bus error IRQ handler for multi-IRQ platforms */
>> +static irqreturn_t flexcan_irq_berr(int irq, void *dev_id)
>> +{
>> +	struct net_device *dev = dev_id;
>> +	struct flexcan_priv *priv = netdev_priv(dev);
>> +	irqreturn_t handled;
>> +
>> +	handled = flexcan_do_berr(dev);
>> +
>> +	if (priv->devtype_data.quirks & FLEXCAN_QUIRK_BROKEN_PERR_STATE)
>> +		handled |= flexcan_do_state(dev);
> 
> [Severity: High]
> This isn't a bug introduced by this patch, but could this multi-IRQ
> setup lead to concurrent device state mutations?
> 
> On platforms like s32g2 and mcf5441x with FLEXCAN_QUIRK_NR_IRQ_3 and
> FLEXCAN_QUIRK_BROKEN_PERR_STATE, a hardware bus error or state change
> can trigger both the boff and berr interrupts on distinct IRQ lines.
> 
> Since flexcan_irq_berr() and flexcan_irq_boff() execute on different
> CPUs, couldn't they both call flexcan_do_state(dev) at the same time?
> 

multi-IRQ concurrency findings in this series should be covered by the 
following patchset [1]

[1] 
https://lore.kernel.org/all/20260901114848.500591-1-ciprianmarian.costea@oss.nxp.com/T/#t

Regards,
Ciprian


  reply	other threads:[~2026-09-01 14:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 14:34 [PATCH v7 0/6] can: flexcan: Add NXP S32N79 SoC support Ciprian Costea
2026-08-31 14:34 ` [PATCH v7 1/6] can: flexcan: use dedicated IRQ handlers for multi-IRQ platforms Ciprian Costea
2026-08-31 18:01   ` sashiko-bot
2026-09-01 14:44     ` Ciprian Marian Costea [this message]
2026-08-31 14:34 ` [PATCH v7 2/6] can: flexcan: disable all IRQ lines in flexcan_chip_interrupts_enable() Ciprian Costea
2026-08-31 18:15   ` sashiko-bot
2026-08-31 14:34 ` [PATCH v7 3/6] can: flexcan: split rx/tx masks per mailbox IRQ line Ciprian Costea
2026-08-31 18:27   ` sashiko-bot
2026-08-31 14:34 ` [PATCH v7 4/6] dt-bindings: can: fsl,flexcan: add NXP S32N79 SoC support Ciprian Costea
2026-08-31 18:37   ` sashiko-bot
2026-08-31 14:34 ` [PATCH v7 5/6] can: flexcan: add FLEXCAN_QUIRK_IRQ_BERR quirk Ciprian Costea
2026-08-31 18:51   ` sashiko-bot
2026-08-31 14:34 ` [PATCH v7 6/6] can: flexcan: add NXP S32N79 SoC support Ciprian Costea
2026-08-31 19:01   ` sashiko-bot

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=cc806640-bb65-486e-a574-1d6e615e6df8@oss.nxp.com \
    --to=ciprianmarian.costea@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-can@vger.kernel.org \
    --cc=mailhol@kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=s32@nxp.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    /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.