Re: [PATCH v1 1/2] spi: dw: Request DMA channels at runtime instead of probe
From: Mark Brown
Date: Thu Sep 24 2026 - 15:05:54 EST
On Wed, Sep 23, 2026 at 02:57:04AM -0700, Changhuang Liang wrote:
> The DW SPI controller requests its DMA channels in
> dw_spi_add_controller(), which ties them up for the entire lifetime of
> the controller. Even a controller that is only ever used for standard
> SPI transfers and never for enhanced SPI transfers holds the channels
> exclusively from probe onwards, preventing them from being shared with
> other users.
> +static int dw_spi_prepare_hardware(struct spi_controller *ctlr)
> +{
> + struct dw_spi *dws = spi_controller_get_devdata(ctlr);
> + int ret;
> +
> + if (!ctlr->can_dma)
> + return 0;
> +
> + ret = dws->dma_ops->dma_init(ctlr->dev.parent, dws);
> + if (ret) {
> + /*
> + * DMA is optional: fall back to the PIO/IRQ path instead of
> + * failing the message. Use dev_dbg() since this may happen
> + * on every prepare.
> + */
> + dev_dbg(&ctlr->dev, "DMA init failed (%d), using PIO\n", ret);
> +
> + return 0;
> + }
> +
> + return 0;
> +}
This seems like a lot of overhead for every existing controller with
DMA, we'll have to go through the request/release cycle whenever DMA
gets used which feels like a bunch of overhead for a hot path -
especially in the fast path in spi_sync(). If some platforms need it
they should be able to opt into it rather than forcing it on every
single platform.
> +static int dw_spi_unprepare_hardware(struct spi_controller *ctlr)
> +{
Adding this also causes overhead since we do the unprepare in the
thread.
Attachment:
signature.asc
Description: PGP signature