linux/drivers/spi
Zhengyu He a88df1d92f
spi: spacemit: Correct TX FIFO slot calculation
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>
Link: https://patch.msgid.link/20260715-k1-spi-tx-fifo-fix-v1-for-next-v1-1-02024223b08a@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
2026-07-19 22:12:52 +01:00
..
atmel-quadspi.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
internals.h
Kconfig spi: cadence-xspi: Revert COMPILE_TEST support 2026-06-08 13:18:16 +01:00
Makefile spi: spacemit: introduce SpacemiT K1 SPI controller driver 2026-05-04 22:21:00 +09:00
spi-airoha-snfi.c spi: spi-mem: Transform the read operation template 2026-05-04 15:02:07 +02:00
spi-altera-core.c
spi-altera-dfl.c
spi-altera-platform.c spi: Use named initializers for platform_device_id arrays 2026-06-09 22:44:23 +01:00
spi-amd-pci.c spi: spi_amd: Remove the use of dev_err_probe() 2025-08-19 13:05:58 +01:00
spi-amd.c spi: amd: Set correct bus number in ACPI probe path 2026-05-11 09:29:12 +09:00
spi-amd.h spi: spi_amd: Add PCI-based driver for AMD HID2 SPI controller 2025-04-06 23:26:10 +01:00
spi-amlogic-spifc-a1.c spi: amlogic-spifc-a1: Use FIELD_MODIFY() 2026-05-11 21:05:04 +09:00
spi-amlogic-spifc-a4.c spi: amlogic: spifc-a4: unregister ECC engine on probe failure and remove() callback 2026-03-30 18:53:06 +01:00
spi-amlogic-spisg.c spi: Use FIELD_MODIFY() for bitfield operations 2026-05-11 21:05:13 +09:00
spi-apple.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-ar934x.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-armada-3700.c spi: armada-3700: switch to managed controller allocation 2026-05-18 10:19:42 +01:00
spi-aspeed-smc.c Aside from preparation changes in the SPI NAND core, the changes carried 2026-06-12 14:00:51 +01:00
spi-at91-usart.c spi: at91-usart: switch to managed controller allocation 2026-05-04 22:09:17 +09:00
spi-atcspi200.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-ath79.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-atmel.c spi: atmel: fix DMA channel and bounce buffer leaks 2026-06-01 15:03:02 +01:00
spi-au1550.c
spi-axi-spi-engine.c spi: Use trace_call__##name() at guarded tracepoint call sites 2026-03-26 10:24:39 -04:00
spi-axiado.c spi: axiado: replace usleep_range() with udelay() in IRQ path 2026-04-28 08:35:59 +09:00
spi-axiado.h spi: axiado: Add driver for Axiado SPI DB controller 2026-01-09 13:21:55 +00:00
spi-bcm-qspi.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
spi-bcm-qspi.h
spi-bcm63xx-hsspi.c spi: bcm63xx-hsspi: switch to managed controller allocation 2026-05-04 22:09:20 +09:00
spi-bcm63xx.c spi: Use named initializers for platform_device_id arrays 2026-06-09 22:44:23 +01:00
spi-bcm2835.c Convert 'alloc_flex' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-bcm2835aux.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-bcmbca-hsspi.c spi: bcmbca-hsspi: fix controller deregistration 2026-04-09 20:08:04 +01:00
spi-bitbang-txrx.h
spi-bitbang.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spi-brcmstb-qspi.c
spi-butterfly.c
spi-cadence-quadspi.c spi: cadence-quadspi: Fix indirect write timeout when DMA read mode is enabled 2026-07-14 12:54:50 +01:00
spi-cadence-xspi.c spi: cadence-xspi: Revert COMPILE_TEST support 2026-06-08 13:18:16 +01:00
spi-cadence.c spi: cadence: switch to managed controller allocation 2026-05-04 22:09:20 +09:00
spi-cavium-octeon.c spi: octeon: switch to managed controller allocation 2026-05-04 22:09:21 +09:00
spi-cavium-thunderx.c spi: cavium-thunderx: switch to managed controller allocation 2026-05-04 22:09:22 +09:00
spi-cavium.c
spi-cavium.h
spi-ch341.c spi: ch341: correct company name in MODULE_DESCRIPTION 2026-05-06 23:09:33 +09:00
spi-clps711x.c spi: clps711x: switch to managed controller allocation 2026-05-18 10:19:43 +01:00
spi-coldfire-qspi.c spi: coldfire-qspi: switch to managed controller allocation 2026-05-04 22:09:23 +09:00
spi-cs42l43.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-davinci.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-dln2.c spi: dln2: switch to managed controller allocation 2026-05-04 22:09:24 +09:00
spi-dw-core.c spi: Fixes for v7.2 2026-07-05 05:24:06 -10:00
spi-dw-dma.c spi: dw-dma: Wait for controller idle before completing Tx 2026-07-14 12:15:51 +01:00
spi-dw-mmio.c spi: dw: Add support for snps,dwc-ssi-2.00a 2026-06-19 18:02:22 +01:00
spi-dw-pci.c spi: dw-pci: remove redundant pci_free_irq_vectors() calls 2026-06-08 19:04:40 +01:00
spi-dw.h spi: dw: fix wrong BAUDR setting after resume 2026-06-16 21:43:53 +01:00
spi-ep93xx.c spi: ep93xx: fix double-free of zeropage on DMA setup failure 2026-06-08 19:03:40 +01:00
spi-falcon.c spi: falcon: switch to managed controller allocation 2026-05-18 10:19:44 +01:00
spi-fsi.c spi: fsi: switch to managed controller allocation 2026-05-18 10:19:45 +01:00
spi-fsl-cpm.c
spi-fsl-cpm.h
spi-fsl-dspi.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spi-fsl-espi.c spi: Fix mismatched DT property access types 2026-06-14 01:18:29 +01:00
spi-fsl-lib.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-fsl-lib.h
spi-fsl-lpspi.c spi: fsl-lpspi: terminate the RX channel on TX prepare failure path 2026-06-01 15:08:06 +01:00
spi-fsl-qspi.c spi: fsl-qspi: Use reinit_completion() for repeated operations 2026-03-09 20:12:06 +00:00
spi-fsl-spi.c spi: fsl: switch to managed controller allocation 2026-05-04 22:09:26 +09:00
spi-fsl-spi.h
spi-geni-qcom.c spi: Updates for v7.2 2026-06-16 07:56:47 +05:30
spi-gpio.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-gxp.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-hisi-kunpeng.c spi: Fix mismatched DT property access types 2026-06-14 01:18:29 +01:00
spi-hisi-sfc-v3xx.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-img-spfi.c spi: img-spfi: switch to managed controller allocation 2026-05-04 22:09:28 +09:00
spi-imx.c spi: imx: reconfigure for PIO when DMA cannot be started 2026-06-24 17:52:44 +01:00
spi-ingenic.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-intel-pci.c spi: Consistently define pci_device_ids using named initializers 2026-05-05 10:08:08 +09:00
spi-intel-platform.c spi: intel: Improve resource mapping 2025-04-24 12:56:59 +01:00
spi-intel.c spi: spi-mem: Transform the read operation template 2026-05-04 15:02:07 +02:00
spi-intel.h spi: intel: Improve resource mapping 2025-04-24 12:56:59 +01:00
spi-iproc-qspi.c
spi-jcore.c spi: jcore: switch to managed controller allocation 2026-05-18 10:19:47 +01:00
spi-kspi2.c
spi-lantiq-ssc.c spi: lantiq-ssc: switch to managed controller allocation 2026-05-04 22:09:29 +09:00
spi-ljca.c spi: Drop duplicate device_set_node() call 2026-01-19 14:42:54 +00:00
spi-lm70llp.c
spi-loongson-core.c spi: Drop duplicate device_set_node() call 2026-01-19 14:42:54 +00:00
spi-loongson-pci.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-loongson-plat.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-loongson.h
spi-loopback-test.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-lp8841-rtc.c spi: lp8841-rtc: drop unused ifdef 2026-05-18 10:19:49 +01:00
spi-mem.c Aside from preparation changes in the SPI NAND core, the changes carried 2026-06-12 14:00:51 +01:00
spi-meson-spicc.c spi: Use FIELD_MODIFY() for bitfield operations 2026-05-11 21:05:13 +09:00
spi-meson-spifc.c spi: meson-spifc: fix runtime PM leak on remove 2026-06-10 00:06:47 +01:00
spi-microchip-core-qspi.c spi: switch to managed controller allocation (part 2/3) 2026-05-11 09:55:56 +09:00
spi-microchip-core-spi.c spi: microchip-core-spi: fix controller deregistration 2026-04-09 20:08:13 +01:00
spi-mpc52xx-psc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-mpc52xx.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spi-mpc512x-psc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-mpfs.c spi: mpfs: fix controller deregistration 2026-04-09 20:08:14 +01:00
spi-mt65xx.c spi: mt65xx: fix controller deregistration 2026-04-10 13:22:24 +01:00
spi-mt7621.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-mtk-nor.c spi: mtk-nor: fix controller deregistration 2026-04-10 13:22:25 +01:00
spi-mtk-snfi.c spi: mtk-snfi: Fix resource leak in mtk_snand_read_page_cache() 2026-05-16 11:27:08 +09:00
spi-mux.c spi: mux: switch to managed controller allocation 2026-05-18 10:19:51 +01:00
spi-mxic.c spi: spi-mem: Transform the read operation template 2026-05-04 15:02:07 +02:00
spi-mxs.c spi: mxs: switch to managed controller allocation 2026-05-04 22:09:30 +09:00
spi-npcm-fiu.c spi: spi-mem: Transform the read operation template 2026-05-04 15:02:07 +02:00
spi-npcm-pspi.c spi: npcm-pspi: switch to managed controller allocation 2026-05-04 22:09:31 +09:00
spi-nxp-fspi.c spi: nxp-fspi: Use reinit_completion() for repeated operations 2026-03-09 20:12:05 +00:00
spi-nxp-xspi.c spi: nxp-xspi: Use FIELD_MODIFY() 2026-05-11 21:05:07 +09:00
spi-oc-tiny.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-offload-trigger-adi-util-sigma-delta.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-offload-trigger-pwm.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-offload.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-omap-uwire.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-omap2-mcspi.c spi: omap2-mcspi: Use of_device_get_match_data() 2026-05-25 13:33:57 +01:00
spi-orion.c spi: orion: switch to managed controller allocation 2026-05-04 22:09:32 +09:00
spi-pci1xxxx.c spi: Consistently define pci_device_ids using named initializers 2026-05-05 10:08:08 +09:00
spi-pic32-sqi.c spi: pic32-sqi: switch to managed controller allocation 2026-05-11 09:55:40 +09:00
spi-pic32.c spi: pic32: switch to managed controller allocation 2026-05-11 09:55:39 +09:00
spi-pl022.c spi: pl022: switch to managed controller allocation 2026-05-11 09:55:40 +09:00
spi-ppc4xx.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-pxa2xx-dma.c spi: pxa2xx: update outdated reference to pump_transfers() 2026-03-24 19:55:23 +00:00
spi-pxa2xx-pci.c
spi-pxa2xx-platform.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-pxa2xx.c spi: pxa2xx: use min() instead of min_t() 2026-02-23 19:10:26 +00:00
spi-pxa2xx.h
spi-qcom-qspi.c spi: spi-qcom-qspi: Add interconnect support for memory path 2026-05-04 22:15:11 +09:00
spi-qpic-snand.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-qup.c spi: Merge up fixes 2026-05-19 09:44:41 +01:00
spi-rb4xx.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-realtek-rtl-snand.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-realtek-rtl.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-rockchip-sfc.c spi: rockchip-sfc: Fix double-free in remove() callback 2026-03-09 19:10:21 +00:00
spi-rockchip.c spi: rockchip: Drop unused and broken CR0 macros 2026-04-27 06:57:20 +09:00
spi-rpc-if.c spi: rpc-if: Use correct device for hardware reinitialization on resume 2026-06-18 19:20:56 +01:00
spi-rspi.c spi: Use named initializers for platform_device_id arrays 2026-06-09 22:44:23 +01:00
spi-rzv2h-rspi.c spi: Fixes for v7.2 2026-07-05 05:24:06 -10:00
spi-rzv2m-csi.c spi: Drop duplicate device_set_node() call 2026-01-19 14:42:54 +00:00
spi-s3c64xx.c spi: Use named initializers for platform_device_id arrays 2026-06-09 22:44:23 +01:00
spi-sc18is602.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-sg2044-nor.c spi: Drop duplicate of_node assignment 2026-01-19 14:42:52 +00:00
spi-sh-hspi.c spi: sh-hspi: switch to managed controller allocation 2026-05-11 09:55:43 +09:00
spi-sh-msiof.c spi: sh-msiof: abort transfers when reset times out 2026-06-25 13:49:00 +01:00
spi-sh-sci.c
spi-sh.c
spi-sifive.c spi: sifive: switch to managed controller allocation 2026-05-11 09:55:45 +09:00
spi-slave-mt27xx.c spi: slave-mt27xx: switch to managed controller allocation 2026-05-11 09:55:45 +09:00
spi-slave-system-control.c
spi-slave-time.c
spi-sn-f-ospi.c spi: sn-f-ospi: Use FIELD_MODIFY() 2026-05-11 21:05:08 +09:00
spi-spacemit-k1.c spi: spacemit: Correct TX FIFO slot calculation 2026-07-19 22:12:52 +01:00
spi-sprd-adi.c spi: aspeed: Improve handling of shared SPI 2026-01-28 11:22:06 +00:00
spi-sprd.c spi: Merge up fixes 2026-05-19 09:44:41 +01:00
spi-st-ssc4.c spi: st-ssc4: switch to managed controller allocation 2026-05-11 09:55:47 +09:00
spi-stm32-ospi.c Aside from preparation changes in the SPI NAND core, the changes carried 2026-06-12 14:00:51 +01:00
spi-stm32-qspi.c Aside from preparation changes in the SPI NAND core, the changes carried 2026-06-12 14:00:51 +01:00
spi-stm32.c spi: stm32: Simplify clock handling with devm_clk_get_enabled() 2026-03-23 19:47:42 +00:00
spi-sun4i.c spi: sun4i: switch to managed controller allocation 2026-05-11 09:55:48 +09:00
spi-sun6i.c spi: sun6i: switch to managed controller allocation 2026-05-11 09:55:49 +09:00
spi-sunplus-sp7021.c spi: sunplus-sp7021: Use FIELD_MODIFY() 2026-05-11 21:05:11 +09:00
spi-synquacer.c spi: syncuacer: switch to managed controller allocation 2026-05-11 09:55:50 +09:00
spi-tegra20-sflash.c spi: tegra20-sflash: switch to managed controller allocation 2026-05-11 09:55:51 +09:00
spi-tegra20-slink.c spi: tegra20-slink: switch to managed controller allocation 2026-03-24 14:25:49 +00:00
spi-tegra114.c spi: tegra114: switch to managed controller allocation 2026-05-11 09:55:51 +09:00
spi-tegra210-quad.c spi: tegra210-quad: Allocate DMA memory for DMA engine 2026-06-01 15:12:06 +01:00
spi-test.h
spi-ti-qspi.c spi: Merge up fixes 2026-05-19 09:44:41 +01:00
spi-tle62x0.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
spi-topcliff-pch.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spi-uniphier.c spi: uniphier: Fix completion initialization order before devm_request_irq() 2026-06-16 21:25:14 +01:00
spi-virtio.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
spi-wpcm-fiu.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
spi-xcomm.c spi: Use named initializers for arrays of i2c_device_data 2026-05-22 12:12:11 +01:00
spi-xilinx.c spi: xilinx: use FIFO occupancy register to determine buffer size 2026-06-12 14:21:28 +01:00
spi-xlp.c spi: xlp: switch to managed controller allocation 2026-05-18 10:19:52 +01:00
spi-xtensa-xtfpga.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spi-zynq-qspi.c spi: zync-qspi: switch to managed controller allocation 2026-05-11 09:55:55 +09:00
spi-zynqmp-gqspi.c spi: zynqmp-gqspi: fix controller deregistration 2026-04-10 13:22:44 +01:00
spi.c spi: Fixes for v7.2 2026-07-05 05:24:06 -10:00
spidev.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00