[PATCH RFC v2 22/35] spi: nxp-xspi: Reject mixed DTR modes
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 27 06:58:51 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] spi: nxp-xspi: inconsistent DTR detection in
nxp_xspi_supports_op()
--
commit ce8d7a3ff5fbe9ec51a6d3a172d4b7891aaf62c1
Author: Miquel Raynal <miquel.raynal at bootlin.com>
spi: nxp-xspi: Reject mixed DTR modes
This commit updates nxp_xspi_supports_op() to reject SPI memory operations
that mix DTR and SDR phases.
> diff --git a/drivers/spi/spi-nxp-xspi.c b/drivers/spi/spi-nxp-xspi.c
> index ccd00c744d186..f2a847b5fd27d 100644
> --- a/drivers/spi/spi-nxp-xspi.c
> +++ b/drivers/spi/spi-nxp-xspi.c
> @@ -385,8 +385,18 @@ static bool nxp_xspi_supports_op(struct spi_mem *mem,
> const struct spi_mem_op *op)
> {
> struct nxp_xspi *xspi = 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]
Does this DTR check match how nxp_xspi_select_mem() detects DTR operations
and how the dummy phase is validated?
In nxp_xspi_select_mem(), op_is_dtr requires dtr to be set on all four
phases unconditionally:
drivers/spi/spi-nxp-xspi.c:nxp_xspi_select_mem() {
...
/* xspi only support one DTR mode: 8D-8D-8D */
bool op_is_dtr = op->cmd.dtr && op->addr.dtr && op->dummy.dtr && op->data.dtr;
...
}
Standard Octal DTR templates that omit an address, dummy, or data phase
(such as SPINAND_PROG_LOAD_8D_8D_8D_OP or SPINAND_WR_EN_8D_0_0_OP) leave
dtr as false on the unused phase via SPI_MEM_OP_NO_DUMMY,
SPI_MEM_OP_NO_ADDR, or SPI_MEM_OP_NO_DATA. Those operations pass
all_true here, and nxp_xspi_prepare_lut() emits DDR LUT instructions for
the active phases, but nxp_xspi_select_mem() evaluates op_is_dtr as false
and calls nxp_xspi_disable_ddr().
In addition, neither all_true nor all_false checks op->dummy.dtr when
op->dummy.ncycles > 0. Because this driver sets dummy_cycles = true in
nxp_xspi_mem_caps, spi_mem_convert_dummy() clears op->dummy.nbytes to 0
before nxp_xspi_supports_op() and spi_mem_default_supports_op() run, so a
mismatched op->dummy.dtr is not caught by spi_mem_default_supports_op()
either.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-macronix-upstreaming-spi-mem-cycles-v2-0-5c93f5e5d630@bootlin.com?part=22
More information about the linux-mtd
mailing list