summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Stach <l.stach@pengutronix.de>2019-05-29 12:43:12 +0200
committerStefan Agner <stefan.agner@toradex.com>2019-08-07 13:12:18 +0200
commitea9b1d98e81a244b8bfc7d2db546df34d40418d2 (patch)
tree581d748db9aba3f698aac30e4dc7cb1e5f11bc7e
parent611c7ecf2e0bbc39e3c36e7171743cdf6f279efd (diff)
drm/etnaviv: use CMA area to compute linear window offset if possible
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>
-rw-r--r--drivers/gpu/drm/etnaviv/etnaviv_gpu.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 5418a1a87b2c..8453fc05dcf2 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;