Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp522252pxy; Fri, 30 Apr 2021 10:11:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdrdhV90sqHN9bwCPO+tLJDrQZusvF5jA6+cVu/Q49LvrE0dVvlttGRmUEX8LOB7kmdGO3 X-Received: by 2002:a17:906:3b10:: with SMTP id g16mr5670008ejf.232.1619802700569; Fri, 30 Apr 2021 10:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619802700; cv=none; d=google.com; s=arc-20160816; b=BRbQjZAXk5aHp076ORvt+kpdhI8PVATqtRFLj5rpQoVsLfYoWP2A3bMmPdKIqJeH6n ZvaW9WEnIuMeAiJ7JGV8EbIeRhtLKbJBwDJoNE/1vlXp5Yx5KzJaTJ5Qif9pNtCaEc+u 09W2yR6YntNNlOwyA8CAM8Z00gP+Yh9jkIL5PRskgo50NOVlvxNnhkrLwug+2sYKFSjd CLnb65yH5nzQgr9u0X0MPV5hn9Ksj9lZ6dSG34QIPKayTiKhvPiMlS5V+PjdhufgWUTU jFgfVhkz5Q9MjyQFNwxyT5WECBd7XjWHJS6II5VVrXpnT4dNhaJALvzLhVlBzPLA/Z3g OlsA== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=0RFHlWsOIO1Q15spIifO7YW711YS5XjeHReyANreFZs=; b=OrPvUIkeg3c1sPZ1RhM4fXbpXsWRdaDns+mIdE3S9pvwj5benujkn12t+GnPu5G0ME XgVEKObOfIfQ2fMnS/gyMj15f1v8uS6X20Kmvims9HgwOryjO18Kx/yVxgXSRxzICht2 6pKE9/WkboXaaa9sjqDCijizwI1Z3pVh0xmj/8HsHvaHI3+O0oXwShKmHyGaXX2KK28C 1hEa0O4hK5RnpRK4C6hNsnb19On/sh9CaHlv4GF6cN3JXFvH5wijwa9uj4SNPNF/bCKR ZSyd0XqihTdgbMZPDWgr3nhpuMbXBLAasvdSbyzNAgkWvWxS67jqFX1NxtAJRCQtzJ0Y YKKw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cs15si3544440ejc.258.2021.04.30.10.11.14; Fri, 30 Apr 2021 10:11:40 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231133AbhD3RLD (ORCPT + 99 others); Fri, 30 Apr 2021 13:11:03 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2969 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbhD3RLC (ORCPT ); Fri, 30 Apr 2021 13:11:02 -0400 Received: from fraeml743-chm.china.huawei.com (unknown [172.18.147.206]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FWz9t0KM8z689R8; Sat, 1 May 2021 00:59:30 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml743-chm.china.huawei.com (10.206.15.224) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 30 Apr 2021 19:10:12 +0200 Received: from localhost (10.52.125.96) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 30 Apr 2021 18:10:11 +0100 Date: Fri, 30 Apr 2021 18:08:36 +0100 From: Jonathan Cameron To: Mauro Carvalho Chehab CC: , , Dmitry Osipenko , Greg Kroah-Hartman , "Jonathan Hunter" , Mauro Carvalho Chehab , Thierry Reding , , , , Subject: Re: [PATCH v4 25/79] staging: media: tegra-vde: use pm_runtime_resume_and_get() Message-ID: <20210430180836.00006da4@Huawei.com> In-Reply-To: References: Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.52.125.96] X-ClientProxiedBy: lhreml721-chm.china.huawei.com (10.201.108.72) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Apr 2021 16:51:46 +0200 Mauro Carvalho Chehab wrote: > 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 LGTM Reviewed-by: Jonathan Cameron > --- > 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); >