From nobody Sat May 10 05:48:31 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1620207779; cv=none; d=zohomail.com; s=zohoarc; b=LtK3EH5xX9CR8V9ZLlocce9kfwmxWhPf5S0TGAWeAmdVyzJ5PJI5T19SQw6LJUCZXeIP0KV6auEHFbAv4Hqcd+oNpus432y9hluDXhs03a1+YRjnjEUAnS7uQs3MI1xFmFnSUWFearV3zeIo4R3IuhqpProR+n+B1DoTqc8VRwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620207779; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Bh3WCbYmBm+OjcVWc+YNhagdhkKFLbLM6WNezAuLjJc=; b=iP5zhThVTDbCFKvJf4JTYCst76stFKWR3I448Ye0uGsv0BUuYX4ruiqCuP7LPWfOyAMyj2OjGxmC2nrX/95DKv048NYEGzN4WMjEaAhKa71acmKcJC5Hk4XD8r27Y9k2YN3B/6hckjgl+FLptulH5XoVdsEkxjlxtSu0ysmSAKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 1620207779679219.04544151894572; Wed, 5 May 2021 02:42:59 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232856AbhEEJnz (ORCPT ); Wed, 5 May 2021 05:43:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbhEEJnR (ORCPT ); Wed, 5 May 2021 05:43:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B8A4361582; Wed, 5 May 2021 09:42:19 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHws-H9; Wed, 05 May 2021 11:42:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=+rTtVWoWq20JhxgxmIT+9kZE/lGmMC43nyN1Fh8TG7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mf9MOyq5thATWWFz9Hfbj8qgxuAvW3JlflD7XQ0cH5Zuor+EZfGkN4Clt6QuA/wuw y//8rOn0wy+PwGVwJR2l2zPRdRAbICxiV10Wht8HhYN9kDf5fwiiGAn5z5+dYRFycg hcs3nteUDogm5vKp4HJiP89KL9dsunC2XF1E+Wy/Yx0g7iHfrGfyqn8+fMGVt3jbap e5CeeWJz/kEw+yVPIXc444DK3B1iQAnTorL0d3P3Fcf0VUbnjuH6RvYudx2oVunGDL MiRntCkCTFvqR19/Zc6WvKZ8WwuoyEiSriT7RmDlXB+pCovVcwfinqKW+5jGx7TF05 whTs4hBFXexEQ== From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Fabien Dessenne , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 22/25] media: sti/bdisp: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:12 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. The bdisp_start_streaming() doesn't take it into account, which would unbalance PM usage counter at bdisp_stop_streaming(). The logic at bdisp_probe() is correct, but the best is to use the same call along the driver. So, replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal wi= th usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/sti/bdisp/bdisp-v4l2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c b/drivers/media/= platform/sti/bdisp/bdisp-v4l2.c index 060ca85f64d5..85288da9d2ae 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-v4l2.c +++ b/drivers/media/platform/sti/bdisp/bdisp-v4l2.c @@ -499,7 +499,7 @@ static int bdisp_start_streaming(struct vb2_queue *q, u= nsigned int count) { struct bdisp_ctx *ctx =3D q->drv_priv; struct vb2_v4l2_buffer *buf; - int ret =3D pm_runtime_get_sync(ctx->bdisp_dev->dev); + int ret =3D pm_runtime_resume_and_get(ctx->bdisp_dev->dev); =20 if (ret < 0) { dev_err(ctx->bdisp_dev->dev, "failed to set runtime PM\n"); @@ -1364,10 +1364,10 @@ static int bdisp_probe(struct platform_device *pdev) =20 /* Power management */ pm_runtime_enable(dev); - ret =3D pm_runtime_get_sync(dev); + ret =3D pm_runtime_resume_and_get(dev); if (ret < 0) { dev_err(dev, "failed to set PM\n"); - goto err_pm; + goto err_remove; } =20 /* Filters */ @@ -1395,6 +1395,7 @@ static int bdisp_probe(struct platform_device *pdev) bdisp_hw_free_filters(bdisp->dev); err_pm: pm_runtime_put(dev); +err_remove: bdisp_debugfs_remove(bdisp); v4l2_device_unregister(&bdisp->v4l2_dev); err_clk: --=20 2.30.2