From patchwork Thu Apr 28 10:25:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 8967741 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D432E9F441 for ; Thu, 28 Apr 2016 10:25:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0F8D62027D for ; Thu, 28 Apr 2016 10:25:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE35C202A1 for ; Thu, 28 Apr 2016 10:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751439AbcD1KZT (ORCPT ); Thu, 28 Apr 2016 06:25:19 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:39211 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751070AbcD1KZS (ORCPT ); Thu, 28 Apr 2016 06:25:18 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O6C00L1VAA3NM90@mailout1.w1.samsung.com>; Thu, 28 Apr 2016 11:25:15 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-cc-5721e50b6241 Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 48.30.05254.B05E1275; Thu, 28 Apr 2016 11:25:15 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O6C002MPA9ZLM80@eusync4.samsung.com>; Thu, 28 Apr 2016 11:25:15 +0100 (BST) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Jacek Anaszewski , Sakari Ailus , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz Subject: [PATCH 2/2] media: s3c-camif: fix deadlock on driver probe() Date: Thu, 28 Apr 2016 12:25:04 +0200 Message-id: <1461839104-29135-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1461839104-29135-1-git-send-email-m.szyprowski@samsung.com> References: <1461839104-29135-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjluLIzCtJLcpLzFFi42I5/e/4NV3up4rhBgde61hsnLGe1aL36nNG i9cvDC16NmxltZhxfh+Txdojd9ktDr9pZ7X4tOUbkwOHx7yTgR59W1YxenzeJBfAHMVlk5Ka k1mWWqRvl8CV8f5uK2PBdL6KFZdvMzYwNvF0MXJySAiYSHR3T2ODsMUkLtxbD2RzcQgJLGWU WHDxNxOE08QkcfnLcxaQKjYBQ4mut11gHSICThILZ/1lByliFljKJLHx3HcmkISwgKvE1I0v wGwWAVWJuw3rmEFsXgEPieVHv7NArJOT+P9yBVgNp4CnxNYLF8CGCgHVXP75jXUCI+8CRoZV jKKppckFxUnpuYZ6xYm5xaV56XrJ+bmbGCGh9GUH4+JjVocYBTgYlXh4JyUohguxJpYVV+Ye YpTgYFYS4TV/AhTiTUmsrEotyo8vKs1JLT7EKM3BoiTOO3fX+xAhgfTEktTs1NSC1CKYLBMH p1QDI3dVC5uYyJdZcTd0w5hV3sg2rNidcoilPPT7j78W7eIXq361s0Y6HtV7Wz3xx4XJIlLv fZJFZvzv3dIh9ejHGX3+23MYJ+7kvxIeqZl78Ba/Qd2T1309bQm+xxaun7PjTLPl5HvTCp5E ZKUt8Hu1MrkycXNg/Q/BjrC3qTYpQY8MctyLgxbrKLEUZyQaajEXFScCAHWH6+YhAgAA Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Commit 0c426c472b5585ed6e59160359c979506d45ae49 ("[media] media: Always keep a graph walk large enough around") changed media_device_register_entity() function to take mdev->graph_mutex. This causes deadlock in driver probe, which calls (indirectly) this function with ->graph_mutex taken. This patch removes taking ->graph_mutex in driver probe to avoid deadlock. Other drivers don't take ->graph_mutex for entity registration, so this change should be safe. Signed-off-by: Marek Szyprowski Reviewed-by: Hans Verkuil --- drivers/media/platform/s3c-camif/camif-core.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/s3c-camif/camif-core.c b/drivers/media/platform/s3c-camif/camif-core.c index 0b44b9accf50..af237af204e2 100644 --- a/drivers/media/platform/s3c-camif/camif-core.c +++ b/drivers/media/platform/s3c-camif/camif-core.c @@ -493,21 +493,17 @@ static int s3c_camif_probe(struct platform_device *pdev) if (ret < 0) goto err_sens; - mutex_lock(&camif->media_dev.graph_mutex); - ret = v4l2_device_register_subdev_nodes(&camif->v4l2_dev); if (ret < 0) - goto err_unlock; + goto err_sens; ret = camif_register_video_nodes(camif); if (ret < 0) - goto err_unlock; + goto err_sens; ret = camif_create_media_links(camif); if (ret < 0) - goto err_unlock; - - mutex_unlock(&camif->media_dev.graph_mutex); + goto err_sens; ret = media_device_register(&camif->media_dev); if (ret < 0) @@ -516,8 +512,6 @@ static int s3c_camif_probe(struct platform_device *pdev) pm_runtime_put(dev); return 0; -err_unlock: - mutex_unlock(&camif->media_dev.graph_mutex); err_sens: v4l2_device_unregister(&camif->v4l2_dev); media_device_unregister(&camif->media_dev);