From: "Nuno Sá" <noname.nuno@gmail.com>
To: "David Lechner" <dlechner@baylibre.com>,
"Mark Brown" <broonie@kernel.org>,
"Jonathan Cameron" <jic23@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
David Jander <david@protonic.nl>,
Martin Sperl <kernel@martin.sperl.org>,
linux-spi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org
Subject: Re: [PATCH RFC v3 2/9] spi: add basic support for SPI offloading
Date: Tue, 23 Jul 2024 09:44:59 +0200 [thread overview]
Message-ID: <ffa0e8ceea5663fa3d93664735fd867b7b5891b8.camel@gmail.com> (raw)
In-Reply-To: <20240722-dlech-mainline-spi-engine-offload-2-v3-2-7420e45df69b@baylibre.com>
On Mon, 2024-07-22 at 16:57 -0500, David Lechner wrote:
> SPI offloading is a feature that allows the SPI controller to perform
> transfers without any CPU intervention. This is useful, e.g. for
> high-speed data acquisition.
>
> This patch adds the basic infrastructure to support SPI offloading. It
> introduces new callbacks that are to be implemented by controllers with
> offload capabilities.
>
> On SPI device probe, the standard spi-offloads devicetree property is
> parsed and passed to the controller driver to reserve the resources
> requested by the peripheral via the map_channel() callback.
>
> The peripheral driver can then use spi_offload_prepare() to load a SPI
> message into the offload hardware.
>
> If the controller supports it, this message can then be passed to the
> SPI message queue as if it was a normal message. Future patches will
> will also implement a way to use a hardware trigger to start the message
> transfers rather than going through the message queue.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
>
> v3 changes:
> * Minor changes to doc comments.
> * Changed to use phandle array for spi-offloads.
> * Changed id to string to make use of spi-offload-names.
>
> v2 changes:
>
> This is a rework of "spi: add core support for controllers with offload
> capabilities" from v1.
>
> The spi_offload_get() function that Nuno didn't like is gone. Instead,
> there is now a mapping callback that uses the new generic devicetree
> binding to request resources automatically when a SPI device is probed.
>
Given my reply to the cover you can start calling me names already :). But even
with that function back I think we need a more explicit provider/consumer logic.
> The spi_offload_enable/disable() functions for dealing with hardware
> triggers are deferred to a separate patch.
>
> This leaves adding spi_offload_prepare/unprepare() which have been
> reworked to be a bit more robust.
>
> In the previous review, Mark suggested that these functions should not
> be separate from the spi_[un]optimize() functions. I understand the
> reasoning behind that. However, it seems like there are two different
> kinds of things going on here. Currently, spi_optimize() only performs
> operations on the message data structures and doesn't poke any hardware.
> This makes it free to be use by any peripheral without worrying about
> tying up any hardware resources while the message is "optimized". On the
> other hand, spi_offload_prepare() is poking hardware, so we need to be
> more careful about how it is used. And in these cases, we need a way to
> specify exactly which hardware resources it should use, which it is
> currently doing with the extra ID parameter.
> ---
> drivers/spi/spi.c | 123
> ++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/spi/spi.h | 57 ++++++++++++++++++++++
> 2 files changed, 180 insertions(+)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index d4da5464dbd0..d01b2e5c8c44 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -2477,6 +2477,51 @@ static int of_spi_parse_dt(struct spi_controller *ctlr,
> struct spi_device *spi,
> of_spi_parse_dt_cs_delay(nc, &spi->cs_hold, "spi-cs-hold-delay-ns");
> of_spi_parse_dt_cs_delay(nc, &spi->cs_inactive, "spi-cs-inactive-
> delay-ns");
>
> + /* Offloads */
> + rc = of_count_phandle_with_args(nc, "spi-offloads", "#spi-offload-
> cells");
> + if (rc > 0) {
> + int num_offload = rc;
> +
> + if (!ctlr->offload_ops) {
> + dev_err(&ctlr->dev, "SPI controller doesn't support
> offloading\n");
> + return -EINVAL;
> + }
> +
> + for (idx = 0; idx < num_offload; idx++) {
> + struct of_phandle_args args;
> + const char *offload_name = NULL;
> +
> + rc = of_parse_phandle_with_args(nc, "spi-offloads",
> + "#spi-offload-cells",
> + idx, &args);
> + if (rc) {
> + dev_err(&spi->dev, "Failed to parse offload
> phandle %d: %d\n",
> + idx, rc);
> + return rc;
> + }
> +
> + if (args.np != ctlr->dev.of_node) {
> + dev_err(&spi->dev, "Offload phandle %d is not
> for this SPI controller\n",
> + idx);
> + of_node_put(args.np);
> + return -EINVAL;
> + }
> +
> + of_property_read_string_index(nc, "spi-offload-
> names",
> + idx, &offload_name);
> +
> + rc = ctlr->offload_ops->map_channel(spi,
> offload_name,
> + args.args,
> + args.args_count);
In here, I would expect for the mapping to return something the core could then
directly pass into the other operations. And hence saving controllers to always
have to do a lookup in all the operations.
It seems we may need a struct spi_offload * object that can be attached to a
given spi_device and that can be directly passed and used by the specific
offload operations.
- Nuno Sá
next prev parent reply other threads:[~2024-07-23 7:41 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-22 21:57 [PATCH RFC v3 0/9] spi: axi-spi-engine: add offload support David Lechner
2024-07-22 21:57 ` [PATCH RFC v3 1/9] spi: dt-bindings: add spi-offload properties David Lechner
2024-07-26 11:47 ` Rob Herring
2024-07-22 21:57 ` [PATCH RFC v3 2/9] spi: add basic support for SPI offloading David Lechner
2024-07-23 7:44 ` Nuno Sá [this message]
2024-07-27 13:15 ` Jonathan Cameron
2024-07-30 19:35 ` David Lechner
2024-08-03 9:58 ` Jonathan Cameron
2024-07-22 21:57 ` [PATCH RFC v3 3/9] spi: add support for hardware triggered offload David Lechner
2024-07-23 7:53 ` Nuno Sá
2024-07-23 14:30 ` David Lechner
2024-07-24 12:59 ` Nuno Sá
2024-07-27 13:26 ` Jonathan Cameron
2024-07-22 21:57 ` [PATCH RFC v3 4/9] spi: add offload TX/RX streaming APIs David Lechner
2024-07-22 21:57 ` [PATCH RFC v3 5/9] spi: dt-bindings: axi-spi-engine: document spi-offloads David Lechner
2024-07-26 12:38 ` Rob Herring
2024-07-26 19:17 ` David Lechner
2024-08-14 15:58 ` Conor Dooley
2024-08-14 17:14 ` David Lechner
2024-07-22 21:57 ` [PATCH RFC v3 6/9] spi: axi-spi-engine: implement offload support David Lechner
2024-07-23 8:01 ` Nuno Sá
2024-07-23 14:19 ` David Lechner
2024-07-24 13:07 ` Nuno Sá
2024-07-22 21:57 ` [PATCH RFC v3 7/9] iio: buffer-dmaengine: generalize requesting DMA channel David Lechner
2024-07-27 13:43 ` Jonathan Cameron
2024-07-22 21:57 ` [PATCH RFC v3 8/9] dt-bindings: iio: adc: adi,ad7944: add SPI offload properties David Lechner
2024-07-22 21:57 ` [PATCH RFC v3 9/9] iio: adc: ad7944: add support for SPI offload David Lechner
2024-07-23 8:22 ` Nuno Sá
2024-07-27 13:50 ` Jonathan Cameron
2024-07-23 7:35 ` [PATCH RFC v3 0/9] spi: axi-spi-engine: add offload support Nuno Sá
2024-07-23 13:48 ` David Lechner
2024-07-24 13:16 ` Nuno Sá
2024-07-23 8:58 ` Conor Dooley
2024-08-14 16:06 ` Conor Dooley
2024-09-05 11:33 ` 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=ffa0e8ceea5663fa3d93664735fd867b7b5891b8.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=david@protonic.nl \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=kernel@martin.sperl.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@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;
as well as URLs for NNTP newsgroup(s).