mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roman Putintsev <roman@putintsev.com>
To: ldewangan@nvidia.com, broonie@kernel.org
Cc: linux-spi@vger.kernel.org, linux-tegra@vger.kernel.org,
	linux-kernel@vger.kernel.org, thierry.reding@kernel.org,
	jonathanh@nvidia.com, skomatineni@nvidia.com,
	Roman Putintsev <roman@putintsev.com>
Subject: [PATCH] spi: tegra114: re-assert CS after a mid-message cs_change
Date: Wed, 18 Nov 2026 13:38:05 -0500	[thread overview]
Message-ID: <20261118183805.25461-1-roman@putintsev.com> (raw)

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

                 reply	other threads:[~2026-11-18 18:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261118183805.25461-1-roman@putintsev.com \
    --to=roman@putintsev.com \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=skomatineni@nvidia.com \
    --cc=thierry.reding@kernel.org \
    /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

all inboxes | Powered by JetHome®