[PATCH RFC v2 18/35] spi: nxp-fspi: Consume dummy cycles directly

sashiko-bot at kernel.org sashiko-bot at kernel.org
Fri Nov 27 06:50:31 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] spi: nxp-fspi: LUT_DUMMY_DDR operand halved in
  nxp_fspi_prepare_lut()
--

commit 1599225157c651da7c372805ec30cf72cfe8b69c
Author: Miquel Raynal <miquel.raynal at bootlin.com>

spi: nxp-fspi: Consume dummy cycles directly

This commit enables the dummy_cycles capability in the NXP FlexSPI driver
and replaces the dummy byte-to-cycle conversions with op->dummy.ncycles.

> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index 66cb58f95fdb1..e6fdded67a00e 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
[ ... ]
> @@ -567,8 +567,7 @@ static bool nxp_fspi_supports_op(struct spi_mem *mem,
>  		return false;
>  
>  	/* Max 64 dummy clock cycles supported */
> -	if (op->dummy.buswidth &&
> -	    (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
> +	if (op->dummy.ncycles > 64)
>  		return false;
>  
>  	/* Max data length, check controller limits and alignment */
> @@ -652,16 +651,15 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
>  		lutidx++;
>  	}
>  
> -	/* dummy bytes, if needed */
> -	if (op->dummy.nbytes) {
> +	/* dummy cycles, if needed */
> +	if (op->dummy.ncycles) {
>  		lutval[lutidx / 2] |= LUT_DEF(lutidx, op->dummy.dtr ? LUT_DUMMY_DDR : LUT_DUMMY,
>  		/*
>  		 * Due to FlexSPI controller limitation number of PAD for dummy
>  		 * buswidth needs to be programmed as equal to data buswidth.
>  		 */
>  					      LUT_PAD(op->data.buswidth),
> -					      op->dummy.nbytes * 8 /
> -					      op->dummy.buswidth);
> +					      op->dummy.ncycles);
>  		lutidx++;
>  	}

[Severity: High]
Does passing op->dummy.ncycles directly to LUT_DUMMY_DDR halve the dummy
cycles programmed in DTR mode?

In DTR mode, FlexSPI runs the serial root clock at 2x the flash SCLK rate
and LUT_DUMMY_DDR counts DDR half-cycles (2 * ncycles).  Previously, DTR
callers doubled op->dummy.nbytes to account for two transfers per clock,
and op->dummy.nbytes * 8 / op->dummy.buswidth intentionally did not divide
by 2, yielding 2 * ncycles.  With .dummy_cycles set,
spi_mem_dummy_bytes_to_cycles() divides by 2 * op->dummy.buswidth when
op->dummy.dtr is true (and direct ncycles callers pass full SCLK cycles),
so nxp_fspi_prepare_lut() now programs half the required LUT_DUMMY_DDR
operand and breaks DTR flash reads.

For the same reason, the > 64 check in nxp_fspi_supports_op() no longer
accounts for the 2x factor when op->dummy.dtr is set.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-macronix-upstreaming-spi-mem-cycles-v2-0-5c93f5e5d630@bootlin.com?part=18



More information about the linux-mtd mailing list