Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1642186pxy; Thu, 6 May 2021 12:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAE+LCscZ4nxOPm9MrMCeg2MmfilL7/dDmhLHefQuelxTVGulnbXcKwAM+Shfvd8HFReb3 X-Received: by 2002:a17:907:3f99:: with SMTP id hr25mr6160423ejc.231.1620328111939; Thu, 06 May 2021 12:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620328111; cv=none; d=google.com; s=arc-20160816; b=uxkTaBXJZB0J3SMd+chbf8ml5zadxpgqYcKSeoVFTinaodtvxApDq71z10FjSMSJUw EPoRBVpMVYkK0Jb6ET64xRLTvVnsybXqBeVyA//bgWQLy36Kr3PpICf4qmnk04aC3hmy bBObhgxVqf1aPuemqp8n2SGdV0AEEY5hFD2EMEDA2go+1kA0rwXNuPqintBdIh9GaaW/ WA54MDu2k9YMvIBXEfNkNM2un8gAWjsejjiAKviia8KGNbs9M4qE+EDPaxtvzQGqwzYM GDaPnTB16EdJa2ZiNYelwsacBhrUcgopKr08xYszwR4fTudWo0sHNNpR40PQf6O2IqBN /pXQ== 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=a5QMVd0AWE2YxmyjOAYVn+UioHRmxxHz79JTa/tgkaI=; b=GqF8hc8GST536WtYqVxFnZKWYgGC89SjG8/UtYIjdi4lnXepqA1WvI8qAwcSh/9T7/ mXhMQa+qkeqGG7sNSXdYy/xt/z56P6TTTmtAbnGzHUNFBQcCbXr7B0p+kkBlCdE43fvU NhunvkD7G2e4HQ952NNJ5RXU+KGCy5iQuDfhWjKMzgOg1Q7kBSVS5Iii4cyglGRlntno QzPE13rRI1bMcA6WgioUl1BhqbWyHuoBM0aKVax2vcbKaZKdKAnFDjuu2rZku6onlAkT OsephnuPOZAX+UfJDmYjBrkuEVs7rxZnGwkLWkQYQd7BiHGzOpmN5BAqVoXL+e8qjYc3 a+jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=gDxRrtQ9; 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 i11si4127083edb.109.2021.05.06.12.08.05; Thu, 06 May 2021 12:08:31 -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=gDxRrtQ9; 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 S235713AbhEFP2c (ORCPT + 99 others); Thu, 6 May 2021 11:28:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40896 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235402AbhEFP1n (ORCPT ); Thu, 6 May 2021 11:27:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BBB646194D; Thu, 6 May 2021 15:26:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620314783; bh=RAO7dmVKLQDcH6CylVWp9ikY4d/9xR0RnopNUcB5ryI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDxRrtQ90nN3tyyyAw1+n/qyklcK+N18nA2ub2ElEnoEKKYe47m1XebwIoqeyrwOH E1I39n2UtxUvdqCbNQCncGSNXqSNdsemO1dGTM5IXnvVpo9m+9asVGGCaovxtyn0Mx OrfqrsvocpVdDjq3wMQGnqq44hLYFxdEGxxvVKFT1LXYpny+QBtNZSfAfR/+jbLJw+ NInGIBtAk94f4ZHicGV+1a4CvFqmvO+zeS0KC9+7rUeR2M3NODJLSc6uFPEk9u7hRt ne6bMxW/yEC0pzYMhtEartKRGZEJb+SWuwS0+49CxQHIlGOIO50yZFs0CURaTrPAsb nBHsa5X04GSLQ== Received: by mail.kernel.org with local (Exim 4.94.2) (envelope-from ) id 1left7-000SBX-TN; Thu, 06 May 2021 17:26:05 +0200 From: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , Jean-Christophe Trotin , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, Jonathan Cameron Subject: [PATCH v5 08/25] media: sti/hva: use pm_runtime_resume_and_get() Date: Thu, 6 May 2021 17:25: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. 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. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab --- 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; } -- 2.30.2