From patchwork Tue Apr 27 10:26:00 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: 12226019 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 3515BC433ED for ; Tue, 27 Apr 2021 10:27:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06D3A613C7 for ; Tue, 27 Apr 2021 10:27:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235733AbhD0K2J (ORCPT ); Tue, 27 Apr 2021 06:28:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:48146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235540AbhD0K2E (ORCPT ); Tue, 27 Apr 2021 06:28:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27746613DD; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=vSVgVx9oCI4BykR40BTa4+7tin+dlK2U4+Benc8+UkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pLaCD4ofqL5rXZRv9KJFm6qqqJsqVPXNi3IXzSjhGRLDdW9MBRZ5iVhqvRmUsYonP pp/8ZGF5xrtnUbbOYSWlRQINpYubh4VTxzD3w4u0Iju9BCtsQan3Iqzo20e/4fiBj4 wxkWEB0iHbYNMPZGR53hBhM2d5U/JxEdM8oYQDBWebB1B9h5izn7/ETooQ6QCwhxkp G/c2H4Z7DdKUO7rT0RA2MTGfoywUxW7tdohSAPKwaQz3RKVmyG5tmdv4nX5r5k0ndt BUwSrcXKUpluwk7ocgeR1Fbk6KUhTz2o1P3azH9yfzFLwvWDkHsAL0dO/nTHDoVTb7 UU8L4DE3DAZDg== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvv-000nzh-BP; Tue, 27 Apr 2021 12:27:11 +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 v3 10/79] media: rcar_fdp1: fix pm_runtime_get_sync() usage count Date: Tue, 27 Apr 2021 12:26:00 +0200 Message-Id: <9a79a72f93981227f21cd8fa8fc8c2d26eeb4d7b.1619519080.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:26:02 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: 12226065 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 72CAAC433B4 for ; Tue, 27 Apr 2021 10:27:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3D0A6610FA for ; Tue, 27 Apr 2021 10:27:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235657AbhD0K2T (ORCPT ); Tue, 27 Apr 2021 06:28:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:48142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235635AbhD0K2F (ORCPT ); Tue, 27 Apr 2021 06:28:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 428DD613E7; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=WqKoYQevkaStNcKaOzNIvfyWSTMDPdaJk89Ynu0GOzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RyBpl6AKaQKI6Mfu73bAvucGOohlNoKilp4m+KOexK1Etf0BZPy0FFCRJ04WDR/HZ VOUn9LsCW3gVbQfuNQe18ZI+Gg7DD/zmNu+WeXMVdZFNQqbE6HQrvTAYIuDssqDJJX K80H2JVkEHyzM5jFBdQQkAWTsEjDAZR57bfR1pnCzp2n0/OV/xh3/RmHroTzLEP8tt l8+lviYnkQ0eGg1WiX5tF9inHLdV6tLBp3sR12fy6AR/677yzDG+pIr3T30TbhWGB2 JxXejjwtLR8n7xyaiTg1uisMlhxGBmXQzj181tYSjwGOCmQjdSYKGLkyIznHa3gU/r r5JX4VExbKuvA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvv-000nzn-FQ; Tue, 27 Apr 2021 12:27:11 +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 v3 12/79] media: renesas-ceu: Properly check for PM errors Date: Tue, 27 Apr 2021 12:26:02 +0200 Message-Id: <54ff89c9e585c21fef85c4a47b6fa1f1b1ba3677.1619519080.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:26:59 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: 12226069 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 DB979C43462 for ; Tue, 27 Apr 2021 10:27:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8F9A611F2 for ; Tue, 27 Apr 2021 10:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235475AbhD0K2a (ORCPT ); Tue, 27 Apr 2021 06:28:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:48152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235777AbhD0K2M (ORCPT ); Tue, 27 Apr 2021 06:28:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8B0DA6141D; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=4l0wYnfzYi1h956EsgOdlzJmS/W0qfvo5eSm9fSkn9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OgcqVxZPSgZY7w2zf8AmOvN23IiVtNmHB0YnDlrUO11w4OUcFW7xpl14zNN3ExSWK dLxQgyBtbZ79yz8XwJt1UHId/8CNpQPc3urkAieF/tMtUo8BgyrnCDvYJY5QuFr3pM WGiO6sU7NfgoLkkYw4gwdlXLfz8ym4BB+GJBQWdZLmepKvlveH+YED92kXRrZhWvHG YuDZlkb4QoDymTVgSrY1YYQTk6DsoXSIySWrO7/JdBjxsdnld9sOztceHLI0mzwgqg hyO4fRQhg1f98yyMXxN9yxy4r2Jd2ky0zZu2Ktedyz0acVbS8i41MnnBIS/0pCCUD/ 1u6AdDcgUsrTA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvz-000o2Y-5O; Tue, 27 Apr 2021 12:27:15 +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 v3 69/79] media: rcar-fcp: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:26:59 +0200 Message-Id: <912eebdb622ebcf20c7c8887ee68b9e5a5201cce.1619519080.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:27:07 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: 12226071 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 053F0C43461 for ; Tue, 27 Apr 2021 10:27:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC744613C9 for ; Tue, 27 Apr 2021 10:27:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237875AbhD0K23 (ORCPT ); Tue, 27 Apr 2021 06:28:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:48138 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbhD0K2M (ORCPT ); Tue, 27 Apr 2021 06:28:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 73FC66140F; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=HzlriyHzqlZAHsYOJEVourXS9CSW2DolwRX6O+Dbyqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HxVP4KEkcKlNvIkQOkmBxLuatgvSRun1ZqFvIYnxgCB/3a7y570rBkCO09tODIHe3 ZE9I2P7BPtdg/pzsuKQ48T9XwJlMQ/RvX9MIHqQcjTlUnGR6ESI2k2CRiYxjbg7x33 SgNWhDzVC/jQ1yxmFFgrj4hGryrt0y+GFNjyI6n9YhGwtT5A7fHIR31ZlIv1FU1YE+ ZhUXWPCLN0eyqiW/xAARYZsg2AZzVNgQUQb7EqGjNNWSUstlHqHnt44+86lbmdUTLS Pt/K5vVh6gI61Bpw+wJ8zDMOaJEtKZf1Z4zVwq005d9Uf2VHRk2kL9O8FnGl8YPutX QYPVLG6GBYJLA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvz-000o2w-P3; Tue, 27 Apr 2021 12:27:15 +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 v3 77/79] media: vsp1: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:27:07 +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:27:08 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: 12226067 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 2619AC433ED for ; Tue, 27 Apr 2021 10:27:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2EAD613C6 for ; Tue, 27 Apr 2021 10:27:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237707AbhD0K2Z (ORCPT ); Tue, 27 Apr 2021 06:28:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:48204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235736AbhD0K2K (ORCPT ); Tue, 27 Apr 2021 06:28:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 710496140C; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=ef7IZ30lWjyFTV9EZRM5TkDA3zgk8AfGs9/mdIqlXQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NnefXPyXnuIWijAghbwvELrHTqlZiXq/Qbhds+I7GeJnKGtoCKf2ygzYDTZNy6YJH 2luLrgK+JSAXl1nhkLDiBsca1EOO6cDy5SY0dOwxcHCwLS6IB31X3GKE3T5EG+IOAC UZOd0/61C+DeJfvW4H+JlCKDxW34nCrPW5kY51imcJFadO5LSDFMeOXnjvxkkQy/6C uiCsJ48DrsdwrcUyjBvJSJaKKHfhV6K5AxCB7dFvwwrwWy/hCKIRliym7/4UfefdUp I9fQBOjuLGVs1afchnLn2NrNZ0ISkkx9umhOZnksf+PUBatrAPl6u7Y/6aqvxFbsxZ PciS3pLnkJ+iA== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvz-000o2z-RN; Tue, 27 Apr 2021 12:27:15 +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 v3 78/79] media: rcar-vin: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:27:08 +0200 Message-Id: <85d92ba9e709ef00673a3e0e11769b121745e9cb.1619519080.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 Reviewed-by: Geert Uytterhoeven --- 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)