linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Jie Qiu <jie.qiu@mediatek.com>,
	Cawa Cheng <cawa.cheng@mediatek.com>,
	YT Shen <yt.shen@mediatek.com>,
	Yingjoe Chen <yingjoe.chen@mediatek.com>,
	devicetree@vger.kernel.org, Jitao Shi <jitao.shi@mediatek.com>,
	kernel@pengutronix.de, Pawel Moll <pawel.moll@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Rob Herring <robh+dt@kernel.org>,
	linux-mediatek@lists.infradead.org,
	dri-devel@lists.freedesktop.org, Paul Bolle <pebolle@tiscali.nl>,
	Emil Velikov <emil.l.velikov@gmail.com>,
	Tomasz Figa <tfiga@chromium.org>,
	Kumar Gala <galak@codeaurora.org>
Subject: Re: [PATCH v12 08/14] arm64: dts: mt8173: Add display subsystem related nodes
Date: Wed, 02 Mar 2016 14:52:02 +0100	[thread overview]
Message-ID: <1456926722.4175.29.camel@pengutronix.de> (raw)
In-Reply-To: <56D6BEA2.3050001@gmail.com>

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@pengutronix.de>
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@pengutronix.de>
---
 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

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

  reply	other threads:[~2016-03-02 13:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 15:20 [PATCH v12 00/14] MT8173 DRM support Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 01/14] dt-bindings: drm/mediatek: Add Mediatek display subsystem dts binding Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 02/14] drm/mediatek: Add DRM Driver for Mediatek SoC MT8173 Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 03/14] drm/mediatek: Add DSI sub driver Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 04/14] drm/mediatek: Add DPI " Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 05/14] dt-bindings: drm/mediatek: Add Mediatek HDMI dts binding Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 06/14] drm/mediatek: Add HDMI support Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 07/14] drm/mediatek: enable hdmi output control bit Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 08/14] arm64: dts: mt8173: Add display subsystem related nodes Philipp Zabel
     [not found]   ` <1456845630-2786-9-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-03-02 10:21     ` Matthias Brugger
2016-03-02 13:52       ` Philipp Zabel [this message]
2016-03-01 15:20 ` [PATCH v12 09/14] arm64: dts: mt8173: Add HDMI " Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 10/14] clk: mediatek: make dpi0_sel propagate rate changes Philipp Zabel
2016-03-01 19:15   ` Stephen Boyd
     [not found] ` <1456845630-2786-1-git-send-email-p.zabel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2016-03-01 15:20   ` [PATCH v12 11/14] clk: mediatek: Add hdmi_ref HDMI PHY PLL reference clock output Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 12/14] dt-bindings: hdmi-connector: add DDC I2C bus phandle documentation Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 13/14] clk: mediatek: remove hdmitx_dig_cts from TOP clocks Philipp Zabel
2016-03-01 15:20 ` [PATCH v12 14/14] arm64: dts: mt8173-evb: enable HDMI output Philipp Zabel

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=1456926722.4175.29.camel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=cawa.cheng@mediatek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=jie.qiu@mediatek.com \
    --cc=jitao.shi@mediatek.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=pawel.moll@arm.com \
    --cc=pebolle@tiscali.nl \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=tfiga@chromium.org \
    --cc=yingjoe.chen@mediatek.com \
    --cc=yt.shen@mediatek.com \
    /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;
as well as URLs for NNTP newsgroup(s).