From: Jonathan Cameron <jic23@kernel.org>
To: "Nuno Sá" <noname.nuno@gmail.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy.shevchenko@gmail.com>,
"Antoniu Miclaus" <antoniu.miclaus@analog.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Mark Brown" <broonie@kernel.org>
Subject: Re: [PATCH] iio: amplifiers: ada4250: use DMA-safe memory for regmap_bulk_read()
Date: Mon, 21 Apr 2025 14:56:06 +0100 [thread overview]
Message-ID: <20250421145606.7620bf25@jic23-huawei> (raw)
In-Reply-To: <3875da4e070f991484b8536f6066347615b0815a.camel@gmail.com>
On Mon, 21 Apr 2025 14:00:30 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Mon, 2025-04-21 at 11:57 +0100, Jonathan Cameron wrote:
> > On Sat, 19 Apr 2025 13:07:25 -0500
> > David Lechner <dlechner@baylibre.com> wrote:
> >
> > > On 4/19/25 10:03 AM, Andy Shevchenko wrote:
> > > > On Fri, Apr 18, 2025 at 02:09:04PM -0500, David Lechner wrote:
> > > > > On 4/18/25 1:58 PM, Andy Shevchenko wrote:
> > > > > > пʼятниця, 18 квітня 2025 р. David Lechner
> > > > > > <dlechner@baylibre.com <mailto:dlechner@baylibre.com>> пише:
> > > > > >
> > > > > > Use DMA-safe memory instead of stack-allocated memory for the call
> > > > > > to
> > > > > > regmap_bulk_read() in the ada4250_init() function as this could be
> > > > > > used
> > > > > > directly by a SPI controller.
> > > > > >
> > > > > > Sorry, but can you elaborate more on this? If driver doesn’t override
> > > > > > the
> > > > > > callbacks the regmap SPI uses spi_write_then_read() which is supposed
> > > > > > to be
> > > > > > dma safe.
> > > > >
> > > > > Ah, I didn't dig that far down. Will send a new patch that just cleans
> > > > > up the
> > > > > unnecessary alignment and unaligned call.
> > > >
> > > > But do you have a real life issue with that? Coincidentally we discussed
> > > > similar case in another driver with colleague of mine, and he insists that
> > > > it
> > > > might be still broken (somewhere).
> > > >
> > >
> > > Some drivers that use regmap with SPI implement their own read and write
> > > callbacks if the default one doesn't work, so maybe something like that?
> > >
> >
> > I asked Mark about this long ago. Maybe the guidance has changed, but the
> > request
> > if my memory is correct was to treat bulk regmap accesses with the same care
> > wrt to
> > DMA safety that we treat direct use of the underlying bus accessors.
> > (unfortunately I have no idea what thread this was in!)
> >
> > The reasoning I think was that it was an implementation detail whether
> > regmap copied the data or not for bulk accesses. Back then I chased through
> > the SPI case and couldn't find a path that didn't bounce the data (though some
> > paths could have been made zero copy).
> >
>
> Looking on the implementation, indeed it looks like that everything should be
> fine... However, IMO, David's reasoning about potential drivers using their own
> regmap_bus (or just overriding read and write) is perhaps justification enough
> for doing it.
That's in a specific driver which is the same one allocating the buffer.
Doing it defensively in other drivers is probably a step too far if we don't
still want to do it everwhere regmap and SPI are combined.
Jonathan
>
> - Nuno Sá
>
> > Anyhow, +CC Mark as maybe I remembered that wrong or his view has
> > changed!
> >
> > Jonathan
next prev parent reply other threads:[~2025-04-21 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 18:16 [PATCH] iio: amplifiers: ada4250: use DMA-safe memory for regmap_bulk_read() David Lechner
[not found] ` <CAHp75Vdxdbqu6qkbuo5y4jADOH_h9Re6m8icSj3Je4hnVsha0g@mail.gmail.com>
2025-04-18 19:09 ` David Lechner
2025-04-19 15:03 ` Andy Shevchenko
2025-04-19 18:07 ` David Lechner
2025-04-21 10:57 ` Jonathan Cameron
2025-04-21 13:00 ` Nuno Sá
2025-04-21 13:56 ` Jonathan Cameron [this message]
2025-05-25 17:31 ` Jonathan Cameron
2025-04-21 10:59 ` Jonathan Cameron
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=20250421145606.7620bf25@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=antoniu.miclaus@analog.com \
--cc=broonie@kernel.org \
--cc=dlechner@baylibre.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=noname.nuno@gmail.com \
--cc=nuno.sa@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox