Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp621486pxy; Wed, 28 Apr 2021 10:38:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLBRjR6dL9W5Nfyu/6nxWdxM+VADZ0B72Jr26+xoT2ULlb7i89uxkhW5tx8DKJZiVTvrFp X-Received: by 2002:a17:906:d978:: with SMTP id rp24mr3912716ejb.333.1619631387140; Wed, 28 Apr 2021 10:36:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619631387; cv=none; d=google.com; s=arc-20160816; b=ddcEB+z9intcJrdTs9c75FyC9YiwDBHNpnLnpQm6jdvyUvFtia6TEni3H+WIh2EdOb UIN+gpidxbi8e4/s/KKPP+3tKaNCDa1Fpjk17R5q3T8dibUGsIy4NHPN36LpXkrFrb4G uCx0MlG/+raKuQXn8w2t6sB7uW7+PexbBHgfVUj72ljsmOOEfc43ofiI8KYZJ9NSIIS7 j0+qs+v4LSztctCUgfiq8dw+tGsMpKnxsGcJtt/IukHDbQYa3/VxQKbNatkajvqtnCgh 8xFdwrR7mOMkdS1xFd8e5RhCC0Lls7avmxgUITjVWBRwzDLOesH47GL7bSINygwEEZmN RQMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=GMhRRKrpI6+bpNhZYx/HZFKUMotxqArhFToQ9HearbQ=; b=wSkrhvzixS+23NMIvzlv+BUgDNKbvZ+/qqESRdCrZVFK2WNNx90qYfIl4pVBHSJrhl Mw4ShBb53NgmGuOn80w3fVz3GyfiJ2thmWEOdfEVFv7PSwHHceX3Tjc/IDIzE19X53bB Bm3xonh7LL+4ILWszt5NelajCkU4gCY+WyD7VlacR8Uqb8F3qmG64Lm8+9DjH8YasBDM PHTaxsVAp9HCjm9Y5GmkgVH17keKq3s6XGGuyHbQlZWeug1AT6o3+2w5F859+AVhLjD7 Ru7YjHvrtBHxikiyPhZsotAS0eHE97+6e3B32sO/5wpxAY1vhom6Yl+89+DoWKHaCcre teYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=DDpRLKcj; 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 b6si721248ejb.254.2021.04.28.10.36.03; Wed, 28 Apr 2021 10:36:27 -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=fail header.i=@kernel.org header.s=k20201202 header.b=DDpRLKcj; 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 S229636AbhD1O66 (ORCPT + 99 others); Wed, 28 Apr 2021 10:58:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:36302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240483AbhD1OyM (ORCPT ); Wed, 28 Apr 2021 10:54:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5321E619A7; Wed, 28 Apr 2021 14:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619621565; bh=llYDk9JyI2jon9eBR93Uie3QTpeZGnmK8q3UUwZjdV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DDpRLKcj+IfcTIa61IFxLfn/lEFs253xaI/l68fMapM9xmWPOcHqXHTIif2SqDfYb GUUZmGE00QAg2fjqq2M+zv0LPVJHuN57mPu8Q9XECT9p0nStWLFjhEN0noXNR36FgH iDsAv2qeNSctEztvMxEmEwFpV+56/1DVI2w9TO4fDaoATjo9NdF/xB3NehEr6WFlQx iHGQcIpDyz9QRobvc//Vi6AtXHE+M10ZB5IaDkk0g/s6d7h+6QNAysZdyDNY04XEBV UzRdzTu9dFdackcTIXnEaqkbjqHEtmhnrP3wV6jFG769iZmD7iV4gSQ9vy/amapyAl GGtj7rfkkuMzg== Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lblYQ-001Dqn-9M; Wed, 28 Apr 2021 16:52:42 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Dmitry Osipenko , Greg Kroah-Hartman , Jonathan Hunter , Mauro Carvalho Chehab , Thierry Reding , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v4 25/79] staging: media: tegra-vde: use pm_runtime_resume_and_get() Date: Wed, 28 Apr 2021 16:51:46 +0200 Message-Id: X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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/staging/media/tegra-vde/vde.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/staging/media/tegra-vde/vde.c b/drivers/staging/media/tegra-vde/vde.c index 28845b5bafaf..1cdacb3f781c 100644 --- a/drivers/staging/media/tegra-vde/vde.c +++ b/drivers/staging/media/tegra-vde/vde.c @@ -775,9 +775,9 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde, if (ret) goto release_dpb_frames; - ret = pm_runtime_get_sync(dev); + ret = pm_runtime_resume_and_get(dev); if (ret < 0) - goto put_runtime_pm; + goto unlock; /* * We rely on the VDE registers reset value, otherwise VDE @@ -843,6 +843,8 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde *vde, put_runtime_pm: pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); + +unlock: mutex_unlock(&vde->lock); release_dpb_frames: @@ -1069,11 +1071,17 @@ static int tegra_vde_probe(struct platform_device *pdev) * power-cycle it in order to put hardware into a predictable lower * power state. */ - pm_runtime_get_sync(dev); + if (pm_runtime_resume_and_get(dev) < 0) + goto err_pm_runtime; + pm_runtime_put(dev); return 0; +err_pm_runtime: + pm_runtime_dont_use_autosuspend(dev); + pm_runtime_disable(dev); + err_deinit_iommu: tegra_vde_iommu_deinit(vde); @@ -1089,7 +1097,12 @@ static int tegra_vde_remove(struct platform_device *pdev) struct tegra_vde *vde = platform_get_drvdata(pdev); struct device *dev = &pdev->dev; + /* + * As it increments RPM usage_count even on errors, we don't need to + * check the returned code here. + */ pm_runtime_get_sync(dev); + pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); -- 2.30.2