* [PATCH] spi: spacemit: Correct TX FIFO slot calculation
@ 2026-07-15 12:52 Zhengyu He
2026-07-19 21:13 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Zhengyu He @ 2026-07-15 12:52 UTC (permalink / raw)
To: Mark Brown, Yixun Lan
Cc: wefu, Zhengyu He, linux-spi, linux-riscv, spacemit, linux-kernel,
Peixin Xie
In k1_spi_write, the count variable is intended to represent the number
of slots available for writing into the TX FIFO.
The current implementation uses FIELD_GET(SSP_STATUS_TFL, val) in an
attempt to determine this count, but this register field returns the
number of occupied slots, not the available space. The previous
implementation attempted to handle this via a ternary operator (? :
K1_SPI_FIFO_SIZE), which incorrectly assumed that the hardware returned
0 when the FIFO was empty (meaning all slots were available), leading to
incorrect accounting of the buffer space.
Fix this by calculating the free slots: count = K1_SPI_FIFO_SIZE -
FIELD_GET(SSP_STATUS_TFL, val);
The associated comment has been updated to reflect the logic change: The
old comment reflected an incorrect assumption about the hardware
behavior, which was the root cause of the previous buggy logic.
This patch accurately and concisely describes the purpose of the new
calculation.
Signed-off-by: Peixin Xie <peixin.xie@spacemit.com>
Signed-off-by: Zhengyu He <hezhy472013@gmail.com>
---
drivers/spi/spi-spacemit-k1.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-spacemit-k1.c b/drivers/spi/spi-spacemit-k1.c
index 215fe66d27b4..0faf7ffed676 100644
--- a/drivers/spi/spi-spacemit-k1.c
+++ b/drivers/spi/spi-spacemit-k1.c
@@ -494,8 +494,8 @@ static bool k1_spi_write(struct k1_spi_driver_data *drv_data, u32 val)
{
unsigned int count;
- /* Get the number of open slots in the FIFO; zero means all */
- count = FIELD_GET(SSP_STATUS_TFL, val) ? : K1_SPI_FIFO_SIZE;
+ /* Get the number of free slots in the FIFO */
+ count = K1_SPI_FIFO_SIZE - FIELD_GET(SSP_STATUS_TFL, val);
/*
* Limit how much we try to send at a time, to reduce the
---
base-commit: 51ed53630915c9cc290036fe4f430849e23bbf8e
change-id: 20260715-k1-spi-tx-fifo-fix-v1-for-next-43cdd0d9213f
Best regards,
--
Zhengyu He <hezhy472013@gmail.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] spi: spacemit: Correct TX FIFO slot calculation
2026-07-15 12:52 [PATCH] spi: spacemit: Correct TX FIFO slot calculation Zhengyu He
@ 2026-07-19 21:13 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2026-07-19 21:13 UTC (permalink / raw)
To: Yixun Lan, Zhengyu He
Cc: wefu, linux-spi, linux-riscv, spacemit, linux-kernel, Peixin Xie
On Wed, 15 Jul 2026 20:52:15 +0800, Zhengyu He wrote:
> spi: spacemit: Correct TX FIFO slot calculation
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2
Thanks!
[1/1] spi: spacemit: Correct TX FIFO slot calculation
https://git.kernel.org/broonie/spi/c/a88df1d92fcf
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-20 13:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-15 12:52 [PATCH] spi: spacemit: Correct TX FIFO slot calculation Zhengyu He
2026-07-19 21:13 ` Mark Brown
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®