From patchwork Wed Dec 26 11:27:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathyush K X-Patchwork-Id: 1910971 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 BF8F93FC85 for ; Wed, 26 Dec 2012 11:12:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD1FEE5F2E for ; Wed, 26 Dec 2012 03:12:21 -0800 (PST) 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 4F4B6E60BA for ; Wed, 26 Dec 2012 03:05:30 -0800 (PST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MFM00JGIXGI8NA0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 26 Dec 2012 20:05:29 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 29.8D.01231.9F9DAD05; Wed, 26 Dec 2012 20:05:29 +0900 (KST) X-AuditID: cbfee61a-b7fa66d0000004cf-51-50dad9f93dc3 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 09.8D.01231.9F9DAD05; Wed, 26 Dec 2012 20:05:29 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MFM0029MXGTEU90@mmp1.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 26 Dec 2012 20:05:29 +0900 (KST) From: Prathyush K To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/8] drm/exynos: add complete_scanout interface Date: Wed, 26 Dec 2012 06:27:43 -0500 Message-id: <1356521265-22749-7-git-send-email-prathyush.k@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1356521265-22749-1-git-send-email-prathyush.k@samsung.com> References: <1356521265-22749-1-git-send-email-prathyush.k@samsung.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNLMWRmVeSWpSXmKPExsWyRsSkWvfnzVsBBq/+yVpc+fqezYHR4373 caYAxigum5TUnMyy1CJ9uwSujNXTJApOa1fcutvB1sD4SKWLkYNDQsBEYsIL/y5GTiBTTOLC vfVsXYxcHEICSxklzh87wAyRMJH4tvQqVGIRo8T13dtZIJyNTBJbOt+BVbEJaEv8mnOXFcQW EVCW+DtxFSOIzSwgIXGk/SwbiC0sYC9x8NJ6dhCbRUBVYufke2C9vALuEue+nGOE2CYn8WHP I7AaTgEPiQsb94DNFAKqaXvwgRWiV0Di2+RDLBAfyEpsAjmUC8i8zCZx59FJFog5khIHV9xg mcAovICRYRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGYAie/vdMagfjygaLQ4wCHIxKPLwb v98MEGJNLCuuzD3EKMHBrCTCq7DqVoAQb0piZVVqUX58UWlOavEhRh+gSyYyS4km5wPjI68k 3tDYxNzU2NTSyMjM1BSHsJI4b7NHSoCQQHpiSWp2ampBahHMOCYOTqkGRvUpycavQ402GJav N97R7H3hg3eAvij7WqXdLJsy/uk1uHxw71aXnDN7zTuNN/PELHXbo71Fb7ybHXl2lWqP+zn9 w9M3qZ9fG/R4kdc/5vhm9nk7mhliJUv2ie3S/fkmRP/Aee3iGg6PScwX5olvXTJPSakvuiWr +0Kk7T2XI98zQxtTvmY7KLEUZyQaajEXFScCAG2piM1uAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmkeLIzCtJLcpLzFFi42I5/e+xgO7Pm7cCDB49F7O48vU9mwOjx/3u 40wBjFENjDYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5 QGOVFMoSc0qBQgGJxcVK+naYJoSGuOlawDRG6PqGBMH1GBmggYQ1jBmrp0kUnNauuHW3g62B 8ZFKFyMnh4SAicS3pVfZIGwxiQv31gPZXBxCAosYJa7v3s4C4WxkktjS+Y4ZpIpNQFvi15y7 rCC2iICyxN+JqxhBbGYBCYkj7WfBJgkL2EscvLSeHcRmEVCV2Dn5Hlgvr4C7xLkv5xghtslJ fNjzCKyGU8BD4sLGPWAzhYBq2h58YJ3AyLuAkWEVo2hqQXJBcVJ6rqFecWJucWleul5yfu4m RnCIP5PawbiyweIQowAHoxIP78bvNwOEWBPLiitzDzFKcDArifAqrLoVIMSbklhZlVqUH19U mpNafIjRB+iqicxSosn5wPjLK4k3NDYxNzU2tTSxMDGzxCGsJM7b7JESICSQnliSmp2aWpBa BDOOiYNTqoFxTcfUwNJAfcnD4rv9tnV5R3bIW523PenZlP6CyfaCeYDqs+u+GxZVZwZesz9k 1vnt+zqbozP3XlJXiNHhucEUcakpSnjJW9fWLg6uAzFW3uJOp47GRD0sjI1LOdux3jNH0jri cb70h/65/HstWWeliO/UKM1ZHvNe4U1E4puECQ+2H6+NrVFiKc5INNRiLipOBAAajMDVngIA AA== X-CFilter-Loop: Reflected 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 Before freeing a framebuffer, we call complete_scanout encoder function which just calls wait for vblank of all the encoders. This is not a very optimized method since a framebuffer might not be in use by a crtc and we end up waiting for vblank unnecessarily. Instead, this patch modifies the wait_for_vblank interface to complete_scanout interface. In this function, each crtc must check if the fb is currently being used. If it is being used, it must wait for vsync (or even disable a window if necessary) and ensure that the buffer is no longer used by crtc before returning. So if a crtc is not actually reading from the buffer, the complete scanout function will just return and not wait for vsync. Signed-off-by: Prathyush K --- drivers/gpu/drm/exynos/exynos_drm_drv.h | 7 ++++--- drivers/gpu/drm/exynos/exynos_drm_encoder.c | 23 +++++++++++------------ drivers/gpu/drm/exynos/exynos_drm_encoder.h | 4 +++- drivers/gpu/drm/exynos/exynos_drm_fb.c | 13 +++++++++++-- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h index b9e51bc..d351daf 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_drv.h +++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h @@ -167,8 +167,7 @@ struct exynos_drm_display_ops { * @commit: set current hw specific display mode to hw. * @enable_vblank: specific driver callback for enabling vblank interrupt. * @disable_vblank: specific driver callback for disabling vblank interrupt. - * @wait_for_vblank: wait for vblank interrupt to make sure that - * hardware overlay is updated. + * @complete_scanout: complete scan of buffer so that it can be freed. */ struct exynos_drm_manager_ops { void (*dpms)(struct device *subdrv_dev, int mode); @@ -183,7 +182,9 @@ struct exynos_drm_manager_ops { void (*commit)(struct device *subdrv_dev); int (*enable_vblank)(struct device *subdrv_dev); void (*disable_vblank)(struct device *subdrv_dev); - void (*wait_for_vblank)(struct device *subdrv_dev); + void (*complete_scanout)(struct device *subdrv_dev, + dma_addr_t dma_addr, + unsigned long size); }; /* diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.c b/drivers/gpu/drm/exynos/exynos_drm_encoder.c index c63721f..7e772ed 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_encoder.c +++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.c @@ -220,28 +220,27 @@ static void exynos_drm_encoder_commit(struct drm_encoder *encoder) exynos_encoder->dpms = DRM_MODE_DPMS_ON; } -void exynos_drm_encoder_complete_scanout(struct drm_framebuffer *fb) +void exynos_drm_encoder_complete_scanout(struct drm_device *drm_dev, + dma_addr_t dma_addr, + unsigned long size) { struct exynos_drm_encoder *exynos_encoder; struct exynos_drm_manager_ops *ops; - struct drm_device *dev = fb->dev; struct drm_encoder *encoder; + struct device *dev; - /* - * make sure that overlay data are updated to real hardware - * for all encoders. - */ - list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { + /* make sure that current framebuffer is not in use for all encoders */ + list_for_each_entry(encoder, &drm_dev->mode_config.encoder_list, head) { exynos_encoder = to_exynos_encoder(encoder); ops = exynos_encoder->manager->ops; + dev = exynos_encoder->manager->dev; /* - * wait for vblank interrupt - * - this makes sure that overlay data are updated to - * real hardware. + * complete_scanout + * - this makes sure that framebuffer is not in use. */ - if (ops->wait_for_vblank) - ops->wait_for_vblank(exynos_encoder->manager->dev); + if (ops->complete_scanout) + ops->complete_scanout(dev, dma_addr, size); } } diff --git a/drivers/gpu/drm/exynos/exynos_drm_encoder.h b/drivers/gpu/drm/exynos/exynos_drm_encoder.h index 89e2fb0..b85211b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_encoder.h +++ b/drivers/gpu/drm/exynos/exynos_drm_encoder.h @@ -32,6 +32,8 @@ void exynos_drm_encoder_plane_mode_set(struct drm_encoder *encoder, void *data); void exynos_drm_encoder_plane_commit(struct drm_encoder *encoder, void *data); void exynos_drm_encoder_plane_enable(struct drm_encoder *encoder, void *data); void exynos_drm_encoder_plane_disable(struct drm_encoder *encoder, void *data); -void exynos_drm_encoder_complete_scanout(struct drm_framebuffer *fb); +void exynos_drm_encoder_complete_scanout(struct drm_device *drm_dev, + dma_addr_t dma_addr, + unsigned long size); #endif diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 294c051..1ef684a 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -69,11 +69,20 @@ static void exynos_drm_fb_destroy(struct drm_framebuffer *fb) { struct exynos_drm_fb *exynos_fb = to_exynos_fb(fb); unsigned int i; + dma_addr_t dma_addr; + unsigned long size; DRM_DEBUG_KMS("%s\n", __FILE__); - /* make sure that overlay data are updated before relesing fb. */ - exynos_drm_encoder_complete_scanout(fb); + for (i = 0; i < ARRAY_SIZE(exynos_fb->exynos_gem_obj); i++) { + if (exynos_fb->exynos_gem_obj[i] == NULL) + continue; + + dma_addr = exynos_fb->exynos_gem_obj[i]->buffer->dma_addr; + size = exynos_fb->exynos_gem_obj[i]->buffer->size; + + exynos_drm_encoder_complete_scanout(fb->dev, dma_addr, size); + } drm_framebuffer_cleanup(fb);