Skip to content

Commit eb9a839

Browse files
can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes
Since commit 50ea544 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode"), the current ring and coalescing configuration is passed to can_ram_get_layout(). That fixed the issue when switching between CAN-CC and CAN-FD mode with configured ring (rx, tx) and/or coalescing parameters (rx-frames-irq, tx-frames-irq). However 50ea544 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode"), introduced a regression when switching CAN modes with disabled coalescing configuration: Even if the previous CAN mode has no coalescing configured, the new mode is configured with active coalescing. This leads to delayed receiving of CAN-FD frames. This comes from the fact, that ethtool uses usecs = 0 and max_frames = 1 to disable coalescing, however the driver uses internally priv->{rx,tx}_obj_num_coalesce_irq = 0 to indicate disabled coalescing. Fix the regression by assigning struct ethtool_coalesce ec->{rx,tx}_max_coalesced_frames_irq = 1 if coalescing is disabled in the driver as can_ram_get_layout() expects this. Reported-by: https://github.com/vdh-robothania Closes: raspberrypi/linux#6407 Fixes: 50ea544 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode") Cc: [email protected] Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/20241025-mcp251xfd-fix-coalesing-v1-1-9d11416de1df@pengutronix.de Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 51e102e commit eb9a839

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// mcp251xfd - Microchip MCP251xFD Family CAN controller driver
44
//
5-
// Copyright (c) 2019, 2020, 2021 Pengutronix,
5+
// Copyright (c) 2019, 2020, 2021, 2024 Pengutronix,
66
// Marc Kleine-Budde <[email protected]>
77
//
88
// Based on:
@@ -483,9 +483,11 @@ int mcp251xfd_ring_alloc(struct mcp251xfd_priv *priv)
483483
};
484484
const struct ethtool_coalesce ec = {
485485
.rx_coalesce_usecs_irq = priv->rx_coalesce_usecs_irq,
486-
.rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq,
486+
.rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq == 0 ?
487+
1 : priv->rx_obj_num_coalesce_irq,
487488
.tx_coalesce_usecs_irq = priv->tx_coalesce_usecs_irq,
488-
.tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq,
489+
.tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq == 0 ?
490+
1 : priv->tx_obj_num_coalesce_irq,
489491
};
490492
struct can_ram_layout layout;
491493

0 commit comments

Comments
 (0)