From patchwork Tue Apr 27 10:12:37 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: 12225771 X-Patchwork-Delegate: kieran@bingham.xyz 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 D654DC43461 for ; Tue, 27 Apr 2021 10:13:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8630613D4 for ; Tue, 27 Apr 2021 10:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235387AbhD0KOf (ORCPT ); Tue, 27 Apr 2021 06:14:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:34518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235246AbhD0KOe (ORCPT ); Tue, 27 Apr 2021 06:14:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC08F613C5; Tue, 27 Apr 2021 10:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518430; bh=vSVgVx9oCI4BykR40BTa4+7tin+dlK2U4+Benc8+UkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DHeOYgg17IAhtKf2kG3l5ENtWblBsn9K//nDeh3BI5v8/jaPW/tPDqgJPSy/cOetP 2ITKnyUMUnRbs0QofKRleV3Nm2SCKuVDgi8OJloO7UgTyOiCpHycLx2GqtFa2WA61q uVlgSsAxagmWMh9CL8UF33VbGYDzyLoCTGzxGr/BNxoHmoAkscZEu8TQhpOgABJwAn om3V9/pdHBgO67UyuHQMGuRz7xebZt1z4eK8LDoh/U/VRhpFDRkhJTCdzcdDQ4ilID FYHnhXzeR6DqiRz4R9Z0jH07yVCT/aPh9L3PG8IQ1Y07FuJ/YJ3psHKyQszyoymlGL 2C2wg2iZ+0lMQ== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j54-K8; Tue, 27 Apr 2021 12:13:48 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Kieran Bingham , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 10/79] media: rcar_fdp1: fix pm_runtime_get_sync() usage count Date: Tue, 27 Apr 2021 12:12:37 +0200 Message-Id: <449ab92cf6920f1d66cb831e15d92aed7f5b7192.1619518193.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.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 and avoid memory leaks. Also, right now, the driver is ignoring any troubles when trying to do PM resume. So, add the proper error handling for the code. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar_fdp1.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rcar_fdp1.c b/drivers/media/platform/rcar_fdp1.c index 01c1fbb97bf6..c32d237af618 100644 --- a/drivers/media/platform/rcar_fdp1.c +++ b/drivers/media/platform/rcar_fdp1.c @@ -2140,7 +2140,13 @@ static int fdp1_open(struct file *file) } /* Perform any power management required */ - pm_runtime_get_sync(fdp1->dev); + ret = pm_runtime_resume_and_get(fdp1->dev); + if (ret < 0) { + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); + v4l2_ctrl_handler_free(&ctx->hdl); + kfree(ctx); + goto done; + } v4l2_fh_add(&ctx->fh); @@ -2351,7 +2357,9 @@ static int fdp1_probe(struct platform_device *pdev) /* Power up the cells to read HW */ pm_runtime_enable(&pdev->dev); - pm_runtime_get_sync(fdp1->dev); + ret = pm_runtime_resume_and_get(fdp1->dev); + if (ret < 0) + return ret; hw_version = fdp1_read(fdp1, FD1_IP_INTDATA); switch (hw_version) { From patchwork Tue Apr 27 10:12:39 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: 12225773 X-Patchwork-Delegate: kieran@bingham.xyz 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 F28E5C43462 for ; Tue, 27 Apr 2021 10:14:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BEA9960FF1 for ; Tue, 27 Apr 2021 10:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235510AbhD0KOm (ORCPT ); Tue, 27 Apr 2021 06:14:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:35230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235415AbhD0KOg (ORCPT ); Tue, 27 Apr 2021 06:14:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 918DE6141E; Tue, 27 Apr 2021 10:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518431; bh=WqKoYQevkaStNcKaOzNIvfyWSTMDPdaJk89Ynu0GOzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LoUuZ1TaQvQ5CxmEUPAH4lqIsqWPje2SWXVaMT/ZtNuDfR3nTI8ZWAsmwr41p2IMM 3z5seHicv+2UAiVd2MiUEchixXZRWwMB+hqJI78+10zMnyEU29EAhOhtUinvb8MGoq ixDj4arF48KriUB2ZlDwz59DGcaI77Eb661OQ3kRbGm0dh27eMsHsnxTR5djV4sSx1 aa6pT5jaxD+42cb2avrORk2voD1zCEF+Gzm9xQh/g/wH5DZhiDbL4Axet3h3E08OuX L/ZcTQiacEtoeseaM0YCvjBIStKyG5ImGvs+LialnnAcTyRvuiLvRUskwOkyICBiv0 O3Uc5it5DhGIg== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j5A-MC; Tue, 27 Apr 2021 12:13:48 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Jacopo Mondi , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 12/79] media: renesas-ceu: Properly check for PM errors Date: Tue, 27 Apr 2021 12:12:39 +0200 Message-Id: <442ba0816c3977dddf01212659443ee13f90bd5d.1619518193.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Right now, the driver just assumes that PM runtime resume worked, but it may fail. Well, the pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. So, using it is tricky. Let's 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") and return an error if something bad happens. This should ensure that the PM runtime usage_count will be properly decremented if an error happens at open time. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/renesas-ceu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c index cd137101d41e..17f01b6e3fe0 100644 --- a/drivers/media/platform/renesas-ceu.c +++ b/drivers/media/platform/renesas-ceu.c @@ -1099,10 +1099,10 @@ static int ceu_open(struct file *file) mutex_lock(&ceudev->mlock); /* Causes soft-reset and sensor power on on first open */ - pm_runtime_get_sync(ceudev->dev); + ret = pm_runtime_resume_and_get(ceudev->dev); mutex_unlock(&ceudev->mlock); - return 0; + return ret; } static int ceu_release(struct file *file) From patchwork Tue Apr 27 10:13:36 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: 12225777 X-Patchwork-Delegate: kieran@bingham.xyz 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 2DC53C433B4 for ; Tue, 27 Apr 2021 10:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0A01613C3 for ; Tue, 27 Apr 2021 10:15:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235495AbhD0KP4 (ORCPT ); Tue, 27 Apr 2021 06:15:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:34660 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235745AbhD0KPJ (ORCPT ); Tue, 27 Apr 2021 06:15:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E67F61948; Tue, 27 Apr 2021 10:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518433; bh=4l0wYnfzYi1h956EsgOdlzJmS/W0qfvo5eSm9fSkn9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dTj5/2g+IuretA4WWeKDmoFHFHBjS15TGHAABgAT6vT1tjWvN2eyDuu49l3Gwt2da TOXSj3AYurMZUu47PRrPLR35UWjYK1oTF2OQDM0SVSYM+x/rcSfkQUw/n+2AfIlvJU sCDCyJRycpNzbyQygvFVMBA1eNdadXIBsGULVeG/GTQzugoKvlBwSoKD+dE4938M9e qu9YoMveKc1YY7XA2veI4VIhBc7zsPnRTgp6zqZshJN77GRIa3/Tn4TlwACTv9yljW bZGUqzbVtPGxv4fSb7BDDauM28XU+hupk7UJ6AmARKC7KIgEvXMxMmo6sLbaYu3QeI NhNi5KFGegjVA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKj1-000j7v-R6; Tue, 27 Apr 2021 12:13:51 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 69/79] media: rcar-fcp: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:13:36 +0200 Message-Id: <64bb917e946815f1c77bf2bb36614ff950a98631.1619518193.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. Use the new API, in order to cleanup the error check logic. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar-fcp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rcar-fcp.c b/drivers/media/platform/rcar-fcp.c index 5c03318ae07b..de76af58013c 100644 --- a/drivers/media/platform/rcar-fcp.c +++ b/drivers/media/platform/rcar-fcp.c @@ -101,11 +101,9 @@ int rcar_fcp_enable(struct rcar_fcp_device *fcp) if (!fcp) return 0; - ret = pm_runtime_get_sync(fcp->dev); - if (ret < 0) { - pm_runtime_put_noidle(fcp->dev); + ret = pm_runtime_resume_and_get(fcp->dev); + if (ret < 0) return ret; - } return 0; } From patchwork Tue Apr 27 10:13:44 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: 12225779 X-Patchwork-Delegate: kieran@bingham.xyz 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 15452C433B4 for ; Tue, 27 Apr 2021 10:15:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF0F1611F2 for ; Tue, 27 Apr 2021 10:15:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237820AbhD0KQW (ORCPT ); Tue, 27 Apr 2021 06:16:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:34910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235942AbhD0KPO (ORCPT ); Tue, 27 Apr 2021 06:15:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1700B61968; Tue, 27 Apr 2021 10:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518434; bh=HzlriyHzqlZAHsYOJEVourXS9CSW2DolwRX6O+Dbyqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J5cpkI1Qlep4gAdUE4qBI4ZNx6+hd1seEK/CICW3B85BWgCm2lMSWzseaXUPQe/uX 5RYajuL18Bpdj1iUMcupp0yxEK4NyK2WTRCAhqalYBtgCP+chu/RmMlaC1ek6zFZ5i 1ytXSg/mrycAk2IjTDYxZHHxbqNP3oqRG4WOLmw5mOIhQ+fHxeNdguB06OEA467LJG HKJXBf18OAdGMv8wSYZEXdB/1GoA6kdBaxSiwkQ6Ks7LgTQQtbp3lJQMDAUdGpddAa W9GT6tyWCHRRUe6D3rPXXAhBRKG+YNlE24bAqE5RVdJMXUWuRa/wt5lXE6ZexoqjP7 KHtMtI3aI8Ntg== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKj2-000j8J-9i; Tue, 27 Apr 2021 12:13:52 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Kieran Bingham , Laurent Pinchart , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org Subject: [PATCH v2 77/79] media: vsp1: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:13:44 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. Use the new API, in order to cleanup the error check logic. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/vsp1/vsp1_drv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c index aa66e4f5f3f3..c2bdb6629657 100644 --- a/drivers/media/platform/vsp1/vsp1_drv.c +++ b/drivers/media/platform/vsp1/vsp1_drv.c @@ -561,11 +561,9 @@ int vsp1_device_get(struct vsp1_device *vsp1) { int ret; - ret = pm_runtime_get_sync(vsp1->dev); - if (ret < 0) { - pm_runtime_put_noidle(vsp1->dev); + ret = pm_runtime_resume_and_get(vsp1->dev); + if (ret < 0) return ret; - } return 0; } From patchwork Tue Apr 27 10:13:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 12225781 X-Patchwork-Delegate: kieran@bingham.xyz 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=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 E6F8EC433B4 for ; Tue, 27 Apr 2021 10:15:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC93861185 for ; Tue, 27 Apr 2021 10:15:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237833AbhD0KQd (ORCPT ); Tue, 27 Apr 2021 06:16:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34780 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236134AbhD0KPO (ORCPT ); Tue, 27 Apr 2021 06:15:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E020611ED; Tue, 27 Apr 2021 10:13:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619518435; bh=ef7IZ30lWjyFTV9EZRM5TkDA3zgk8AfGs9/mdIqlXQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RB3Q5l/+RxAU8Jsd4tjtOWG3kz+K+KNeI0F0TYSc68vmC/Y9CU7c+TXrc6Js29jDr nRymjCPnKpJo4cDfNU7p4MMKKKZ7JewDJzQ/1XC/TB45YnTBJW6fQgdohfcitDLNIW Y+4h8BajogEp6yBzVlSt99afe7ZS3/CIR9zhRqJ6FK6t9B/0TAK227JqwSrZwqrj2I KC/DvyHDzx3OTOY7OnUsV3L7YTy5JNpMG4bmBdewOuUyMD9lEFFVe68kStsGuMDwDD K9APVYPUfpZGgv4vStvVCYZeXcWcloWaRAP+SLfTF3GL7YMCgrLsz/TGJ6PJ378ysJ c3HR51tTcDLVg== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKj2-000j8M-BJ; Tue, 27 Apr 2021 12:13:52 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6?= =?utf-8?q?derlund?= , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, =?utf-8?q?N?= =?utf-8?q?iklas_S=C3=B6derlund?= Subject: [PATCH v2 78/79] media: rcar-vin: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:13:45 +0200 Message-Id: <9ebf042135b50dedc6e1f654e4c8487602645d29.1619518193.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") added pm_runtime_resume_and_get() in order to automatically handle dev->power.usage_count decrement on errors. Use the new API, in order to cleanup the error check logic. Reviewed-by: Niklas Söderlund Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/rcar-vin/rcar-csi2.c | 6 ++++++ drivers/media/platform/rcar-vin/rcar-dma.c | 6 ++---- drivers/media/platform/rcar-vin/rcar-v4l2.c | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-csi2.c b/drivers/media/platform/rcar-vin/rcar-csi2.c index e06cd512aba2..ce8e84f9e3d9 100644 --- a/drivers/media/platform/rcar-vin/rcar-csi2.c +++ b/drivers/media/platform/rcar-vin/rcar-csi2.c @@ -408,6 +408,12 @@ static void rcsi2_enter_standby(struct rcar_csi2 *priv) static void rcsi2_exit_standby(struct rcar_csi2 *priv) { + /* + * The code at rcsi2_enter_standby() assumes + * inconditionally that PM runtime usage count was + * incremented. So, it shouldn't use pm_runtime_resume_and_get() + * here. + */ pm_runtime_get_sync(priv->dev); reset_control_deassert(priv->rstc); } diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c index f30dafbdf61c..f5f722ab1d4e 100644 --- a/drivers/media/platform/rcar-vin/rcar-dma.c +++ b/drivers/media/platform/rcar-vin/rcar-dma.c @@ -1458,11 +1458,9 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel) u32 vnmc; int ret; - ret = pm_runtime_get_sync(vin->dev); - if (ret < 0) { - pm_runtime_put_noidle(vin->dev); + ret = pm_runtime_resume_and_get(vin->dev); + if (ret < 0) return ret; - } /* Make register writes take effect immediately. */ vnmc = rvin_read(vin, VNMC_REG); diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c index 457a65bf6b66..b1e9f86caa5c 100644 --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c @@ -870,11 +870,9 @@ static int rvin_open(struct file *file) struct rvin_dev *vin = video_drvdata(file); int ret; - ret = pm_runtime_get_sync(vin->dev); - if (ret < 0) { - pm_runtime_put_noidle(vin->dev); + ret = pm_runtime_resume_and_get(vin->dev); + if (ret < 0) return ret; - } ret = mutex_lock_interruptible(&vin->lock); if (ret)