All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gurchetan Singh <gurchetansingh@chromium.org>
To: dri-devel@lists.freedesktop.org
Cc: daniel.vetter@ffwll.ch, kraxel@redhat.com, tzimmermann@suse.de
Subject: [PATCH 1/2] drm/shmem: add support for per object dma api operations
Date: Thu, 11 Jun 2020 18:36:24 -0700	[thread overview]
Message-ID: <20200612013625.547-1-gurchetansingh@chromium.org> (raw)

This is useful for the next patch.  Also, should we only unmap the
amount entries that we mapped with the dma-api?

Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org>
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 16 +++++++++++-----
 include/drm/drm_gem_shmem_helper.h     | 10 ++++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 0a7e3b664bc2..d439074ad7b5 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -124,8 +124,10 @@ void drm_gem_shmem_free_object(struct drm_gem_object *obj)
 		drm_prime_gem_destroy(obj, shmem->sgt);
 	} else {
 		if (shmem->sgt) {
-			dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
-				     shmem->sgt->nents, DMA_BIDIRECTIONAL);
+			if (!shmem->skip_dma_api)
+				dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
+					     shmem->dma_map_count,
+					     DMA_BIDIRECTIONAL);
 			sg_free_table(shmem->sgt);
 			kfree(shmem->sgt);
 		}
@@ -422,8 +424,9 @@ void drm_gem_shmem_purge_locked(struct drm_gem_object *obj)
 
 	WARN_ON(!drm_gem_shmem_is_purgeable(shmem));
 
-	dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
-		     shmem->sgt->nents, DMA_BIDIRECTIONAL);
+	if (!shmem->skip_dma_api)
+		dma_unmap_sg(obj->dev->dev, shmem->sgt->sgl,
+			     shmem->dma_map_count, DMA_BIDIRECTIONAL);
 	sg_free_table(shmem->sgt);
 	kfree(shmem->sgt);
 	shmem->sgt = NULL;
@@ -695,7 +698,10 @@ struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj)
 		goto err_put_pages;
 	}
 	/* Map the pages for use by the h/w. */
-	dma_map_sg(obj->dev->dev, sgt->sgl, sgt->nents, DMA_BIDIRECTIONAL);
+	if (!shmem->skip_dma_api)
+		shmem->dma_map_count = dma_map_sg(obj->dev->dev, sgt->sgl,
+						  sgt->nents,
+						  DMA_BIDIRECTIONAL);
 
 	shmem->sgt = sgt;
 
diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index 5381f0c8cf6f..2669d87cbfdd 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -101,6 +101,16 @@ struct drm_gem_shmem_object {
 	 * @map_cached: map object cached (instead of using writecombine).
 	 */
 	bool map_cached;
+
+	/**
+	 * @skip_dma_api: skip using dma api in certain places.
+	 */
+	bool skip_dma_api;
+
+	/**
+	 * @skip_dma_api: number of pages mapped by dma-api.
+	 */
+	bool dma_map_count;
 };
 
 #define to_drm_gem_shmem_obj(obj) \
-- 
2.25.1

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

             reply	other threads:[~2020-06-12  1:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-12  1:36 Gurchetan Singh [this message]
2020-06-12  1:36 ` [PATCH 2/2] drm/virtio: rely on drm shmem helpers to take care of dma_map/dma_unmap Gurchetan Singh
2020-06-12  9:47 ` [PATCH 1/2] drm/shmem: add support for per object dma api operations Thomas Zimmermann
2020-06-12 10:16   ` Gerd Hoffmann
2020-06-12 12:10     ` Daniel Vetter
2020-06-12 18:54     ` Gurchetan Singh
2020-06-15  6:58       ` Thomas Zimmermann
2020-06-15  7:21       ` Gerd Hoffmann
2020-06-22 23:56         ` Gurchetan Singh

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=20200612013625.547-1-gurchetansingh@chromium.org \
    --to=gurchetansingh@chromium.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=kraxel@redhat.com \
    --cc=tzimmermann@suse.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 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.