mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: "Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Vinod Koul" <vkoul@kernel.org>
Cc: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org,
	dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org
Subject: Re: Question: partial transfers of DMABUFs
Date: Wed, 15 Feb 2023 11:47:55 +0000	[thread overview]
Message-ID: <d540965a25138772fa063d62e907ffd611f93205.camel@crapouillou.net> (raw)
In-Reply-To: <836d600a-bb1c-fbb2-89f5-7c79c3150e8c@linux.intel.com>

Hi Maarten,

Le mercredi 15 février 2023 à 12:30 +0100, Maarten Lankhorst a écrit :
> Hey,
> 
> On 2023-02-15 11:48, Paul Cercueil wrote:
> > Hi,
> > 
> > I am working on adding support for DMABUFs in the IIO subsystem.
> > 
> > One thing we want there, is the ability to specify the number of
> > bytes
> > to transfer (while still defaulting to the DMABUF size).
> > 
> > Since dma_buf_map_attachment() returns a sg_table, I basically have
> > two
> > options, and I can't decide which one is the best (or the less
> > ugly):
> > 
> > - Either I add a new API function similar to
> > dmaengine_prep_slave_sg(),
> > which still takes a scatterlist as argument but also takes the
> > number
> > of bytes as argument;
> > 
> > - Or I add a function to duplicate the scatterlist and then shrink
> > it
> > manually, which doesn't sound like a good idea either.
> > 
> > What would be the recommended way?
> 
> Does this need an api change? If you create a DMA-BUF of size X, it
> has 
> to be of size X. You can pad with a dummy page probably if you know
> it 
> in advance. But after it has been imported, it cannot change size.

Yes, the sizes are fixed.

> You don´t have to write the entire dma-buf either, so if you want to 
> create a 1GB buf and only use the first 4K, that is allowed. The 
> contents of  the remainder of the DMA-BUF are undefined. It's up to 
> userspace to assign a meaning to it.
> 
> I think I'm missing something here that makes the whole question
> m,ake 
> more sense.

I want my userspace to be able to specify how much of the DMABUF is to
be read from or written to.

So in my new "dmabuf enqueue" IOCTL that I want to add to IIO, I added
a parameter to specify the number of bytes to transfer (where 0 means
the whole buffer).

The problem I have now, is that the current dmaengine core does not
have a API function that takes a scatterlist (returned by
dma_map_attachment()) and a transfer size in bytes, it will always
transfer the whole scatterlist.

So my two options would be to add a new API function to support
specifying a bytes count, or add a mechanism to duplicate a
scatterlist, so that I can tweak it to the right size.

> ~Maarten

Cheers,
-Paul

  reply	other threads:[~2023-02-15 11:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 10:48 Paul Cercueil
2023-02-15 11:30 ` Maarten Lankhorst
2023-02-15 11:47   ` Paul Cercueil [this message]
2023-02-15 11:52     ` Maarten Lankhorst
2023-02-15 12:00       ` Paul Cercueil
2023-02-15 12:13         ` Maarten Lankhorst
2023-02-15 13:17           ` Paul Cercueil
2023-02-15 12:58 ` Christian König
2023-02-15 13:24   ` Paul Cercueil
2023-02-15 13:46     ` Christian König
2023-02-15 13:52       ` Paul Cercueil
2023-02-15 13:56         ` Christian König

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=d540965a25138772fa063d62e907ffd611f93205.camel@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=christian.koenig@amd.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=sumit.semwal@linaro.org \
    --cc=vkoul@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®