[PATCH RFC v2 19/35] spi: nxp-fspi: Reject mixed DTR modes

sashiko-bot at kernel.org sashiko-bot at kernel.org
Fri Nov 27 07:00:45 PST 2026


Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] spi: nxp-fspi: missing dummy.dtr check in
  nxp_fspi_supports_op()
--

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

spi: nxp-fspi: Reject mixed DTR modes

This commit adds checks in nxp_fspi_supports_op() to reject spi-mem
operations that mix SDR and DTR phases.

> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index e6fdded67a00e..04999369dd1bd 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -536,8 +536,18 @@ static bool nxp_fspi_supports_op(struct spi_mem *mem,
>  				 const struct spi_mem_op *op)
>  {
>  	struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->controller);
> +	bool all_true, all_false;
>  	int ret;
>  
> +	all_true = op->cmd.dtr &&
> +		   (!op->addr.nbytes || op->addr.dtr) &&
> +		   (!op->data.nbytes || op->data.dtr);
> +
> +	all_false = !op->cmd.dtr && !op->addr.dtr && !op->data.dtr;
> +
> +	if (!all_true && !all_false)
> +		return false;

[Severity: Medium]
Should all_true and all_false also check op->dummy.dtr when
op->dummy.ncycles is non-zero?

Because nxp_fspi_mem_caps sets dummy_cycles = true,
spi_mem_convert_dummy() converts op->dummy.nbytes to op->dummy.ncycles and
clears op->dummy.nbytes before nxp_fspi_supports_op() and
spi_mem_default_supports_op() run.  Since spi_mem_default_supports_op()
only checks op->dummy.nbytes, an operation whose dummy phase has a
different DTR setting from the command, address, and data phases passes
validation.

Unlike other drivers that ignore op->dummy.dtr once dummy bytes are
converted to cycles, this driver still uses op->dummy.dtr to program the
LUT and to select the controller DTR mode and clock rate:

drivers/spi/spi-nxp-fspi.c:nxp_fspi_prepare_lut() {
    ...
	if (op->dummy.ncycles) {
		lutval[lutidx / 2] |= LUT_DEF(lutidx, op->dummy.dtr ? LUT_DUMMY_DDR : LUT_DUMMY,
    ...
}

drivers/spi/spi-nxp-fspi.c:nxp_fspi_select_mem() {
    ...
	/* flexspi only support one DTR mode: 8D-8D-8D */
	bool op_is_dtr = op->cmd.dtr && op->addr.dtr && op->dummy.dtr && op->data.dtr;
    ...
}

Also note that all_true permits empty addr or data phases to have .dtr
set to false, whereas op_is_dtr in nxp_fspi_select_mem() requires all four
.dtr fields to be true unconditionally.

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



More information about the linux-mtd mailing list