From patchwork Wed May 5 09:42:14 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: 12239627 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.7 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 04410C433ED for ; Wed, 5 May 2021 09:48:10 +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 9D9C061008 for ; Wed, 5 May 2021 09:48:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D9C061008 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-arm-kernel-bounces+linux-arm-kernel=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=5JSLbsumszDcDUsGyeBkbG4OPSuFWsMWJO9WSDThV1A=; b=gOBQtC9wJ4V5M4ql7l7T2xUM8 jxAJ78Uo6Nue6BCpYvPkrnSqUGRODPVXjvrWwrpDS/4Z5/qt8hRniAejN0dYND1plSbIIpn2/KRzH brBdj0qu5HtJz9PK65E1caiWzb2hHDHu0Dp/Jh/+qPGOtQgaMoY0SSxH5vWhzuqBDbAVuYTFgWQkl +uve/w9XLSUoliA+2VEv/kt8s5NNq1FNmAU3r1SqTJScdSmcXpYl1aZ3EgZmfSnaGNCe6yQy+VnoZ deMmwJzzuCYTt+XunS0N/iScJYc4sfsu5+Ax/gdLC7hMo7qPI3j7X0v5Us5jW/YiOTklmxnbHMP1Z uUrwhyZQg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1leE6p-000mcy-RU; Wed, 05 May 2021 09:46:24 +0000 Received: from mail.kernel.org ([198.145.29.99]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1leE32-000l4d-Ku for linux-arm-kernel@lists.infradead.org; Wed, 05 May 2021 09:42:34 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9E07561574; Wed, 5 May 2021 09:42:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620207739; bh=YXL+gA4goxj5s7MMwTgNIwMfazgaE4VAbN8eHBvZ4x4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uOp+Ty69wRZVl3P+vvXIUlGYDh3ay+6S+YyfcKN1CT3Jme/0sPsvIppoJDG83Ju8R 8xYian6y1N4CZxugY3gFZJbOoyS0leNUBXNYaws9CSN8nc8wzyAjmlJS5E/4BaecLP 6+7NnEgLJrYAd4E/vIZF1lqkOYW2A2IDBy4RtoVjNxejWauNkwc0YbOS3NtcI5KJba vnIB7fVnDhzE9bdEVsVQYJtcakBROkoOhTXOTFQSpI8hCUbnPKXkZ8liJpfnCqqtqS fCoSll02cfuw87x5iK/Nhwaey5Oiw27cL09Plyan79ObHMLRlUJXbqLptv0Hm4niUw IPv5nnCUdmdTw== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1leE2r-00AHwy-KJ; Wed, 05 May 2021 11:42:17 +0200 From: Mauro Carvalho Chehab To: Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Ezequiel Garcia , Hans Verkuil , Krzysztof Kozlowski , Mauro Carvalho Chehab , Sylwester Nawrocki , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH 24/25] media: exynos-gsc: fix pm_runtime_get_sync() usage count Date: Wed, 5 May 2021 11:42:14 +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-20210505_104231_223509_4EEE6C37 X-CRM114-Status: GOOD ( 10.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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, avoiding a potential PM usage counter leak. As a bonus, as pm_runtime_get_sync() always return 0 on success, the logic can be simplified. Reviewed-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab Reviewed-by: Jonathan Cameron --- drivers/media/platform/exynos-gsc/gsc-m2m.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-m2m.c b/drivers/media/platform/exynos-gsc/gsc-m2m.c index 27a3c92c73bc..f1cf847d1cc2 100644 --- a/drivers/media/platform/exynos-gsc/gsc-m2m.c +++ b/drivers/media/platform/exynos-gsc/gsc-m2m.c @@ -56,10 +56,8 @@ static void __gsc_m2m_job_abort(struct gsc_ctx *ctx) static int gsc_m2m_start_streaming(struct vb2_queue *q, unsigned int count) { struct gsc_ctx *ctx = q->drv_priv; - int ret; - ret = pm_runtime_get_sync(&ctx->gsc_dev->pdev->dev); - return ret > 0 ? 0 : ret; + return pm_runtime_resume_and_get(&ctx->gsc_dev->pdev->dev); } static void __gsc_m2m_cleanup_queue(struct gsc_ctx *ctx)