Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1032902ybs; Mon, 25 May 2020 05:42:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl/Io6oXOoVqreehtnrOPxQn4K9avhA+aip5Vxicfw42fPT/6WT6tHk9aXHs94enIXzWd3 X-Received: by 2002:a17:906:4113:: with SMTP id j19mr18220081ejk.144.1590410521337; Mon, 25 May 2020 05:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590410521; cv=none; d=google.com; s=arc-20160816; b=exQkxgPI5BSyBCoNB2uCUXCho5zVaSWLklhrEuDyldxrPR7x2mGjS7xixTZClVUsRJ AoFSLjmlu4NXtLMNoMkInGnB/YeAbfk4LaoOvs7RnpgDBsP5RMu3qcNhyNfibOWQLCPA VRtZ10d1tvN5AoSLXZFGHhEpPy5ks/F23pMGCJOoWnQjgloDV8u9EvKOm45G41CvmgeS mJnRxPmKzu5uXAl++ke+/tSiollE/JLRqbzJ2Eh8QW7Bk8VklqND8+d79MzSKhKSuoEY Ldc9a6nEIlc4OsnmDg9/arNclTqAo9mEyGEB0hoM0Ykzr/Ez74KiiATHmRIhTrIpwyRi yLdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=n8NhEWQflHVpdItN9qEemJbps+O9DfXRKOuO5rWileo=; b=kJJckwumJ7uKL+pm2gfdeC/1G7oW9HIBet/Rz9FjTbtO1SM4ZLOSV+hPhqUmRSOTY2 mGSbxWrSmeymQWz83YFEXgNgl/P85h34PtM4/v6GOeMK/lzE6ez+Vjdge2jncIst6HSh Is0Vsx4RGLMNgMzQ20GVZxvVPK0gSFfvJf+CPWjw6RR0t0qjt5p6JpFKDmYlxxyqtz9V hr78mAKyWWvE/iJ5+fAE2nwrFUdToWpefCiECzaIzv0wiQNXGd+JbwObX2lasjsXfqnk McTwVpSqu40Tv9LH1ad743l8l4FY/18O2LXeqfhqxC9UNd6RWUMQ+ivHKO5vwqAktR2u YABg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si8516987edk.69.2020.05.25.05.41.37; Mon, 25 May 2020 05:42:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390564AbgEYMi7 (ORCPT + 99 others); Mon, 25 May 2020 08:38:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390488AbgEYMi7 (ORCPT ); Mon, 25 May 2020 08:38:59 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E3F3C061A0E for ; Mon, 25 May 2020 05:38:59 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jdCNR-0002xS-7D; Mon, 25 May 2020 14:38:45 +0200 Received: from pza by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1jdCNK-0004LN-Ul; Mon, 25 May 2020 14:38:38 +0200 Date: Mon, 25 May 2020 14:38:38 +0200 From: Philipp Zabel To: Dinghao Liu Cc: kjlu@umn.edu, Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: coda: Fix runtime PM imbalance in coda_probe Message-ID: <20200525123838.GA12983@pengutronix.de> References: <20200523100332.32626-1-dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200523100332.32626-1-dinghao.liu@zju.edu.cn> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 14:21:25 up 95 days, 19:51, 121 users, load average: 0.21, 0.19, 0.19 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: pza@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dinghao, thank you for the patch! The first part is fine, but I think the second part is not necessary, see below: On Sat, May 23, 2020 at 06:03:32PM +0800, Dinghao Liu wrote: > When coda_firmware_request() returns an error code, > a pairing runtime PM usage counter decrement is needed > to keep the counter balanced. > > Also, the caller expects coda_probe() to increase PM > usage counter, there should be a refcount decrement > in coda_remove() to keep the counter balanced. coda_probe() increments the usage counter only until coda_fw_callback() decrements it again. Where is the imbalance? > Signed-off-by: Dinghao Liu > --- > drivers/media/platform/coda/coda-common.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/media/platform/coda/coda-common.c b/drivers/media/platform/coda/coda-common.c > index d0d093dd8f7c..550e9a1266da 100644 > --- a/drivers/media/platform/coda/coda-common.c > +++ b/drivers/media/platform/coda/coda-common.c > @@ -3119,6 +3119,8 @@ static int coda_probe(struct platform_device *pdev) > return 0; > > err_alloc_workqueue: > + pm_runtime_disable(&pdev->dev); > + pm_runtime_put_noidle(&pdev->dev); These seem right, they balance out the pm_runtime_enable() and pm_runtime_get_noresume() right before the error. > destroy_workqueue(dev->workqueue); > err_v4l2_register: > v4l2_device_unregister(&dev->v4l2_dev); > @@ -3136,6 +3138,7 @@ static int coda_remove(struct platform_device *pdev) > } > if (dev->m2m_dev) > v4l2_m2m_release(dev->m2m_dev); > + pm_runtime_put_noidle(&pdev->dev); I think this is incorrect. There is one pm_runtime_get_noresume() in coda_probe(), and one pm_runtime_put_sync() in coda_fw_callback(). By the time coda_remove() is called, balance is already restored. regards Philipp