From: Jason Gunthorpe <jgg@mellanox.com>
To: Daniel Drake <drake@endlessm.com>
Cc: "imre.deak@intel.com" <imre.deak@intel.com>,
Linux Kernel <linux-kernel@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
Oleksij Rempel <linux@rempel-privat.de>
Subject: Re: sg_dma_page_iter offset & length considerations
Date: Wed, 24 Apr 2019 11:21:59 +0000 [thread overview]
Message-ID: <20190424112153.GB16077@mellanox.com> (raw)
In-Reply-To: <CAD8Lp47JYdZzbV9F+asNwvSfLF_po_J7ir6R_Vb-Dab21_=Krw@mail.gmail.com>
On Wed, Apr 24, 2019 at 03:22:18PM +0800, Daniel Drake wrote:
> Hi,
>
> In drivers/mmc/alcor.c we're working with a MMC controller which
> supports DMA transfers split up into page-sized chunks.
Keep in mind that sg_page_iter_page splits into PAGE_SIZE chuncks, so
if you HW needs exactly a 4k chunk or something then it is not the
right API.
I have in mind the idea to move this code:
https://patchwork.kernel.org/patch/10909379/
Into the global scatterlist someday if there are other users in the
tree that need arbitary splitting..
> Specifically I can see userspace generates requests which present a
> sglist such as:
> - first entry with offset=1536 length=2560
> - 7 entries with offset=0 length=4096
> - last entry with offset=0 length=1536
>
> I gather that dma_map_sg() will take care off the offsets, i.e. any
> physical address I get with sg_page_iter_dma_address() will already
> have the offset applied, so I don't have to worry about tracking that.
Well the DMA iter aligns everything to pages so all the offsets are
lost.
> But what about the length? For every page returned by the iterator, I
> can't assume that I am being asked to work with the full page,
> right?
So far no user has required the length/offset, but it would be easy
enough to make a function to calculate these values for the current
step.
This is because this API is used by drivers building page lists for
HW, and they usually have additional information outside the SGL that
indicates what the start/end offsets are.
A driver that simply wants a SGL with a capped max size (ie 4k?)
should use the dma_set_max_seg_size() API and just never get a SGE
with a larger length.
But the SGE may still cross a page boundary..
Jason
next prev parent reply other threads:[~2019-04-24 11:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-24 7:22 Daniel Drake
2019-04-24 7:57 ` Arnd Bergmann
2019-04-24 11:21 ` Jason Gunthorpe [this message]
2019-04-25 7:38 ` Daniel Drake
2019-04-25 8:02 ` Christoph Hellwig
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=20190424112153.GB16077@mellanox.com \
--to=jgg@mellanox.com \
--cc=drake@endlessm.com \
--cc=imre.deak@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux@rempel-privat.de \
/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®