Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp313882pxy; Wed, 5 May 2021 02:57:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfw8XeBRsP7mQTYsoepN78G88x0RGLPHU2tw8CEXsAiRXXtgV528tE/hpS3XpNCAIqU4a9 X-Received: by 2002:a65:47cc:: with SMTP id f12mr27724657pgs.252.1620208663164; Wed, 05 May 2021 02:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620208663; cv=none; d=google.com; s=arc-20160816; b=ovP6+mVjwfQUOWQobTMmWGBEHAiudJIVNJ+vBOrm0JGZqX13+uevRVqFi1MgpjETRN +sLiFe/s30OaTPwbOOSVihh6o33ov5LPJZNL2UQbWQHsEUxgO6kkhXWAYtmX/yOkcnxk iNTpewoh4IHiT88bPQEiNrqg5cSdfBHxTvnWJW5FhXu3mnPDf2hnqCt/T8up1QR0wrt3 Ing6q7nJf+tQY9JESO6F8Q3uuAWMykJmL3+7NEzwLY/1DmiQDQQGJZTGHjwHt10ZkJyp WqXnt0GOZsQM2LZm/E0OPlZ72mglL1qtKlqEEn0Sm+uRMAKqRI4s9/2pHtravy39mjvT /wFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=8Q/FNkTFfC3iBO/8UxAaRXIKCb3JDt8QvXLwcxDmXcs=; b=RnPWyzMLMLSrJafVow2KDvrP6yDZ928vK5ebhd0sc625P8eVXk/1DB7frETlPvwPpm /K6esPWccOhLJkgpO8fHP3amRbmUhq0kkQg0C2X53lelGPaBkUXn6oZ8z6V8EHnlPRDN KLX+e8QjqvmApa4t+8MvZUJGEZeniBC723zQpySd52erjrx1jDnkpJAkQmpnhXLawRDe xQi+aWlMg/vV6NycJQ7QYaPnQ3m8UsjvuxNPbRfzQ+QQy+0FsvNfBgFioYVtH0m6Kvpi io2yO/ImxcRGK0IUYfMej2cwgbstdhTkz4Ub80xDpbGgr3z+arAkD2Drz185EILjeoW9 L7KA== 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 p23si7351980pli.76.2021.05.05.02.57.29; Wed, 05 May 2021 02:57:43 -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 S232458AbhEEJ40 (ORCPT + 99 others); Wed, 5 May 2021 05:56:26 -0400 Received: from relay9-d.mail.gandi.net ([217.70.183.199]:57929 "EHLO relay9-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232331AbhEEJ4Y (ORCPT ); Wed, 5 May 2021 05:56:24 -0400 X-Originating-IP: 93.61.96.190 Received: from uno.localdomain (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) (Authenticated sender: jacopo@jmondi.org) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id AE699FF809; Wed, 5 May 2021 09:55:24 +0000 (UTC) Date: Wed, 5 May 2021 11:56:08 +0200 From: Jacopo Mondi To: Mauro Carvalho Chehab Cc: linuxarm@huawei.com, mauro.chehab@huawei.com, Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Jonathan Cameron Subject: Re: [PATCH 14/25] media: renesas-ceu: Properly check for PM errors Message-ID: <20210505095608.cpe45sljqkyeyeez@uno.localdomain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mauro, On Wed, May 05, 2021 at 11:42:04AM +0200, Mauro Carvalho Chehab wrote: > Right now, the driver just assumes that PM runtime resume > worked, but it may fail. > > Well, the pm_runtime_get_sync() internally increments the > dev->power.usage_count without decrementing it, even on errors. > > So, using it is tricky. Let's 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") > and return an error if something bad happens. > > This should ensure that the PM runtime usage_count will be > properly decremented if an error happens at open time. > > Reviewed-by: Jonathan Cameron > Signed-off-by: Mauro Carvalho Chehab Looks good! Acked-by: Jacopo Mondi Thanks j > --- > drivers/media/platform/renesas-ceu.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/renesas-ceu.c b/drivers/media/platform/renesas-ceu.c > index cd137101d41e..17f01b6e3fe0 100644 > --- a/drivers/media/platform/renesas-ceu.c > +++ b/drivers/media/platform/renesas-ceu.c > @@ -1099,10 +1099,10 @@ static int ceu_open(struct file *file) > > mutex_lock(&ceudev->mlock); > /* Causes soft-reset and sensor power on on first open */ > - pm_runtime_get_sync(ceudev->dev); > + ret = pm_runtime_resume_and_get(ceudev->dev); > mutex_unlock(&ceudev->mlock); > > - return 0; > + return ret; > } > > static int ceu_release(struct file *file) > -- > 2.30.2 >