From patchwork Sat Oct 20 16:18:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1621701 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 1A338DF26F for ; Sat, 20 Oct 2012 16:22:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12EFC9ECEF for ; Sat, 20 Oct 2012 09:22:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 94E8D9EB76 for ; Sat, 20 Oct 2012 09:19:34 -0700 (PDT) Received: by mail-pa0-f49.google.com with SMTP id bi5so1003005pad.36 for ; Sat, 20 Oct 2012 09:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=wW496Mmq40i0Zw4rNciLiOcQ0EZKk4jbjj2vp6IIBYM=; b=krJQ55VMs7UFjv3iNL3npOnBSw1AQEx1V6aM3PXBCLzaQYX6vDdVucoHsf0Rz5f3bJ aOsfwJgIEeEQu0UD+7wtnWlvf1HHOKFop4/yCXOnnwpH0SBVzVPlacbxamfxbqu7oCLp w9gRI1Zrt02p+LL+DZ7oHjhyJRR8+3iVf9jZswxHlWFZ10OCgoMq19YxYWJt72m7C4wf bh0dgFQARAWehQ20oFZNtKhchwLyBQxqBedaev7VTbcF0bBPJaue0fO9ZqX7Sh7MNvxk wIp3KE+c5UJKo3dU+z/BNwP05hc/Ej801qam27hUGf95/AqTdmI7s7OyWVeTPJhilgC4 UPMw== Received: by 10.68.235.71 with SMTP id uk7mr16655833pbc.10.1350749974425; Sat, 20 Oct 2012 09:19:34 -0700 (PDT) Received: from localhost.localdomain ([222.117.162.7]) by mx.google.com with ESMTPS id tw5sm3026699pbc.48.2012.10.20.09.19.31 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 20 Oct 2012 09:19:33 -0700 (PDT) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH 3/3] drm/exynos: add iommu support for hdmi driver Date: Sat, 20 Oct 2012 09:18:51 -0700 Message-Id: <1350749931-9232-4-git-send-email-daeinki@gmail.com> X-Mailer: git-send-email 1.8.0.rc3.16.g8ead1bf In-Reply-To: <1350749931-9232-1-git-send-email-daeinki@gmail.com> References: <1350749931-9232-1-git-send-email-daeinki@gmail.com> Cc: kyungmin.park@samsung.com, sw0312.kim@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 From: Inki Dae 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 | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c index 0cb8a8c..997fb6e 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.c @@ -368,9 +368,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 (hdmi_ops->iommu_on) + hdmi_ops->iommu_on(ctx->hdmi_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 (hdmi_ops->iommu_on) + hdmi_ops->iommu_on(ctx->hdmi_ctx->ctx, false); +} + static int __devinit exynos_drm_hdmi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -390,6 +404,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..5c033d1 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_hdmi.h +++ b/drivers/gpu/drm/exynos/exynos_drm_hdmi.h @@ -50,6 +50,7 @@ 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); diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 2c115f8..d1a1d71 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -40,6 +40,7 @@ #include "exynos_drm_drv.h" #include "exynos_drm_hdmi.h" +#include "exynos_drm_iommu.h" #include "exynos_hdmi.h" @@ -1946,6 +1947,25 @@ 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) @@ -2102,6 +2122,7 @@ 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,