From patchwork Wed Mar 2 13:52:02 2016
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Philipp Zabel
X-Patchwork-Id: 8480701
Return-Path:
X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.29.136])
by patchwork2.web.kernel.org (Postfix) with ESMTP id 54B47C0553
for ;
Wed, 2 Mar 2016 13:53:33 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 3538D2038A
for ;
Wed, 2 Mar 2016 13:53:32 +0000 (UTC)
Received: from bombadil.infradead.org (bombadil.infradead.org
[198.137.202.9])
(using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by mail.kernel.org (Postfix) with ESMTPS id 1F42C2037C
for ;
Wed, 2 Mar 2016 13:53:31 +0000 (UTC)
Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org)
by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux))
id 1ab7DW-0001ES-BN; Wed, 02 Mar 2016 13:53:30 +0000
Received: from metis.ext.pengutronix.de
([2001:67c:670:201:290:27ff:fe1d:cc33])
by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat
Linux)) id 1ab7DT-00016I-Jw for linux-mediatek@lists.infradead.org;
Wed, 02 Mar 2016 13:53:29 +0000
Received: from paszta.hi.pengutronix.de
([2001:67c:670:100:96de:80ff:fec2:9969] helo=paszta)
by metis.ext.pengutronix.de with esmtp (Exim 4.80)
(envelope-from )
id 1ab7CB-0002Fm-E2; Wed, 02 Mar 2016 14:52:07 +0100
Message-ID: <1456926722.4175.29.camel@pengutronix.de>
Subject: Re: [PATCH v12 08/14] arm64: dts: mt8173: Add display subsystem
related nodes
From: Philipp Zabel
To: Matthias Brugger
Date: Wed, 02 Mar 2016 14:52:02 +0100
In-Reply-To: <56D6BEA2.3050001@gmail.com>
References: <1456845630-2786-1-git-send-email-p.zabel@pengutronix.de>
<1456845630-2786-9-git-send-email-p.zabel@pengutronix.de>
<56D6BEA2.3050001@gmail.com>
X-Mailer: Evolution 3.12.9-1+b1
Mime-Version: 1.0
X-SA-Exim-Connect-IP: 2001:67c:670:100:96de:80ff:fec2:9969
X-SA-Exim-Mail-From: p.zabel@pengutronix.de
X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de);
SAEximRunCond expanded to false
X-PTX-Original-Recipient: linux-mediatek@lists.infradead.org
X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3
X-CRM114-CacheID: sfid-20160302_055327_854170_EE73F479
X-CRM114-Status: GOOD ( 22.33 )
X-Spam-Score: -1.9 (-)
X-BeenThere: linux-mediatek@lists.infradead.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Cc: Mark Rutland , Stephen Boyd ,
Michael Turquette ,
Dave Airlie ,
Jie Qiu , Cawa Cheng ,
Daniel Stone , YT Shen ,
Yingjoe Chen , devicetree@vger.kernel.org,
Jitao Shi , kernel@pengutronix.de,
Pawel Moll ,
Ian Campbell ,
CK Hu , Rob Herring ,
linux-mediatek@lists.infradead.org, dri-devel@lists.freedesktop.org,
Paul Bolle ,
Emil Velikov ,
Tomasz Figa , Daniel Vetter ,
Kumar Gala
Sender: "Linux-mediatek"
Errors-To:
linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org
X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED,
RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Virus-Scanned: ClamAV using ClamSMTP
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
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
---
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
#include
+#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) {