From patchwork Mon Dec 3 06:38:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1832101 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 39ED03FCA5 for ; Mon, 3 Dec 2012 06:15:57 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29BB8E5F17 for ; Sun, 2 Dec 2012 22:15:57 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by gabe.freedesktop.org (Postfix) with ESMTP id 05796E5CC5 for ; Sun, 2 Dec 2012 22:15:43 -0800 (PST) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MEF003MGYP6CEP0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 03 Dec 2012 15:15:40 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.122]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C7.C5.12699.C834CB05; Mon, 03 Dec 2012 15:15:40 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-88-50bc438cea22 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 67.C5.12699.C834CB05; Mon, 03 Dec 2012 15:15:40 +0900 (KST) Received: from localhost.localdomain ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MEF00J8ZYPX5K70@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 03 Dec 2012 15:15:40 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: enable iommu for mixer and not hdmi Date: Mon, 03 Dec 2012 12:08:40 +0530 Message-id: <1354516720-4807-1-git-send-email-prathyush.k@samsung.com> X-Mailer: git-send-email 1.7.0.4 DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrKLMWRmVeSWpSXmKPExsWyRsSkSrfHeU+AwZKj5hZXvr5nc2D0uN99 nCmAMYrLJiU1J7MstUjfLoEr48eZZ8wFh40rJm/9zdTA+FCri5GTQ0LARGLBjXVsELaYxIV7 64FsLg4hgaWMEv/nvGKBKdow9yhUYjqjxKeXnVDOaiaJzs1rwdrZBLQlfs25ywpiiwgoS/yd uIoRxGYWMJCY964DrEZYwEGi5dl5JhCbRUBVou/oNzCbV8BNYtu+X8wQ2xQkWpcdYoeoEZD4 NvkQ0BUcQHFZiU0HmEH2SghsYZOYtOUJ1HWSEgdX3GCZwCi4gJFhFaNoakFyQXFSeq6RXnFi bnFpXrpecn7uJkZgWJ3+90x6B+OqBotDjAIcjEo8vA+/7A4QYk0sK67MPcQowcGsJMIbZb0n QIg3JbGyKrUoP76oNCe1+BCjD9AlE5mlRJPzgSGfVxJvaGxibmpsamlkZGZqikNYSZy32SMl QEggPbEkNTs1tSC1CGYcEwenVAOjxaEHN18L5PNd0zZuOXjis9ufFY6Pg89nh62sTVqcbuKs /vyO7Ldgf2+tfW86txWr6IXy3gvnkrR059HSXerx8/lRAavjL+s+LS2ZFsZt86ietbl27Z7i IpkdKtMLFr/uYjiwX+W2oeH1NKXwjZfEjrv2Wll8nLilWGzqrG1bvj6NZ89Q5JJUYinOSDTU Yi4qTgQA2Px2eVgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsVy+t9jQd0e5z0BBs09ehZXvr5nc2D0uN99 nCmAMaqB0SYjNTEltUghNS85PyUzL91WyTs43jne1MzAUNfQ0sJcSSEvMTfVVsnFJ0DXLTMH aKySQlliTilQKCCxuFhJ3w7ThNAQN10LmMYIXd+QILgeIwM0kLCGMePHmWfMBYeNKyZv/c3U wPhQq4uRk0NCwERiw9yjbBC2mMSFe+uBbC4OIYHpjBKfXnZCOauZJDo3rwWrYhPQlvg15y4r iC0ioCzxd+IqRhCbWcBAYt67DrAaYQEHiZZn55lAbBYBVYm+o9/AbF4BN4lt+34xQ2xTkGhd doh9AiP3AkaGVYyiqQXJBcVJ6blGesWJucWleel6yfm5mxjBQftMegfjqgaLQ4wCHIxKPLwP v+wOEGJNLCuuzD3EKMHBrCTCG2W9J0CINyWxsiq1KD++qDQntfgQow/Q9onMUqLJ+cCIyiuJ NzQ2MTc1NrU0sTAxs8QhrCTO2+yREiAkkJ5YkpqdmlqQWgQzjomDU6qBcVnj/1X2JVwTApp/ GghpvJmh23hvz668+HlXtEKzBCVCzl1ku/H5qX/KJN/cmrA/Z/fKntq2ttwxeM/LHqbSSQV2 7effKxpVXW26M8Ni3XsLvRIm1pBfFnmmSx9VT/Lq9us74Lb2w4LTAua3uLSM5t5wlVrQOn8L 29muQwaP3vneZAiS7z06RYmlOCPRUIu5qDgRAA2Z6pGHAgAA X-CFilter-Loop: Reflected Cc: pullip.cho@samsung.com 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 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>; }; This patch moves the iommu_on function from the hdmi context to the mixer context. And this patch is based on exynos-drm-next-iommu branch of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_hdmi.c | 8 ++++---- drivers/gpu/drm/exynos/exynos_drm_hdmi.h | 2 +- drivers/gpu/drm/exynos/exynos_hdmi.c | 24 ------------------------ drivers/gpu/drm/exynos/exynos_mixer.c | 23 +++++++++++++++++++++++ 4 files changed, 28 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index 997fb6e..8b771a3 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c @@ -368,8 +368,8 @@ 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 (hdmi_ops->iommu_on) - hdmi_ops->iommu_on(ctx->hdmi_ctx->ctx, true); + if (mixer_ops->iommu_on) + mixer_ops->iommu_on(ctx->mixer_ctx->ctx, true); return 0; } @@ -381,8 +381,8 @@ static void hdmi_subdrv_remove(struct drm_device *drm_dev, struct device *dev) ctx = get_ctx_from_subdrv(subdrv); - if (hdmi_ops->iommu_on) - hdmi_ops->iommu_on(ctx->hdmi_ctx->ctx, false); + 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) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h index 5c033d1..54b5223 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h @@ -50,7 +50,6 @@ struct exynos_hdmi_ops { int (*power_on)(void *ctx, int mode); /* manager */ - int (*iommu_on)(void *ctx, bool enable); void (*mode_fixup)(void *ctx, struct drm_connector *connector, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode); @@ -63,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 d1a1d71..7df1d85 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -40,7 +40,6 @@ #include "exynos_drm_drv.h" #include "exynos_drm_hdmi.h" -#include "exynos_drm_iommu.h" #include "exynos_hdmi.h" @@ -68,7 +67,6 @@ struct hdmi_resources { struct hdmi_context { struct device *dev; - struct drm_device *drm_dev; bool hpd; bool powered; bool dvi_mode; @@ -85,7 +83,6 @@ struct hdmi_context { int cur_conf; struct hdmi_resources res; - void *parent_ctx; int hpd_gpio; @@ -1947,25 +1944,6 @@ static void hdmi_conf_apply(struct hdmi_context *hdata) hdmi_regs_dump(hdata, "start"); } -static int hdmi_iommu_on(void *ctx, bool enable) -{ - struct exynos_drm_hdmi_context *drm_hdmi_ctx; - struct hdmi_context *hdata = ctx; - struct drm_device *drm_dev; - - drm_hdmi_ctx = hdata->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, hdata->dev); - - drm_iommu_detach_device(drm_dev, hdata->dev); - } - - return 0; -} - static void hdmi_mode_fixup(void *ctx, struct drm_connector *connector, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) @@ -2122,7 +2100,6 @@ static struct exynos_hdmi_ops hdmi_ops = { .check_timing = hdmi_check_timing, /* manager */ - .iommu_on = hdmi_iommu_on, .mode_fixup = hdmi_mode_fixup, .mode_set = hdmi_mode_set, .get_max_resol = hdmi_get_max_resol, @@ -2379,7 +2356,6 @@ static int __devinit hdmi_probe(struct platform_device *pdev) mutex_init(&hdata->hdmi_mutex); drm_hdmi_ctx->ctx = (void *)hdata; - hdata->parent_ctx = (void *)drm_hdmi_ctx; platform_set_drvdata(pdev, drm_hdmi_ctx); diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c index 614b2e9..574ed3f 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, @@ -1149,6 +1171,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;