[PATCH RFC 15/16] spi: stm32-qspi: Consume dummy cycles directly
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 25 10:14:09 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] spi: stm32-qspi: missing dummy phase on GPIO CS fallback in
spi_mem_exec_op()
--
commit f2e2b0be96bbca647ad2610bfa7badf82f59967f
Author: Miquel Raynal <miquel.raynal at bootlin.com>
spi: stm32-qspi: Consume dummy cycles directly
This commit advertises dummy_cycles in stm32_qspi_mem_caps and uses
op->dummy.ncycles directly in stm32_qspi_send() and
stm32_qspi_transfer_one_message().
> diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c
> index b77daba6db83a..993b09cc51240 100644
> --- a/drivers/spi/spi-stm32-qspi.c
> +++ b/drivers/spi/spi-stm32-qspi.c
[ ... ]
> @@ -593,7 +592,7 @@ static int stm32_qspi_transfer_one_message(struct spi_controller *ctrl,
> */
> if (transfer->dummy_data) {
> op.dummy.buswidth = transfer->tx_nbits;
> - op.dummy.nbytes = transfer->len;
> + op.dummy.ncycles = transfer->len * 8 / transfer->tx_nbits;
> dummy_bytes = transfer->len;
>
> /* if happens, means that message is not correctly built */
> @@ -773,6 +772,10 @@ static const struct spi_controller_mem_ops stm32_qspi_mem_ops = {
> .poll_status = stm32_qspi_poll_status,
> };
>
> +static const struct spi_controller_mem_caps stm32_qspi_mem_caps = {
> + .dummy_cycles = true,
> +};
> +
> static int stm32_qspi_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -856,6 +859,7 @@ static int stm32_qspi_probe(struct platform_device *pdev)
> ctrl->setup = stm32_qspi_setup;
> ctrl->bus_num = -1;
> ctrl->mem_ops = &stm32_qspi_mem_ops;
> + ctrl->mem_caps = &stm32_qspi_mem_caps;
> ctrl->use_gpio_descriptors = true;
> ctrl->transfer_one_message = stm32_qspi_transfer_one_message;
> ctrl->num_chipselect = STM32_QSPI_MAX_NORCHIP;
[Severity: High]
Does enabling dummy_cycles drop the dummy phase when a GPIO chip-select is
used?
In spi_mem_exec_op(), spi_mem_convert_dummy() runs first and sets
op->dummy.nbytes = 0 because the controller advertises dummy_cycles. When
spi_get_csgpiod(mem->spi, 0) is non-NULL, spi_mem_exec_op() bypasses
ctlr->mem_ops->exec_op and falls back to building spi_transfers for
stm32_qspi_transfer_one_message(), but that fallback path only creates a
dummy_data transfer when op->dummy.nbytes is non-zero:
drivers/spi/spi-mem.c:spi_mem_exec_op() {
...
if (ctlr->mem_ops && ctlr->mem_ops->exec_op && !spi_get_csgpiod(mem->spi, 0)) {
...
if (op->dummy.nbytes) {
memset(tmpbuf + op->addr.nbytes + 1, 0xff, op->dummy.nbytes);
xfers[xferpos].tx_buf = tmpbuf + op->addr.nbytes + 1;
xfers[xferpos].len = op->dummy.nbytes;
xfers[xferpos].tx_nbits = op->dummy.buswidth;
xfers[xferpos].dummy_data = 1;
...
}
As a result, no dummy_data transfer is added to the message, so
stm32_qspi_transfer_one_message() leaves op.dummy.ncycles at 0 and corrupts
flash operations that require dummy cycles on boards using cs-gpios (such
as dual-flash configurations).
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-macronix-upstreaming-spi-mem-cycles-v1-0-fd036402fd37@bootlin.com?part=15
More information about the linux-mtd
mailing list