From patchwork Tue Apr 27 10:12:38 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: 12225785 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.2 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 81FC4C43460 for ; Tue, 27 Apr 2021 10:17:13 +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 0049D611ED for ; Tue, 27 Apr 2021 10:17:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0049D611ED 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-rockchip-bounces+linux-rockchip=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=8v+o3h2RWKxMIDfKdAPXeKf7hZAi6GW7fDbdXcRg9Ng=; b=q/gJ/1MjPRpAx/Pf0d8gFzFI5 BqyLwSJ5QENaYYa/RvsU70NdUxTU3IbupLyMBoRSrNHeQzrza99DCL59T9pHvmILtmw8Docd9Zll/ cdKyBs0V3+njT88ZfIP3FatT6BLhU5JezXibV8lfJoE4+JCisZ0ZVUoiAdtElzaCVJ+J6tcBY9JBF UWh7/NvD8NSJuGtYudXJY9pLgIvoi4NjLUcybA1xCiCFkMgZLQyakpobh+c4Gw5Vc7VHJp8uRQ4Pc GZvrCI+BFd8PLj33Il67pz0u3jMbhER2HLFENqAaD8WJFQmImaQKtfCDOPc2sqWbI1D95NHtcts+Y J9w+B60NA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbKm6-001K5I-To; Tue, 27 Apr 2021 10:17:03 +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 1lbKjC-001JCs-2T; Tue, 27 Apr 2021 10:14:02 +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=k/JT4xNc8q+xgw65KVZhdHtvOyVt1/eDaJCw7AtYUJ4=; b=WJdMX8BJv7l7gsa+WNDRce+HY6 DEQ4NMrX7iQvAKy0pFvOFUvQWdiUlezZ2HM+5Gvpybc02e72gP876jdniyJLlPd4lXTMN7ZgSx0ww KtDdaWokOCoot8EisPrZDSnou5DXERTaE08RYGx9Syk4OaOVMJPDl1cubo2A2xil7JsH8T5Mj/lOM aeYaGgxaBcqlfTLxE4VkaaGkuKpTsqeKqIo5AhayBNfT5uCfd15gYnLBBii9B8NRdrwna+H6fzxtE W02lWylPsTMNXpXsVziWYqncWyeQBK+IyxEKeo1XqVjcFySVwkgk4U0CVo7EVvyFlC+1aKExmOBAn xW+AJEiQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKj7-00Gbs2-73; Tue, 27 Apr 2021 10:14:00 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88BAA61002; 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=uJQR0czm+DeAW2PWQeBvZ4Rvzd+S5i8+90myFebensI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NiQvYMF7OEWPJzkJcicJ7WcKvB0H3GERIgYfA5qd0WtSjnaR0/nAV3hMCadwmEBnt 4Q0sn828e2ClzSrXWAtUuIDkwINCzefQc5ICV1bguILEAdRR66cv/1jXdl9aEvRcRD Bhx8pj/CKQr/EPlPqWchTGcwCLeQnx+qsO71Obg5pOpy0+39ert3POkP7ii32N1zeU XveXVnKAn9x/663ekqaHhQLsC16Ik7jDuulgkWxnbnMOCpwuwSCaBDoZ6iUKIiOLGH xkHRvRXlm6NGdmEAOPXnHv5P+44UCyanuBFz0MRONQIWQyeh8mwCBCsqWRTqxDSKDW SKrNb8oYv9xlQ== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j57-LA; Tue, 27 Apr 2021 12:13:48 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Heiko Stuebner , Jacob Chen , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 11/79] media: rga-buf: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:12:38 +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-20210427_031357_320403_AB0072E1 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.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/rockchip/rga/rga-buf.c | 3 +-- drivers/media/platform/rockchip/rga/rga.c | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rockchip/rga/rga-buf.c b/drivers/media/platform/rockchip/rga/rga-buf.c index bf9a75b75083..81508ed5abf3 100644 --- a/drivers/media/platform/rockchip/rga/rga-buf.c +++ b/drivers/media/platform/rockchip/rga/rga-buf.c @@ -79,9 +79,8 @@ static int rga_buf_start_streaming(struct vb2_queue *q, unsigned int count) struct rockchip_rga *rga = ctx->rga; int ret; - ret = pm_runtime_get_sync(rga->dev); + ret = pm_runtime_resume_and_get(rga->dev); if (ret < 0) { - pm_runtime_put_noidle(rga->dev); rga_buf_return_buffers(q, VB2_BUF_STATE_QUEUED); return ret; } diff --git a/drivers/media/platform/rockchip/rga/rga.c b/drivers/media/platform/rockchip/rga/rga.c index 9d122429706e..bf3fd71ec3af 100644 --- a/drivers/media/platform/rockchip/rga/rga.c +++ b/drivers/media/platform/rockchip/rga/rga.c @@ -866,7 +866,9 @@ static int rga_probe(struct platform_device *pdev) goto unreg_video_dev; } - pm_runtime_get_sync(rga->dev); + ret = pm_runtime_resume_and_get(rga->dev); + if (ret < 0) + goto unreg_video_dev; rga->version.major = (rga_read(rga, RGA_VERSION_INFO) >> 24) & 0xFF; rga->version.minor = (rga_read(rga, RGA_VERSION_INFO) >> 20) & 0x0F; From patchwork Tue Apr 27 10:12:47 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: 12225783 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.2 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 08484C433B4 for ; Tue, 27 Apr 2021 10:14:31 +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 923E5613C5 for ; Tue, 27 Apr 2021 10:14:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 923E5613C5 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-rockchip-bounces+linux-rockchip=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=pPmT+Ll9kXIX7EunXRwTezaS5m0ecUFlRy2VwaoQH4o=; b=oC9oMbvO6OxQsQ0F4WWIEWtmX uLstDxykieZZ8f6GVe7ntyHS/9dnFQrDQn2TJOQ7MF6zYgDCRzXG+26ogppP+v6cMAO7jlSHde5ZZ WiOcu8Rtf7mxSxeoJRWMWGZi3yE6xjIo0iXdtyMWGum+phXlQdLNw/A6dgOU+00xuM2ks5fIHC3lk cFYF4rvqsbEPbw592yxu5qxRCLmenODhaJIA4OVMaf0efwc7/BHV00P0nnULLycwz+1hHVVJZmtHn ZOjnVee1HyRe+Oc/32owMX4Ixiczy6QTQc28V6qtPbPjKvekUO0mNksiRClTGFSHbm/s1/liqJSoc TQzlY/pmA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbKjV-001JIx-Cm; Tue, 27 Apr 2021 10:14:21 +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 1lbKj9-001JBt-LE for linux-rockchip@desiato.infradead.org; Tue, 27 Apr 2021 10:13:59 +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=u5PcMNolJ+Hbjx5TaiiRECAjrT7wB+0xPtci4EIZYbc=; b=gIa77u+209SN0pgEVcfxtBausr Z7opXwJ31Q5TnTQcXUAzju2L/zBEhT7ZHfGIJnBzYeA4PBPvmA3DOwBdDauVc1CIrrrSAAiuwXRMu vQmrygCypzGhiyYBzxH+I1qVwZvvIzN9Dpdcu6uzPwQv8esJgW2rIqvaKuyvf0izXfj2BB2AaPPmz U6FKt/VjE0Q3K56sD1qlHv/cm1P0POInhKFRANvg1yK2NMB1m3OJyL3VsFvK+udS/Pr2cARDLgAct sk4j8UYIffCCY5pJjgEP9YB8ibZlmH/hppHONcO3/+1Mmn4JOOM1BhW/R1piNfCMdUqPkYKeDyGS4 /gQttbgg==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKj5-00GbpS-Nh for linux-rockchip@lists.infradead.org; Tue, 27 Apr 2021 10:13:58 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2DE0E613DE; 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=LvHrsFJn6JLbIexuKZaI+hIEIjqhrM13uG8Z/t+ytHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MVqLR7mFtMTLO0mK1TyVv9e+yTmOBkTKp+10OaJB+E8GKGvWzwvNELM5c29euVRTA USlnGTJVTJc1qUs5eiLRzGraPsUzUVxRBRdZb3dj2QYodiUjT21ZyJ3XdxD0sYvdb5 R8n08vJvzfzrjwR87IG9TYbo7F4hAXUTNwwiFTlSYLHGpPGL5JMt9a5XVt+otKb7Fk Qh8UHDBRVwMqDuoD7fHrAIuahwrZK7Ok4dbmXenwn7JQ3KIOyRWLDB3g8TBY9UOjrV XfCHLr0ZmqO/JJOaR4g8tbEZIoDPZc/cz4Ha+yXKWAuRKkaY4AHE5VXNYUixFP0vK3 +74rLo8FW28lQ== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKiy-000j5Y-Uq; Tue, 27 Apr 2021 12:13:48 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Greg Kroah-Hartman , Mauro Carvalho Chehab , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 20/79] staging: media: rkvdec: fix pm_runtime_get_sync() usage count Date: Tue, 27 Apr 2021 12:12:47 +0200 Message-Id: <8990782e13de0f4b91fa6675bc5fdaeda2fd038a.1619518193.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-20210427_031355_849976_61396612 X-CRM114-Status: GOOD ( 10.71 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=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 and avoid memory leaks. Reviewed-by: Ezequiel Garcia Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/rkvdec/rkvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/rkvdec/rkvdec.c b/drivers/staging/media/rkvdec/rkvdec.c index d821661d30f3..8c17615f3a7a 100644 --- a/drivers/staging/media/rkvdec/rkvdec.c +++ b/drivers/staging/media/rkvdec/rkvdec.c @@ -658,7 +658,7 @@ static void rkvdec_device_run(void *priv) if (WARN_ON(!desc)) return; - ret = pm_runtime_get_sync(rkvdec->dev); + ret = pm_runtime_resume_and_get(rkvdec->dev); if (ret < 0) { rkvdec_job_finish_no_pm(ctx, VB2_BUF_STATE_ERROR); return; From patchwork Tue Apr 27 10:13: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: 12225993 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.2 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 EE2FDC43461 for ; Tue, 27 Apr 2021 10:19:57 +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 97877613C3 for ; Tue, 27 Apr 2021 10:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97877613C3 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-rockchip-bounces+linux-rockchip=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=uYhhwvdzAHsd1sxiMTRQPeg++8Pl9jgPFWj73GiLEqE=; b=RqXEOvAvCl4dcqxZ8lG24Xl/n bbix9wZa0zMXTuIdM2sQ9MLtn1q39gsl5Q38hEihcz9Iu6N5uWksY7ECuMQPSVngnvZjZaRDk7BqN DWEpX2b6cE5pPoPFUH1UZ27g1YewxmsDjwYJ+6yJ26Q+33OEJ/NeIjHJ7E30XvPRF+7ONTO75Ckaj Lwq7dYhK0xsWGcWGOuQZzQugr6OdwQ/MyUcJdWlH8hSjWya1Db9rMmynralXhJ2Bnw6SzealY/p4C nnfZW5MQNrkxRlWqijzGjkzc79qmaGyJQMq2Lq2bqiNL5QxPKhqCW1e5yVSaPd6uv3W9ej9FgQFXa MWaM43nPw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbKon-001LBK-JE; Tue, 27 Apr 2021 10:19:49 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKjF-001JBm-Ha; Tue, 27 Apr 2021 10:14:10 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id A85186194C; 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=rChg/pXG2Qjbehywcb/+z5hE6+LFH66GvNnoCtLFEBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSkxcPymxCcHvHCHnPGNTKlIe7N/iWkE12x5+iF06VhEniD4QeFLHL9o7KnQB+6gf z4w6rnmCHtOLpZfpsniFLxW1j67cKbiF5B3xZQMPX5VM+R6ZNBmTJnvUqrk+yUC9KL 25AEapb+FpzGnfeGIkYNUyaLx/9e0zpGHp6v2p2bMvObUY8EyraseE1M4pdSdy7Bxk drk2/1vsmSUype/gw8qJUaMh17jCJiAZmGkIge8RsuRJs+WJy4bkTwPUIlUOWMEMLf Nyxv9LZ/Zaq1kI+6vFlRV9c7q7XiWJWFVt3MBptI/LPv1d3x9yScwa3SsWg2HzjRab T5IhMmxNp2Uag== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKj1-000j7y-Sx; Tue, 27 Apr 2021 12:13:51 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Dafna Hirschfeld , Heiko Stuebner , Helen Koike , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 70/79] media: rkisp1: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:13:37 +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-20210427_111407_804146_49E31D62 X-CRM114-Status: GOOD ( 10.41 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.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/rockchip/rkisp1/rkisp1-capture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 5f6c9d1623e4..3730376897d9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -1003,9 +1003,8 @@ rkisp1_vb2_start_streaming(struct vb2_queue *queue, unsigned int count) if (ret) goto err_pipeline_stop; - ret = pm_runtime_get_sync(cap->rkisp1->dev); + ret = pm_runtime_resume_and_get(cap->rkisp1->dev); if (ret < 0) { - pm_runtime_put_noidle(cap->rkisp1->dev); dev_err(cap->rkisp1->dev, "power up failed %d\n", ret); goto err_destroy_dummy; } From patchwork Tue Apr 27 10:13:46 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: 12225991 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.2 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 45B95C433B4 for ; Tue, 27 Apr 2021 10:18:01 +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 A9706611ED for ; Tue, 27 Apr 2021 10:18:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9706611ED 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-rockchip-bounces+linux-rockchip=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=+Rae2ZtGICAqJ8v9P9Bfp7HOOsi0SgNHRQZJR1yxU6Y=; b=A+uEBnKt1aNix4EP5+A9VWztZ f/axqyySUWS12IzNl0rQqeiKajZ89iSvzsK3KRx2psoYaQm6L/eCh/iLuF6cOOnMN8h6B8JQlLwX5 CXQCoxNS5nMrcIyfxnNh0xZf5YAi8oTUItrktfNQttMNWN7L31lZ5S5P+sQf4cjA5oGVkU5V2wB4I bl+PG2p+ozuh0uqx6oW2ybzrzKrzCbkGOUOTlt0MAHlk6dK+aS4T1dUXkhz3nRdNnIB3yEihgWppV 8Ut1Twc1Edo6WfMorz1v/TkyiAN+TyZvvXUQSDaaoMblX0F4EsoF/o6M+uB2C3mBV/AayH7ub4DlC nW5p0yfSA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lbKmv-001KRq-Q0; Tue, 27 Apr 2021 10:17:54 +0000 Received: from bombadil.infradead.org ([198.137.202.133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKjE-001JDU-Ep for linux-rockchip@desiato.infradead.org; Tue, 27 Apr 2021 10:14:05 +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=6aHqXZX0GvEv8M689VN0ZTC03Iuok2m3bZyU4jw0V6I=; b=yYTqz04+6z5lJHxyNXPZ+yW8d6 3CAvezdnb06kbTXlIuzoAQj14OyN1VDK12pLKGixTEK4N6lEQ+XK8OMkL5UvamuAFbMIrZTqCgxti 7SgOUxHEg2Lt6HOPFfIPgwJBnWFUBARPMSm+vxB/7o4SydPDhssoB3PcWX/D3O1r8EnXGYOWuGE9G RuVl9OhTcu1e4fSrgB8wUV76ZXMS1hexkTPjLK143BRWe3NkJoGq/ZSpUKb4LserBj61LDK29tITD XEQvtMnf7M8a3YzURTeujaBG+FhzRNqTPoBvGT2LDL82mcMxyGkRNhhYr2KoUSiw4cBqozRqgo8UH E4MeuGnQ==; Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lbKj8-00GbpW-NJ for linux-rockchip@lists.infradead.org; Tue, 27 Apr 2021 10:14:03 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 359A36196E; 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=9XhzsT7qorzb0O8m+AZfDrHyIqnxWFrm1sswMUzcdRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=homNswZsvi3mGrB+l98sroFS+C/F69CJQA+9KlUyxudW74Xi+ByY6ffj9t9pty0oW FYXGAGj4eQvOAlOjxHYdmWM7AfKSOtbfXnvOoKlORsojpR0Srlv/xGdiLrTZWhnQhq 21ZL05Qiwme2NsO12Oq5nal3qRX+lK7scfhjCNDDm8Micc1frReWiNqg4jR1xgxQy8 7/958He9RkPM/f9Njh/2KDGtyHv++RK5fa5eI2aZL1sBez0PzbgpA4tOhDsf/x9pPC lzut5TGIjsXxw9UAWXjvu7Vc8BRNzyE5omQiYa0pNduj9esu1e0x8IHZjYKwvlLj5z iV7WA6drJOYyQ== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKj2-000j8P-Cq; Tue, 27 Apr 2021 12:13:52 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Greg Kroah-Hartman , Mauro Carvalho Chehab , Philipp Zabel , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2 79/79] media: hantro: document the usage of pm_runtime_get_sync() Date: Tue, 27 Apr 2021 12:13:46 +0200 Message-Id: <29a5f9cf9680a36fc1f6277364aa7c53776ed0cc.1619518193.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-20210427_031358_811826_4FDCD0E3 X-CRM114-Status: GOOD ( 10.89 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Despite other *_get()/*_put() functions, where usage count is incremented only if not errors, the pm_runtime_get_sync() has a different behavior, incrementing the counter *even* on errors. That's an error prone behavior, as people often forget to decrement the usage counter. However, the hantro driver depends on this behavior, as it will decrement the usage_count unconditionally at the m2m job finish time, which makes sense. So, intead of using the pm_runtime_resume_and_get() that would decrement the counter on error, keep the current API, but add a documentation explaining the rationale for keep using pm_runtime_get_sync(). Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/hantro/hantro_drv.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index 595e82a82728..96f940c1c85c 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -155,6 +155,13 @@ static void device_run(void *priv) ret = clk_bulk_enable(ctx->dev->variant->num_clocks, ctx->dev->clocks); if (ret) goto err_cancel_job; + + /* + * The pm_runtime_get_sync() will increment dev->power.usage_count, + * even on errors. That's the expected behavior here, since the + * hantro_job_finish() function at the error handling code + * will internally call pm_runtime_put_autosuspend(). + */ ret = pm_runtime_get_sync(ctx->dev->dev); if (ret < 0) goto err_cancel_job;