From patchwork Tue Dec 4 05:56:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1836101 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id D15DC3FC71 for ; Tue, 4 Dec 2012 05:56:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 70A96E5FAE for ; Mon, 3 Dec 2012 21:56:42 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id 3BF86E5D08 for ; Mon, 3 Dec 2012 21:56:30 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEH00BEHSHJTM60@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 04 Dec 2012 14:56:27 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.44]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 40.C6.12699.B809DB05; Tue, 04 Dec 2012 14:56:27 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-a5-50bd908b6137 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EF.B6.12699.A809DB05; Tue, 04 Dec 2012 14:56:26 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.90.51.53]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MEH00FFASI14990@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 04 Dec 2012 14:56:26 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: add iommu support for hdmi driver Date: Tue, 04 Dec 2012 14:56:24 +0900 Message-id: <1354600584-8688-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1350749931-9232-4-git-send-email-daeinki@gmail.com> References: <1350749931-9232-4-git-send-email-daeinki@gmail.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrDLMWRmVeSWpSXmKPExsVy+t8zHd3uCXsDDPYtYbG48vU9mwOjx/3u 40wBjFFcNimpOZllqUX6dglcGXM+z2MsmKtRceHcKuYGxrWKXYycHBICJhJzz55mhLDFJC7c W8/WxcjFISSwjFHiZs8JVpiiaS3LWCAS0xkl3rfvZoZw1jNJ3Hx7gw2kik1AVWLiivtgtoiA qUTHpKUsIDazgJ/EifMrwWxhAUeJ6evfgdWwANWvXfOOHcTmFXCWeHPjMjPENgWJBffegtVw AtUvfv6DqYuRA2iZg8S/bnaIVgGJb5MPsYCEJQRkJTYdADtHQuAym8SkWV1sEGMkJQ6uuMEy gVF4ASPDKkbR1ILkguKk9FwjveLE3OLSvHS95PzcTYyQIJTewbiqweIQowAHoxIP74IXewKE WBPLiitzDzFKcDArifCe8dobIMSbklhZlVqUH19UmpNafIjRB+iSicxSosn5wAjJK4k3NDYw NjS0NDQztTQ1wCGsJM7b7JESICSQnliSmp2aWpBaBDOOiYNTqoFRZp7Gqesb5gReq2LxqdHq lTFIimHLe+9VwneIKXMi77b9fx8WG4sL8Cq9L//PrPKj9PlCu5yU1o+aEssc/u7+V/fOImyn oRv3VJb7f1d1r+PLPHErVS3cf0JVmVhe5owHTax+8mue3J6zKOHq2lVeKh0cP+44a/4xnLTJ 80ntunuaX6eGRM5XYinOSDTUYi4qTgQAXESOHW8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xoG7XhL0BBrN2WFtc+fqezYHR4373 caYAxqgGRpuM1MSU1CKF1Lzk/JTMvHRbJe/geOd4UzMDQ11DSwtzJYW8xNxUWyUXnwBdt8wc oLFKCmWJOaVAoYDE4mIlfTtME0JD3HQtYBojdH1DguB6jAzQQMI6xow5n+cxFszVqLhwbhVz A+NaxS5GTg4JAROJaS3LWCBsMYkL99azdTFycQgJTGeUeN++mxnCWc8kcfPtDTaQKjYBVYmJ K+6D2SICphIdk5aCdTML+EmcOL8SzBYWcJSYvv4dWA0LUP3aNe/YQWxeAWeJNzcuM0NsU5BY cO8tWA0nUP3i5z+Yuhg5gJY5SPzrZp/AyLuAkWEVo2hqQXJBcVJ6rpFecWJucWleul5yfu4m RnCIP5PewbiqweIQowAHoxIP74IXewKEWBPLiitzDzFKcDArifCe8dobIMSbklhZlVqUH19U mpNafIjRB+ioicxSosn5wPjLK4k3NDYxM7I0MjM2MTc2xiGsJM7b7JESICSQnliSmp2aWpBa BDOOiYNTqoFRe3P9JfMZ639+ffPm8KZrMXzH+df7WdsZJ943nOrjFfe1san+iBVXyJkCEX2j D6wfDrdYMrqb9V3g/TZn2yemmg9HGBclKof/9rsxs/1i+2xZh3+XUi8Wdn6XlPp4SlRMeucE 9jon6Q8BHTKrWspuHSucGyqT8fzQpavHX3b/e1Gh0LEsb7mcEktxRqKhFnNRcSIA2daQGJ4C AAA= X-CFilter-Loop: Reflected Cc: Kyungmin Park X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Changelog v2: move iommu support feature to mixer side. And below is Prathyush's comment. According to the new IOMMU framework for exynos sysmmus, the owner of the sysmmu-tv is mixer (which is the actual device that does DMA) and not hdmi. The mmu-master in sysmmu-tv node is set as below in exynos5250.dtsi sysmmu-tv { - mmu-master = <&mixer>; }; Changelog v1: The iommu will be enabled when hdmi sub driver is probed and will be disabled when removed. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_hdmi.c | 15 +++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_hdmi.h | 1 + drivers/gpu/drm/exynos/exynos_hdmi.c | 2 +- drivers/gpu/drm/exynos/exynos_mixer.c | 23 +++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index c3b9e2b..2d11e70 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c @@ -346,9 +346,23 @@ static int hdmi_subdrv_probe(struct drm_device *drm_dev, ctx->hdmi_ctx->drm_dev = drm_dev; ctx->mixer_ctx->drm_dev = drm_dev; + if (mixer_ops->iommu_on) + mixer_ops->iommu_on(ctx->mixer_ctx->ctx, true); + return 0; } +static void hdmi_subdrv_remove(struct drm_device *drm_dev, struct device *dev) +{ + struct drm_hdmi_context *ctx; + struct exynos_drm_subdrv *subdrv = to_subdrv(dev); + + ctx = get_ctx_from_subdrv(subdrv); + + if (mixer_ops->iommu_on) + mixer_ops->iommu_on(ctx->mixer_ctx->ctx, false); +} + static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -368,6 +382,7 @@ static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev) subdrv->dev = dev; subdrv->manager = &hdmi_manager; subdrv->probe = hdmi_subdrv_probe; + subdrv->remove = hdmi_subdrv_remove; platform_set_drvdata(pdev, subdrv); diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h index 2da5ffd..54b5223 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h @@ -62,6 +62,7 @@ struct exynos_hdmi_ops { struct exynos_mixer_ops { /* manager */ + int (*iommu_on)(void *ctx, bool enable); int (*enable_vblank)(void *ctx, int pipe); void (*disable_vblank)(void *ctx); void (*dpms)(void *ctx, int mode); diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 2c115f8..c73f438 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -74,6 +74,7 @@ struct hdmi_context { struct mutex hdmi_mutex; void __iomem *regs; + void *parent_ctx; int external_irq; int internal_irq; @@ -84,7 +85,6 @@ struct hdmi_context { int cur_conf; struct hdmi_resources res; - void *parent_ctx; int hpd_gpio; diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 0d3ed28..50100cf 100644 --- a/drivers/gpu/drm/exynos/exynos_mixer.c +++ b/drivers/gpu/drm/exynos/exynos_mixer.c @@ -36,6 +36,7 @@ #include "exynos_drm_drv.h" #include "exynos_drm_hdmi.h" +#include "exynos_drm_iommu.h" #define get_mixer_context(dev) platform_get_drvdata(to_platform_device(dev)) @@ -80,6 +81,7 @@ enum mixer_version_id { struct mixer_context { struct device *dev; + struct drm_device *drm_dev; int pipe; bool interlace; bool powered; @@ -90,6 +92,7 @@ struct mixer_context { struct mixer_resources mixer_res; struct hdmi_win_data win_data[MIXER_WIN_NR]; enum mixer_version_id mxr_ver; + void *parent_ctx; }; struct mixer_drv_data { @@ -665,6 +668,24 @@ static void mixer_win_reset(struct mixer_context *ctx) spin_unlock_irqrestore(&res->reg_slock, flags); } +static int mixer_iommu_on(void *ctx, bool enable) +{ + struct exynos_drm_hdmi_context *drm_hdmi_ctx; + struct mixer_context *mdata = ctx; + struct drm_device *drm_dev; + + drm_hdmi_ctx = mdata->parent_ctx; + drm_dev = drm_hdmi_ctx->drm_dev; + + if (is_drm_iommu_supported(drm_dev)) { + if (enable) + return drm_iommu_attach_device(drm_dev, mdata->dev); + + drm_iommu_detach_device(drm_dev, mdata->dev); + } + return 0; +} + static void mixer_poweron(struct mixer_context *ctx) { struct mixer_resources *res = &ctx->mixer_res; @@ -866,6 +887,7 @@ static void mixer_win_disable(void *ctx, int win) static struct exynos_mixer_ops mixer_ops = { /* manager */ + .iommu_on = mixer_iommu_on, .enable_vblank = mixer_enable_vblank, .disable_vblank = mixer_disable_vblank, .dpms = mixer_dpms, @@ -1140,6 +1162,7 @@ static int __devinit mixer_probe(struct platform_device *pdev) } ctx->dev = &pdev->dev; + ctx->parent_ctx = (void *)drm_hdmi_ctx; drm_hdmi_ctx->ctx = (void *)ctx; ctx->vp_enabled = drv->is_vp_enabled; ctx->mxr_ver = drv->version;