Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1099460rwb; Sat, 14 Jan 2023 14:11:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtfrkIq3WDyZY4CJ9YuPw9g524WxhiW5CBcUtsOmvr33aQkm6rJcbS9caL8OP7FZeAdZ2Bc X-Received: by 2002:a05:6402:380d:b0:47e:eaae:9a5b with SMTP id es13-20020a056402380d00b0047eeaae9a5bmr72683152edb.42.1673734316881; Sat, 14 Jan 2023 14:11:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673734316; cv=pass; d=google.com; s=arc-20160816; b=lY8zqiEnFVmJstQ2iHvJXYPED9p6w1hoFSIhHmdCX2CzN0zAc/CKcMCJ+Ni4zTbkVX lD1pwjvUarkYmRtY+Te1IJuUqRoFHGMK7o5LVdnRq721vQktkp0CRiuUTGt/Y1DcFVvi fGFct4l9WqqWy9kZw1d093KnHy2qx22fuhaYUC9SYgKL5LrD0eHhf87OHOuE/Gvkwdum OW+3lktJorbsruoBeL21UnQwy392Y7mDvKyWnM9EU5gg1n6UBCNuUbWx/P3LaTVEmHcU ESubqhBJ7VeOdAObDmHIusIQBI0UZ6x+Z1DrznLxGOqTnNQRxiPENS0Ni7rl6DPGo2Qd fH9w== ARC-Message-Signature: i=2; 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=N7hLwEJw4Pb7qb2KhIKkhf2vUiG3X5VhrWk9rvmzvPY=; b=LysOr4sakjaIZZpaKampel27+9G8JWVvUVt+S7GHbvgypPFum3/fZPcx3tcDbwIy2U 5IDwGQsjsXs7danHyUkmqmPTQL/yFkeXQeMPRVcxRilVyM9BB8vZhVO+bQYjsPXugUwp uHEMCLhLsOvu+uIK09NHQ9fPZYakXflVbkgPJPo5i3FijhFpCN+06jdO54wCaNCF60jM j07Uwp8+l9cOyM4aGrVGMhSO2kVIGFyTBVdayNXbbIGD1ma2PEkn6HKk7fSTsdFLKAgY wG6UM5LugdFpQ+uiXjogiL8456lu04bprHBa5LsRyOXOHSbDMK8LP5hkhu5EF47MvUA6 H62w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=nhqhLjQT; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a056402280600b00486a1eddd65si502580ede.125.2023.01.14.14.11.43; Sat, 14 Jan 2023 14:11:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@iki.fi header.s=lahtoruutu header.b=nhqhLjQT; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230513AbjANVtN (ORCPT + 54 others); Sat, 14 Jan 2023 16:49:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbjANVtH (ORCPT ); Sat, 14 Jan 2023 16:49:07 -0500 X-Greylist: delayed 36696 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sat, 14 Jan 2023 13:49:05 PST Received: from lahtoruutu.iki.fi (lahtoruutu.iki.fi [185.185.170.37]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49D319EDF; Sat, 14 Jan 2023 13:49:05 -0800 (PST) Received: from hillosipuli.retiisi.eu (dkwgw2td6j41r63crh2zt-3.rev.dnainternet.fi [IPv6:2001:14ba:448b:2b40:7a3e:2aed:5c4e:35a9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sailus) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id DDC4F1B002E5; Sat, 14 Jan 2023 23:49:02 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1673732943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N7hLwEJw4Pb7qb2KhIKkhf2vUiG3X5VhrWk9rvmzvPY=; b=nhqhLjQT0fLgQJW1voOwxafw7q0M1KeoEJsZUW1a6FLutkQMk1DOlcnROZTMJYEkbMFz9T 2hUkh0UN+hIovAaApPt0tjZdkEUpORAZ+puZZh5wP90AryXrl1P+OuJmeyclbFY2N5/01d M9dbyjvINCH2BgVttCfU3IoD3TzezYC/ZRW4/IY4nqIWGDm1EkE3PhgjqU5PjKVefyQt4I MmiLs5avL5wWTjOrLfR8FqcOSJP/TcWBnNY8mlW0MtRkwnCn5DQNYBcRBgnSYZEkvlWqTy OmIm0nHkEDA3/OTqsyvU4Y9mY5PrKz9nqF1xKIzqxM3m+QFSb44Jn99WJqV8/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1673732943; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=N7hLwEJw4Pb7qb2KhIKkhf2vUiG3X5VhrWk9rvmzvPY=; b=IgIeVSwnpc1Wx/CAsLAUlwujHbXTuObgfgmSEIiebc699UcKXASR2KJ43+ARVlK4x4hXEI BpCwB/V0LCtF2wZR7Tlh80STTPSfzC+zvSGpm0podoOJ5uZBOnHwwYa3Cz6jaD1rDGXsjr tqyfkQuGYAl98Bcq/PWjT0K3JQCHJVuwzBSpNce5UjezClnTQ862IH0kYjolYp/d0wxu7H q8frsbLmwDVpMCVgJRcWzOvSa7Zp7txwvaitq1hduAdIOo8Odqkd02ETX4+cpNpAPqWGpu DAryGU6Dcv4oJb7BA/e7GdCj98S1K0j342sd+f0BEs5H/SLp3os+m1W9panw3A== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=sailus smtp.mailfrom=sakari.ailus@iki.fi ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1673732943; a=rsa-sha256; cv=none; b=m7KRI8Qr3qiNKxvJ2oKy5mtphFMEuKqm2PAOODaiQ1vjXCV/QEDeqT0ds8ydvpEBQjlGVL HbfqaMMh5rQqogkI5WomXlFd5xT/0MJcsSyUMDjc9QYdkxafeB0El0i0EHLpE49xh0YnZK UtW0WLKaKQ2vm/AXgLRcx7p3a8vzTxk+LwZhcltfGYTsch4ktKGgT40YdZinYOt/4srdov 9zodTdVL4y+p2p4aBsy0U1akgnLHfOEB9YTPT+EXUEdzvYR1gVCOtyRfLFDq0Dk7Zurstd zutwpyOznZR/yV1KMInb1n4Rbip/nDvixlOrLYRVipNeRugUiDGomQHcciixFA== Received: from valkosipuli.retiisi.eu (valkosipuli.localdomain [192.168.4.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by hillosipuli.retiisi.eu (Postfix) with ESMTPS id 5C92B634C91; Sat, 14 Jan 2023 23:49:02 +0200 (EET) Date: Sat, 14 Jan 2023 23:49:02 +0200 From: Sakari Ailus To: Jacopo Mondi Cc: Andrey Skvortsov , Steve Longerbeam , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: ov5640: Update last busy timestamp to reset autosuspend timer Message-ID: References: <20230114112109.982005-1-andrej.skvortzov@gmail.com> <20230114151906.gkgmhzpq64dhwouu@uno.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230114151906.gkgmhzpq64dhwouu@uno.localdomain> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jacopo, On Sat, Jan 14, 2023 at 04:19:06PM +0100, Jacopo Mondi wrote: > Hi Sakari > > On Sat, Jan 14, 2023 at 02:29:14PM +0200, Sakari Ailus wrote: > > Hi Andrey, > > > > On Sat, Jan 14, 2023 at 02:21:09PM +0300, Andrey Skvortsov wrote: > > > Otherwise autosuspend delay doesn't work and power is cut off > > > immediately as device is freed. > > > > > > Signed-off-by: Andrey Skvortsov > > > --- > > > drivers/media/i2c/ov5640.c | 9 ++++++++- > > > 1 file changed, 8 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c > > > index ac35350..f71c0f7 100644 > > > --- a/drivers/media/i2c/ov5640.c > > > +++ b/drivers/media/i2c/ov5640.c > > > @@ -1238,6 +1238,7 @@ static int ov5640_write_reg(struct ov5640_dev *sensor, u16 reg, u8 val) > > > return ret; > > > } > > > > > > + pm_runtime_mark_last_busy(&sensor->i2c_client->dev); > > > return 0; > > > } > > > > > > @@ -1305,6 +1306,7 @@ static int ov5640_read_reg(struct ov5640_dev *sensor, u16 reg, u8 *val) > > > } > > > > > > *val = buf[0]; > > > + pm_runtime_mark_last_busy(&sensor->i2c_client->dev); > > > > I wouldn't add these calls to register accesses. It's generally relevant > > with autosuspend_put(). > > > > The rest seems fine to me. > > > > Does it mean the same should be done for the all the sensor drivers that > use autosuspend ? I count 8 of them, not a huge number. pm_runtime_mark_last_busy() should be called before pm_runtime_put_autosuspend(). I was thinking of adding a helper that would simply call both of them. We don't have that yet though. > > > > return 0; > > > } > > > > > > @@ -3615,6 +3617,7 @@ static int ov5640_g_volatile_ctrl(struct v4l2_ctrl *ctrl) > > > break; > > > } > > > > > > + pm_runtime_mark_last_busy(&sensor->i2c_client->dev); > > > pm_runtime_put_autosuspend(&sensor->i2c_client->dev); > > > > > > return 0; > > > @@ -3702,6 +3705,7 @@ static int ov5640_s_ctrl(struct v4l2_ctrl *ctrl) > > > break; > > > } > > > > > > + pm_runtime_mark_last_busy(&sensor->i2c_client->dev); > > > pm_runtime_put_autosuspend(&sensor->i2c_client->dev); > > > > > > return ret; > > > @@ -4034,8 +4038,10 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable) > > > out: > > > mutex_unlock(&sensor->lock); > > > > > > - if (!enable || ret) > > > + if (!enable || ret) { > > > + pm_runtime_mark_last_busy(&sensor->i2c_client->dev); > > > pm_runtime_put_autosuspend(&sensor->i2c_client->dev); > > > + } > > > > > > return ret; > > > } > > > @@ -4203,6 +4209,7 @@ static int ov5640_probe(struct i2c_client *client) > > > > > > pm_runtime_set_autosuspend_delay(dev, 1000); > > > pm_runtime_use_autosuspend(dev); > > > + pm_runtime_mark_last_busy(dev); > > > pm_runtime_put_autosuspend(dev); > > > > > > return 0; -- Kind regards, Sakari Ailus