Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp2027094pxy; Sat, 24 Apr 2021 03:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySKDanrbRGnTFP7tr+laj+MOi6Fb3ZKAfXMoYRuqu6GwK0LzJ5zM1Yr4McqryfTarAsBpV X-Received: by 2002:a17:90a:a781:: with SMTP id f1mr9509409pjq.57.1619258494279; Sat, 24 Apr 2021 03:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619258494; cv=none; d=google.com; s=arc-20160816; b=0iAL+ZxlNqB1kplzClSvp3/EdsYncNtUIqUKT6MQDa0Gvab8kepNxDikRu3gDli8mI YjpjO2YjI+fQH/rcoK19R+vzuYQXzBwWHwbTwE0wj+cfAj+7HDz5ptYg66CxWjOLivi6 SEe3+/o8dVhxqKIjhJti9VF/BWCAoR9Q+W84bPAoegbpgsj1SGelZz8VuPj1ToXF6YS0 h4yU+w6ihWZXADWvmgIb0peb+Rm5bkdtUnsGlMk5G1k0YgwYjS3GjCsuwC6ouLRf2Up1 RQSIbcKlh5Z3vIaadeJOH6Lh4OgCzEds7QO6yQIYzgI+GvTQ1c+K8ULnbNMaQlgpMzyi SO2Q== 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:dkim-signature; bh=M4elDPIHf/Y4ovxC3YIoR3rfvNjX/hok/S+kabExW1Q=; b=PZKUAcVzjED1chNRvkKpYXMKARWzhIWZrnTHNHMv9nt1zxvbvAftfrp4CVc9l+cVUv wJkiZEmRYKThCUcT0wp5zxBLkF+4gM2WOMorVPYFdt1Uo86rQEh3HLzEeQm8oo7nd7dB vMCvsC/xnIK0wQ52FtRkeCA3P3WyJOWVl7nEtaPqa4Mnffn7rlDEo5lfgMCopzr12wfN YqGasiWEJNVHMgOzwg5Z+hl2BnZUbBGzhEjE29/8bqyt4WaqPAD556XmzZ5qxIDbFJK2 4cqTavR0gkQfjiOyc7yRf1vZeEuy1H9eSrKBJidqmNXOoLF8TUzvSxpzwg2Mdufj0IYy Mp+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pwpDYIPN; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si10342171plo.239.2021.04.24.03.01.21; Sat, 24 Apr 2021 03:01: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=@kernel.org header.s=k20201202 header.b=pwpDYIPN; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232048AbhDXKBP (ORCPT + 99 others); Sat, 24 Apr 2021 06:01:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:40584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229848AbhDXKBO (ORCPT ); Sat, 24 Apr 2021 06:01:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BE3F61184; Sat, 24 Apr 2021 10:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619258436; bh=xpqWyIBQQdTi83NwQGIXV4Il7t/xyfvadRSbg8U1WH8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pwpDYIPNP6ueqeqGdf8U6NHfSVA9thFHwZvlmkQCIUcIPeV1u/hDXMYdiedj1C4JR t75HQKgc+3tQEUTkVVHNmiqrxkeOYUARH3wpJUgwnb5VH5BvETD4J/aAX+0F/mCdWv LLRtEG3d3meZqN7/ON7AOAQor+ingX1ai5WyPnZnPa9h2niphQs+IjJLwHSlrif6Fo 0U1s7gQx3ORwHxr81ROyWX3yNTXnruCY+U47AuzkqTONBqepkxYjmNKeDUU2yssLqE Nnev0tnU7ZSFkzPQ6FuBZd5rGEvX0bVnzSWp8LS04nRrDo6gAzHNbbJgSBne0AoOqT BAptY8daVShKw== Received: from johan by xi.lan with local (Exim 4.93.0.4) (envelope-from ) id 1laF5i-0001oZ-Pk; Sat, 24 Apr 2021 12:00:47 +0200 Date: Sat, 24 Apr 2021 12:00:46 +0200 From: Johan Hovold To: Jacopo Mondi Cc: Mauro Carvalho Chehab , linuxarm@huawei.com, mauro.chehab@huawei.com, Hans Verkuil , Jacopo Mondi , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH 38/78] media: i2c: mt9m001: use pm_runtime_resume_and_get() Message-ID: References: <20210424082454.2ciold3j3h2jw47m@uno.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210424082454.2ciold3j3h2jw47m@uno.localdomain> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 24, 2021 at 10:24:54AM +0200, Jacopo Mondi wrote: > Hi Mauro, > > On Sat, Apr 24, 2021 at 08:44:48AM +0200, Mauro Carvalho Chehab wrote: > > 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. > > > > Use the new API, in order to cleanup the error check logic. > > > > Signed-off-by: Mauro Carvalho Chehab > > Thanks > Acked-by: Jacopo Mondi > > I should re-work the error handling sequence there on top of this > patch as right now it's not the best, that 'done' label bothers me... > anyway, for later. > > > --- > > drivers/media/i2c/mt9m001.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c > > index 3b0ba8ed5233..57e15a291ebd 100644 > > --- a/drivers/media/i2c/mt9m001.c > > +++ b/drivers/media/i2c/mt9m001.c > > @@ -217,9 +217,9 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable) > > goto done; > > > > if (enable) { > > - ret = pm_runtime_get_sync(&client->dev); > > + ret = pm_runtime_resume_and_get(&client->dev); > > if (ret < 0) > > - goto put_unlock; > > + goto unlock; > > > > ret = mt9m001_apply_selection(sd); > > if (ret) > > @@ -247,6 +247,7 @@ static int mt9m001_s_stream(struct v4l2_subdev *sd, int enable) > > > > put_unlock: > > pm_runtime_put(&client->dev); > > +unlock: > > mutex_unlock(&mt9m001->mutex); > > > > return ret; > > @@ -834,7 +835,7 @@ static int mt9m001_remove(struct i2c_client *client) > > { > > struct mt9m001 *mt9m001 = to_mt9m001(client); > > > > - pm_runtime_get_sync(&client->dev); > > + pm_runtime_resume_and_get(&client->dev); > > > > v4l2_async_unregister_subdev(&mt9m001->subdev); > > media_entity_cleanup(&mt9m001->subdev.entity); I couldn't help looking at one more now that you got feedback on this one. Here you have the same problem as the one I reported earlier, in that the usage count could end up negative on resume failure due to the later put_noidle() call in remove(). Also note that you're adding more lines than you're removing. I'd say this kind of mass-conversion is of questionable worth as pm_runtime_resume_and_get() isn't necessarily an improvement (even if it may have its use in some places). Johan