From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: "Nuno Sá" <nuno.sa@analog.com>,
linux-iio@vger.kernel.org, "Paul Cercueil" <paul@crapouillou.net>,
"David Lechner" <dlechner@baylibre.com>,
"Andy Shevchenko" <andy@kernel.org>
Subject: Re: [PATCH] iio: buffer-dmaengine: fix sg entry iteration when building dma_vecs
Date: Sun, 23 Aug 2026 01:23:18 +0100 [thread overview]
Message-ID: <20260823012318.77fcd990@jic23-huawei> (raw)
In-Reply-To: <aoYYB5ANWI6GILER@ashevche-desk.local>
On Wed, 19 Aug 2026 23:54:31 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> On Wed, Aug 19, 2026 at 01:41:04AM +0100, Jonathan Cameron wrote:
> > On Tue, 18 Aug 2026 17:45:29 +0100
> > Nuno Sá <nuno.sa@analog.com> wrote:
>
> ...
>
> > > sgl = block->sg_table->sgl;
> > > - nents = sg_nents_for_len(sgl, block->bytes_used);
> > > - if (nents < 0)
> > > - return nents;
> > > + nents = sg_nents_for_dma(sgl, block->sg_table->nents, max_size);
> >
> > So this fun function will generally give us the number of sgl entries, but not
> > quite always. It will give us how many chunks of up to max_size fit into
> > a particularly large entry.
>
> It gives the number of SG entries needed for the case if each of them will
> satisfy the limit. Whatever following code does, it may allocate a new SG
> list based on the number returned by this function and resplit.
Yup. That's what would be needed if the condition can actually occur.
Also, Nuno is (I think) suggesting the dma engine driver itself
deals with that splitting when it is needed. So hopefully this
is a place where we can apply the someone else's problem field ;)
>
> > > - for (i = 0; i < nents; i++) {
> > > + for (i = 0; i < nents && len_total; i++) {
> > So this needs to be more clever as we aren't just iterating entrees and filling
> > them in, some of them could at least in theory be too big to fit
> > in a single vec - hence you need to do a loop in here that sets
> > multiple entries if that occurs.
> >
> > If that can't happen for some other reason then I think you can
> > just use block->sgtable->nents instead of the more complex call above.
>
> Perhaps sg_split() is what people are looking for in this case?
I'd forgotten that nugget of fun existed. There is a patch on list
to drop the one driver I ever used it in - bringing the total users
down to 4! :) I don't think it applies here though as we are talking
splitting one entry of the list, not the whole list.
That list splitting is for when you have a constraint on the total max DMA
done in one request.
Jonathan
>
prev parent reply other threads:[~2026-08-23 0:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 16:45 [PATCH] iio: buffer-dmaengine: fix sg entry iteration when building dma_vecs Nuno Sá
2026-08-19 0:41 ` Jonathan Cameron
2026-08-19 10:16 ` Nuno Sá
2026-08-23 0:16 ` Jonathan Cameron
2026-08-24 10:48 ` Nuno Sá
2026-08-19 20:54 ` Andy Shevchenko
2026-08-23 0:23 ` Jonathan Cameron [this message]
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=20260823012318.77fcd990@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=paul@crapouillou.net \
/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