From: Jonathan Cameron <jic23@kernel.org>
To: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
Cc: Rodrigo Alencar via B4 Relay
<devnull+rodrigo.alencar.analog.com@kernel.org>,
rodrigo.alencar@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Michael Auchter <michael.auchter@ni.com>,
linux-hardening@vger.kernel.org,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Philipp Zabel <p.zabel@pengutronix.de>
Subject: Re: [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus
Date: Fri, 24 Apr 2026 18:02:35 +0100 [thread overview]
Message-ID: <20260424180235.22bdf98c@jic23-huawei> (raw)
In-Reply-To: <umhebqm7nwcg6h5y77egrh7nirtpjpin5t42oxifo5em4jmsyj@gavxnwsadyuh>
On Fri, 24 Apr 2026 09:58:39 +0100
Rodrigo Alencar <455.rodrigo.alencar@gmail.com> wrote:
> On 26/04/23 07:18PM, Jonathan Cameron wrote:
> > On Wed, 22 Apr 2026 15:45:54 +0100
> > Rodrigo Alencar via B4 Relay <devnull+rodrigo.alencar.analog.com@kernel.org> wrote:
> >
> > > From: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > >
> > > Use of local SPI bus data to manage a collection of SPI transfers and
> > > flush them to the SPI platform driver with the sync() operation. This
> > > allows for faster handling of multiple channel DAC writes, avoiding kernel
> > > overhead per spi_sync() call, which will be helpful when enabling
> > > triggered buffer support.
> > >
> > > Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
> > Interesting approach to potentially optimise for SPI. Do you have
> > perf numbers or similar to support it being worth the effort?
>
> Short answer is no, I can try to produce some benchmarks, but I am not sure it
> is needed. The implementation here prepares the ground for triggered buffer support,
> which adds the capability of implementing a control loop in userspace that updates
> all the enabled channels at once. That will happen in a trigger handler, then we want
> that to be as fast as possible, so it can be prepared for the next trigger event.
> It is not really about calling a function once rather than multiple times, but the
> problem happens when the device is sharing the spi bus with other devices and how busy the
> system is in general, so there may be context switches in the spi platform driver with
> one or two mutex acquire/release operations, which may add bigger delays between
> transfers, which depends on what the other devices are doing. I suppose that devices with
> high channel count like 8 or 16 can benefit with this.
Fair enough. There is enough complexity here that maybe a perf
number would strengthen the argument. I'm reasonably happy with
that complexity anyway so this would be if anyone else pushed back.
>
> > Otherwise a few minor comments inline.
>
> ...
>
> > > @@ -84,8 +107,18 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr)
> > > AD5686_ADDR(addr));
> > > st->data[1].d32 = cpu_to_be32(AD5686_CMD(AD5686_CMD_NOOP));
> > >
> > > - ret = spi_sync_transfer(spi, t, ARRAY_SIZE(t));
> > > - if (ret < 0)
> > > + xfer[0].tx_buf = &st->data[0].d8[1];
> > > + xfer[0].len = 3;
> > > + xfer[0].cs_change = 1;
> > > + xfer[1].tx_buf = &st->data[1].d8[1];
> > > + xfer[1].rx_buf = &st->data[2].d8[1];
> > > + xfer[1].len = 3;
> > > + xfer[1].cs_change = 0;
> > > +
> > > + spi_message_init_with_transfers(&bus_data->msg, xfer, 2);
> >
> > Why not carry on using spi_sync_transfer() here?
> > We'll end up with an spi message the stack but I suspect that's
> > not a significant performance cost.
>
> True, it would be around 200 extra bytes in the stack, and read operations
> would not happen concurrently with writes, so why not reuse resources
> (message and transfer structs) that is now available in the bus data?
> To me, it allows for consistency in this implementation.
>
Reusing transfers makes sense. I was a little less clear on reusing the
message because we can't then use the helper (which is all spi_sync_transfer()
really is). Not particularly important either way.
> > > +
> > > + ret = spi_sync(spi, &bus_data->msg);
> > > + if (ret)
> > > return ret;
> > >
> > > return be32_to_cpu(st->data[2].d32);
>
next prev parent reply other threads:[~2026-04-24 17:02 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 14:45 [PATCH 00/22] Extend device support for AD5686 driver Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 01/22] dt-bindings: iio: dac: ad5696: extend device support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:33 ` Conor Dooley
2026-04-22 14:45 ` [PATCH 02/22] dt-bindings: iio: dac: ad5696: add reset/ldac/gain gpio support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:34 ` Conor Dooley
2026-04-22 14:45 ` [PATCH 03/22] dt-bindings: iio: dac: ad5696: rework on power supplies Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:47 ` Jonathan Cameron
2026-04-24 7:44 ` Rodrigo Alencar
2026-04-24 17:04 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 04/22] dt-bindings: iio: dac: ad5686: extend device support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:33 ` Conor Dooley
2026-04-22 14:45 ` [PATCH 05/22] dt-bindings: iio: dac: ad5686: add reset/ldac/gain gpio support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:34 ` Conor Dooley
2026-04-22 14:45 ` [PATCH 06/22] dt-bindings: iio: dac: ad5686: rework on power supplies Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 17:32 ` Conor Dooley
2026-04-24 7:35 ` Rodrigo Alencar
2026-04-24 17:10 ` Conor Dooley
2026-04-22 14:45 ` [PATCH 07/22] iio: dac: ad5686: refactor include headers Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:43 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 08/22] iio: dac: ad5686: remove redundant register definition Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:47 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 09/22] iio: dac: ad5686: drop enum id Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 10/22] iio: dac: ad5686: add of_match table to the spi driver Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 11/22] iio: dac: ad5686: fix ref bit initialization for single-channel parts Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 19:58 ` Andy Shevchenko
2026-04-23 17:56 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 12/22] iio: dac: ad5686: fix powerdown control Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 20:25 ` Andy Shevchenko
2026-04-23 17:59 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 13/22] iio: dac: ad5686: fix input raw value check Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 8:13 ` Nuno Sá
2026-04-23 18:03 ` Jonathan Cameron
2026-04-24 8:03 ` Nuno Sá
2026-04-22 14:45 ` [PATCH 14/22] iio: dac: ad5686: add support for missing power supplies Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 18:05 ` Jonathan Cameron
2026-04-24 8:08 ` Rodrigo Alencar
2026-04-24 17:10 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 15/22] iio: dac: ad5686: create bus ops struct Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 18:09 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 16/22] iio: dac: ad5686: extend device support with new parts Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 17/22] iio: dac: ad5686: update device list description Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 20:06 ` Andy Shevchenko
2026-04-22 20:07 ` Andy Shevchenko
2026-04-22 14:45 ` [PATCH 18/22] iio: dac: ad5686: consume optional reset signal Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-24 9:25 ` Philipp Zabel
2026-04-22 14:45 ` [PATCH 19/22] iio: dac: ad5686: add ldac gpio Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-22 14:45 ` [PATCH 20/22] iio: dac: ad5686: implement new sync() op for the spi bus Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 18:18 ` Jonathan Cameron
2026-04-24 8:58 ` Rodrigo Alencar
2026-04-24 17:02 ` Jonathan Cameron [this message]
2026-04-22 14:45 ` [PATCH 21/22] iio: dac: ad5686: add triggered buffer support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 18:27 ` Jonathan Cameron
2026-04-24 9:20 ` Rodrigo Alencar
2026-04-24 17:11 ` Jonathan Cameron
2026-04-22 14:45 ` [PATCH 22/22] iio: dac: ad5686: add gain control support Rodrigo Alencar
2026-04-22 14:45 ` Rodrigo Alencar via B4 Relay
2026-04-23 18:29 ` Jonathan Cameron
2026-04-22 20:28 ` [PATCH 00/22] Extend device support for AD5686 driver Andy Shevchenko
2026-04-23 18:32 ` Jonathan Cameron
2026-04-23 8:44 ` Krzysztof Kozlowski
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=20260424180235.22bdf98c@jic23-huawei \
--to=jic23@kernel.org \
--cc=455.rodrigo.alencar@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+rodrigo.alencar.analog.com@kernel.org \
--cc=dlechner@baylibre.com \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.auchter@ni.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=rodrigo.alencar@analog.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.