linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: "Andrew Morton" <akpm@linux-foundation.org>,
	"Yue Hu" <huyue2@yulong.com>,
	"Michał Nazarewicz" <mina86@mina86.com>,
	"Marek Szyprowski" <m.szyprowski@samsung.com>,
	"Dmitry Vyukov" <dvyukov@google.com>
Cc: etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-mm@kvack.org, kernel@pengutronix.de,
	patchwork-lst@pengutronix.de
Subject: [PATCH 2/2] drm/etnaviv: use CMA area to compute linear window offset if possible
Date: Wed, 29 May 2019 12:43:12 +0200	[thread overview]
Message-ID: <20190529104312.27835-2-l.stach@pengutronix.de> (raw)
In-Reply-To: <20190529104312.27835-1-l.stach@pengutronix.de>

The dma_required_mask might overestimate the memory size, or might not match
up with the CMA area placement for other reasons. Get the information about
CMA area placement directly from CMA where it is available, but keep the
dma_required_mask as an approximate fallback for architectures where CMA is
not available.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 72d01e873160..b144f1bbbb3c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -4,7 +4,9 @@
  */
 
 #include <linux/clk.h>
+#include <linux/cma.h>
 #include <linux/component.h>
+#include <linux/dma-contiguous.h>
 #include <linux/dma-fence.h>
 #include <linux/moduleparam.h>
 #include <linux/of_device.h>
@@ -724,11 +726,18 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
 	 */
 	if (!(gpu->identity.features & chipFeatures_PIPE_3D) ||
 	    (gpu->identity.minor_features0 & chipMinorFeatures0_MC20)) {
-		u32 dma_mask = (u32)dma_get_required_mask(gpu->dev);
-		if (dma_mask < PHYS_OFFSET + SZ_2G)
+		struct cma *cma = dev_get_cma_area(gpu->dev);
+		phys_addr_t end_mask;
+
+		if (cma)
+			end_mask = cma_get_base(cma) - 1 + cma_get_size(cma);
+		else
+			end_mask = dma_get_required_mask(gpu->dev);
+
+		if (end_mask < PHYS_OFFSET + SZ_2G)
 			gpu->memory_base = PHYS_OFFSET;
 		else
-			gpu->memory_base = dma_mask - SZ_2G + 1;
+			gpu->memory_base = end_mask - SZ_2G + 1;
 	} else if (PHYS_OFFSET >= SZ_2G) {
 		dev_info(gpu->dev, "Need to move linear window on MC1.0, disabling TS\n");
 		gpu->memory_base = PHYS_OFFSET;
-- 
2.20.1


  reply	other threads:[~2019-05-29 10:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 10:43 [PATCH 1/2] mm: cma: export functions to get CMA base and size Lucas Stach
2019-05-29 10:43 ` Lucas Stach [this message]
2021-05-03  7:46   ` [PATCH 2/2] drm/etnaviv: use CMA area to compute linear window offset if possible Primoz Fiser
2019-05-30  6:26 ` [PATCH 1/2] mm: cma: export functions to get CMA base and size 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=20190529104312.27835-2-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    --cc=etnaviv@lists.freedesktop.org \
    --cc=huyue2@yulong.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-mm@kvack.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.com \
    --cc=patchwork-lst@pengutronix.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