From: Jason Gunthorpe <jgg@ziepe.ca>
To: Oded Gabbay <ogabbay@kernel.org>
Cc: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
sumit.semwal@linaro.org, christian.koenig@amd.com,
daniel.vetter@ffwll.ch, galpress@amazon.com, sleybo@amazon.com,
dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org,
linux-media@vger.kernel.org, dledford@redhat.com,
airlied@gmail.com, alexander.deucher@amd.com, leonro@nvidia.com,
hch@lst.de, amd-gfx@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, Tomer Tayar <ttayar@habana.ai>
Subject: Re: [PATCH v4 2/2] habanalabs: add support for dma-buf exporter
Date: Mon, 5 Jul 2021 13:52:26 -0300 [thread overview]
Message-ID: <20210705165226.GJ4604@ziepe.ca> (raw)
In-Reply-To: <20210705130314.11519-3-ogabbay@kernel.org>
On Mon, Jul 05, 2021 at 04:03:14PM +0300, Oded Gabbay wrote:
> + rc = sg_alloc_table(*sgt, nents, GFP_KERNEL | __GFP_ZERO);
> + if (rc)
> + goto error_free;
If you are not going to include a CPU list then I suggest setting
sg_table->orig_nents == 0
And using only the nents which is the length of the DMA list.
At least it gives some hope that other parts of the system could
detect this.
> +
> + /* Merge pages and put them into the scatterlist */
> + cur_page = 0;
> + for_each_sgtable_sg((*sgt), sg, i) {
for_each_sgtable_sg should never be used when working with
sg_dma_address() type stuff, here and everywhere else. The DMA list
should be iterated using the for_each_sgtable_dma_sg() macro.
> + /* In case we got a large memory area to export, we need to divide it
> + * to smaller areas because each entry in the dmabuf sgt can only
> + * describe unsigned int.
> + */
Huh? This is forming a SGL, it should follow the SGL rules which means
you have to fragment based on the dma_get_max_seg_size() of the
importer device.
> + hl_dmabuf->pages = kcalloc(hl_dmabuf->npages, sizeof(*hl_dmabuf->pages),
> + GFP_KERNEL);
> + if (!hl_dmabuf->pages) {
> + rc = -ENOMEM;
> + goto err_free_dmabuf_wrapper;
> + }
Why not just create the SGL directly? Is there a reason it needs to
make a page list?
Jason
next prev parent reply other threads:[~2021-07-05 16:52 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 13:03 [PATCH v4 0/2] Add p2p via dmabuf to habanalabs Oded Gabbay
2021-07-05 13:03 ` [PATCH v4 1/2] habanalabs: define uAPI to export FD for DMA-BUF Oded Gabbay
2021-07-05 13:03 ` [PATCH v4 2/2] habanalabs: add support for dma-buf exporter Oded Gabbay
2021-07-05 16:52 ` Jason Gunthorpe [this message]
2021-07-06 9:44 ` Oded Gabbay
2021-07-06 13:54 ` Jason Gunthorpe
2021-07-06 8:40 ` [PATCH v4 0/2] Add p2p via dmabuf to habanalabs Daniel Vetter
2021-07-06 10:03 ` Oded Gabbay
2021-07-06 10:36 ` Daniel Vetter
2021-07-06 10:47 ` Daniel Vetter
2021-07-06 12:07 ` Daniel Vetter
2021-07-06 13:44 ` Jason Gunthorpe
2021-07-06 14:09 ` Daniel Vetter
2021-07-06 14:56 ` Jason Gunthorpe
2021-07-06 15:52 ` Daniel Vetter
2021-07-06 12:23 ` Christoph Hellwig
2021-07-06 14:23 ` Jason Gunthorpe
2021-07-06 14:39 ` Daniel Vetter
2021-07-06 15:25 ` Jason Gunthorpe
2021-07-06 15:49 ` Daniel Vetter
2021-07-06 16:07 ` Daniel Vetter
2021-07-06 17:28 ` Jason Gunthorpe
2021-07-06 17:31 ` Christoph Hellwig
2021-07-06 17:59 ` Jason Gunthorpe
2021-07-09 14:47 ` Dennis Dalessandro
2021-07-06 16:29 ` Jason Gunthorpe
2021-07-06 17:35 ` Daniel Vetter
2021-07-06 18:03 ` Daniel Vetter
2021-07-06 18:31 ` Jason Gunthorpe
2021-07-06 19:06 ` Daniel Vetter
2021-07-06 19:09 ` Alex Deucher
2021-07-06 12:21 ` Christoph Hellwig
2021-07-06 12:23 ` [Linaro-mm-sig] " Daniel Vetter
2021-07-06 12:45 ` Oded Gabbay
2021-07-06 13:17 ` Daniel Vetter
2021-07-06 13:45 ` Oded Gabbay
2021-07-07 12:17 ` Christian König
2021-07-07 12:54 ` Daniel Vetter
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=20210705165226.GJ4604@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dledford@redhat.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=galpress@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=hch@lst.de \
--cc=leonro@nvidia.com \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=ogabbay@kernel.org \
--cc=sleybo@amazon.com \
--cc=sumit.semwal@linaro.org \
--cc=ttayar@habana.ai \
/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;
as well as URLs for NNTP newsgroup(s).