Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arun Muthusamy" <arun.muthusamy@gaisler.com>
Cc: krzk+dt@kernel.org, conor+dt@kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v7 13/15] can: grcan: Add CANFD RX support alongside legacy CAN
Date: Fri, 08 May 2026 23:08:40 +0000	[thread overview]
Message-ID: <20260508230841.51EF6C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508070121.6918-14-arun.muthusamy@gaisler.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Failure to advance the DMA ring read pointer on SKB allocation failure causes a CPU livelock.
- [Medium] The driver silently ignores the Bit Rate Switch (BRS) flag for received CAN FD frames.
--

commit ce68eaadc0f30d6e6864ce5c3ae7544dc009b802
Author: Arun Muthusamy <arun.muthusamy@gaisler.com>

can: grcan: Add CANFD RX support alongside legacy CAN

This commit adds CAN FD reception capabilities to the grcan driver,
allowing it to handle extended data payloads and higher bit rates.

> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index 690e07c7b1ef8..eba52701c882e 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c
[ ... ]
> @@ -1269,47 +1276,62 @@ static int grcan_receive(struct net_device *dev, int budget)
>  		if (rd == wr)
>  			break;
>  
> -		/* Take care of packet */
> -		skb = alloc_can_skb(dev, &cf);
> -		if (skb == NULL) {
> -			netdev_err(dev,
> -				   "dropping frame: skb allocation failed\n");
> +		hdr = grcan_msg_header_at(&dma->rx, rd);
> +		if (hdr->ctrl & GRCAN_RX_FDF)
> +			skb = alloc_canfd_skb(dev, &cf);
> +		else
> +			skb = alloc_can_skb(dev, (struct can_frame **)&cf);
> +
> +		if (unlikely(!skb)) {
> +			netdev_err(dev, "dropping frame: skb allocation failed\n");
>  			stats->rx_dropped++;
>  			continue;
>  		}

This isn't a bug introduced by this patch, but if the skb allocation fails
here under memory pressure, the loop executes a continue without advancing the
hardware read pointer (rd).

Because rd is not advanced, the next iteration of the loop will attempt to read
the exact same packet, fail allocation again, and repeat this until the NAPI
budget is exhausted. Will this cause NAPI to continuously reschedule the poll
function, leading to a CPU softirq lockup?

Should the driver calculate the number of descriptors and advance rd
appropriately before continuing?

>  
> -		hdr = grcan_msg_header_at(&dma->rx, rd);
> +		dlc = FIELD_GET(GRCAN_MSG_DLC_MASK, hdr->ctrl);
> +		if (hdr->ctrl & GRCAN_RX_FDF)
> +			cf->len = can_fd_dlc2len(dlc);
> +		else
> +			cf->len = can_cc_dlc2len(dlc);
> +

The patch defines GRCAN_RX_BRS as BIT(25) to indicate that the hardware
received a CAN FD frame with Bit Rate Switch enabled, but the receive path
does not appear to check this bit.

If hdr->ctrl & GRCAN_RX_BRS is set, does the driver need to set the CANFD_BRS
bit in cf->flags before passing the frame to the network stack?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260508070121.6918-1-arun.muthusamy@gaisler.com?part=13

  reply	other threads:[~2026-05-08 23:08 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  7:01 [PATCH v7 RESEND 00/15] can: grcan: Enhance driver with CANFD Support and Improvements Arun Muthusamy
2026-05-08  7:01 ` [PATCH v7 01/15] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Arun Muthusamy
2026-05-08  7:01 ` [PATCH v7 02/15] dt-bindings: net: can: gaisler,grcan: Convert to DT schema Arun Muthusamy
2026-05-08 18:37   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 03/15] MAINTAINERS: Add maintainers for GRCAN CAN network driver Arun Muthusamy
2026-05-08  7:01 ` [PATCH v7 04/15] can: grcan: Add clock handling Arun Muthusamy
2026-05-08 18:50   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 05/15] can: grcan: Replace bit timing macros with literal values Arun Muthusamy
2026-05-08  7:01 ` [PATCH v7 06/15] can: grcan: Simplify timing configuration Arun Muthusamy
2026-05-08 19:28   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 07/15] can: grcan: add FD capability detection and nominal bit-timing Arun Muthusamy
2026-05-08 19:45   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 08/15] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Arun Muthusamy
2026-05-08 19:53   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 09/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers Arun Muthusamy
2026-05-08 21:35   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 10/15] can: grcan: Reserve space between cap and next register to align with address layout Arun Muthusamy
2026-05-08  7:01 ` [PATCH v7 11/15] can: grcan: Refactor GRCAN DMA buffer to use structured memory layout Arun Muthusamy
2026-05-08 22:03   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 12/15] can: grcan: Add CANFD TX support alongside legacy CAN Arun Muthusamy
2026-05-08 22:40   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 13/15] can: grcan: Add CANFD RX " Arun Muthusamy
2026-05-08 23:08   ` sashiko-bot [this message]
2026-05-08  7:01 ` [PATCH v7 14/15] can: grcan: Update echo skb handling to match variable length CANFD frame Arun Muthusamy
2026-05-08 23:25   ` sashiko-bot
2026-05-08  7:01 ` [PATCH v7 15/15] can: grcan: Advertise CANFD capability Arun Muthusamy
2026-05-08 23:50   ` 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=20260508230841.51EF6C2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arun.muthusamy@gaisler.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko@lists.linux.dev \
    /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