Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3343389pxv; Sun, 4 Jul 2021 16:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvpJbYYoKBMeQ6t02LarMUwT4z5WspEzTq1d6cdpHHkEDzIZAAzdNWP82ASGPY5Wc8iDEU X-Received: by 2002:a05:6638:688:: with SMTP id i8mr7091640jab.75.1625439919337; Sun, 04 Jul 2021 16:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625439919; cv=none; d=google.com; s=arc-20160816; b=ds3HnhsbJGP1L+wO5nX7sZvVlDhFfwKk6EhsAj1vHel2ZlekA7hys2RF6fPqDdJVOV OatYHY+z0GDr9v8UZAEasJYNIBw86Y/G12LNqE0lxHw0jkX7XPIoMr+cJblLz8o7Zs65 Ksx8tXRWkGEyvODCXcfLWtwOlLz6/xrCGoNr8wkIqZuQ0Mh8PQw1gm3EWwRyVulN4JZ9 IITZZEtb7pU4puF426WhfU7B7IFsTd5pBcluWTITMhsVI7Vn6mpzpMYsCU4RApVrq+D4 HnBalJtsXzviGk4sXkAWwBlBjXXZQ3GynpnshMhjbdvq11ePwh+wgu/P3JiSMkmRsHXi 1L6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZTd0GvVlFMRKSXwu13tdOhTyipXGX/xu+MlTM2WEudo=; b=vtUJgLKfJD2Cx08HbAz843faqW8TfOByeefIzyacjetShlv6PeCQVUh5MuKhHYC/vz kJ+DSvuc1x7URvtdnPBYNbLXUGqV+nJeEwzeiLMLVWyhMJ7oxZroHL60nD1qNxBYdYGd wLJpE2nUpHEL0l9toYmAmf6EyX7JRsva/CLbE+jAoffsZXo72a+VVcyBhGpyQDaAdqk+ x7RSlnVoULGMVNGDSqpIvl6AvaALBgj+Zp3C4UHLw4c7fojM3Y9we8lE+wra+GjOvtuo 9VOhfM/rqb3OA4RtfOrBP0K132WmBLoM4kv0CYKzEOHXa1Lsw+HH3Jag60UNn5QNNXC+ O+Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=by6Fv+KJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si12319985jad.12.2021.07.04.16.05.07; Sun, 04 Jul 2021 16:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=by6Fv+KJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229942AbhGDXHI (ORCPT + 99 others); Sun, 4 Jul 2021 19:07:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:44982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbhGDXHF (ORCPT ); Sun, 4 Jul 2021 19:07:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE2A9613D2; Sun, 4 Jul 2021 23:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439869; bh=/FSnNNOCk5OXokZXqDDrrMtWOMQjuygAvziNQZGw/TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=by6Fv+KJcSveRWAd5mFoxp0JwLQ0BCLptBPuInkxMhoyozLYBaZRaxgeVYq0hfNNx IIIAlMM5ISxukxo8NwIy6vpZkhRhGsZeYUfFc6+A2LioLD3CmN1DkIT/A8d74e/adV 49Ubo5geJDT8GTWysir4qDHY7chmgVCgMUAK46f+6PiP3yVpywI00K/fPwruwyat4p jpVM7qAddlMsiJNhCyio/VdpuHeG6BsG8KH+/f1RFbhsUlV+b+/Usg8Kfw/AbWpepX U0TU2dKGo7OrUuzyESkHZBRIxsjGLCy6sl52XW/2I7EqoAW0oxGxpC7xvTJpwDLBX3 dc/+5rEAEetRQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Sasha Levin , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.13 06/85] media: mdk-mdp: fix pm_runtime_get_sync() usage count Date: Sun, 4 Jul 2021 19:03:01 -0400 Message-Id: <20210704230420.1488358-6-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ 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 Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- 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