Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp968757rbd; Fri, 23 Feb 2024 09:00:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU7aY1E1Fcfjz5nptaNG49H5SkzUCWn3AtX0TZACAE5dOptTsp9b3Y/zBQqELZ8IV5tfD73hVmkWW1mmELan2QWwBGKeiq+dAbcsHkC4A== X-Google-Smtp-Source: AGHT+IEKxvimdDy0OazxJQC28Rn9YAmP/ieXvIqwb6AsoVfoZZYU5zDnA9jO0pyvS05kb+LKmXON X-Received: by 2002:a05:6102:1892:b0:470:5667:5d6a with SMTP id ji18-20020a056102189200b0047056675d6amr398153vsb.27.1708707645460; Fri, 23 Feb 2024 09:00:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708707645; cv=pass; d=google.com; s=arc-20160816; b=PEJyyAUvxwrZ2VKzMyZqN+z53/8Dk4bHu/IhsJmVxZhn/v23XhoP0KLQgsOXbS8e4S CYT7LVfkgh7XhgTpbbIJa0ZxeBrG0dL+AXZZkzjq6jfYzVCMpEmWyicAAluO1hiiWXwk jGwDE5IQaJwr0j+nwgc+RJRMSJII/1nqj9fF3V/okEL+acMijLMxCoYOE1NJ1I3jHu1i Ho+xJEp7T+k5vctK0sn9BRN6CIRbX1pSVewLOYQ0O6a3HPcAkrUb8Qbo+eF3IQ5ZS2Yx +3BizHEo/7Rzl7m29paEcSX/6c1gZu71thoskCrVxqkNoeTTH70tdcAXBpiQOf6I+1WQ hxNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:in-reply-to:date:subject:cc:to:from:user-agent :references:dkim-signature; bh=KdZCvZnQvtvoXFrprhSZehsA4lrftV7UQsxYXFE5r3k=; fh=7NE/Ab36zdmGTg3/EsiGVuEi3UZaQOsGOh5EMfnL5VM=; b=O+qolhUaS+6N5J2ftFuXDMFhoTzJG3HzEpe2DRSLwGnUTkthgjhLzgZ4JVSa8HVS2H RW+GW6qnky+FLGq5QzRL5dwApQHG6VdQAwvpVlM5x/6D354P784imSW2e7LDAaJA1urs 2H255Tt90REL0hIEKokHin+yt1D8XS4FObIx0fAbRfhUnkXgtgh1d5i8YkQt2b3ue7dK gIoCjhZrT1HrUY3OEa4MAq1VtschYcfXEcxpcIwHjIFbzwgq01ZtHq1xUlCNKZzV8OGJ nom5MdItRIu569QViLWJRhvoN0nX0Ku7E/x1EQYjrqCYLzTBrJgHqfCyzL+IktED1+B/ rn1Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SJTgMIab; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v19-20020a056102331300b0046d22a15aa7si2607914vsc.268.2024.02.23.09.00.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 09:00:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SJTgMIab; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-78770-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78770-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 057B71C23CEB for ; Fri, 23 Feb 2024 17:00:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C75E41292DF; Fri, 23 Feb 2024 17:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SJTgMIab" Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 176BF1292C6; Fri, 23 Feb 2024 17:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708707632; cv=none; b=k4BfV0EV8sglukBWGrsCRpUzcFnm8GrashRVBPAngs+XEilGhLDqSFziv2BXic+t18TtWe4BMaCU9nEXzGxRb0u8G9l4N1Ab1AzlW+6/o9E9x7HF2mjH8H0CttDq2cx7NFxHPzSThLN7vQX/2tkQUR2yIJlnfQk3wzHAfA6wJdY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708707632; c=relaxed/simple; bh=DP07s/Kd4y5Nre6qJCsFlczCNJviiMGXk8qxZy4ibMM=; h=References:From:To:Cc:Subject:Date:In-reply-to:Message-ID: MIME-Version:Content-Type; b=PecNZfdT5iyPfV0UeCHipB+aAiQB1/XFutddR7D0rrgFhBqvuKGTikR1/CqAWImVRtuMR0GFVOS/AR/QtoPHkKZO6ex65Fa5+Xn/subwV8lA1aO4f8EVvpS/ESNiPvq+r1kqdO0Bg1+tQ0AXi9vfftLtPsXvz+eakzcURkh83hA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SJTgMIab; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-512ab55fde6so792491e87.2; Fri, 23 Feb 2024 09:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708707629; x=1709312429; darn=vger.kernel.org; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:from:to:cc:subject:date:message-id:reply-to; bh=KdZCvZnQvtvoXFrprhSZehsA4lrftV7UQsxYXFE5r3k=; b=SJTgMIabpAlnz4uH50iUovUdHjBJvSj8Usj1UcvUedXchcdDU1fk7yxDI0dGpVjZ5a 3h6oJ3At9Jqru45+g/klxbJIN4kkktFJaOkyV+PzF4uSTW1//haeEHllKEYkMrOI88YE ADBAQawhbtfEM5/9Ms+HdPztL2yL2YjnVFG/jKHKwuf21Ry9tit4Pu9O0Y2e2jQsDSjh XedHzrniNwr2rifZGb0N9Qwf+YUXvA31Wfc7MdaOH1Bv+j3KCPZCvNBEe8Oiie1ybWaL hY8ZXndFlLfUFxNEubYFC3yg92K+t91goqnQD3vYc9FQq/iqH5/5eBqlamFM5HrAtF0f fPcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708707629; x=1709312429; h=mime-version:message-id:in-reply-to:date:subject:cc:to:from :user-agent:references:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=KdZCvZnQvtvoXFrprhSZehsA4lrftV7UQsxYXFE5r3k=; b=IghkoEMCElNZGVIi7qPuLj4/cThjo67Qd3y8q0rOF3tKKbApB9FkNVoZKlQT+IO7jp CTVwijk5GsQLhtpm/ULfWy34Xg1+js+Igc2SOB6YxyNp2TfEPMrod775CL+fiGoqbY0u l1YvPT9LmLOSw54dybulp675DsFs8uj9zc3VjVBokr/cGlWBSuvT51gAABdoP5DaqmRH X9yf+VSoE5pYJPA057zHTwD8b3k4rJ3QuBj9JuKRLlTD8VLSlqmb2DkDe7IW4cCMgui+ 4YBco/EEz7E0YBpztJqit2QhXNpFgYZaYNwiGSYRbIhB5rjllTAyx7ZQgAeo4qSeV1ev F8zw== X-Forwarded-Encrypted: i=1; AJvYcCUiz8dOE3Yv+wzCpXnBWUDFhZ0pas23/nkufNvqs8AWsFKQR64b9FrurAno/4RKuf5unvHFMw9kv1UAIZpGcoGFwVcIUmpgjWxbAHPFurPfcFnspgYzNJqBF9kAl7cMpl3NhenSkPHJJvo= X-Gm-Message-State: AOJu0Yyc3Q/JUZt00oiXltx7rrBEaebLFBt8caHlpcsG14DY2ULnALaD 9BwqFazpck8DRwm4dKVzzCip/d/Ph821r4OgvouZRBvpFUeTVuGT X-Received: by 2002:a19:f710:0:b0:512:bd51:a0ea with SMTP id z16-20020a19f710000000b00512bd51a0eamr234006lfe.9.1708707628879; Fri, 23 Feb 2024 09:00:28 -0800 (PST) Received: from razdolb ([37.1.50.248]) by smtp.gmail.com with ESMTPSA id j9-20020a19f509000000b00512ebe08d7bsm173052lfb.290.2024.02.23.09.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 09:00:28 -0800 (PST) References: <20231218174042.794012-1-mike.rudenko@gmail.com> <20231218174042.794012-10-mike.rudenko@gmail.com> <878r4z4ysb.fsf@gmail.com> User-agent: mu4e 1.10.8; emacs 29.2.50 From: Mikhail Rudenko To: Sakari Ailus 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 Date: Fri, 23 Feb 2024 18:18:12 +0300 In-reply-to: Message-ID: <87le7bdsk4.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 Hi Sakari, and thanks for the review! On 2024-02-23 at 08:19 GMT, Sakari Ailus wrote: > 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]. > > There's no need to use the _sync() variant here. And at least it wouldn't > be related to autosuspend, were you to switch to that. Ok, will use pm_runtime_put in v3. Or do you suggest dropping this patch altogether? Laurent? >> >> >> 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/ >> -- Best regards, Mikhail Rudenko