netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH can] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes
@ 2024-10-25 14:47 Marc Kleine-Budde
  2024-10-26 12:54 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2024-10-25 14:47 UTC (permalink / raw)
  To: Manivannan Sadhasivam, Thomas Kopp, Vincent Mailhol, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: linux-can, netdev, linux-kernel, stable, Marc Kleine-Budde

Since commit 50ea5449c563 ("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 50ea5449c563 ("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: https://github.com/raspberrypi/linux/issues/6407
Fixes: 50ea5449c563 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
index e684991fa3917d4f6b6ebda8329f72971237574e..7209a831f0f2089e409c6be635f0e5dc7b2271da 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-ring.c
@@ -2,7 +2,7 @@
 //
 // mcp251xfd - Microchip MCP251xFD Family CAN controller driver
 //
-// Copyright (c) 2019, 2020, 2021 Pengutronix,
+// Copyright (c) 2019, 2020, 2021, 2024 Pengutronix,
 //               Marc Kleine-Budde <kernel@pengutronix.de>
 //
 // Based on:
@@ -483,9 +483,11 @@ int mcp251xfd_ring_alloc(struct mcp251xfd_priv *priv)
 		};
 		const struct ethtool_coalesce ec = {
 			.rx_coalesce_usecs_irq = priv->rx_coalesce_usecs_irq,
-			.rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq,
+			.rx_max_coalesced_frames_irq = priv->rx_obj_num_coalesce_irq == 0 ?
+				1 : priv->rx_obj_num_coalesce_irq,
 			.tx_coalesce_usecs_irq = priv->tx_coalesce_usecs_irq,
-			.tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq,
+			.tx_max_coalesced_frames_irq = priv->tx_obj_num_coalesce_irq == 0 ?
+				1 : priv->tx_obj_num_coalesce_irq,
 		};
 		struct can_ram_layout layout;
 

---
base-commit: 9efc44fb2dba6138b0575826319200049078679a
change-id: 20241010-mcp251xfd-fix-coalesing-f373066dd42e

Best regards,
-- 
Marc Kleine-Budde <mkl@pengutronix.de>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH can] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes
  2024-10-25 14:47 [PATCH can] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes Marc Kleine-Budde
@ 2024-10-26 12:54 ` Simon Horman
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2024-10-26 12:54 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Manivannan Sadhasivam, Thomas Kopp, Vincent Mailhol, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-can, netdev, linux-kernel, stable

On Fri, Oct 25, 2024 at 04:47:19PM +0200, Marc Kleine-Budde wrote:
> Since commit 50ea5449c563 ("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 50ea5449c563 ("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: https://github.com/raspberrypi/linux/issues/6407
> Fixes: 50ea5449c563 ("can: mcp251xfd: fix ring configuration when switching from CAN-CC to CAN-FD mode")
> Cc: stable@vger.kernel.org
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-10-26 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-25 14:47 [PATCH can] can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes Marc Kleine-Budde
2024-10-26 12:54 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).