Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1034536pxj; Sat, 8 May 2021 06:03:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzotHgvJZxJ/N+BXtdRa0HbcHe/9SXMPyb0n5uGxCMGDgROPasZWPwIz6TR9OsEKjtxzDmz X-Received: by 2002:a17:906:2c16:: with SMTP id e22mr15401172ejh.395.1620479014870; Sat, 08 May 2021 06:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620479014; cv=none; d=google.com; s=arc-20160816; b=WVfCcu/BvKs2D5VOywWfVyc+7FnGbFAqH6gXvFnSnamFSYHnZG5Nxh+kxpphZZUGRs 51dsZHX4eEtE+voNUe47chp0+0j+2PWIRfbT2a1H1Vjfsa3EwbOLKcx4rQ/ELgKJfg68 7/L7f4RTId501DdTl4Xh2ni+c2V3DEIY0Bzda2p6iISY7kZjQqQxni53SGdF8IXEkiUj kF2V75jTqueZUYhPdKr26l6jkGFwRLIuiQI1ihy5ddg3IGs2wx3/Hf8Xh+AlwJnSpcYd 0TS4uV2bKWG3Xk6RCIbZ7OY6WRqnydHLkth4EsvPP+rFVg3X1z44ahyvqUWHq8qVvrEA e2Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=m8n1RVy0uySX4EeEK2a9QiZXfMDvuOsOW8yZyEoM5m0=; b=F8FIaPFHqabTkRCYrqo7IG0WoyqmUmLaRy1ES3gg8h8HbEr82A8MSPUJJiHuiK5Va8 uFvOde1FsniomQXPkFCiITx908ZrP1sJxe54WIoqqOYKqz6hOL3i4cGXBdhfWC+Mtwgd T5J/uyyo0uct2U3VRoW/WpX6XElXvBE9EWsliD5eiO8pwwVg4u//epecp7L9zdn3ZC3q U4qKkHWexIskmBG4f3Mv0oJ2PoJoorhxXeSFhu04MB4wpDgZJVkqkhf31qUkIX4bMgbd eJsq/VrfX4nm/dn94gMWl3BpSI8MndAG2HM43042lZBNylvG9QFkG4PpS/n4AhLMLolk rSyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LIyOTWm4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si7721618ejs.275.2021.05.08.06.03.11; Sat, 08 May 2021 06:03:34 -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=pass header.i=@gmail.com header.s=20161025 header.b=LIyOTWm4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231135AbhEHNDW (ORCPT + 99 others); Sat, 8 May 2021 09:03:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230438AbhEHNDU (ORCPT ); Sat, 8 May 2021 09:03:20 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3113C061574; Sat, 8 May 2021 06:02:17 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id 15so15589391ybc.0; Sat, 08 May 2021 06:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m8n1RVy0uySX4EeEK2a9QiZXfMDvuOsOW8yZyEoM5m0=; b=LIyOTWm4CuS3iXqrOiO7M5nyflSltv/6B9Az6rQX22H6hVA7q+hF+Uc66rRdUN/djp R8t4R3Nlg6Wh/jNfSZfP3zfRE93jw8oqTom2lb7+dkedDfZ58CEDe1RC3+27chOYHuB/ kDXWLzKT6COm1KHDAnhbe0ZrxHDhjMFqNYePkBv0kGnIw4PIERACivg63B6uahmysh5q dzjI3ean2/2knd3ctBmToy82Iqmw/MjZ2fBQdDJNirhBtl8laTmbed2ZFgx/5BmKAvs1 Qowgqz2BJNXqJ+SjTmCWIPU48xe/JDXbZD/xM5+jDoDA+lTVBd7/7u0VQDqbiNq9Ah1U jlWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=m8n1RVy0uySX4EeEK2a9QiZXfMDvuOsOW8yZyEoM5m0=; b=OMazGBUvtHPL3Ko93eivJuPRrKGZxsH+3nGAQ0rAvhL7QqiLUR7iI8ViPmNX0CKu9F /6A0crrMJdWp6oaQF5ji8fKc6vABjDDiqxy3Yl+MdLXi/TQs1h7/eSK3l10ew2aPn3K6 QRNyc1BkcYg3VhLbpIkc2Ve1lvV0gKFWKXgR6h8qP81aLWX58gmy4SSrahbDa7CnN0pc XMkdXSQv/JrSv+SGbRLJsg8GAxtEPo/LRqwG5rfEO/67I7pOXBOhgb9EgSnZxsPWKtpy 3EQkvnFstVcFtyInWqon7gQ5Mz5IRGTpVHBV12ZJQcGevMw10EBvUOzGj/PKCqKDD2Vg bqvQ== X-Gm-Message-State: AOAM530QfOiWXWUiX11eakGcWvXh1Y9YahBuQvxXbizT4Ghb/VBp36zP xHlxlLO3ifKpEqN2q95luhTjE2PV80iiPB9Muof3XqsyAAaeOw== X-Received: by 2002:a25:5741:: with SMTP id l62mr19739217ybb.119.1620478936935; Sat, 08 May 2021 06:02:16 -0700 (PDT) MIME-Version: 1.0 References: <8688555079cf30f5848bb020b5ecf0b0132b2c7e.1620207353.git.mchehab+huawei@kernel.org> In-Reply-To: <8688555079cf30f5848bb020b5ecf0b0132b2c7e.1620207353.git.mchehab+huawei@kernel.org> From: "Lad, Prabhakar" Date: Sat, 8 May 2021 14:01:51 +0100 Message-ID: Subject: Re: [PATCH 16/25] media: am437x: fix pm_runtime_get_sync() usage count To: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , LKML , linux-media Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, Thank you for the patch. On Wed, May 5, 2021 at 10:42 AM Mauro Carvalho Chehab wrote: > > The pm_runtime_get_sync() internally increments the > dev->power.usage_count without decrementing it, even on errors. > Replace it by the new pm_runtime_resume_and_get(), introduced by: > commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") > in order to properly decrement the usage counter, avoiding > a potential PM usage counter leak. > > While here, ensure that the driver will check if PM runtime > resumed at vpfe_initialize_device(). > > Signed-off-by: Mauro Carvalho Chehab > --- > drivers/media/platform/am437x/am437x-vpfe.c | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > Acked-by: Lad Prabhakar Cheers, Prabhakar > diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c > index 6cdc77dda0e4..1c9cb9e05fdf 100644 > --- a/drivers/media/platform/am437x/am437x-vpfe.c > +++ b/drivers/media/platform/am437x/am437x-vpfe.c > @@ -1021,7 +1021,9 @@ static int vpfe_initialize_device(struct vpfe_device *vpfe) > if (ret) > return ret; > > - pm_runtime_get_sync(vpfe->pdev); > + ret = pm_runtime_resume_and_get(vpfe->pdev); > + if (ret < 0) > + return ret; > > vpfe_config_enable(&vpfe->ccdc, 1); > > @@ -2443,7 +2445,11 @@ static int vpfe_probe(struct platform_device *pdev) > pm_runtime_enable(&pdev->dev); > > /* for now just enable it here instead of waiting for the open */ > - pm_runtime_get_sync(&pdev->dev); > + ret = pm_runtime_resume_and_get(&pdev->dev); > + if (ret < 0) { > + vpfe_err(vpfe, "Unable to resume device.\n"); > + goto probe_out_v4l2_unregister; > + } > > vpfe_ccdc_config_defaults(ccdc); > > @@ -2530,6 +2536,11 @@ static int vpfe_suspend(struct device *dev) > > /* only do full suspend if streaming has started */ > if (vb2_start_streaming_called(&vpfe->buffer_queue)) { > + /* > + * ignore RPM resume errors here, as it is already too late. > + * A check like that should happen earlier, either at > + * open() or just before start streaming. > + */ > pm_runtime_get_sync(dev); > vpfe_config_enable(ccdc, 1); > > -- > 2.30.2 >