From: Rob Clark <robdclark@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Christoph Hellwig <hch@lst.de>,
Rob Clark <robdclark@chromium.org>,
Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] drm/msm: stop abusing DMA API
Date: Wed, 14 Aug 2019 15:00:00 -0700 [thread overview]
Message-ID: <20190814220011.26934-6-robdclark@gmail.com> (raw)
In-Reply-To: <20190814220011.26934-1-robdclark@gmail.com>
From: Rob Clark <robdclark@chromium.org>
Use arch_sync_dma_for_{device,cpu}() rather than abusing the DMA API to
indirectly get at the arch_sync_dma code.
Signed-off-by: Rob Clark <robdclark@chromium.org>
---
drivers/gpu/drm/msm/msm_gem.c | 37 +++++++++++------------------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 8cf6362e64bf..a2611e62df19 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -7,6 +7,7 @@
#include <linux/spinlock.h>
#include <linux/shmem_fs.h>
#include <linux/dma-buf.h>
+#include <linux/dma-noncoherent.h>
#include <linux/pfn_t.h>
#include "msm_drv.h"
@@ -32,43 +33,27 @@ static bool use_pages(struct drm_gem_object *obj)
return !msm_obj->vram_node;
}
-/*
- * Cache sync.. this is a bit over-complicated, to fit dma-mapping
- * API. Really GPU cache is out of scope here (handled on cmdstream)
- * and all we need to do is invalidate newly allocated pages before
- * mapping to CPU as uncached/writecombine.
- *
- * On top of this, we have the added headache, that depending on
- * display generation, the display's iommu may be wired up to either
- * the toplevel drm device (mdss), or to the mdp sub-node, meaning
- * that here we either have dma-direct or iommu ops.
- *
- * Let this be a cautionary tail of abstraction gone wrong.
- */
-
static void sync_for_device(struct msm_gem_object *msm_obj)
{
struct device *dev = msm_obj->base.dev->dev;
+ struct scatterlist *sg;
+ int i;
- if (get_dma_ops(dev)) {
- dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
- msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
- } else {
- dma_map_sg(dev, msm_obj->sgt->sgl,
- msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+ for_each_sg(msm_obj->sgt->sgl, sg, msm_obj->sgt->nents, i) {
+ arch_sync_dma_for_device(dev, sg_phys(sg), sg->length,
+ DMA_BIDIRECTIONAL);
}
}
static void sync_for_cpu(struct msm_gem_object *msm_obj)
{
struct device *dev = msm_obj->base.dev->dev;
+ struct scatterlist *sg;
+ int i;
- if (get_dma_ops(dev)) {
- dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
- msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
- } else {
- dma_unmap_sg(dev, msm_obj->sgt->sgl,
- msm_obj->sgt->nents, DMA_BIDIRECTIONAL);
+ for_each_sg(msm_obj->sgt->sgl, sg, msm_obj->sgt->nents, i) {
+ arch_sync_dma_for_cpu(dev, sg_phys(sg), sg->length,
+ DMA_BIDIRECTIONAL);
}
}
--
2.21.0
next prev parent reply other threads:[~2019-08-14 22:16 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-14 21:59 [PATCH 0/6] drm+dma: cache support for arm, etc Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` [PATCH 1/6] arm64: export arch_sync_dma_for_*() Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` [PATCH 2/6] mips: " Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` [PATCH 3/6] powerpc: " Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` [PATCH 4/6] arm: add arch_sync_dma_for_*() Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 21:59 ` Rob Clark
2019-08-14 22:00 ` Rob Clark [this message]
2019-08-14 22:00 ` [PATCH 6/6] drm/vgem: fix cache synchronization on arm/arm64 (take two) Rob Clark
2019-08-15 6:51 ` [PATCH 0/6] drm+dma: cache support for arm, etc Christoph Hellwig
2019-08-15 6:51 ` Christoph Hellwig
2019-08-15 6:51 ` Christoph Hellwig
2019-08-15 13:54 ` Rob Clark
2019-08-15 13:54 ` Rob Clark
2019-08-15 13:54 ` Rob Clark
2019-08-15 17:53 ` Christoph Hellwig
2019-08-15 17:53 ` Christoph Hellwig
2019-08-15 17:53 ` Christoph Hellwig
2019-08-15 18:21 ` Koenig, Christian
2019-08-15 18:21 ` Koenig, Christian
2019-08-15 18:21 ` Koenig, Christian
2019-08-15 18:27 ` Christoph Hellwig
2019-08-15 18:27 ` Christoph Hellwig
2019-08-15 18:27 ` Christoph Hellwig
2019-08-16 21:04 ` Rob Clark
2019-08-16 21:04 ` Rob Clark
2019-08-16 21:04 ` Rob Clark
2019-08-19 5:23 ` Christoph Hellwig
2019-08-19 5:23 ` Christoph Hellwig
2019-08-19 5:23 ` Christoph Hellwig
2019-08-19 14:39 ` Rob Clark
2019-08-19 14:39 ` Rob Clark
2019-08-19 14:39 ` Rob Clark
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=20190814220011.26934-6-robdclark@gmail.com \
--to=robdclark@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=freedreno@lists.freedesktop.org \
--cc=hch@lst.de \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robdclark@chromium.org \
--cc=sean@poorly.run \
/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.