From patchwork Thu May 29 02:49:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YoungJun Cho X-Patchwork-Id: 4258591 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 826B99F32B for ; Thu, 29 May 2014 02:49:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 855D820328 for ; Thu, 29 May 2014 02:49:27 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8C7502034C for ; Thu, 29 May 2014 02:49:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E94896E95B; Wed, 28 May 2014 19:49:19 -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 AB7496E2D0 for ; Wed, 28 May 2014 19:49:18 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6B006LEEI48380@mailout1.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 29 May 2014 11:49:16 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.46]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id EF.C7.14704.C20A6835; Thu, 29 May 2014 11:49:16 +0900 (KST) X-AuditID: cbfee68f-b7fef6d000003970-3d-5386a02ca774 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id A8.89.07139.B20A6835; Thu, 29 May 2014 11:49:16 +0900 (KST) Received: from localhost.localdomain ([10.252.75.90]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N6B000AMEI0TZ00@mmp1.samsung.com>; Thu, 29 May 2014 11:49:15 +0900 (KST) From: YoungJun Cho To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH 4/8] drm/exynos: ipp: add cmd_lock for cmd_list Date: Thu, 29 May 2014 11:49:08 +0900 Message-id: <1401331752-15417-5-git-send-email-yj44.cho@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1401331752-15417-1-git-send-email-yj44.cho@samsung.com> References: <1401331752-15417-1-git-send-email-yj44.cho@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRmVeSWpSXmKPExsVy+t8zPV2dBW3BBivXcFvcWneO1aL33Ekm iytf37NZTLo/gcXixb2LLBZnm96wW8yY/JLNgd1j+7cHrB73u48zefRtWcUYwBzFZZOSmpNZ llqkb5fAlTHl9UW2gl8qFWvuXGNrYJwl38XIySEhYCKx//xONghbTOLCvfVANheHkMAyRomF m9pYYIqu35vNBJFYxCgx9eVXZginlUli8c6LrCBVbAKaEs8/7gCzRQRMJTomLQXrZhaollg8 cS4TiC0sYC+x7eB3ZhCbRUBVYtX6pWA2r4CLxMt504FsDqBtChJzJtmAmJwCrhJfvzqDVAgB Vdz6tJYZ4p5+dol9J1ghpghIfJt8iAWiU1Zi0wGoEkmJgytusExgFF7AyLCKUTS1ILmgOCm9 yFivODG3uDQvXS85P3cTIySg+3cw3j1gfYgxGWjcRGYp0eR8YETklcQbGpsZWZiamBobmVua kSasJM57/2FSkJBAemJJanZqakFqUXxRaU5q8SFGJg5OqQZGA9X99hvPXF/EH3VjscNysVlH V3y7cyBqwskYzb8PwqrW231+x/O/Mq7YRcTCWJXbaOnCNOWSk4qMu88ZP6/esz08K/31pE33 jrpM3z7FNlPwbMysnlU7RcUEHM6v6jqV1qm7/31A3cE1D26oaVcFndpv1HNLW+9v+o6Id0+X FiguvM+YtOhYsRJLcUaioRZzUXEiANUvpIB+AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRmVeSWpSXmKPExsVy+t9jAV2dBW3BBn82sVvcWneO1aL33Ekm iytf37NZTLo/gcXixb2LLBZnm96wW8yY/JLNgd1j+7cHrB73u48zefRtWcUYwBzVwGiTkZqY klqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA7ReSaEsMacUKBSQ WFyspG+HaUJoiJuuBUxjhK5vSBBcj5EBGkhYx5gx5fVFtoJfKhVr7lxja2CcJd/FyMkhIWAi cf3ebCYIW0ziwr31bF2MXBxCAosYJaa+/MoM4bQySSzeeZEVpIpNQFPi+ccdYLaIgKlEx6Sl LCA2s0C1xOKJc8EmCQvYS2w7+J0ZxGYRUJVYtX4pmM0r4CLxct50IJsDaJuCxJxJNiAmp4Cr xNevziAVQkAVtz6tZZ7AyLuAkWEVo2hqQXJBcVJ6rpFecWJucWleul5yfu4mRnDEPJPewbiq weIQowAHoxIPr4RsW7AQa2JZcWXuIUYJDmYlEV6NcKAQb0piZVVqUX58UWlOavEhxmSgmyYy S4km5wOjOa8k3tDYxMzI0sjM2MTc2Jg0YSVx3oOt1oFCAumJJanZqakFqUUwW5g4OKUaGOfm vk3+0r84f+O5UPHLDvvnn3ubrfrw+q9rsi+sdwfnfHXf0up6Q+HseXabHIZi64Z77ZfPL0mq 2f+xqLC1O1Q/ZP8SrnXrVszNOLaq/SfXVs1rYjclfmvzLb142+KkQkxTDN+nYC4xhZZ/tt+m +/GoVpz2T/CTjf0550SP8gmtd0/WO7wuO6bEUpyRaKjFXFScCACFRw8t3AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: a.hajda@samsung.com, kyungmin.park@samsung.com, sw0312.kim@samsung.com 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 This patch adds cmd_lock for cmd_list synchronization. Signed-off-by: YoungJun Cho Reviewed-by: Seong-Woo Kim Reviewed-by: Andrzej Hajda Acked-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_ipp.c | 19 +++++++++++++++++-- drivers/gpu/drm/exynos/exynos_drm_ipp.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c index 0d85433..cad2cad 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c @@ -284,9 +284,14 @@ static struct exynos_drm_ippdrv *ipp_find_drv_by_handle(u32 prop_id) list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) { DRM_DEBUG_KMS("count[%d]ippdrv[0x%x]\n", count++, (int)ippdrv); - list_for_each_entry(c_node, &ippdrv->cmd_list, list) - if (c_node->property.prop_id == prop_id) + mutex_lock(&ippdrv->cmd_lock); + list_for_each_entry(c_node, &ippdrv->cmd_list, list) { + if (c_node->property.prop_id == prop_id) { + mutex_unlock(&ippdrv->cmd_lock); return ippdrv; + } + } + mutex_unlock(&ippdrv->cmd_lock); } return ERR_PTR(-ENODEV); @@ -379,9 +384,11 @@ static int ipp_find_and_set_property(struct drm_exynos_ipp_property *property) * when we find this command no using prop_id. * return property information set in this command node. */ + mutex_lock(&ippdrv->cmd_lock); list_for_each_entry(c_node, &ippdrv->cmd_list, list) { if ((c_node->property.prop_id == prop_id) && (c_node->state == IPP_STATE_STOP)) { + mutex_unlock(&ippdrv->cmd_lock); DRM_DEBUG_KMS("found cmd[%d]ippdrv[0x%x]\n", property->cmd, (int)ippdrv); @@ -389,6 +396,7 @@ static int ipp_find_and_set_property(struct drm_exynos_ipp_property *property) return 0; } } + mutex_unlock(&ippdrv->cmd_lock); DRM_ERROR("failed to search property.\n"); @@ -519,7 +527,9 @@ int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void *data, INIT_LIST_HEAD(&c_node->event_list); list_splice_init(&priv->event_list, &c_node->event_list); + mutex_lock(&ippdrv->cmd_lock); list_add_tail(&c_node->list, &ippdrv->cmd_list); + mutex_unlock(&ippdrv->cmd_lock); /* make dedicated state without m2m */ if (!ipp_is_m2m_cmd(property->cmd)) @@ -1110,10 +1120,12 @@ int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void *data, c_node->state = IPP_STATE_STOP; ippdrv->dedicated = false; + mutex_lock(&ippdrv->cmd_lock); ipp_clean_cmd_node(c_node); if (list_empty(&ippdrv->cmd_list)) pm_runtime_put_sync(ippdrv->dev); + mutex_unlock(&ippdrv->cmd_lock); break; case IPP_CTRL_PAUSE: cmd_work = c_node->stop_work; @@ -1688,6 +1700,7 @@ static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device *dev) ippdrv->event_workq = ctx->event_workq; ippdrv->sched_event = ipp_sched_event; INIT_LIST_HEAD(&ippdrv->cmd_list); + mutex_init(&ippdrv->cmd_lock); if (is_drm_iommu_supported(drm_dev)) { ret = drm_iommu_attach_device(drm_dev, ippdrv->dev); @@ -1757,6 +1770,7 @@ static void ipp_subdrv_close(struct drm_device *drm_dev, struct device *dev, DRM_DEBUG_KMS("for priv[0x%x]\n", (int)priv); list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list, drv_list) { + mutex_lock(&ippdrv->cmd_lock); list_for_each_entry_safe(c_node, tc_node, &ippdrv->cmd_list, list) { DRM_DEBUG_KMS("count[%d]ippdrv[0x%x]\n", @@ -1781,6 +1795,7 @@ static void ipp_subdrv_close(struct drm_device *drm_dev, struct device *dev, pm_runtime_put_sync(ippdrv->dev); } } + mutex_unlock(&ippdrv->cmd_lock); } kfree(priv); diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.h b/drivers/gpu/drm/exynos/exynos_drm_ipp.h index fbb80ac..09cb5a2 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.h +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.h @@ -148,6 +148,7 @@ struct exynos_drm_ipp_ops { * @event_workq: event work queue. * @c_node: current command information. * @cmd_list: list head for command information. + * @cmd_lock: lock for synchronization of access to cmd_list. * @prop_list: property informations of current ipp driver. * @check_property: check property about format, size, buffer. * @reset: reset ipp block. @@ -165,6 +166,7 @@ struct exynos_drm_ippdrv { struct workqueue_struct *event_workq; struct drm_exynos_ipp_cmd_node *c_node; struct list_head cmd_list; + struct mutex cmd_lock; struct drm_exynos_ipp_prop_list prop_list; int (*check_property)(struct device *dev,