linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org
Subject: [PATCH AUTOSEL 5.12 06/80] media: mdk-mdp: fix pm_runtime_get_sync() usage count
Date: Sun,  4 Jul 2021 19:05:02 -0400	[thread overview]
Message-ID: <20210704230616.1489200-6-sashal@kernel.org> (raw)
In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org>

From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

[ Upstream commit d07bb9702cf5f5ccf3fb661e6cab54bbc33cd23f ]

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 <Jonathan.Cameron@huawei.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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,
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

       reply	other threads:[~2021-07-04 23:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210704230616.1489200-1-sashal@kernel.org>
2021-07-04 23:05 ` Sasha Levin [this message]
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 10/80] media: mtk-vcodec: fix PM runtime get logic Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 11/80] media: s5p-jpeg: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 12/80] media: sunxi: " Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 14/80] media: exynos4-is: " Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 15/80] media: exynos-gsc: " Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 19/80] regulator: uniphier: Add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 20/80] sched/core: Initialize the idle task with preemption disabled Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 21/80] hwrng: exynos - Fix runtime PM imbalance on error Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 28/80] media: hevc: Fix dependent slice segment flags Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 30/80] media: imx: imx7_mipi_csis: Fix logging of only error event counters Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 34/80] arm64: perf: Convert snprintf to sysfs_emit Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 41/80] media: cedrus: Fix .buf_prepare Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 51/80] mmc: sdhci-of-aspeed: Turn down a phase correction warning Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 52/80] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 53/80] spi: meson-spicc: fix memory leak in meson_spicc_probe Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 54/80] regulator: mt6315: Fix checking return value of devm_regmap_init_spmi_ext Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 59/80] media: imx-csi: Skip first few frames from a BT.656 source Sasha Levin
2021-07-04 23:05 ` [PATCH AUTOSEL 5.12 63/80] drivers/perf: fix the missed ida_simple_remove() in ddr_perf_probe() Sasha Levin
2021-07-04 23:06 ` [PATCH AUTOSEL 5.12 64/80] KVM: arm64: Restore PMU configuration on first run Sasha Levin
2021-07-04 23:06 ` [PATCH AUTOSEL 5.12 78/80] regulator: mt6358: Fix vdram2 .vsel_mask Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210704230616.1489200-6-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).