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

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch breaks the `grcan_txbug_workaround` mitigation for a known hardware hang, causing it to bypass the trigger condition or unconditionally time out.
--

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

can: grcan: Add CANFD TX support alongside legacy CAN

This commit includes CANFD TX support with the legacy CAN support, enabling
extended data payloads to provide higher bit rates.

> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index 4921da349a0ef..690e07c7b1ef8 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c

[ ... ]

> @@ -1441,40 +1484,55 @@ static netdev_tx_t grcan_start_xmit(struct sk_buff *skb,
>  	spin_lock_irqsave(&priv->lock, flags);
>  
>  	txwr = grcan_read_reg(&regs->txwr);
>  	space = grcan_txspace(dma->tx.size, txwr, priv->eskbp);
>  
>  	slotindex = txwr / GRCAN_MSG_SIZE;
> +	bds = grcan_numbds(len);

[ ... ]

> +	copy_len = min_t(u32, len, CAN_MAX_DLEN);
> +	memcpy(hdr->data, payload, copy_len);
> +	payload_offset = copy_len;
>  
> -	if (dlc > 0)
> -		memcpy(hdr->data, cf->data, min_t(u32, cf->len, CAN_MAX_DLEN));
> +	txwr = grcan_ring_add(txwr, GRCAN_MSG_SIZE, dma->tx.size);
> +
> +	for (i = 1; i < bds; i++) {
> +		frag = grcan_msg_frag_at(&dma->tx, txwr);
> +
> +		memset(frag, 0, sizeof(*frag));
> +		copy_len = min_t(u32, (u32)len - payload_offset, (u32)GRCAN_MSG_SIZE);
> +		memcpy(frag->data, payload + payload_offset, copy_len);
> +		payload_offset += copy_len;
> +
> +		txwr = grcan_ring_add(txwr, GRCAN_MSG_SIZE, dma->tx.size);
> +	}

[ ... ]

>  	/* Bug workaround for old version of grcan where updating txwr
>  	 * in the same clock cycle as the controller updates txrd to
>  	 * the current txwr could hang the can controller
>  	 */
>  	if (priv->need_txbug_workaround) {
>  		txrd = grcan_read_reg(&regs->txrd);
>  		if (unlikely(grcan_ring_sub(txwr, txrd, dma->tx.size) == 1)) {

Does this break the grcan_txbug_workaround mitigation?

In the original code, txwr represented the current hardware write pointer 
when it was used in this check. Now, txwr is updated in the loop above to 
calculate the end of the new message fragments before the workaround check 
is evaluated.

Because txwr is now the new advanced write pointer, won't the trigger
condition grcan_ring_sub(txwr, txrd, dma->tx.size) == 1 evaluate against 
the wrong offset and fail to prevent the controller hang?

Additionally, grcan_txbug_workaround() waits for the hardware read pointer
to catch up to the provided txwr. Since the advanced txwr hasn't been 
written to the hardware yet (it is updated in the hardware at the end of 
the function), will this guarantee a timeout, returning -EBUSY and 
permanently stalling the TX queue?

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

  reply	other threads:[~2026-05-08 22:40 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 [this message]
2026-05-08  7:01 ` [PATCH v7 13/15] can: grcan: Add CANFD RX " Arun Muthusamy
2026-05-08 23:08   ` sashiko-bot
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=20260508224051.3849EC2BCB0@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