]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
d5c176b6962722b4ca62cf396d667ff7a2f37360
[thirdparty/kernel/stable-queue.git] /
1 From eb9a839b3d8a989be5970035a5cf29bcd6ffd24d Mon Sep 17 00:00:00 2001
2 From: Marc Kleine-Budde <mkl@pengutronix.de>
3 Date: Fri, 25 Oct 2024 14:34:40 +0200
4 Subject: can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes
5
6 From: Marc Kleine-Budde <mkl@pengutronix.de>
7
8 commit eb9a839b3d8a989be5970035a5cf29bcd6ffd24d upstream.
9
10 Since commit 50ea5449c563 ("can: mcp251xfd: fix ring configuration
11 when switching from CAN-CC to CAN-FD mode"), the current ring and
12 coalescing configuration is passed to can_ram_get_layout(). That fixed
13 the issue when switching between CAN-CC and CAN-FD mode with
14 configured ring (rx, tx) and/or coalescing parameters (rx-frames-irq,
15 tx-frames-irq).
16
17 However 50ea5449c563 ("can: mcp251xfd: fix ring configuration when
18 switching from CAN-CC to CAN-FD mode"), introduced a regression when
19 switching CAN modes with disabled coalescing configuration: Even if
20 the previous CAN mode has no coalescing configured, the new mode is
21 configured with active coalescing. This leads to delayed receiving of
22 CAN-FD frames.
23
24 This comes from the fact, that ethtool uses usecs = 0 and max_frames =
25 1 to disable coalescing, however the driver uses internally
26 priv->{rx,tx}_obj_num_coalesce_irq = 0 to indicate disabled
27 coalescing.
28
29 Fix the regression by assigning struct ethtool_coalesce
30 ec->{rx,tx}_max_coalesced_frames_irq = 1 if coalescing is disabled in
31 the driver as can_ram_get_layout() expects this.
32
33 Reported-by: https://github.com/vdh-robothania
34 Closes: https://github.com/raspberrypi/linux/issues/6407
35 Fixes: 50ea5449c563 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode")
36 Cc: stable@vger.kernel.org
37 Reviewed-by: Simon Horman <horms@kernel.org>
38 Link: https://patch.msgid.link/20241025-mcp251xfd-fix-coalesing-v1-1-9d11416de1df@pengutronix.de
39 Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41 ---
42 drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c | 8 +++++---
43 1 file changed, 5 insertions(+), 3 deletions(-)
44
45 --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
46 +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
47 @@ -2,7 +2,7 @@
48 //
49 // mcp251xfd - Microchip MCP251xFD Family CAN controller driver
50 //
51 -// Copyright (c) 2019, 2020, 2021 Pengutronix,
52 +// Copyright (c) 2019, 2020, 2021, 2024 Pengutronix,
53 // Marc Kleine-Budde <kernel@pengutronix.de>
54 //
55 // Based on:
56 @@ -483,9 +483,11 @@ int mcp251xfd_ring_alloc(struct mcp251xf
57 };
58 const struct ethtool_coalesce ec = {
59 .rx_coalesce_usecs_irq = priv->rx_coalesce_usecs_irq,
60 - .rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq,
61 + .rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq == 0 ?
62 + 1 : priv->rx_obj_num_coalesce_irq,
63 .tx_coalesce_usecs_irq = priv->tx_coalesce_usecs_irq,
64 - .tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq,
65 + .tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq == 0 ?
66 + 1 : priv->tx_obj_num_coalesce_irq,
67 };
68 struct can_ram_layout layout;
69