From patchwork Tue Aug 21 02:23:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 1351501 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 D919DDFB6E for ; Tue, 21 Aug 2012 02:23:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC7D19F5DF for ; Mon, 20 Aug 2012 19:23:38 -0700 (PDT) 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 7F4E29F367 for ; Mon, 20 Aug 2012 19:23:25 -0700 (PDT) Received: from epcpsbgm2.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M93003DM2L35NH0@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 21 Aug 2012 11:23:21 +0900 (KST) X-AuditID: cbfee61b-b7faf6d00000476a-9b-5032f1197158 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 5E.95.18282.911F2305; Tue, 21 Aug 2012 11:23:21 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.90.51.53]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M9300HHT2MWW9A0@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 21 Aug 2012 11:23:20 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH v2] drm/exynos: add wait_for_vblank callback interface. Date: Tue, 21 Aug 2012 11:23:20 +0900 Message-id: <1345515800-3969-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1345466155-9154-7-git-send-email-inki.dae@samsung.com> References: <1345466155-9154-7-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jAV3Jj0YBBtPWsltc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujO1H7zMWLBCtePhxLlMD43rBLkZODgkBE4mjN/exQdhiEhfu rQeyuTiEBBYxSlx8PhfKWc8ksfptG1gVm4CqxMQV98FsEQFTiY5JS1lAbGaBQomFPU/BbGEB d4kre84zg9gsQPU/2vaydzFycPAKOEtc3ScCsUxBYsG9t2BjOAVcJGZfPsIEYgsBlezdPod1 AiPvAkaGVYyiqQXJBcVJ6blGesWJucWleel6yfm5mxjBPn8mvYNxVYPFIUYBDkYlHt4fi4wC hFgTy4orcw8xSnAwK4nwChYDhXhTEiurUovy44tKc1KLDzFKc7AoifPy9xkGCAmkJ5akZqem FqQWwWSZODilGhhnHox8z9D+7eiMhR6aeUUWFlr/lk2ZyPdV+cHaqjUzffnZ/iTtn7H++XeT Dx5md2b4HF0x0TSsfp6gH8O7JRO+VpkY/pD6N8/zugff3l3PGnasSpX+tOhgf7bbhbmOZfrT dzFnM31SenDui/PVTD0m7bfHXx0PaUlOz7i4UXXxl5lzpNYzvvrOocRSnJFoqMVcVJwIACcF qpv1AQAA X-TM-AS-MML: No Cc: kyungmin.park@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 Changelog v2: fixed comments. Changelog v1: this interface can be used to make sure that hardware overlay is disabled to avoid that memory region is accessed by dma after gem buffer was released. Signed-off-by: Inki Dae Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_drv.h | 17 +++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_encoder.c | 10 ++++++++++ 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index 24c45d8..eec77aa 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -37,6 +37,20 @@ #define MAX_FB_BUFFER 4 #define DEFAULT_ZPOS -1 +#define _wait_for(COND, MS) ({ \ + unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \ + int ret__ = 0; \ + while (!(COND)) { \ + if (time_after(jiffies, timeout__)) { \ + ret__ = -ETIMEDOUT; \ + break; \ + } \ + } \ + ret__; \ +}) + +#define wait_for(COND, MS) _wait_for(COND, MS) + struct drm_device; struct exynos_drm_overlay; struct drm_connector; @@ -61,6 +75,8 @@ enum exynos_drm_output_type { * @commit: apply hardware specific overlay data to registers. * @enable: enable hardware specific overlay. * @disable: disable hardware specific overlay. + * @wait_for_vblank: wait for vblank interrupt to make sure that + * hardware overlay is disabled. */ struct exynos_drm_overlay_ops { void (*mode_set)(struct device *subdrv_dev, @@ -68,6 +84,7 @@ struct exynos_drm_overlay_ops { void (*commit)(struct device *subdrv_dev, int zpos); void (*enable)(struct device *subdrv_dev, int zpos); void (*disable)(struct device *subdrv_dev, int zpos); + void (*wait_for_vblank)(struct device *subdrv_dev); }; /* diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c index 08ba62f..f453116 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c +++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c @@ -430,4 +430,14 @@ void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data) if (overlay_ops && overlay_ops->disable) overlay_ops->disable(manager->dev, zpos); + + /* + * wait for vblank interrupt + * - this makes sure that hardware overlay is disabled to avoid + * for the dma accesses to memory after gem buffer was released + * because the setting for disabling the overlay will be updated + * at vsync. + */ + if (overlay_ops->wait_for_vblank) + overlay_ops->wait_for_vblank(manager->dev); }