Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp543002pxy; Fri, 30 Apr 2021 10:38:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAOyMXizJXKKhY91PDDUDpuvzj1d03bF66m4ma7LPw/KGJvDfNS7r3Y21ugfpubwf6kvIr X-Received: by 2002:a17:906:9246:: with SMTP id c6mr5877688ejx.10.1619804285645; Fri, 30 Apr 2021 10:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619804285; cv=none; d=google.com; s=arc-20160816; b=r4Tfvgsr3OmksZI5xwNOYa13Pmlx6ANuqsbUyHuK+wx/JHYp1grqrp0Oe+sDKDz8Om HFNyWGqNYwivQvqqRxFm+Mq/WbqhIZCf6An3MoBfDtOyy5EBjjExVEEKOynhGYO4lzp+ TH1557/K7gHvxbS1EMNE2cwOcnvLWxeSRZHnBiZLNZArQ+0FAlYG7egBncTWZw3fbWH7 CD3/9VoMYQXuqYyz/RGmm7QaV+sRPZvRgFht8Uj3vFnQ0fmJoKhOzDtJILLZkHEXYed5 OZb+M/fqrQXLbx12zIsF4ISEtfEKK7v29Edag9dqtsHgtDq3WHdIQZ9HiNfazVP0uBAP hJPw== 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=CskYaKbGgqgy6/U6+YU4Vqj6uzvx0Enz0t3a7LzmkMQ=; b=eopqZrrpprk20AG4Hwi8AcsfY6A+u4VJ8pfCZIpjiEi2kswLUrDP8/3H+CjFXuU4ib s+AN1Qj57mw/Rsio1X6fshYQO7RaUDiBey8NR3MQYCRcHVn7vNC+a7VbZvgF7CqQrI0J u5yixH2DVdTiMA+jwGwSLwyZuNjIpKHYg36WIYmz14kBpv5MQWFfk8VLXN3pC3Ejzo0P Zyb2JLSuVPW9gmGVOB1kxfKEzX8+oV+30au2RIuLZVcABg0CQ96stxxQ5VJZOVR0jKhc nUk1Mfn6gkhKJmg5RCfqz4/LT0gxY2iT0r0H7oITjyAGcKqWhgH/R/JoV5+zDzoY/4Fd WHBw== 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 ml14si3781600ejb.661.2021.04.30.10.37.41; Fri, 30 Apr 2021 10:38:05 -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 S230511AbhD3Rha (ORCPT + 99 others); Fri, 30 Apr 2021 13:37:30 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2974 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbhD3Rh3 (ORCPT ); Fri, 30 Apr 2021 13:37:29 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FWztB25k8z6wjs0; Sat, 1 May 2021 01:30:58 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml714-chm.china.huawei.com (10.206.15.33) 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:36:39 +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:36:38 +0100 Date: Fri, 30 Apr 2021 18:35:03 +0100 From: Jonathan Cameron To: Mauro Carvalho Chehab CC: , , Jean-Christophe Trotin , Mauro Carvalho Chehab , , Subject: Re: [PATCH v4 58/79] media: sti/hva: use pm_runtime_resume_and_get() Message-ID: <20210430183503.00002a9e@Huawei.com> In-Reply-To: <58543e7897c8700b5529182343e189a6345ff5d2.1619621413.git.mchehab+huawei@kernel.org> References: <58543e7897c8700b5529182343e189a6345ff5d2.1619621413.git.mchehab+huawei@kernel.org> 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:52:19 +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. > > While the hva driver does it right, there are lots of errors > on other drivers due to its misusage. So, let's change > this driver to also use pm_runtime_resume_and_get(), as we're > doing similar changes all over the media subsystem. > > Signed-off-by: Mauro Carvalho Chehab Bit of a fiddly one, but looks right to me. Reviewed-by: Jonathan Cameron > --- > drivers/media/platform/sti/hva/hva-hw.c | 17 +++++++++-------- > 1 file changed, 9 insertions(+), 8 deletions(-) > > diff --git a/drivers/media/platform/sti/hva/hva-hw.c b/drivers/media/platform/sti/hva/hva-hw.c > index f59811e27f51..77b8bfa5e0c5 100644 > --- a/drivers/media/platform/sti/hva/hva-hw.c > +++ b/drivers/media/platform/sti/hva/hva-hw.c > @@ -270,9 +270,8 @@ static unsigned long int hva_hw_get_ip_version(struct hva_dev *hva) > struct device *dev = hva_to_dev(hva); > unsigned long int version; > > - if (pm_runtime_get_sync(dev) < 0) { > + if (pm_runtime_resume_and_get(dev) < 0) { > dev_err(dev, "%s failed to get pm_runtime\n", HVA_PREFIX); > - pm_runtime_put_noidle(dev); > mutex_unlock(&hva->protect_mutex); > return -EFAULT; > } > @@ -386,10 +385,10 @@ int hva_hw_probe(struct platform_device *pdev, struct hva_dev *hva) > pm_runtime_set_suspended(dev); > pm_runtime_enable(dev); > > - ret = pm_runtime_get_sync(dev); > + ret = pm_runtime_resume_and_get(dev); > if (ret < 0) { > dev_err(dev, "%s failed to set PM\n", HVA_PREFIX); > - goto err_pm; > + goto err_clk; > } > > /* check IP hardware version */ > @@ -462,6 +461,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, > u8 client_id = ctx->id; > int ret; > u32 reg = 0; > + bool got_pm = false; > > mutex_lock(&hva->protect_mutex); > > @@ -469,12 +469,13 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, > enable_irq(hva->irq_its); > enable_irq(hva->irq_err); > > - if (pm_runtime_get_sync(dev) < 0) { > + if (pm_runtime_resume_and_get(dev) < 0) { > dev_err(dev, "%s failed to get pm_runtime\n", ctx->name); > ctx->sys_errors++; > ret = -EFAULT; > goto out; > } > + got_pm = true; > > reg = readl_relaxed(hva->regs + HVA_HIF_REG_CLK_GATING); > switch (cmd) { > @@ -537,7 +538,8 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_hw_cmd_type cmd, > dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd); > } > > - pm_runtime_put_autosuspend(dev); > + if (got_pm) > + pm_runtime_put_autosuspend(dev); > mutex_unlock(&hva->protect_mutex); > > return ret; > @@ -553,9 +555,8 @@ void hva_hw_dump_regs(struct hva_dev *hva, struct seq_file *s) > > mutex_lock(&hva->protect_mutex); > > - if (pm_runtime_get_sync(dev) < 0) { > + if (pm_runtime_resume_and_get(dev) < 0) { > seq_puts(s, "Cannot wake up IP\n"); > - pm_runtime_put_noidle(dev); > mutex_unlock(&hva->protect_mutex); > return; > }