mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Changhuang Liang <changhuang.liang@starfivetech.com>
Cc: Serge Semin <fancer.lancer@gmail.com>,
	linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] spi: dw: Request DMA channels at runtime instead of probe
Date: Thu, 24 Sep 2026 19:02:23 +0100	[thread overview]
Message-ID: <4688e732-0fab-4e23-9d3c-e0326b3bd65e@sirena.org.uk> (raw)
In-Reply-To: <20260923095705.233297-2-changhuang.liang@starfivetech.com>

[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2026-09-24 18:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  9:57 [PATCH v1 0/2] Add enhance SPI DMA support for JHB100 SFC Changhuang Liang
2026-09-23  9:57 ` [PATCH v1 1/2] spi: dw: Request DMA channels at runtime instead of probe Changhuang Liang
2026-09-24 18:02   ` Mark Brown [this message]
2026-09-25  6:30     ` Changhuang Liang
2026-09-23  9:57 ` [PATCH v1 2/2] spi: dw: Add DMA support for enhanced memory operations Changhuang Liang
2026-09-24 18:10   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4688e732-0fab-4e23-9d3c-e0326b3bd65e@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=changhuang.liang@starfivetech.com \
    --cc=fancer.lancer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®