Re: [PATCH v12 08/14] arm64: dts: mt8173: Add display subsystem related nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi Matthias,

Am Mittwoch, den 02.03.2016, 11:21 +0100 schrieb Matthias Brugger:
> > @@ -576,7 +621,183 @@
> >   		mmsys: clock-controller@14000000 {
> >   			compatible = "mediatek,mt8173-mmsys", "syscon";
> >   			reg = <0 0x14000000 0 0x1000>;
> > +			power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
> >   			#clock-cells = <1>;
> > +
> > +			/* FIXME - remove iommus here */
> > +			iommus = <&iommu M4U_PORT_DISP_OVL0>,
> > +				 <&iommu M4U_PORT_DISP_OVL1>;
> > +		};
> 
> Do we need this iommus?
> Sorry I wasn't able to follow this series, but it looks suspicious here :)
> 
> Regards,
> Matthias

Thanks for the pointer, I completely forgot about that issue. Yes, I'd
like to get rid of the iommus property in the mmsys node. If I just drop
it though, currently all the DMA buffer allocations from the mmsys
device fail. It works if I use any of the OVL devices (which have the
iommus property) to do the DMA allocations instead:

-----8<-----
>From 8cfd59df22659a1fb5bb4355ceca18bfe5725361 Mon Sep 17 00:00:00 2001
From: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
Date: Wed, 2 Mar 2016 14:33:41 +0100
Subject: [PATCH] drm/mediatek: use OVL device for DMA allocations

Change-Id: Ic809a9d544e84c4f152a2a8dc280cb795523e180
Signed-off-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 13 +++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  1 +
 drivers/gpu/drm/mediatek/mtk_drm_gem.c | 17 ++++++++++-------
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index e212052..80056d1 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -132,6 +132,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
 {
 	struct mtk_drm_private *private = drm->dev_private;
 	struct platform_device *pdev;
+	struct device_node *np;
 	int ret;
 
 	if (!iommu_present(&platform_bus_type))
@@ -177,6 +178,18 @@ static int mtk_drm_kms_init(struct drm_device *drm)
 	if (ret < 0)
 		goto err_component_unbind;
 
+	/* Use OVL device for all DMA memory allocations */
+	np = private->comp_node[mtk_ddp_main[0]] ?:
+	     private->comp_node[mtk_ddp_ext[0]];
+	pdev = of_find_device_by_node(np);
+	if (!pdev) {
+		ret = -ENODEV;
+		dev_err(drm->dev, "Need at least one OVL device\n");
+		goto err_component_unbind;
+	}
+
+	private->dma_dev = &pdev->dev;
+
 	/*
 	 * We don't use the drm_irq_install() helpers provided by the DRM
 	 * core, so we need to set this manually in order to allow the
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index b1340d3..e0fff2c 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -30,6 +30,7 @@ struct regmap;
 
 struct mtk_drm_private {
 	struct drm_device *drm;
+	struct device *dma_dev;
 
 	struct drm_crtc *crtc[MAX_CRTC];
 	unsigned int num_pipes;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
index 6bc494e..a773bfa 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
@@ -15,6 +15,7 @@
 #include <drm/drm_gem.h>
 #include <linux/dma-buf.h>
 
+#include "mtk_drm_drv.h"
 #include "mtk_drm_gem.h"
 
 static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev,
@@ -42,6 +43,7 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev,
 struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev,
 					   size_t size, bool alloc_kmap)
 {
+	struct mtk_drm_private *priv = dev->dev_private;
 	struct mtk_drm_gem_obj *mtk_gem;
 	struct drm_gem_object *obj;
 	int ret;
@@ -58,7 +60,7 @@ struct mtk_drm_gem_obj *mtk_drm_gem_create(struct drm_device *dev,
 	if (!alloc_kmap)
 		dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &mtk_gem->dma_attrs);
 
-	mtk_gem->cookie = dma_alloc_attrs(dev->dev, obj->size,
+	mtk_gem->cookie = dma_alloc_attrs(priv->dma_dev, obj->size,
 					  &mtk_gem->dma_addr, GFP_KERNEL,
 					  &mtk_gem->dma_attrs);
 	if (!mtk_gem->cookie) {
@@ -85,11 +87,12 @@ err_gem_free:
 void mtk_drm_gem_free_object(struct drm_gem_object *obj)
 {
 	struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
+	struct mtk_drm_private *priv = obj->dev->dev_private;
 
 	if (mtk_gem->sg)
 		drm_prime_gem_destroy(obj, mtk_gem->sg);
 	else
-		dma_free_attrs(obj->dev->dev, obj->size, mtk_gem->cookie,
+		dma_free_attrs(priv->dma_dev, obj->size, mtk_gem->cookie,
 			       mtk_gem->dma_addr, &mtk_gem->dma_attrs);
 
 	/* release file pointer to gem object. */
@@ -160,7 +163,7 @@ static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj,
 {
 	int ret;
 	struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
-	struct drm_device *drm = obj->dev;
+	struct mtk_drm_private *priv = obj->dev->dev_private;
 
 	/*
 	 * dma_alloc_attrs() allocated a struct page table for mtk_gem, so clear
@@ -169,8 +172,8 @@ static int mtk_drm_gem_object_mmap(struct drm_gem_object *obj,
 	vma->vm_flags &= ~VM_PFNMAP;
 	vma->vm_pgoff = 0;
 
-	ret = dma_mmap_attrs(drm->dev, vma, mtk_gem->cookie, mtk_gem->dma_addr,
-			     obj->size, &mtk_gem->dma_attrs);
+	ret = dma_mmap_attrs(priv->dma_dev, vma, mtk_gem->cookie,
+			     mtk_gem->dma_addr, obj->size, &mtk_gem->dma_attrs);
 	if (ret)
 		drm_gem_vm_close(vma);
 
@@ -211,7 +214,7 @@ int mtk_drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj)
 {
 	struct mtk_drm_gem_obj *mtk_gem = to_mtk_gem_obj(obj);
-	struct drm_device *drm = obj->dev;
+	struct mtk_drm_private *priv = obj->dev->dev_private;
 	struct sg_table *sgt;
 	int ret;
 
@@ -219,7 +222,7 @@ struct sg_table *mtk_gem_prime_get_sg_table(struct drm_gem_object *obj)
 	if (!sgt)
 		return ERR_PTR(-ENOMEM);
 
-	ret = dma_get_sgtable_attrs(drm->dev, sgt, mtk_gem->cookie,
+	ret = dma_get_sgtable_attrs(priv->dma_dev, sgt, mtk_gem->cookie,
 				    mtk_gem->dma_addr, obj->size,
 				    &mtk_gem->dma_attrs);
 	if (ret) {
-- 
2.7.0
----->8-----

Is there a better way?

regards
Philipp

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux