From patchwork Tue Jan 5 15:28:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 357159 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 678DBC433E6 for ; Tue, 5 Jan 2021 15:39:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3467322AAD for ; Tue, 5 Jan 2021 15:39:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728310AbhAEPjx (ORCPT ); Tue, 5 Jan 2021 10:39:53 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:38190 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728302AbhAEPjx (ORCPT ); Tue, 5 Jan 2021 10:39:53 -0500 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 71FE31C0D; Tue, 5 Jan 2021 16:30:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1609860621; bh=G3K8VzGEsDLC76cfwp3+WmdKEKRsUIc0Qb0rtl0tj+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oPeTXyRX4jdr5GKUgU4rGpkwMBImB3CBUNfPZCK+lF08hpyFJX1+G/31yib3VPkm8 k3rz0hB8GEk1aIPEkJS8URmePoauKUMIKIV2rFX6N9odFuf2DNqCYiCRtgimA8JgG8 3Jseev+YSDa4OpXDlx0niua1M4Lm6vpfSBLjSzcU= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Steve Longerbeam , Philipp Zabel , Ezequiel Garcia Subject: [PATCH 67/75] media: imx: imx7_mipi_csis: Move link setup check out of locked section Date: Tue, 5 Jan 2021 17:28:44 +0200 Message-Id: <20210105152852.5733-68-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210105152852.5733-1-laurent.pinchart@ideasonboard.com> References: <20210105152852.5733-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Checking if the link setup operation is called for the sink or source pad doesn't require any locking. Move it out of the section protected by the mutex. Signed-off-by: Laurent Pinchart --- drivers/staging/media/imx/imx7-mipi-csis.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 4e85611fcdc6..3c68ee8b2a59 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -668,20 +668,23 @@ static int mipi_csis_link_setup(struct media_entity *entity, dev_dbg(state->dev, "link setup %s -> %s", remote_pad->entity->name, local_pad->entity->name); + /* We only care about the link to the source. */ + if (!(local_pad->flags & MEDIA_PAD_FL_SINK)) + return 0; + remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity); mutex_lock(&state->lock); - if (local_pad->flags & MEDIA_PAD_FL_SINK) { - if (flags & MEDIA_LNK_FL_ENABLED) { - if (state->src_sd) { - ret = -EBUSY; - goto out; - } - state->src_sd = remote_sd; - } else { - state->src_sd = NULL; + if (flags & MEDIA_LNK_FL_ENABLED) { + if (state->src_sd) { + ret = -EBUSY; + goto out; } + + state->src_sd = remote_sd; + } else { + state->src_sd = NULL; } out: