From patchwork Mon Aug 20 12:35: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: 1348261 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 10912DFF0F for ; Mon, 20 Aug 2012 12:41:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BCD799E85B for ; Mon, 20 Aug 2012 05:41:57 -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 52D259E814 for ; Mon, 20 Aug 2012 05:36:00 -0700 (PDT) Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M92003S50BWVCU0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 20 Aug 2012 21:35:58 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-95-50322f2eed2f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 69.A4.17335.E2F22305; Mon, 20 Aug 2012 21:35:58 +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 <0M9200B9O0BWMOD0@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 20 Aug 2012 21:35:58 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH 06/10] drm/exynos: add wait_for_vblank callback interface. Date: Mon, 20 Aug 2012 21:35:51 +0900 Message-id: <1345466155-9154-7-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1345466155-9154-1-git-send-email-inki.dae@samsung.com> References: <1345466155-9154-1-git-send-email-inki.dae@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQV09faMAg0fLRS2ufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXxt2HvawFL0UqHm45zd7A2CLYxcjJISFgIvFyzUV2CFtM4sK9 9WxdjFwcQgLTGSXWbu5khnDWM0lcO9TOClLFJqAqMXHFfTYQW0TAVKJj0lIWEJtZoFBiYc9T IJuDQ1jAS2LR5iKQMAtQ+azLfcwgNq+As8Sv3UeZIJYpSCy49xZsDKeAi8TqO+/AxgsB1fy8 sI99AiPvAkaGVYyiqQXJBcVJ6bmGesWJucWleel6yfm5mxjBPn8mtYNxZYPFIUYBDkYlHt6T 0w0DhFgTy4orcw8xSnAwK4nw/hExChDiTUmsrEotyo8vKs1JLT7EKM3BoiTOy98HVC2QnliS mp2aWpBaBJNl4uCUamA0OCiQ66G9PWOJVp5IVMMb3btmLLU5D+b/5JB/MSOM75Jv8TOHRJ5T 56dt9nOXCCl52O74S8965ualneXlGnP6TvuHXZY7ypt25b++Z4COw7UPTxyTFi1fXlBtlR+W +aO9Mqdza5eh/2pRyyrLyA1rPpZ7FZn+Vozer/3MjjlhU5i9r87LN0osxRmJhlrMRcWJAHUq Abb1AQAA 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 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..00e4bdc 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 + * dma transfer is completed. */ 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..98d5576 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 + * - with iommu, the dma operation could induce page fault + * when accessed to memory after gem buffer was released so + * make sure that the dma operation is completed before releasing + * the gem bufer. + */ + if (overlay_ops->wait_for_vblank) + overlay_ops->wait_for_vblank(manager->dev); }