[PATCH RFC v2 22/35] spi: nxp-xspi: Reject mixed DTR modes
Miquel Raynal
miquel.raynal at bootlin.com
Wed Dec 2 04:05:58 PST 2026
On 30/11/2026 at 21:20:47 +08, Bough Chen <haibo.chen at oss.nxp.com> wrote:
> On Fri, Nov 27, 2026 at 02:58:51PM +0000, sashiko-bot at kernel.org wrote:
>> 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().
>
> This is a really good catch. I double check the spi nor, for spi nor WR_EN,
> it is 8D-0D-0D-0D, add.dtr, dummy.dtr and data.dtr are all true.
> xspi and fspi do not run any OCT DTR spi-nand before, so the bool op_is_dtr
> maybe not correct.
> Can we just change the spi nand to align with spi nor?
While I agree there is a problem, I don't really like this proposal. If
there is (for exemple) no address phase, I do not expect any settings to
be set for this phase. Forcing DTR=true there seems the wrong way to
tackle the problem. Either the driver shall be fixed (for not evaluating
op_is_dtr as false) or supports_op() shall return false in some well
crafted conditions.
Thanks,
Miquèl
More information about the linux-amlogic
mailing list