From patchwork Thu May 29 02:49:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YoungJun Cho X-Patchwork-Id: 4258641 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 0C5D99F32B for ; Thu, 29 May 2014 02:49:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3872B202F8 for ; Thu, 29 May 2014 02:49:34 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4819720279 for ; Thu, 29 May 2014 02:49:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 697716E95C; Wed, 28 May 2014 19:49:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 534236E03D for ; Wed, 28 May 2014 19:49:18 -0700 (PDT) Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N6B00GZYEI41V30@mailout3.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.44]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id DD.77.24374.C20A6835; Thu, 29 May 2014 11:49:16 +0900 (KST) X-AuditID: cbfee68d-b7fd46d000005f36-de-5386a02c7f80 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 3A.89.07139.C20A6835; 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:16 +0900 (KST) From: YoungJun Cho To: airlied@linux.ie, dri-devel@lists.freedesktop.org Subject: [PATCH 7/8] drm/exynos: ipp: rearrange c_node->event_lock using routine Date: Thu, 29 May 2014 11:49:11 +0900 Message-id: <1401331752-15417-8-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+t8zHV2dBW3BBl/+SlncWneO1aL33Ekm iytf37NZTLo/gcXixb2LLBZnm96wW8yY/JLNgd1j+7cHrB73u48zefRtWcUYwBzFZZOSmpNZ llqkb5fAlbH/yxSmgpvSFZ19r1kaGHeIdzFyckgImEh0nVrOAmGLSVy4t56ti5GLQ0hgGaPE j7Zz7DBFHzra2EBsIYFFjBL/DsRCFLUySfTtaATrZhPQlHj+cQcriC0iYCrRMWkpWJxZoFpi 8cS5TCC2sECAxINzEPUsAqoS876sBLN5BVwknv+YDLSMA2iZgsScSTYgJqeAq8TXr84Qa10k bn1aywyyVkKgnV3i2Me9UGMEJL5NPsQC0SorsekAM8TJkhIHV9xgmcAovICRYRWjaGpBckFx UnqRoV5xYm5xaV66XnJ+7iZGSED37mC8fcD6EGMy0LiJzFKiyfnAiMgriTc0NjOyMDUxNTYy tzQjTVhJnDfpYVKQkEB6YklqdmpqQWpRfFFpTmrxIUYmDk6pBsZNe3YKfgo79/FDblv/n4db l/FqWZXqZf0Lrm6v6ueV7Nw0Me3Al4cGl49KFx/2EZY4PnlVHse1DTca1wV9s7ryqoI50Ycn 1KJ11Ymsp6q53JdDrqi2ze6zY1K0V7IR4F7ezK9x5Zv2CeNrJw2KTjHM3/Jr7T/Z9XUJCRmG zOZT1oQXsFw/9UaJpTgj0VCLuag4EQBiw5rWfgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrBIsWRmVeSWpSXmKPExsVy+t9jAV2dBW3BBv/+iVrcWneO1aL33Ekm iytf37NZTLo/gcXixb2LLBZnm96wW8yY/JLNgd1j+7cHrB73u48zefRtWcUYwBzVwGiTkZqY klqkkJqXnJ+SmZduq+QdHO8cb2pmYKhraGlhrqSQl5ibaqvk4hOg65aZA7ReSaEsMacUKBSQ WFyspG+HaUJoiJuuBUxjhK5vSBBcj5EBGkhYx5ix/8sUpoKb0hWdfa9ZGhh3iHcxcnJICJhI fOhoY4OwxSQu3FsPZgsJLGKU+HcgtouRC8huZZLo29HIApJgE9CUeP5xByuILSJgKtExaSlY nFmgWmLxxLlMILawQIDEg3MQ9SwCqhLzvqwEs3kFXCSe/5jM3sXIAbRMQWLOJBsQk1PAVeLr V2eItS4Stz6tZZ7AyLuAkWEVo2hqQXJBcVJ6rpFecWJucWleul5yfu4mRnC8PJPewbiqweIQ owAHoxIPr4RsW7AQa2JZcWXuIUYJDmYlEV6NcKAQb0piZVVqUX58UWlOavEhxmSgmyYyS4km 5wNjOa8k3tDYxMzI0sjM2MTc2Jg0YSVx3oOt1oFCAumJJanZqakFqUUwW5g4OKUaGGur96Yp V+uXbzLpKmOv2GfLrrRrxx+Gl8fYum7aKZzb/ny70LHl+aHX2IzPNS1pZN61NrWp9mphXRLj bidz33dPNNKW701zWVET8OjZY6GyR4smBTLufefdMSV34d3Zte3Gcav8DWy6nC+J3/zXumjB DDuBW2Esopf/RYeFcZ4rmbEuQfmvixJLcUaioRZzUXEiACpua6rbAgAA 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 The c_node->event_list should be protected with c_node->event_lock. 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 | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_ipp.c b/drivers/gpu/drm/exynos/exynos_drm_ipp.c index 92350ba..76da630 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_ipp.c +++ b/drivers/gpu/drm/exynos/exynos_drm_ipp.c @@ -795,7 +795,9 @@ static int ipp_get_event(struct drm_device *drm_dev, e->base.event = &e->event.base; e->base.file_priv = file; e->base.destroy = ipp_free_event; + mutex_lock(&c_node->event_lock); list_add_tail(&e->base.link, &c_node->event_list); + mutex_unlock(&c_node->event_lock); return 0; } @@ -806,6 +808,7 @@ static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node, struct drm_exynos_ipp_send_event *e, *te; int count = 0; + mutex_lock(&c_node->event_lock); list_for_each_entry_safe(e, te, &c_node->event_list, base.link) { DRM_DEBUG_KMS("count[%d]e[0x%x]\n", count++, (int)e); @@ -826,9 +829,13 @@ static void ipp_put_event(struct drm_exynos_ipp_cmd_node *c_node, /* delete list */ list_del(&e->base.link); kfree(e); - return; + goto out_unlock; } } + +out_unlock: + mutex_unlock(&c_node->event_lock); + return; } static void ipp_handle_cmd_work(struct device *dev, @@ -1514,9 +1521,11 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv, return -EINVAL; } + mutex_lock(&c_node->event_lock); if (list_empty(&c_node->event_list)) { DRM_DEBUG_KMS("event list is empty.\n"); - return 0; + ret = 0; + goto err_event_unlock; } mutex_lock(&c_node->mem_lock); @@ -1608,11 +1617,6 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv, e = list_first_entry(&c_node->event_list, struct drm_exynos_ipp_send_event, base.link); - if (!e) { - DRM_ERROR("empty event.\n"); - return -EINVAL; - } - do_gettimeofday(&now); DRM_DEBUG_KMS("tv_sec[%ld]tv_usec[%ld]\n", now.tv_sec, now.tv_usec); e->event.tv_sec = now.tv_sec; @@ -1627,6 +1631,7 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv, list_move_tail(&e->base.link, &e->base.file_priv->event_list); wake_up_interruptible(&e->base.file_priv->event_wait); spin_unlock_irqrestore(&drm_dev->event_lock, flags); + mutex_unlock(&c_node->event_lock); DRM_DEBUG_KMS("done cmd[%d]prop_id[%d]buf_id[%d]\n", property->cmd, property->prop_id, tbuf_id[EXYNOS_DRM_OPS_DST]); @@ -1635,6 +1640,8 @@ static int ipp_send_event(struct exynos_drm_ippdrv *ippdrv, err_mem_unlock: mutex_unlock(&c_node->mem_lock); +err_event_unlock: + mutex_unlock(&c_node->event_lock); return ret; } @@ -1677,8 +1684,6 @@ void ipp_sched_event(struct work_struct *work) goto err_completion; } - mutex_lock(&c_node->event_lock); - ret = ipp_send_event(ippdrv, c_node, event_work->buf_id); if (ret) { DRM_ERROR("failed to send event.\n"); @@ -1688,8 +1693,6 @@ void ipp_sched_event(struct work_struct *work) err_completion: if (ipp_is_m2m_cmd(c_node->property.cmd)) complete(&c_node->start_complete); - - mutex_unlock(&c_node->event_lock); } static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device *dev)