From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 790B0C43460 for ; Fri, 30 Apr 2021 15:56:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44EB0613DC for ; Fri, 30 Apr 2021 15:56:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbhD3P5I (ORCPT ); Fri, 30 Apr 2021 11:57:08 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2955 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229532AbhD3P5F (ORCPT ); Fri, 30 Apr 2021 11:57:05 -0400 Received: from fraeml744-chm.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FWxfL00N1z72f4w; Fri, 30 Apr 2021 23:50:33 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml744-chm.china.huawei.com (10.206.15.225) 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 17:56:15 +0200 Received: from localhost (10.52.124.90) 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 16:56:14 +0100 Date: Fri, 30 Apr 2021 16:54:39 +0100 From: Jonathan Cameron To: Mauro Carvalho Chehab CC: , , "Paul J. Murphy" , Daniele Alessandrelli , Mauro Carvalho Chehab , , , Dan Carpenter Subject: Re: [PATCH v4 06/79] media: i2c: imx334: fix the pm runtime get logic Message-ID: <20210430165439.0000712c@Huawei.com> In-Reply-To: <10ec24ee3e3a33a4ca5c431fc19d3441d59136c3.1619621413.git.mchehab+huawei@kernel.org> References: <10ec24ee3e3a33a4ca5c431fc19d3441d59136c3.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.124.90] X-ClientProxiedBy: lhreml719-chm.china.huawei.com (10.201.108.70) 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:51:27 +0200 Mauro Carvalho Chehab wrote: > The PM runtime get logic is currently broken, as it checks if > ret is zero instead of checking if it is an error code, > as reported by Dan Carpenter. > > While here, use the pm_runtime_resume_and_get() as added by: > 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. Perhaps also call out that a fail of pm_runtime_get_sync in current code would potentially result in a spurious runtime_suspend() call whereas using pm_runtime_resume_and_get() will call pm_runtime_put_noidle() > > Reported-by: Dan Carpenter > Reviewed-by: Daniele Alessandrelli > Signed-off-by: Mauro Carvalho Chehab > --- > drivers/media/i2c/imx334.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c > index 047aa7658d21..23f28606e570 100644 > --- a/drivers/media/i2c/imx334.c > +++ b/drivers/media/i2c/imx334.c > @@ -717,9 +717,9 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) > } > > if (enable) { > - ret = pm_runtime_get_sync(imx334->dev); > - if (ret) > - goto error_power_off; > + ret = pm_runtime_resume_and_get(imx334->dev); > + if (ret < 0) > + goto error_unlock; > > ret = imx334_start_streaming(imx334); > if (ret) > @@ -737,6 +737,7 @@ static int imx334_set_stream(struct v4l2_subdev *sd, int enable) > > error_power_off: > pm_runtime_put(imx334->dev); > +error_unlock: > mutex_unlock(&imx334->mutex); > > return ret;