From patchwork Wed May 5 09:41:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239557 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 D0078C433ED for ; Wed, 5 May 2021 09:46:28 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8125D613D6 for ; Wed, 5 May 2021 09:46:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8125D613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zt9rCs27D1TDEMZPtGYDy1woGMoPxGrEiye5mT32JGg=; b=Qatqa6/mvi6MhWdmn0q6Njag5 o0b7ipUmuws+NinDgfYc1S+iQE2vIKlVHMoLr80Hks9scbVRHSEq9ZCA3pJQh1KQE59xq1f4MHqOE ISiMbhPiR5MF4VaRl+vXV0MAa5AhLCVjgIAZTjyd0NjUaCyUnn4726VC6Wkm/xvlgK2qpXNjDPZqv FI6sO/E/Ool4+OgZXqxVhv8dmCWeT1HVGfT3RxMzlVxIHKmgNfnzueo1CveR0Z0ntqrCQRX4OhzRn 4yFVMa8QacOco7GAcoGTTNwySTPpIMc5RJE2JhCGmLH12reqZd62Lr5GG3ZI2yD+ZayV4DyylDFfg XKygVEsDg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE3P-000lGb-96; Wed, 05 May 2021 09:42:51 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2x-000l4i-Po for linux-arm-kernel@desiato.infradead.org; Wed, 05 May 2021 09:42:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=v90TsbXff/6HaEkiq25pR07ZEPd3x2tTwFoulVzsnEE=; b=HhdieCsgKgxG75IsPjKHLt2F8h e/E7oYXr4FHyVltogGE73Rf79XG4MmyPwfwlT6qBnvfCBIg4pgoVnZ4Ix4vZvm7uT0aeWIT6+uGJC Ih8etdOVxiFNPMF2l02ij0ob1FvjKig53I4ohztmUZ3KjbaLryynMVa8ogpdgCVcllevyZPCjNGB9 o2hxAi6SVpIzGu0PihDbSbHoM8UbMZMRXaKpEl5XjbCuqtgcy67LDge14+eJN6tdi9XvTFejtt1nq kkYR209g9MOfb6HS0AakIxd+MnRfqdxbUEcTHAlOBXR2erPAe/i9sDTwO28/R/fbHP4XTZPzFIRY8 OGJGIAnQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2u-004cd2-CU for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:22 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1A6E961410; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=Y6Mm5CQ5FccRV1mq5OQxwJw1oJhZ1ZvSJdtqtRhzZk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FyMdhJCuzAtmH21EpjHJi9AkSctdAjlolAuDFK9T9+1ZpeeMTuNEg8MvWc3YVlHDM M5Z8ao/2Vj+/WMSzRRKIaPPB3DMfyiEbzx7xCdTzPJohz/n4w4I+wJsfZiG3vfuvTn KxsNLutY32UJby0kkjcChUAbY+NWDNWxDvXi3x91NCienVvc64uFXhFGqv7fJ7sBuj p6s+95Rk7RJBJX3Cyp0ZFpZM1l4ERgXU178uQQDojjxXQN0wDn/7TvnbR0NOW/ZZTQ P8cd9cD250qbzKtNtVCFuX0s7XlZvNqjRkYOea2Mc+WfEgvICojJSUhlz+IwGFzz9B SLcxBj27xLT5Q== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2q-00AHvt-Lf; Wed, 05 May 2021 11:42:16 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Fabio Estevam , Greg Kroah-Hartman , Mauro Carvalho Chehab , NXP Linux Team , Pengutronix Kernel Team , Philipp Zabel , Rui Miguel Silva , Sascha Hauer , Shawn Guo , Steve Longerbeam , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 02/25] staging: media: imx7-mipi-csis: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:41:52 +0200 Message-Id: <793a5806a63b6313606fd1c344b9eec41e61a440.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024220_483340_5EB3F01A X-CRM114-Status: GOOD ( 11.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. Acked-by: Rui Miguel Silva Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/imx/imx7-mipi-csis.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c index 025fdc488bd6..1dc680d94a46 100644 --- a/drivers/staging/media/imx/imx7-mipi-csis.c +++ b/drivers/staging/media/imx/imx7-mipi-csis.c @@ -695,11 +695,10 @@ static int mipi_csis_s_stream(struct v4l2_subdev *mipi_sd, int enable) mipi_csis_clear_counters(state); - ret = pm_runtime_get_sync(&state->pdev->dev); - if (ret < 0) { - pm_runtime_put_noidle(&state->pdev->dev); + ret = pm_runtime_resume_and_get(&state->pdev->dev); + if (ret < 0) return ret; - } + ret = v4l2_subdev_call(state->src_sd, core, s_power, 1); if (ret < 0 && ret != -ENOIOCTLCMD) goto done; From patchwork Wed May 5 09:41:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239555 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 A0779C433B4 for ; Wed, 5 May 2021 09:46:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D9ED613EC for ; Wed, 5 May 2021 09:46:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D9ED613EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CMhBpKHzcFpHd5kcbffGdI0iMBSHt0DN5L0l1DUmQQo=; b=QGzDtbCDkJ8GKShpQsfLiAYMJ HLQFX6Xd256iT1WIjpWRrneBVAAuwWCqRM4PbgiPFpXZvuVKzrf6ddPrPt/mw2dkrG7u5sHfD7tKC Z/vEidsaoo32uqV5WH7K3rgdSXPYcWXBKmlhLQ/3AeCYHmc861wQ/DfaNmIwM/o+eHs4OgdsKMFU1 oM5DfVe4qZGFL78STB8x0ezFAJr2ri9NHzw4fOAGk5xZw/eumfrMwVX1uybu60l6+KWcsXCupaMjU UGiixmfZQ9p8ozEvNQYxkFce3KBUxZGAQLOL5BiJ/nxwkWk8MOhc/K1eicvcY1cYqlB+GTLHGJJAD +rNGAz+eA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE36-000l5w-8c; Wed, 05 May 2021 09:42:32 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2w-000l3o-Kk for linux-arm-kernel@desiato.infradead.org; Wed, 05 May 2021 09:42:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=OI77eR4nGyZxIXpCKbXz8jMtKZLMEeKKY17oeWDLdic=; b=IM+YqYsvRDTZkGTQTbUL11nFjU w+TAmENx5ksk1Ua3ZlMIUFc1ImrDS3AJml0/pQRhgp21v7asp8OMN9w30afDqxGhAT4IDJA64dAhf NSmYd2a9YP23SM9cUXS02C/k4Q2myNkowGPBrrfZP60VWLw/Pyq5/pLo4SpjRx5QXbFModHf/EuL4 +03BS+f10Mpj4zqNVtxNVLgcGvXaiVkMbH61Ly1vym/i9R6HaQNf21YMvAzNcKi7njz/MMCGnyi70 UEuLDQeOL7F+NA+nSBHvRg4IHgF9WiOs6xO+qbZBLWa+reZVjfFL7eV6WFavjIjqfvocely+R7dqB WuP2EmYA==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2u-004ccu-4I for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:21 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id D7FEB613D6; Wed, 5 May 2021 09:42:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207738; bh=mnwOoPbSt3peAjkyotn8X7kUrTzZPsSiyyacWXI13wM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bgfruVEEULYmgG8/EtzRxyrlkAlbXqpxHyLYWRYORK3lTHHwyE7wPJ96drcdorIc1 D4GndNvQT0xO0M8kqfe9fdMGZ13MftfEJ7aNDQXUnKYnhAxqwIEdivyt2LzNIvHgyG kHJIUUIyHL9ZZYkaxLrCB/jUI08u1rsRDK6zvm+J6e+8CUZoomYLuKMeHIxlOx4oa3 hj57c8Kq3+kCxjge4PuopSuXt+QDkKzP81q4VppzM+6p+GxklFiqhfK0P8dhMUHExH Ob4zfKSovQbjxrWNOnQ9cG8JpzDBcP0SS/LqlwzybnI4AsnfAwCYVx0qI5iYi3PNX7 cjyOBBv8BA+iw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2q-00AHw9-Sx; Wed, 05 May 2021 11:42:16 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Hans Verkuil , Krzysztof Kozlowski , Mauro Carvalho Chehab , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 07/25] media: exynos-gsc: don't resume at remove time Date: Wed, 5 May 2021 11:41:57 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024220_222955_9E4A8428 X-CRM114-Status: GOOD ( 12.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Calling pm_runtime_get_sync() at driver's removal time is not needed, as this will resume PM runtime. Also, the PM runtime code at pm_runtime_disable() already calls it, if it detects the need. So, change the logic in order to disable PM runtime earlier. Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/media/platform/exynos-gsc/gsc-core.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index 9f41c2e7097a..f49f3322f835 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -1210,18 +1210,19 @@ static int gsc_remove(struct platform_device *pdev) struct gsc_dev *gsc = platform_get_drvdata(pdev); int i; - pm_runtime_get_sync(&pdev->dev); - gsc_unregister_m2m_device(gsc); v4l2_device_unregister(&gsc->v4l2_dev); vb2_dma_contig_clear_max_seg_size(&pdev->dev); - for (i = 0; i < gsc->num_clocks; i++) - clk_disable_unprepare(gsc->clock[i]); - pm_runtime_put_noidle(&pdev->dev); pm_runtime_disable(&pdev->dev); + if (!pm_runtime_status_suspended(&pdev->dev)) + for (i = 0; i < gsc->num_clocks; i++) + clk_disable_unprepare(gsc->clock[i]); + + pm_runtime_set_suspended(&pdev->dev); + dev_dbg(&pdev->dev, "%s driver unloaded\n", pdev->name); return 0; } From patchwork Wed May 5 09:41:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239549 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 B35F1C433ED for ; Wed, 5 May 2021 09:45:32 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 20EC561106 for ; Wed, 5 May 2021 09:45:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20EC561106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9Q6pY3NCUUkjkqm2/tE564Vy2SsDSPbeIyf4iE9KH1c=; b=EQnZ1wDGRNwXcPpKndNQ1pTGr zIViLim0iwG3Ir49c5Em867YgBxGMJ5bmeEmevWvCXOhiBKl79k0dCLekFSAUfDUG6kQIdgsiAQdi mj11dOLQzOtL5wglgq+Qe5DYhEcPW5GbA6yDSmf/mOTPX5VdSgrOzbQnD/UujifYnul0AeCbi+p15 pk3a8pnr//NUhbq5I/OzcHz+k2hyAqybiVIS0ORXSYKbviH0HSkCqHFC0TWQGDsYP+g4pXoXdyMwm PD58NOTkPiATPD2B08tLqzvAM2xBFgyre5DeYEyMgjU46h8VLLEYcuTBKvmJjVAYHjWIoJEsnFPI1 hMfNr0qxA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE4P-000le5-2i; Wed, 05 May 2021 09:43:53 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE30-000l5q-BW for linux-arm-kernel@desiato.infradead.org; Wed, 05 May 2021 09:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=PeH2yNupdb6YP3gWNbcFAVQ1vpfjUUipct6SLHlV93U=; b=sIs/sGI83wIJ01HoSCmp1/Yxgw 62G0a919e14g0186Xf4+heJxUhyHtNi/3xUAcNNVGNHdN+J3M+PADd13kYUm84ulgR8RLUyCppR3F zgqN/I7OYGJT4I3+9CGoOU3wAR2C5K2+QXPOWK6tjTLLX1qT7mS4w2tJOV2Qd7+wWCV23Q4LJsRR1 zUI1Zj4U4PTNHXefaukags5d13jgs13vGmyVynHdZHUr3Alli0GifaZ8YjHiXSYcKipBaFa+y6mi0 FeoRnaC/TB7geFPi7Zlamu6sPkPaaK4uBlo5tMN8Gf6zBg4y7y9VPzk99kpEv1ZEOUPdExs1wiHjU t2deuI8A==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2v-004cfL-NS for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3004661417; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=ddHMsoQJIeEVxpJKZdA1kNWkPpxjkyAVmGR/xG7ZBGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n11nVBSoJJrK6LOv5J1TgVtk+WKAJeHa8zqHPGr2rmaI/NlH/NBTMyZb7f5miyt/K EWZTEkOwphSu7IYzIO2dpQa0QbNMQwihy6PTpTXaj9bvbH/KRL65dtZmN+k6hFYMMV i7GjR/27WjjHIGlaXflro8tlT6iC3mn7/dMzOULXeXpmCjhHDij8EeMklc9yb8myt0 9wHo1DdbCuyQ3XGv1wI8NheBpnS0UlXub4LaM220gbWYJRWHjrJNquNWqUtOI7vWW1 1T2sl2BMpqo8qmWNN1NjAVNIP/sE8aHSUAF+3U1MhTn6iWLQyp2L0pKIWS7iop2GQ/ R5CZNFTv40rGw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2q-00AHwC-U6; Wed, 05 May 2021 11:42:16 +0200 From: Mauro Carvalho Chehab To: Subject: [PATCH 08/25] media: atmel: properly get pm_runtime Date: Wed, 5 May 2021 11:41:58 +0200 Message-Id: <975645970144b6c8401ab9bd1243619978a868a9.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024221_859610_02E27700 X-CRM114-Status: GOOD ( 20.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linuxarm@huawei.com, Ludovic Desroches , mauro.chehab@huawei.com, Eugen Hristev , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are several issues in the way the atmel driver handles pm_runtime_get_sync(): - it doesn't check return codes; - it doesn't properly decrement the usage_count on all places; - it starts streaming even if pm_runtime_get_sync() fails. - while it tries to get pm_runtime at the clock enable logic, it doesn't check if the operation was suceeded. Replace all occurrences of it to use the new kAPI: pm_runtime_resume_and_get(), which ensures that, if the return code is not negative, the usage_count was incremented. With that, add additional checks when this is called, in order to ensure that errors will be properly addressed. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/atmel/atmel-isc-base.c | 30 ++++++++++++++----- drivers/media/platform/atmel/atmel-isi.c | 19 +++++++++--- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index fe3ec8d0eaee..ce8e1351fa53 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -294,9 +294,13 @@ static int isc_wait_clk_stable(struct clk_hw *hw) static int isc_clk_prepare(struct clk_hw *hw) { struct isc_clk *isc_clk = to_isc_clk(hw); + int ret; - if (isc_clk->id == ISC_ISPCK) - pm_runtime_get_sync(isc_clk->dev); + if (isc_clk->id == ISC_ISPCK) { + ret = pm_runtime_resume_and_get(isc_clk->dev); + if (ret < 0) + return ret; + } return isc_wait_clk_stable(hw); } @@ -353,9 +357,13 @@ static int isc_clk_is_enabled(struct clk_hw *hw) { struct isc_clk *isc_clk = to_isc_clk(hw); u32 status; + int ret; - if (isc_clk->id == ISC_ISPCK) - pm_runtime_get_sync(isc_clk->dev); + if (isc_clk->id == ISC_ISPCK) { + ret = pm_runtime_resume_and_get(isc_clk->dev); + if (ret < 0) + return 0; + } regmap_read(isc_clk->regmap, ISC_CLKSR, &status); @@ -807,7 +815,12 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) goto err_start_stream; } - pm_runtime_get_sync(isc->dev); + ret = pm_runtime_resume_and_get(isc->dev); + if (ret < 0) { + v4l2_err(&isc->v4l2_dev, "RPM resume failed in subdev %d\n", + ret); + goto err_pm_get; + } ret = isc_configure(isc); if (unlikely(ret)) @@ -838,7 +851,7 @@ static int isc_start_streaming(struct vb2_queue *vq, unsigned int count) err_configure: pm_runtime_put_sync(isc->dev); - +err_pm_get: v4l2_subdev_call(isc->current_subdev->sd, video, s_stream, 0); err_start_stream: @@ -1809,6 +1822,7 @@ static void isc_awb_work(struct work_struct *w) u32 baysel; unsigned long flags; u32 min, max; + int ret; /* streaming is not active anymore */ if (isc->stop) @@ -1831,7 +1845,9 @@ static void isc_awb_work(struct work_struct *w) ctrls->hist_id = hist_id; baysel = isc->config.sd_format->cfa_baycfg << ISC_HIS_CFG_BAYSEL_SHIFT; - pm_runtime_get_sync(isc->dev); + ret = pm_runtime_resume_and_get(isc->dev); + if (ret < 0) + return; /* * only update if we have all the required histograms and controls diff --git a/drivers/media/platform/atmel/atmel-isi.c b/drivers/media/platform/atmel/atmel-isi.c index e392b3efe363..5b1dd358f2e6 100644 --- a/drivers/media/platform/atmel/atmel-isi.c +++ b/drivers/media/platform/atmel/atmel-isi.c @@ -422,7 +422,9 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) struct frame_buffer *buf, *node; int ret; - pm_runtime_get_sync(isi->dev); + ret = pm_runtime_resume_and_get(isi->dev); + if (ret < 0) + return ret; /* Enable stream on the sub device */ ret = v4l2_subdev_call(isi->entity.subdev, video, s_stream, 1); @@ -782,9 +784,10 @@ static int isi_enum_frameintervals(struct file *file, void *fh, return 0; } -static void isi_camera_set_bus_param(struct atmel_isi *isi) +static int isi_camera_set_bus_param(struct atmel_isi *isi) { u32 cfg1 = 0; + int ret; /* set bus param for ISI */ if (isi->pdata.hsync_act_low) @@ -801,12 +804,16 @@ static void isi_camera_set_bus_param(struct atmel_isi *isi) cfg1 |= ISI_CFG1_THMASK_BEATS_16; /* Enable PM and peripheral clock before operate isi registers */ - pm_runtime_get_sync(isi->dev); + ret = pm_runtime_resume_and_get(isi->dev); + if (ret < 0) + return ret; isi_writel(isi, ISI_CTRL, ISI_CTRL_DIS); isi_writel(isi, ISI_CFG1, cfg1); pm_runtime_put(isi->dev); + + return 0; } /* -----------------------------------------------------------------------*/ @@ -1085,7 +1092,11 @@ static int isi_graph_notify_complete(struct v4l2_async_notifier *notifier) dev_err(isi->dev, "No supported mediabus format found\n"); return ret; } - isi_camera_set_bus_param(isi); + ret = isi_camera_set_bus_param(isi); + if (ret) { + dev_err(isi->dev, "Can't wake up device\n"); + return ret; + } ret = isi_set_default_fmt(isi); if (ret) { From patchwork Wed May 5 09:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239559 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 5A927C433ED for ; Wed, 5 May 2021 09:46:39 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0788C61182 for ; Wed, 5 May 2021 09:46:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0788C61182 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hZeRUDpv2KIqxeIhFhw7r61aI4aeh7RWLPDcggsGPew=; b=OZsXOGJUNKbdvxs10nInTev7+ uU95RtchGmJZ9V06nVgC9z8JQj8IPX5C4uQUVb/t6GEOiI53ldJkdT+bWwZ9CwwAFjsIYGHfuLshR W33HlzyTG207f0eGw2E0kMK+eCoxJYlx2v+8n8R79ya8Wj+JFZFH+eTL1oF4zldrkrQq8AP+rMc2N 0PsRzOdR/gLHiNW6ySXqmsJV2mtvrF7sU6XheHKc3hPVR7m/5iZahSj1qi4ktIa/owQDkco0F4jNC m1FkgV20eA2pI7uxnfO2bUs1R0lF4uGwhmFDkEgtEdZIJb8avKejkPDUFiMOExGWkfOgxVcbWeV46 CqPIhRd3Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE3h-000lLn-ON; Wed, 05 May 2021 09:43:10 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2y-000l59-Ix; Wed, 05 May 2021 09:42:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=EzCCb+m27jvqAKs/f/gbZSYwnky8XiDJU+IaJBa5yK8=; b=nj8De6Dh8QYEqWiZHXxyqA3cWp IgcmKjGHpJ8h53SvPNbbjvBhnmfYLTOPdoHi/8sDFyzawHAXMk9qgzqNUxMsppLDzyBTAu+WNuKhL pBWN55aINX5psLRaBi6UexhsSB9SUwFu1yOSIavJ27JH66rkkXZhlTwJLwHCqbUb4L7wSBEK6eFGC j1rB0ANTuCyavEsmCmTXvgkM22tAcI18MInOhk0E9TDjt1l4nIRcCZWQ3Fpygk7KUcZgmWzB3nD2R UhMMPPeARNqK2z9pSgcTvUDZJN1fUFRESWlT9wrzKgxlaSNbwlHJECb0CO9FB9Skcrl5S+tNdaljm PFTX84mg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2u-004cd3-F7; Wed, 05 May 2021 09:42:23 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F5EE61415; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=Dvc8kv3rKA2FJT+3+TlwvMpufC19eU96pvINXTVj9yE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WlacScYsZHSgKh8Ot7sqL1EzbBeavncCcTzCxZIIZTPtaofe6Z8uUJ7AyBMRzB1xR 281CWNgec/9yBilH+h09gCn3Pc9jeBlmUxFChA/rLB8qUGvOmAUQ6f8c0Upw8MV3IC lbVEozVF4xF4YJ7XlSVuU5Bqxnzy1vinOlyC8lOlU64go6JucQHXOoytv0rC6nhs9q e8Fpef25VBTXLf4bf8QVnTniQky8cyVWp3x9BCi+x87Lh8aGBjaQo3BS/v/3WWPu+1 daW42h4iOPWy6rIbYESir2FwHlAB1iBrxi7j9iaEZl/j/6JK1drAAHLwTiNOQa51PI M8X6v1PD/IUQw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwL-2w; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Andrew-CT Chen , Houlong Wei , Matthias Brugger , Mauro Carvalho Chehab , Minghsiu Tsai , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, Jonathan Cameron Subject: [PATCH 11/25] media: mdk-mdp: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:01 +0200 Message-Id: <319026fb56190e19ab2b940952ebe8fa233ccb4e.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024220_566625_D0AC246A X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. While here, fix the return contition of mtk_mdp_m2m_start_streaming(), as it doesn't make any sense to return 0 if the PM runtime failed to resume. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c index ace4528cdc5e..f14779e7596e 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_m2m.c @@ -391,12 +391,12 @@ static int mtk_mdp_m2m_start_streaming(struct vb2_queue *q, unsigned int count) struct mtk_mdp_ctx *ctx = q->drv_priv; int ret; - ret = pm_runtime_get_sync(&ctx->mdp_dev->pdev->dev); + ret = pm_runtime_resume_and_get(&ctx->mdp_dev->pdev->dev); if (ret < 0) - mtk_mdp_dbg(1, "[%d] pm_runtime_get_sync failed:%d", + mtk_mdp_dbg(1, "[%d] pm_runtime_resume_and_get failed:%d", ctx->id, ret); - return 0; + return ret; } static void *mtk_mdp_m2m_buf_remove(struct mtk_mdp_ctx *ctx, From patchwork Wed May 5 09:42:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239553 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 5016AC433ED for ; Wed, 5 May 2021 09:46:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1F60613D6 for ; Wed, 5 May 2021 09:45:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1F60613D6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mlTWyMDIBohF5WQtdhMwG2nEHP3XCUgnXX7rINw1u/o=; b=qFbWqeYsGj5jOGwHbIxJYqWZM jfoOInGu5ANHtVW5OEPQyuJNRf9w+fhbLxMDfL8blNTX3AwhLi7hiJDqH5VF1mmcXQ35HfhUrYohd vVYLLjhO//tznIavIwlVGwze+DLe7Ao72QR3GDJcKlkavpbqJKvxIg5GMBzX2MydNSNxleGvgI9Ig 7V0odkn5LYMHgd9CJUKIYapgthrFTl4P8BKF4zw3YnZTHsS4XjF0Fiavl6yGqRu+nXS1vr4da44i+ X/nRmeC+RxFmIJQLjh08JL9f1OihguBRb3kapxjsTgJpvXlwv/JoTQFFlQFKb4+KfXWbMfvc9RlNK jP7dNMqNA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE53-000lrI-6X; Wed, 05 May 2021 09:44:33 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE30-000l5r-J7; Wed, 05 May 2021 09:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=NuW+KAd/xrl2dTshnq8aqOIb+0lzuagTY5SYke9WJ/w=; b=tHrN3thGvOUKVEyHYIYkIThF3K wM6A4RiJ11M3twh1OjFkiLQelOxecBXPQNn59LzsQ5s7CGQBaJGVxwCwIHrVtX6ufhVthh66EvLdK tHPS5e614tJuHIpw+aiVJD0+/KnYlBppBWVgWLhxT2Ulc7QopV6rUNh9lv3tZsa72CjTbFOXiwMeg cDmImC98k+l4LKBGA/lIRnRF3JR6v4xwaCqENQge2OEpZqIFwgtwA96iS3n6DHeU2jTsEjaQHtVc2 KRPMXJHsMMciPhQWjDYAmN7swNAA2G6KdeCmMoC8Uo8+AZf4V1el+wgJ4uL/MKCdzzj960+QSQfL0 Atp8CHog==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2w-004cg6-HD; Wed, 05 May 2021 09:42:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 745C861442; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=jUOSb8B9UNKJb4CE+kKLFa5IDIlxTUV4my+V18i70ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pvz3y1mbOSUJt0QSW0upnvSm2Y3anXrjyUxdYZ3k0aLlwT4LaZaNha8HUW0mZdlbr Q92lXHYKY4fS8BRySZyoX2vBkayQSyKr1O67BmOX9WrmpLGEdgs+v27T1qsYyrdg0P CJvdWltm/ibL4jPbaO08LScm2ScyAxPJLuE68I18mwCFd7qPAsvv373PqBq95774I0 df+q6EMijreBjWVwxEN3nFk5n7BzdAYBTmHypk52NiqahPgJs6i5IiUVdWqdFWTGrh tL6RYsE4S4sCgs0nhiUobH/14oMJrduz1/UelMcpaAT6K32ktvObSS9SPb36egAAJB SnyiNSbFfXJ/g== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwg-C1; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Andrew-CT Chen , Matthias Brugger , Mauro Carvalho Chehab , Tiffany Lin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: [PATCH 18/25] media: mtk-vcodec: fix PM runtime get logic Date: Wed, 5 May 2021 11:42:08 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024222_707373_ABE76695 X-CRM114-Status: GOOD ( 14.68 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, the driver just assumes that PM runtime logic succeded resuming the device. That may not be the case, as pm_runtime_get_sync() can fail (but keeping the usage count incremented). Replace the code to use pm_runtime_resume_and_get(), and letting it return the error code. This way, if mtk_vcodec_dec_pw_on() fails, the logic under fops_vcodec_open() will do the right thing and return an error, instead of just assuming that the device is ready to be used. Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 +++- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 8 +++++--- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 147dfef1638d..f87dc47d9e63 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -126,7 +126,9 @@ static int fops_vcodec_open(struct file *file) mtk_vcodec_dec_set_default_params(ctx); if (v4l2_fh_is_singular(&ctx->fh)) { - mtk_vcodec_dec_pw_on(&dev->pm); + ret = mtk_vcodec_dec_pw_on(&dev->pm); + if (ret < 0) + goto err_load_fw; /* * Does nothing if firmware was already loaded. */ diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c index ddee7046ce42..6038db96f71c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c @@ -88,13 +88,15 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev) put_device(dev->pm.larbvdec); } -void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm) +int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm) { int ret; - ret = pm_runtime_get_sync(pm->dev); + ret = pm_runtime_resume_and_get(pm->dev); if (ret) - mtk_v4l2_err("pm_runtime_get_sync fail %d", ret); + mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret); + + return ret; } void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h index 872d8bf8cfaf..280aeaefdb65 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h @@ -12,7 +12,7 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev); void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev); -void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm); +int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm); From patchwork Wed May 5 09:42:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239547 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 C908EC433ED for ; Wed, 5 May 2021 09:45:21 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 719DC61106 for ; Wed, 5 May 2021 09:45:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 719DC61106 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=vOhFjXdm1Qy2gb5NW3YolPhqtZnUx7T1s89wIud8p+8=; b=kBkYsxm0i8ZB9at+XITlrr+vG q6ZEUKN+E+rCNwnU82l01bqwxu3m0FVDkKEz4fum/HSNU0s9UkckHFU6od5vZ/gMaYwWjnyI01FS/ /MdguDDZ2DpmTSaddkHcgBf9mmk2X85j8Ksy3Xn0fuB2L00UAqB6FYXL56/qTDtC+n1EUmAszWebT /tpGIkBhtxtHu3lmNM6BK3HZ2oZJYJfB0ZHZlOu8Qxw8nXX5kL+xKCWy44c1djNUm1tEJV8+Dvmgp 8jch3Ji5pPsj+teszxtvv4DClh9eaXwOcCma/Mgpv8y8sOGIPAj7lUtuS8/XhgblpPWBaEzIPVHKp 54ikNQCow==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE46-000lVk-51; Wed, 05 May 2021 09:43:35 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE30-000l5p-5x for linux-arm-kernel@desiato.infradead.org; Wed, 05 May 2021 09:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=hAzvCMfXmM31wnnMYELCuw2vdG4i0jsxaa94c+IOnPg=; b=jQ33SCZePbwxxjIbNfmEoQYrBL O5n+VVL5GbYdMAJGiGupXYD+9d5PXaaSmwDMJaihyszPxgZYeWknaOoYCk708Ose61FkRKuzkpsJz 65hPnDBdLaqa8Y+3JEAW0JM1zCsa+3aUJVlM6SVb1MXuu7i0FHtm9s12MO/QYQtuOUFW4LQVlMdc/ lFVwUY9GdwLcyboHAhpGAlIslURa0JEMNRO09wHiEOtWPY+syk7n4qSqOoCr+TDMa2y/7ZqAKVAdA QVHs3FhRdnBa2iHq5ejX38I+AwdRTSUrAAtrKe+TneqdLlmdT4v74RC9l/Y0eiax6DT4o5xkuqpkQ 7OgLLdqg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2w-004cg8-Gl for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:25 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 74FF061443; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=xqjVaoUsuvsxOD3cWDtjlqWziU1GM7gOpoA6IP+HHjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=USQxtYLCvlBgP5V/QBTap4t8elEYo77Tb1JnmJSdCTKlUDmhPFWlnGSIPZaJCyloV x+5zQzze2KZs0VukHfF62wzi+yw6y+3VvDnquHBFoVkXk573kcQGUODGVoRGmV/CWy l8HvH85dBOt8yrn9AuSCfEgQuprIKqO1CgHRtiXOyNHXA2wjSCbjBPWpPaPcmsmKp6 w+rNH8Ok5yKHPwN0SbkIp+Jm4wvWbOdI1swTVQvKNqbXxAmhMEBYYuKv7OpwNLvic7 3V/R3+wn/WSfQiwK4xRJhrfFCwRCqYMUKa05ZQLhI5dJKJ1nYbESOjJYu1gIzDEhVa F5Pw9vh6UUS0w== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwj-Dl; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Andrzej Pietrasiewicz , Jacek Anaszewski , Mauro Carvalho Chehab , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 19/25] media: s5p-jpeg: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:09 +0200 Message-Id: <534deda71f3cf5f865611aa839a5279e43ebe1c9.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024222_636554_57FE397F X-CRM114-Status: GOOD ( 10.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. As a plus, pm_runtime_resume_and_get() doesn't return positive numbers, so the return code validation can be removed. Reviewed-by: Sylwester Nawrocki Acked-by: Andrzej Pietrasiewicz Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/media/platform/s5p-jpeg/jpeg-core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c index 026111505f5a..d402e456f27d 100644 --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c @@ -2566,11 +2566,8 @@ static void s5p_jpeg_buf_queue(struct vb2_buffer *vb) static int s5p_jpeg_start_streaming(struct vb2_queue *q, unsigned int count) { struct s5p_jpeg_ctx *ctx = vb2_get_drv_priv(q); - int ret; - ret = pm_runtime_get_sync(ctx->jpeg->dev); - - return ret > 0 ? 0 : ret; + return pm_runtime_resume_and_get(ctx->jpeg->dev); } static void s5p_jpeg_stop_streaming(struct vb2_queue *q) From patchwork Wed May 5 09:42:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239563 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 6BE08C433B4 for ; Wed, 5 May 2021 09:47:34 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 311A8613EC for ; Wed, 5 May 2021 09:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 311A8613EC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gPmTYbPB6ERTey/G5YkfYR5TucfqFv2qPGzbeAwSSaU=; b=LhyqqFZPbNpOUEpUuHWdWdcrj UJlcRn8T/o0WptJdOQu5LRprFMPmCnmoQfHapriO7XXfE1kwWvpNKrbim6exs6D0UKC1HuQq1eDXF CeCjm8Z+sNlakeP9qM6eTRXzRIYuhwh258Zb8g4UJKY14L09e6LKAROTOGqs3XG5vDo0f0drPf+YT rP1mLMwVeAiW/gQXhh+QEiiz1D6j6ANqJg3n9ngzdOguowGO1NsZBxETn7mlOB5IEq2JWjnYxyhKX 5t95ba3RF/ccgBoE9/GzYg/olqKAtJ/ng4s9cDKttji0AYVEMdWnXyjTwzOV02FBAhI3iirA8mTGl oxfIC8fUw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE6D-000mNP-Uj; Wed, 05 May 2021 09:45:46 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE33-000l4e-J4 for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7452861441; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=364y8EHJw+K9cWcJ3TfK59fyAMvbTh2YZ4HqAVyg8A8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KndRsQn6wUyNi6eN7k33M1w7kqzJ24+MX/2EQ0eQjTL8hFb+QvTYQcVyx3lu26OZz /6e553NH+Go/bMLU3TXK+Y3rjWMtO0RryzewWuUkbMjKDIwFPpi7sfyrBUJs6ny0hC /6HGkeImhGk8ixnl0PFf4rJe+zxn6hmgeZbk2MKJpZTXhUn6M25A/DNR4/iaJIYue7 8cf/K3YZ8ysnQpz04o8qVWiibQ+Hhu5zWH7ec9xHyjTbVCG3qoHupemmTLNl2SmGtr PavTMKvW4zjUj74wRAztvZkpXYiA+ykl0dZxxlTxhhcKse87GIQiPyPryZfwfueTep 3Pp+Z6bLFeeSA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwp-G3; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Mauro Carvalho Chehab , Maxime Ripard , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-sunxi@lists.linux.dev, Jonathan Cameron Subject: [PATCH 21/25] media: sunxi: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:11 +0200 Message-Id: <0dea9a799700efd0f3ceaf9d25ded282295e2db9.1620207353.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_104231_210539_0FBF8F30 X-CRM114-Status: GOOD ( 12.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c index 3f81dd17755c..fbcca59a0517 100644 --- a/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c +++ b/drivers/media/platform/sunxi/sun8i-rotate/sun8i_rotate.c @@ -494,7 +494,7 @@ static int rotate_start_streaming(struct vb2_queue *vq, unsigned int count) struct device *dev = ctx->dev->dev; int ret; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) { dev_err(dev, "Failed to enable module\n"); From patchwork Wed May 5 09:42:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239561 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 67D88C433ED for ; Wed, 5 May 2021 09:47:00 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB9D961008 for ; Wed, 5 May 2021 09:46:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB9D961008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=OwQs7Z06CbQA17Lxa+n2+3hs1RLzHu4m6D6UXtvOMbo=; b=eyRJ2mIQ+riir1ElMkpL19+8N haJHwtu+0SqgBSWiqUAts7faSClSfesCreF+zqyc9UmvQLMNoFHdc0f/gcwknIqlc5luYSP1GfWvW FoFaK6aUhXQDn6U8qkD7Ce3gOEG3OVT4wwS+XQfxjVT+qKl4E6ODo6cfFeo9npykcmjR1+F75FC88 AZoihSC0GzJshpKZWE+WP0j9RdTVuoTfQO8DjYAZwsWxdnTv8WzKyKGuFk8rhG8v5X+5PCbDokGWe 5scrxQyNpLiKyKalVi0y1GIMF+dv1hjMLiNXQyZrIWSznqxFMfTTs8JfXE4o2XBjZi99F4rIFUkN/ WigSeVv3g==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE5P-000m0w-Si; Wed, 05 May 2021 09:44:57 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE33-000l5x-7m for linux-arm-kernel@desiato.infradead.org; Wed, 05 May 2021 09:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=+V/2KgUnu/LcluN4ClAjTKBcD2xNHHy8kg3yBbzaRmE=; b=Ske/VxB0/MM8SFIWZAuJ813bpM rP9h21/cjjQyfJo9C/9S+fpAP6aGwV3EUZipUI6zt/jXhvd6TEI5JMccUax8Htf2B8GLGMmLjjGEq 578zVe//x0pIjWb/6c0xhqSU5iZcKBEE+Tin63EPskREfrocAbHxUWmICUKuR3aXgG3KZ44qGiNi9 LOhY2KisOYRV1tCFoS/2Nc790xEeeXELB62lptKFuq3Qo/8qwJp0/dOoxefpjOVlVcdPQ7nboXZer YLXCGdLJFec8tQgNF2SDqjoBqH3Qv/vWSC4wQ4EP3fF+cibjCNQQjNTuuusNanCtO0M0D/K9hVxfq CZE9ANCw==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE2x-004ciU-Nv for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:27 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 95F5A61476; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=lRJ3n/3+0Uz/DBoeHwgXYdPz/aOz29/E1f/JBv9ZJSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sr/JrECuqbum39pjXZUdbX+yOi4Clsm9QETjmsY3BYuf4DeYbhJwkR+kydCEf1GcG FiJeK8/n/KTDIHv1GDr6wm7/ho2TpPBwDI142inU0hbNKneMcd9nHL05ccbNPSdULm ENW9ToSY8zkKBj8h5B4NzoVet5tx2sGDPOvU6CKLKndwcdDAze4abbfVHJmmpNGm6i SY3MADG+LwmpFH1DdQnEC50VtZRf1y5RUC+ENOCGPtxKThZ0gqu3pBZ8IdZm1Jj8d8 U+G6sSNQ7FJrTLzhK3erTivE4F2vDXjrzOPVlrTfxMXrjFT5iLQXqBcKy1fXxkAsPz e5hiXdQ7AOhpw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwv-J0; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Krzysztof Kozlowski , Mauro Carvalho Chehab , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 23/25] media: exynos4-is: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:13 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_024223_880595_F184CBA8 X-CRM114-Status: GOOD ( 16.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. On some places, this is ok, but on others the usage count ended being unbalanced on failures. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. As a bonus, such function always return zero on success. So, some code can be simplified. Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/exynos4-is/fimc-capture.c | 6 ++---- drivers/media/platform/exynos4-is/fimc-is.c | 4 ++-- drivers/media/platform/exynos4-is/fimc-isp-video.c | 3 +-- drivers/media/platform/exynos4-is/fimc-isp.c | 7 +++---- drivers/media/platform/exynos4-is/fimc-lite.c | 5 +++-- drivers/media/platform/exynos4-is/fimc-m2m.c | 5 +---- drivers/media/platform/exynos4-is/media-dev.c | 9 +++------ drivers/media/platform/exynos4-is/mipi-csis.c | 10 ++++------ 8 files changed, 19 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c b/drivers/media/platform/exynos4-is/fimc-capture.c index 13c838d3f947..0da36443173c 100644 --- a/drivers/media/platform/exynos4-is/fimc-capture.c +++ b/drivers/media/platform/exynos4-is/fimc-capture.c @@ -478,11 +478,9 @@ static int fimc_capture_open(struct file *file) goto unlock; set_bit(ST_CAPT_BUSY, &fimc->state); - ret = pm_runtime_get_sync(&fimc->pdev->dev); - if (ret < 0) { - pm_runtime_put_sync(&fimc->pdev->dev); + ret = pm_runtime_resume_and_get(&fimc->pdev->dev); + if (ret < 0) goto unlock; - } ret = v4l2_fh_open(file); if (ret) { diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c index 972d9601d236..1b24f5bfc4af 100644 --- a/drivers/media/platform/exynos4-is/fimc-is.c +++ b/drivers/media/platform/exynos4-is/fimc-is.c @@ -828,9 +828,9 @@ static int fimc_is_probe(struct platform_device *pdev) goto err_irq; } - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) - goto err_pm; + goto err_irq; vb2_dma_contig_set_max_seg_size(dev, DMA_BIT_MASK(32)); diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/media/platform/exynos4-is/fimc-isp-video.c index 612b9872afc8..8d9dc597deaa 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -275,7 +275,7 @@ static int isp_video_open(struct file *file) if (ret < 0) goto unlock; - ret = pm_runtime_get_sync(&isp->pdev->dev); + ret = pm_runtime_resume_and_get(&isp->pdev->dev); if (ret < 0) goto rel_fh; @@ -293,7 +293,6 @@ static int isp_video_open(struct file *file) if (!ret) goto unlock; rel_fh: - pm_runtime_put_noidle(&isp->pdev->dev); v4l2_fh_release(file); unlock: mutex_unlock(&isp->video_lock); diff --git a/drivers/media/platform/exynos4-is/fimc-isp.c b/drivers/media/platform/exynos4-is/fimc-isp.c index a77c49b18511..74b49d30901e 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp.c +++ b/drivers/media/platform/exynos4-is/fimc-isp.c @@ -304,11 +304,10 @@ static int fimc_isp_subdev_s_power(struct v4l2_subdev *sd, int on) pr_debug("on: %d\n", on); if (on) { - ret = pm_runtime_get_sync(&is->pdev->dev); - if (ret < 0) { - pm_runtime_put(&is->pdev->dev); + ret = pm_runtime_resume_and_get(&is->pdev->dev); + if (ret < 0) return ret; - } + set_bit(IS_ST_PWR_ON, &is->state); ret = fimc_is_start_firmware(is); diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index fe20af3a7178..4d8b18078ff3 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -469,9 +469,9 @@ static int fimc_lite_open(struct file *file) } set_bit(ST_FLITE_IN_USE, &fimc->state); - ret = pm_runtime_get_sync(&fimc->pdev->dev); + ret = pm_runtime_resume_and_get(&fimc->pdev->dev); if (ret < 0) - goto err_pm; + goto err_in_use; ret = v4l2_fh_open(file); if (ret < 0) @@ -499,6 +499,7 @@ static int fimc_lite_open(struct file *file) v4l2_fh_release(file); err_pm: pm_runtime_put_sync(&fimc->pdev->dev); +err_in_use: clear_bit(ST_FLITE_IN_USE, &fimc->state); unlock: mutex_unlock(&fimc->lock); diff --git a/drivers/media/platform/exynos4-is/fimc-m2m.c b/drivers/media/platform/exynos4-is/fimc-m2m.c index c9704a147e5c..df8e2aa454d8 100644 --- a/drivers/media/platform/exynos4-is/fimc-m2m.c +++ b/drivers/media/platform/exynos4-is/fimc-m2m.c @@ -73,17 +73,14 @@ static void fimc_m2m_shutdown(struct fimc_ctx *ctx) static int start_streaming(struct vb2_queue *q, unsigned int count) { struct fimc_ctx *ctx = q->drv_priv; - int ret; - ret = pm_runtime_get_sync(&ctx->fimc_dev->pdev->dev); - return ret > 0 ? 0 : ret; + return pm_runtime_resume_and_get(&ctx->fimc_dev->pdev->dev); } static void stop_streaming(struct vb2_queue *q) { struct fimc_ctx *ctx = q->drv_priv; - fimc_m2m_shutdown(ctx); fimc_m2m_job_finish(ctx, VB2_BUF_STATE_ERROR); pm_runtime_put(&ctx->fimc_dev->pdev->dev); diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c index 13d192ba4aa6..e025178db06c 100644 --- a/drivers/media/platform/exynos4-is/media-dev.c +++ b/drivers/media/platform/exynos4-is/media-dev.c @@ -512,11 +512,9 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) if (!fmd->pmf) return -ENXIO; - ret = pm_runtime_get_sync(fmd->pmf); - if (ret < 0) { - pm_runtime_put(fmd->pmf); + ret = pm_runtime_resume_and_get(fmd->pmf); + if (ret < 0) return ret; - } fmd->num_sensors = 0; @@ -1291,8 +1289,7 @@ static int cam_clk_prepare(struct clk_hw *hw) if (camclk->fmd->pmf == NULL) return -ENODEV; - ret = pm_runtime_get_sync(camclk->fmd->pmf); - return ret < 0 ? ret : 0; + return pm_runtime_resume_and_get(camclk->fmd->pmf); } static void cam_clk_unprepare(struct clk_hw *hw) diff --git a/drivers/media/platform/exynos4-is/mipi-csis.c b/drivers/media/platform/exynos4-is/mipi-csis.c index 1aac167abb17..ebf39c856894 100644 --- a/drivers/media/platform/exynos4-is/mipi-csis.c +++ b/drivers/media/platform/exynos4-is/mipi-csis.c @@ -494,7 +494,7 @@ static int s5pcsis_s_power(struct v4l2_subdev *sd, int on) struct device *dev = &state->pdev->dev; if (on) - return pm_runtime_get_sync(dev); + return pm_runtime_resume_and_get(dev); return pm_runtime_put_sync(dev); } @@ -509,11 +509,9 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable) if (enable) { s5pcsis_clear_counters(state); - ret = pm_runtime_get_sync(&state->pdev->dev); - if (ret && ret != 1) { - pm_runtime_put_noidle(&state->pdev->dev); + ret = pm_runtime_resume_and_get(&state->pdev->dev); + if (ret < 0) return ret; - } } mutex_lock(&state->lock); @@ -535,7 +533,7 @@ static int s5pcsis_s_stream(struct v4l2_subdev *sd, int enable) if (!enable) pm_runtime_put(&state->pdev->dev); - return ret == 1 ? 0 : ret; + return ret; } static int s5pcsis_enum_mbus_code(struct v4l2_subdev *sd, From patchwork Wed May 5 09:42:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12239627 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=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 04410C433ED for ; Wed, 5 May 2021 09:48:10 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D9C061008 for ; Wed, 5 May 2021 09:48:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D9C061008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5JSLbsumszDcDUsGyeBkbG4OPSuFWsMWJO9WSDThV1A=; b=gOBQtC9wJ4V5M4ql7l7T2xUM8 jxAJ78Uo6Nue6BCpYvPkrnSqUGRODPVXjvrWwrpDS/4Z5/qt8hRniAejN0dYND1plSbIIpn2/KRzH brBdj0qu5HtJz9PK65E1caiWzb2hHDHu0Dp/Jh/+qPGOtQgaMoY0SSxH5vWhzuqBDbAVuYTFgWQkl +uve/w9XLSUoliA+2VEv/kt8s5NNq1FNmAU3r1SqTJScdSmcXpYl1aZ3EgZmfSnaGNCe6yQy+VnoZ deMmwJzzuCYTt+XunS0N/iScJYc4sfsu5+Ax/gdLC7hMo7qPI3j7X0v5Us5jW/YiOTklmxnbHMP1Z uUrwhyZQg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE6p-000mcy-RU; Wed, 05 May 2021 09:46:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE32-000l4d-Ku for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E07561574; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=YXL+gA4goxj5s7MMwTgNIwMfazgaE4VAbN8eHBvZ4x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOp+Ty69wRZVl3P+vvXIUlGYDh3ay+6S+YyfcKN1CT3Jme/0sPsvIppoJDG83Ju8R 8xYian6y1N4CZxugY3gFZJbOoyS0leNUBXNYaws9CSN8nc8wzyAjmlJS5E/4BaecLP 6+7NnEgLJrYAd4E/vIZF1lqkOYW2A2IDBy4RtoVjNxejWauNkwc0YbOS3NtcI5KJba vnIB7fVnDhzE9bdEVsVQYJtcakBROkoOhTXOTFQSpI8hCUbnPKXkZ8liJpfnCqqtqS fCoSll02cfuw87x5iK/Nhwaey5Oiw27cL09Plyan79ObHMLRlUJXbqLptv0Hm4niUw IPv5nnCUdmdTw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwy-KJ; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Hans Verkuil , Krzysztof Kozlowski , Mauro Carvalho Chehab , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 24/25] media: exynos-gsc: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:14 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210505_104231_223509_4EEE6C37 X-CRM114-Status: GOOD ( 10.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. As a bonus, as pm_runtime_get_sync() always return 0 on success, the logic can be simplified. Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c index 27a3c92c73bc..f1cf847d1cc2 100644 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c @@ -56,10 +56,8 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx) static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count) { struct gsc_ctx *ctx = q->drv_priv; - int ret; - ret = pm_runtime_get_sync(&ctx->gsc_dev->pdev->dev); - return ret > 0 ? 0 : ret; + return pm_runtime_resume_and_get(&ctx->gsc_dev->pdev->dev); } static void __gsc_m2m_cleanup_queue(struct gsc_ctx *ctx)