From patchwork Tue Apr 29 01:38:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 4084111 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 41F999F38E for ; Tue, 29 Apr 2014 01:38:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5D06B201F5 for ; Tue, 29 Apr 2014 01:38:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7A0DF201CE for ; Tue, 29 Apr 2014 01:38:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B1FE36E92E; Mon, 28 Apr 2014 18:38:14 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id C2D926E92E for ; Mon, 28 Apr 2014 18:38:13 -0700 (PDT) Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N4R00K5WR7OEW80@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 29 Apr 2014 10:38:12 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.112]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id CF.CA.09952.1820F535; Tue, 29 Apr 2014 10:38:09 +0900 (KST) X-AuditID: cbfee690-b7fcd6d0000026e0-9b-535f02813281 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 2A.20.25708.1820F535; Tue, 29 Apr 2014 10:38:09 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.83.67]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N4R00IK6R7LWG50@mmp2.samsung.com>; Tue, 29 Apr 2014 10:38:09 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: fimd: clear channel before enabling iommu Date: Tue, 29 Apr 2014 10:38:08 +0900 Message-id: <1398735488-19475-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsWyRsSkQLeRKT7Y4Pl9VYvecyeZLFZ9Psdq ceXrezaLSfcnsFhcWLGR3YHVY/u3B6we97uPM3n0bVnFGMAcxWWTkpqTWZZapG+XwJWx/Fs/ S8Fp6Yr9/3tZGhjPinUxcnJICJhI/PzxiBnCFpO4cG89WxcjF4eQwFJGicVtPawwRWten2OF SExnlDj88SQjhNPNJHFg0WdGkCo2AVWJiSvus4HYIgKmEh2TlrKA2MwChRKvepvAaoQFPCXa 5/0Am8oCVP9nXx+YzSvgItF74hh7FyMH0DYFiTmTbEDmSwg8ZpO43QbRyyIgIPFt8iEWiBpZ iU0HoK6WlDi44gbLBEbBBYwMqxhFUwuSC4qT0otM9IoTc4tL89L1kvNzNzECA/L0v2cTdjDe O2B9iDEZaNxEZinR5HxgQOeVxBsamxlZmJqYGhuZW5qRJqwkzqv2KClISCA9sSQ1OzW1ILUo vqg0J7X4ECMTB6dUA6NGz4PeDd1ZQU4nueO37T3/ZWmG++0FojKPp5gujvwzTe1JR0JPRS1/ +bwHMXPUGWc2/PIKWjdd5ci8zcv6NzAdmXstoTrw1BIfq5MRO/X2mfcZ1lidUz645uZhoePh FwO1c/9yLN6qe/LyBWcD9/nnOzl2czXUap2pb6s8n31p3nnXtgky/yKVWIozEg21mIuKEwGT dTKHXgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsVy+t9jQd1Gpvhgg6PbpS16z51kslj1+Ryr xZWv79ksJt2fwGJxYcVGdgdWj+3fHrB63O8+zuTRt2UVYwBzVAOjTUZqYkpqkUJqXnJ+SmZe uq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7QUiWFssScUqBQQGJxsZK+HaYJoSFu uhYwjRG6viFBcD1GBmggYQ1jxvJv/SwFp6Ur9v/vZWlgPCvWxcjJISFgIrHm9TlWCFtM4sK9 9WxdjFwcQgLTGSUOfzzJCOF0M0kcWPSZEaSKTUBVYuKK+2wgtoiAqUTHpKUsIDazQKHEq94m sBphAU+J9nk/wKayANX/2dcHZvMKuEj0njjG3sXIAbRNQWLOJJsJjNwLGBlWMYqmFiQXFCel 5xrpFSfmFpfmpesl5+duYgSH+zPpHYyrGiwOMQpwMCrx8HbExAULsSaWFVfmHmKU4GBWEuG1 bQUK8aYkVlalFuXHF5XmpBYfYkwGWj6RWUo0OR8Yi3kl8YbGJmZGlkbmhhZGxuakCSuJ8x5s tQ4UEkhPLEnNTk0tSC2C2cLEwSnVwGg1PylGUX+Z17ZFTEGv7t8L4axNC+3kyQ/hYCx95nLz eqW1gYl0v0HppvttEzfxXtFeIpaZxf3u5uSD8ruDq+PZQ149MprUr3m4+QtH9I3l7Fv7bs0t jHtvbv3hiFfz5c3luwtOa6f/DXLJfRtyS6Riy53bajxOhTpVz/KMHwWZuk6e+1BbUomlOCPR UIu5qDgRAOY/la+7AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: Akshu Agrawal , Prathyush K X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.8 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 From: Akshu Agrawal If any fimd channel was already active, initializing iommu will result in a PAGE FAULT (e.e. u-boot could have turned on the display and not disabled it before the kernel starts). This patch checks if any channel is active before initializing iommu and disables it. Changelog v2: - consider SoC without SHADOWCON register Signed-off-by: Akshu Agrawal Signed-off-by: Prathyush K Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 70 +++++++++++++++++++++--------- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c index 40fd6cc..ef21ce4 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c @@ -143,6 +143,48 @@ static inline struct fimd_driver_data *drm_fimd_get_driver_data( return (struct fimd_driver_data *)of_id->data; } +static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr) +{ + struct fimd_context *ctx = mgr->ctx; + + if (ctx->suspended) + return; + + atomic_set(&ctx->wait_vsync_event, 1); + + /* + * wait for FIMD to signal VSYNC interrupt or return after + * timeout which is set to 50ms (refresh rate of 20). + */ + if (!wait_event_timeout(ctx->wait_vsync_queue, + !atomic_read(&ctx->wait_vsync_event), + HZ/20)) + DRM_DEBUG_KMS("vblank wait timed out.\n"); +} + + +static void fimd_clear_channel(struct exynos_drm_manager *mgr) +{ + struct fimd_context *ctx = mgr->ctx; + int win, ch_enabled = 0; + + DRM_DEBUG_KMS("%s\n", __FILE__); + + /* Check if any channel is enabled. */ + for (win = 0; win < WINDOWS_NR; win++) { + u32 val = readl(ctx->regs + SHADOWCON); + if (val & SHADOWCON_CHx_ENABLE(win)) { + val &= ~SHADOWCON_CHx_ENABLE(win); + writel(val, ctx->regs + SHADOWCON); + ch_enabled = 1; + } + } + + /* Wait for vsync, as disable channel takes effect at next vsync */ + if (ch_enabled) + fimd_wait_for_vblank(mgr); +} + static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, struct drm_device *drm_dev, int pipe) { @@ -169,8 +211,15 @@ static int fimd_mgr_initialize(struct exynos_drm_manager *mgr, drm_dev->vblank_disable_allowed = true; /* attach this sub driver to iommu mapping if supported. */ - if (is_drm_iommu_supported(ctx->drm_dev)) + if (is_drm_iommu_supported(ctx->drm_dev)) { + /* + * If any channel is already active, iommu will throw + * a PAGE FAULT when enabled. So clear any channel if enabled. + */ + if (ctx->driver_data->has_shadowcon) + fimd_clear_channel(mgr); drm_iommu_attach_device(ctx->drm_dev, ctx->dev); + } return 0; } @@ -324,25 +373,6 @@ static void fimd_disable_vblank(struct exynos_drm_manager *mgr) } } -static void fimd_wait_for_vblank(struct exynos_drm_manager *mgr) -{ - struct fimd_context *ctx = mgr->ctx; - - if (ctx->suspended) - return; - - atomic_set(&ctx->wait_vsync_event, 1); - - /* - * wait for FIMD to signal VSYNC interrupt or return after - * timeout which is set to 50ms (refresh rate of 20). - */ - if (!wait_event_timeout(ctx->wait_vsync_queue, - !atomic_read(&ctx->wait_vsync_event), - HZ/20)) - DRM_DEBUG_KMS("vblank wait timed out.\n"); -} - static void fimd_win_mode_set(struct exynos_drm_manager *mgr, struct exynos_drm_overlay *overlay) {