Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1715931rdb; Mon, 8 Jan 2024 08:03:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIhedjo+HgLwaGWiYRZs0VFefQmbDzqyC/yLg4HlrYltT0zQ/U7uV4eNI66QLZl2Q0wy6o X-Received: by 2002:a17:906:b0c6:b0:a28:65ce:21a9 with SMTP id bk6-20020a170906b0c600b00a2865ce21a9mr744219ejb.292.1704729820421; Mon, 08 Jan 2024 08:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704729820; cv=none; d=google.com; s=arc-20160816; b=jXFzQIwiyDeJlB78qJssyi/ihp5KUtwk7/dy861v6bL74T/2lYYFHibeIY4mJRN0Ni BfX+foXzZElXewV+cJ4Tx3oDre+ICbuBzM6BJfg3G+y+hSY7vmgChJ812DlQjzEXnWm/ LltfSYXeDwkGprDVuKNICP2+dfx3/nI1jpeYBOi3L0QyM/BFbKkX9BMErqeMiDg13R/6 Ghx9ikTJvGCldX0ehusDm2Xu63n+cIk0d9c03xAo7lg3E0rS1oSC2KfUpFd9NGfV717C X0kw7BRKPepXrwCBGD9TE0UNyjRlvGqSRUapmQIN/TThJX6m23c+8gDf6M5rGJ/vix3G VKkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ts8gymdxNkfeyy/vYbTYXt3oKxpISLx0cXCHps/4UMo=; fh=xnV+MkYQZQNvR+dgmQYH4RbFbw4nFc7lAxPI9VtfbD8=; b=Z0r0LkC6QFeTEmS5RM2KBcdgQ3iOiAF6egOO7E+W8MC1EiCt1Kpcy4KT+ugPBvdzxr 2R4BTHWF2+l5qzocG4oXKGU2L9i6V4s6h1pAkIULpUebKfskjZYsHYDMmUUygQHp/DUs cn6EWkawHKqZ4SkmkF7w2nhG+zfe4GrZr0ANdAqQMtacFt+SivjmhqVvNcIRZd53i+rG K/MeSXV1qxnFOmAL1AFPv+r84+jKb4cn/MbaVrZObtdwKc+pfkJyOsw+2vcF6GMkn7z+ PzWSYEuUSYVuhFLrJSP8GEooaT9LCNxun5nBsvL6jUJqIUy2BpjEWXuVatNVnsbjO4GU lsRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IQHlGjSV; spf=pass (google.com: domain of linux-kernel+bounces-19814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19814-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id cf15-20020a170906b2cf00b00a2af02c94f4si26365ejb.259.2024.01.08.08.03.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 08:03:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IQHlGjSV; spf=pass (google.com: domain of linux-kernel+bounces-19814-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19814-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2C5481F234F3 for ; Mon, 8 Jan 2024 16:03:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F264D524CD; Mon, 8 Jan 2024 16:03:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IQHlGjSV" X-Original-To: linux-kernel@vger.kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D195524A8; Mon, 8 Jan 2024 16:03:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1704729808; x=1736265808; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=CKxV7cW/dr88DaCe3HV5TLid9v8tv0V60AXriv3nGP8=; b=IQHlGjSVXqguU2+LpC2Etofv7rlnlOBvo4eREZidl+OKLYGnekuHWhR7 kaw5NZeyuyj3koJHDw3TUBTCBklSvbh9MkvPg0DBbDMp0b5Eg5rvzdxFU gyXnRvLs/tmLXffUcA3r9/B2JKSmxcLpnloVt2ftKd1cMfHLsHtrTBh11 9NWlkzzZPIKta6+pQ96DrGjCXn6wuP+H2OQ0GZh1U5abbXJhCzw+1JpRP glUDvSnoJa89cdnXEcGtREBJFQhL8Zk1dVP4B9gPM8EwXKBREiN4ZFb6+ bFXrBSCsV0NDPBb3q7KY6TMse4vQSVUXorSXXi3zG4p722a0aiYy/iNkV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="5291062" X-IronPort-AV: E=Sophos;i="6.04,180,1695711600"; d="scan'208";a="5291062" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 08:03:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10947"; a="757657915" X-IronPort-AV: E=Sophos;i="6.04,180,1695711600"; d="scan'208";a="757657915" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jan 2024 08:03:23 -0800 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 5640911F913; Mon, 8 Jan 2024 18:03:20 +0200 (EET) Date: Mon, 8 Jan 2024 16:03:20 +0000 From: Sakari Ailus To: Mikhail Rudenko Cc: Sakari Ailus , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab Subject: Re: [PATCH v2 09/20] media: i2c: ov4689: Use runtime PM autosuspend Message-ID: References: <20231218174042.794012-1-mike.rudenko@gmail.com> <20231218174042.794012-10-mike.rudenko@gmail.com> <878r4z4ysb.fsf@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <878r4z4ysb.fsf@gmail.com> Hi Mikhail, On Mon, Jan 08, 2024 at 06:06:52PM +0300, Mikhail Rudenko wrote: > Hi Sakari, > > Thanks for the review! > > On 2024-01-08 at 11:18 GMT, Sakari Ailus wrote: > > > Hi Mikhail, > > > > On Mon, Dec 18, 2023 at 08:40:30PM +0300, Mikhail Rudenko wrote: > >> Use runtime PM autosuspend to avoid powering off the sensor during > >> fast stop-reconfigure-restart cycles. > >> > >> Signed-off-by: Mikhail Rudenko > >> --- > >> drivers/media/i2c/ov4689.c | 22 +++++++++++++++------- > >> 1 file changed, 15 insertions(+), 7 deletions(-) > >> > >> diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c > >> index 5300e621ff90..64cc6d9e48cc 100644 > >> --- a/drivers/media/i2c/ov4689.c > >> +++ b/drivers/media/i2c/ov4689.c > >> @@ -407,26 +407,27 @@ static int ov4689_s_stream(struct v4l2_subdev *sd, int on) > >> ov4689->cur_mode->num_regs, > >> NULL); > >> if (ret) { > >> - pm_runtime_put(dev); > >> + pm_runtime_put_sync(dev); > > > > Why are you switching to pm_runtime_put_sync() here? That isn't covered by > > the commit message (nor I think should be done). > > PM autosuspend conversion was suggested earlier by Laurent in his review > of this series [1], and he adviced looking at how it was done for the > imx290 driver. I followed along the lines of the corresponding patch > [2]. Ah, I suppose all of these are error cases. I suppose it won't do any harm in this case but it's not really useful either. You can get more benefits from autosuspend if you can avoid writing registers that already have the same values you're writing to them. Thay may be better left outside this set as it's already fairly big. > > >> goto unlock_and_return; > >> } > >> > >> ret = __v4l2_ctrl_handler_setup(&ov4689->ctrl_handler); > >> if (ret) { > >> - pm_runtime_put(dev); > >> + pm_runtime_put_sync(dev); > >> goto unlock_and_return; > >> } > >> > >> ret = cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, > >> OV4689_MODE_STREAMING, NULL); > >> if (ret) { > >> - pm_runtime_put(dev); > >> + pm_runtime_put_sync(dev); > >> goto unlock_and_return; > >> } > >> } else { > >> cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, > >> OV4689_MODE_SW_STANDBY, NULL); > >> - pm_runtime_put(dev); > >> + pm_runtime_mark_last_busy(dev); > >> + pm_runtime_put_autosuspend(dev); > >> } > >> > >> unlock_and_return: > >> @@ -606,7 +607,9 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl) > >> break; > >> } > >> > >> - pm_runtime_put(dev); > >> + pm_runtime_mark_last_busy(dev); > >> + pm_runtime_put_autosuspend(dev); > > > > Also note that with runtime PM autosuspend, you have to use > > pm_runtime_get_if_active() instead of pm_runtime_get_if_in_use(). > > Noted, will do so in v3. > > >> + > >> return ret; > >> } > >> > >> @@ -877,8 +880,10 @@ static int ov4689_probe(struct i2c_client *client) > >> } > >> > >> pm_runtime_set_active(dev); > >> + pm_runtime_get_noresume(dev); > >> pm_runtime_enable(dev); > >> - pm_runtime_idle(dev); > >> + pm_runtime_set_autosuspend_delay(dev, 1000); > >> + pm_runtime_use_autosuspend(dev); > >> > >> ret = v4l2_async_register_subdev_sensor(sd); > >> if (ret) { > >> @@ -886,11 +891,14 @@ static int ov4689_probe(struct i2c_client *client) > >> goto err_clean_subdev_pm; > >> } > >> > >> + pm_runtime_mark_last_busy(dev); > >> + pm_runtime_put_autosuspend(dev); > >> + > >> return 0; > >> > >> err_clean_subdev_pm: > >> pm_runtime_disable(dev); > >> - pm_runtime_set_suspended(dev); > >> + pm_runtime_put_noidle(dev); > >> v4l2_subdev_cleanup(sd); > >> err_clean_entity: > >> media_entity_cleanup(&sd->entity); > > [1] https://lore.kernel.org/all/20231211181935.GG27535@pendragon.ideasonboard.com/ > [2] https://lore.kernel.org/all/20230116144454.1012-14-laurent.pinchart@ideasonboard.com/ > -- Regards, Sakari Ailus