mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] spi: tegra114: re-assert CS after a mid-message cs_change
@ 2026-11-18 18:38 Roman Putintsev
  0 siblings, 0 replies; only message in thread
From: Roman Putintsev @ 2026-11-18 18:38 UTC (permalink / raw)
  To: ldewangan, broonie
  Cc: linux-spi, linux-tegra, linux-kernel, thierry.reding, jonathanh,
	skomatineni, Roman Putintsev

When a transfer has cs_change set and is not the last one of a message,
tegra_spi_transfer_one_message() ends it with tegra_spi_transfer_end().
That function deasserts CS and stores the deasserted state in
tspi->command1_reg (SPI_CS_SW_VAL). The next transfer is not the first one
of the message, so tegra_spi_setup_transfer_one() reuses command1_reg
unchanged: the controller clocks that transfer out with CS inactive. The
slave never sees the data and no error is reported.

Every driver that splits a message into "write payload, toggle CS, write
trigger" hits this. mcp251xfd does it for every CAN frame, so an MCP2518FD
never transmits: the frame reaches the chip's RAM, but the write that sets
UINC|TXREQ in the TX FIFO control register is lost. Reception uses
single-transfer messages and still works.

Before commit f3e182c33e53 ("spi: tegra114: de-assert CS before SPI mode
change") the deassertion did not touch command1_reg and the next transfer
asserted CS on its own. Mark the following transfer as the first one of a
message again, so that it takes the setup path that asserts CS.

Tested on a reComputer Orin J40 Mini with an MCP2518FD on spi1.0. No frame
was transmitted before this change; with it CAN traffic runs in both
directions with no errors.

Fixes: f3e182c33e53 ("spi: tegra114: de-assert CS before SPI mode change")
Cc: stable@vger.kernel.org
Signed-off-by: Roman Putintsev <roman@putintsev.com>
---
 drivers/spi/spi-tegra114.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/spi/spi-tegra114.c b/drivers/spi/spi-tegra114.c
index f43f2df..d2fda21 100644
--- a/drivers/spi/spi-tegra114.c
+++ b/drivers/spi/spi-tegra114.c
@@ -1116,6 +1116,8 @@ complete_xfer:
 		} else if (xfer->cs_change) {
 			tegra_spi_transfer_end(spi);
 			spi_transfer_delay_exec(xfer);
+			/* CS was deasserted, assert it for the next transfer */
+			is_first_msg = true;
 		}
 
 	}

base-commit: 20eef29b7c8465ac98d7dd6d6f2ac07a8d8056ca

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-18 18:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 18:38 [PATCH] spi: tegra114: re-assert CS after a mid-message cs_change Roman Putintsev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®