From nobody Sat May 10 06:04:18 2025 Delivered-To: importer2@patchew.org Received-SPF: pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; envelope-from=linux-kernel-owner@vger.kernel.org; helo=vger.kernel.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1619519533; cv=none; d=zohomail.com; s=zohoarc; b=Occ2dO6VsnxCQ144Pr85bCqaak7Eso9SIkOxi3N5AT+NdrAA1moq58MqTbNsFvE7AhKGpaEwBXnDmWxH93YNC/NPviYrlBIhC7VJD2eEqFQt5T6oGBwZNucSJqBk4gMQ+3O1sNB1sLcb6ccCwdZIt4pTpBkWXFWA5FyUyvnIV+o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619519533; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ySrC2wlDMi90CsTzUZ9Z9K+attwrMxignhDqr647Jbg=; b=cnNa9lu8s2czSGLdbygolWU4SLr11Huo5ZZjP1vPpZPY3+nsLWn41VBeIrUH6+LGU2aaMEhhVlHKn3tzYc5CGXQ0891lU5KRebyRBkoydHWFNaw58NwxyyjtO899Jppdn5pw5FxLy+HX2JmfBPgX7wbor/w4Lox4eEm6JxJS5FI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mx.zohomail.com with SMTP id 161951953376087.50423363001664; Tue, 27 Apr 2021 03:32:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238288AbhD0Kcz (ORCPT ); Tue, 27 Apr 2021 06:32:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235463AbhD0K20 (ORCPT ); Tue, 27 Apr 2021 06:28:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A667861432; Tue, 27 Apr 2021 10:27:16 +0000 (UTC) Received: by mail.kernel.org with local (Exim 4.94) (envelope-from ) id 1lbKvy-000o24-9L; Tue, 27 Apr 2021 12:27:14 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619519236; bh=AWaRUuBTKGjvblFCBeNGn4e+vA3INJOtepNAWbdP4RE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9W0Vuvr6+gV8tq55gTnOpltULBX7jBEm6Dh/6niGD8yy47Wx+418XsxnqmLu+83m jAt1J/mqZ204qtaCm2SnbOO9WG6OVEJfZUTFhKwuBY7sRiL3OXGDstQv/US7JHsgID DJpqgutZJd3XiOF5JQQEbJG7TuS8xi24xubZAd6BsMX597ajD4REHoeMpnmWcUObsX Vy+mkXuR8x0zwpVtE4KkMlNCb2Y9oK5gW9dpcB8+nh2nGXAtsqAesaEaAWOT42od2u 7pc8bjEpB3RRHyBCfOTADxZAfLlkGplAhoBilztgSXIuEpLJqaofkwSGHeJbAAlgLl ifSKX3YGSsOyg== 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 Subject: [PATCH v3 59/79] media: sti/hva: use pm_runtime_resume_and_get() Date: Tue, 27 Apr 2021 12:26:49 +0200 Message-Id: <0a396696a6a6d4398a91fedde53f992035a463c3.1619519080.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal wi= th 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 --- 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/platfo= rm/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 h= va_dev *hva) struct device *dev =3D hva_to_dev(hva); unsigned long int version; =20 - 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); =20 - ret =3D pm_runtime_get_sync(dev); + ret =3D 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; } =20 /* check IP hardware version */ @@ -462,6 +461,7 @@ int hva_hw_execute_task(struct hva_ctx *ctx, enum hva_h= w_cmd_type cmd, u8 client_id =3D ctx->id; int ret; u32 reg =3D 0; + bool got_pm =3D false; =20 mutex_lock(&hva->protect_mutex); =20 @@ -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); =20 - 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 =3D -EFAULT; goto out; } + got_pm =3D true; =20 reg =3D 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_h= w_cmd_type cmd, dev_dbg(dev, "%s unknown command 0x%x\n", ctx->name, cmd); } =20 - pm_runtime_put_autosuspend(dev); + if (got_pm) + pm_runtime_put_autosuspend(dev); mutex_unlock(&hva->protect_mutex); =20 return ret; @@ -553,9 +555,8 @@ void hva_hw_dump_regs(struct hva_dev *hva, struct seq_f= ile *s) =20 mutex_lock(&hva->protect_mutex); =20 - 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; } --=20 2.30.2