All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org
Subject: [PATCH 14/14] drm/tegra: gem: Use sg_alloc_table_from_pages()
Date: Mon, 14 Oct 2019 14:50:49 +0200	[thread overview]
Message-ID: <20191014125049.425101-15-thierry.reding@gmail.com> (raw)
In-Reply-To: <20191014125049.425101-1-thierry.reding@gmail.com>

From: Thierry Reding <treding@nvidia.com>

Instead of manually creating the SG table for a discontiguous buffer,
use the existing sg_alloc_table_from_pages(). Note that this is not safe
to be used with the ARM DMA/IOMMU integration code because that will not
ensure that the whole buffer is mapped contiguously. Depending on the
size of the individual entries the mapping may end up containing holes
to ensure alignment.

However, we only ever use these buffers with explicit IOMMU API usage
and know how to avoid these holes.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/gpu/drm/tegra/gem.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tegra/gem.c b/drivers/gpu/drm/tegra/gem.c
index 00701cadaceb..d2f88cc3134f 100644
--- a/drivers/gpu/drm/tegra/gem.c
+++ b/drivers/gpu/drm/tegra/gem.c
@@ -508,14 +508,9 @@ tegra_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
 		return NULL;
 
 	if (bo->pages) {
-		struct scatterlist *sg;
-		unsigned int i;
-
-		if (sg_alloc_table(sgt, bo->num_pages, GFP_KERNEL))
+		if (sg_alloc_table_from_pages(sgt, bo->pages, bo->num_pages,
+					      0, gem->size, GFP_KERNEL) < 0)
 			goto free;
-
-		for_each_sg(sgt->sgl, sg, bo->num_pages, i)
-			sg_set_page(sg, bo->pages[i], PAGE_SIZE, 0);
 	} else {
 		if (dma_get_sgtable(attach->dev, sgt, bo->vaddr, bo->iova,
 				    gem->size) < 0)
-- 
2.23.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2019-10-14 12:50 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-14 12:50 [PATCH 00/14] drm/tegra: Miscellaneous cleanups Thierry Reding
2019-10-14 12:50 ` [PATCH 01/14] gpu: host1x: Do not limit DMA segment size Thierry Reding
2019-10-14 12:50 ` [PATCH 02/14] gpu: host1x: Remove gratuitous blank line Thierry Reding
2019-10-14 12:50 ` [PATCH 03/14] gpu: host1x: Explicitly initialize host1x_info structures Thierry Reding
2019-10-14 12:50 ` [PATCH 04/14] gpu: host1x: Request channels for clients, not devices Thierry Reding
2019-10-14 12:50 ` [PATCH 05/14] drm/tegra: Inherit device DMA parameters from host1x Thierry Reding
2019-10-14 12:50 ` [PATCH 06/14] drm/tegra: Use DRM_DEBUG_DRIVER for driver messages Thierry Reding
2019-10-14 12:50 ` [PATCH 07/14] drm/tegra: vic: Skip stream ID programming without IOMMU Thierry Reding
2019-10-14 12:50 ` [PATCH 08/14] drm/tegra: vic: Inherit DMA mask from host1x Thierry Reding
2019-10-14 12:50 ` [PATCH 09/14] drm/tegra: vic: Use common IOMMU attach/detach code Thierry Reding
2019-10-14 12:50 ` [PATCH 10/14] drm/tegra: Move IOMMU group into host1x client Thierry Reding
2019-10-14 14:06   ` kbuild test robot
2019-10-16 15:33   ` Dmitry Osipenko
2019-10-18 11:05     ` Dmitry Osipenko
2019-10-14 12:50 ` [PATCH 11/14] drm/tegra: gem: Rename paddr -> iova Thierry Reding
2019-10-14 12:50 ` [PATCH 12/14] drm/tegra: gem: Use dma_get_sgtable() Thierry Reding
2019-10-14 12:50 ` [PATCH 13/14] drm/tegra: gem: Always map SG tables for DMA-BUFs Thierry Reding
2019-10-14 12:50 ` Thierry Reding [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=20191014125049.425101-15-thierry.reding@gmail.com \
    --to=thierry.reding@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-tegra@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.