From patchwork Mon Mar 28 18:11:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 8680171 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 267B4C0553 for ; Mon, 28 Mar 2016 18:12:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 433FE20272 for ; Mon, 28 Mar 2016 18:12:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3EE4B201CD for ; Mon, 28 Mar 2016 18:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754206AbcC1SMA (ORCPT ); Mon, 28 Mar 2016 14:12:00 -0400 Received: from [198.137.202.9] ([198.137.202.9]:51209 "EHLO bombadil.infradead.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1754086AbcC1SL6 (ORCPT ); Mon, 28 Mar 2016 14:11:58 -0400 Received: from 177.43.19.111.dynamic.adsl.gvt.net.br ([177.43.19.111] helo=smtp.w2.samsung.com) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1akbd7-0003lW-PG; Mon, 28 Mar 2016 18:11:10 +0000 Received: from mchehab by smtp.w2.samsung.com with local (Exim 4.86_2) (envelope-from ) id 1akbd3-0002PJ-W0; Mon, 28 Mar 2016 15:11:05 -0300 From: Mauro Carvalho Chehab To: Linux Media Mailing List Cc: Mauro Carvalho Chehab , Mauro Carvalho Chehab , Shuah Khan , Sakari Ailus Subject: [PATCH 2/2] [media] avoid double locks with graph_mutex Date: Mon, 28 Mar 2016 15:11:04 -0300 Message-Id: <3cabc4b828abac3c6dea240ae22d4754a438ad1b.1459188623.git.mchehab@osg.samsung.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <91b3d9b66d52707ca95d996edd423c0f5e36b6ca.1459188623.git.mchehab@osg.samsung.com> References: <20160328150948.3efa93ee@recife.lan> <91b3d9b66d52707ca95d996edd423c0f5e36b6ca.1459188623.git.mchehab@osg.samsung.com> In-Reply-To: <91b3d9b66d52707ca95d996edd423c0f5e36b6ca.1459188623.git.mchehab@osg.samsung.com> References: <91b3d9b66d52707ca95d996edd423c0f5e36b6ca.1459188623.git.mchehab@osg.samsung.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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 Add a note at the headers telling that the link setup callbacks are called with the mutex hold. Also, removes a double lock at the PM suspend callbacks. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas --- drivers/media/media-device.c | 1 - drivers/media/v4l2-core/v4l2-mc.c | 4 ---- include/media/media-device.h | 3 ++- include/media/media-entity.h | 3 +++ 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 6cfa890af7b4..6af5e6932271 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -93,7 +93,6 @@ static struct media_entity *find_entity(struct media_device *mdev, u32 id) media_device_for_each_entity(entity, mdev) { if (((media_entity_id(entity) == id) && !next) || ((media_entity_id(entity) > id) && next)) { - mutex_unlock(&mdev->graph_mutex); return entity; } } diff --git a/drivers/media/v4l2-core/v4l2-mc.c b/drivers/media/v4l2-core/v4l2-mc.c index 2228cd3a846e..d44ff2ec314f 100644 --- a/drivers/media/v4l2-core/v4l2-mc.c +++ b/drivers/media/v4l2-core/v4l2-mc.c @@ -348,8 +348,6 @@ int v4l2_pipeline_pm_use(struct media_entity *entity, int use) int change = use ? 1 : -1; int ret; - mutex_lock(&mdev->graph_mutex); - /* Apply use count to node. */ entity->use_count += change; WARN_ON(entity->use_count < 0); @@ -359,8 +357,6 @@ int v4l2_pipeline_pm_use(struct media_entity *entity, int use) if (ret < 0) entity->use_count -= change; - mutex_unlock(&mdev->graph_mutex); - return ret; } EXPORT_SYMBOL_GPL(v4l2_pipeline_pm_use); diff --git a/include/media/media-device.h b/include/media/media-device.h index b04cfa907350..e6ad30c323fc 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h @@ -312,7 +312,8 @@ struct media_entity_notify { * @enable_source: Enable Source Handler function pointer * @disable_source: Disable Source Handler function pointer * - * @link_notify: Link state change notification callback + * @link_notify: Link state change notification callback. This callback is + * Called with the graph_mutex hold. * * This structure represents an abstract high-level media device. It allows easy * access to entities and provides basic media device-level support. The diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 6dc9e4e8cbd4..0b16ebe36db7 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -179,6 +179,9 @@ struct media_pad { * @link_validate: Return whether a link is valid from the entity point of * view. The media_entity_pipeline_start() function * validates all links by calling this operation. Optional. + * + * Note: Those ioctls should not touch the struct media_device.@graph_mutex + * field, as they're called with it already hold. */ struct media_entity_operations { int (*link_setup)(struct media_entity *entity,