Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3974011rdb; Thu, 14 Sep 2023 08:12:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEMA6x7CP3o5XXcRQpIN4K26J2oTwf2sQNspyZ3jJMDnKDr8AqlI8iZzVtp/uDDjAZwg0bq X-Received: by 2002:a05:6a21:19b:b0:152:efa4:228 with SMTP id le27-20020a056a21019b00b00152efa40228mr6597743pzb.20.1694704327295; Thu, 14 Sep 2023 08:12:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694704327; cv=none; d=google.com; s=arc-20160816; b=eEwynmFZnTq8BEobvZ2SDvmehSDrryBMwRfljvsMueBuOYzvMAGmzQnVldW8HAdzpm a4fDFOr5zJ+6Fu0jbhZOXiAvjDaTXe2ovifUlmDcT+Bh3UFo6gkdai8g72aMkctDe5ov +8JgfztMwRfLc2rV+F3uYVCqzpwoIEvpFDhQtnoOGpisC14d6QV9cnaB9GAO5hmkktv2 hz//QwQKQ+WkX/7lRI8ovT5jhC+QxaU8ypRnFQFIvOsh6XC/yo2GjqIVO7kjtpaoPbUK Ok6srKOpYzr+ID6RYbe5cC33fBYhUqqi913K2vnohWxoD7I3E+hewMlYqpV1UaxG1ljs C+lQ== 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:to:from:date:dkim-signature; bh=mxn+PVoN7UhiYWM/SfM9bMz5yl8AQ8Sa4QX+Gph7Bws=; fh=XD6GFOzmUrGqcJf97y3iGy8UEFO20DNeOXHrUSQYoBQ=; b=JQkr+W1sbdZZSZvlza1eEeUjv7wTB1iPIXclfD9GR33U3IidvSrKzLdU94OyJeoHaN uwKQqwcL/cqtqD2ag2CfQ4kG2olhixXe1wMR+urEyTXNkLNLArY1tkUgCHQnpyiGOVbC AngRN4MkfDqrQaa1fiwZvjUrBDtwohjk1VIyjQSNhQVs8muk1GhteIo+jf/bptgEb3+n iAqy2dYHM1MXIg99NPcZduQdocXcmGv1SGScLbaTi7sGmajyk7QtbHTfrr/dxhe8Ksli JskhXSrntj4R527wSW9cKtbvI6sIV00Z+Z7VBbFkSfVpoephY5qngfAG+lfWm4Q6Hsy0 zD7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GHt+EvmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id d19-20020a637353000000b00573fe94635fsi1693096pgn.398.2023.09.14.08.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:12:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GHt+EvmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 593CC81F2774; Thu, 14 Sep 2023 01:55:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236298AbjINIy6 (ORCPT + 99 others); Thu, 14 Sep 2023 04:54:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbjINIyv (ORCPT ); Thu, 14 Sep 2023 04:54:51 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3407B1BEF; Thu, 14 Sep 2023 01:54:47 -0700 (PDT) Received: from ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0243910A0; Thu, 14 Sep 2023 10:53:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1694681592; bh=OH84/PBeWWziSquWHkX0+RoW9ezYH9hrzygtXuMSelA=; h=Date:From:To:Subject:References:In-Reply-To:From; b=GHt+EvmHSnNOSEqSvcK7C0MtrcIdhTgMMZM5MN1WeTxIqMm6oWH98HC2RlplnB9jg uKIcbO4SjgWI85OGiu1tnjtvBNfak9JJx1zX/RMgptgdCvjgYiQM+jQFl4x+vdc1Zb egh3er3CZu2Ddc7UgSGUAmF1iWUifZJ+VJbhLgSU= Date: Thu, 14 Sep 2023 10:54:40 +0200 From: Jacopo Mondi To: Andrey Skvortsov , Sakari Ailus , Steve Longerbeam , Sakari Ailus , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jarrah Gosbell , Arnaud Ferraris , laurent.pinchart@ideasonboard.com Subject: Re: [PATCH] media: ov5640: use pm_runtime_force_suspend/resume for system suspend Message-ID: References: <20230818173416.2467832-1-andrej.skvortzov@gmail.com> 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Thu, 14 Sep 2023 01:55:02 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Hi Andrey On Wed, Sep 13, 2023 at 11:48:13PM +0300, Andrey Skvortsov wrote: > Hi Sakari, > > On 23-09-13 15:27, Sakari Ailus wrote: > > Hi Andrey, > > > > On Fri, Aug 18, 2023 at 08:34:16PM +0300, Andrey Skvortsov wrote: > > > If system was suspended while camera sensor was used, data and > > > interrupts were still coming from sensor and that caused unstable > > > system. Sometimes system hanged during a resume. Use > > > pm_runtime_force_* helpers in order to support system suspend. > > > > > > Signed-off-by: Andrey Skvortsov > > > > Thanks for the patch. > > > > It's not been documented really how system suspend and resume should > > work for complex cameras. But I don't think it can be done by drivers > > separately as the CSI-2 bus initialisation requires actions from both > > sender and receiver drivers, at particular points of time. > > Thanks for the review. > > I've tested this on PinePhone A64. It uses DVP, maybe because of that > system suspend/resume worked good in my case. > Originally I've implemented system suspend/resume similar to this [1] > or [2] as I've seen this approach in other mainlined drivers. But some > drivers reuse pm_runtime_force_* helpers, so I've went with this. > > Do you think it would be better to use something like [2] until there > is better well defined way for system suspend/resume for complex cameras? > please don't :) https://patchwork.linuxtv.org/project/linux-media/patch/20230913135638.26277-16-laurent.pinchart@ideasonboard.com/ However... > > > > So I think we'll need to initiate this from the driver handling DMA, just > > as starting and stopping streaming. Even then, there needs to be a > > certainty that the sensor device has resumed before streaming is started. I > > recall Laurent suggested device links for that purpose, but I don't think > > any work has been done to implement it that way. .. as Sakari suggested, the driver handling the DMA should be in charge of calling s_stream() on the sensor subdev in its suspend/resume handlers. There's the risk the receiver resumes while the sensor is still suspended, and at this time there's no solution in mainline to handle this correctly. Laurent/Sakari, how should this be handled for the time being ? Laurent's patch for imx219 (and his forthcoming patch to remove the same pattern from all sensor drivers in mainline) might be opening th door for unexpected bugs as long as we don't enforce a resume/suspend ordering ? > > 1. https://salsa.debian.org/Mobian-team/devices/kernels/sunxi64-linux/-/blob/mobian-6.1/debian/patches/camera/0076-media-gc2145-implement-system-suspend.patch > 2. https://elixir.bootlin.com/linux/latest/source/drivers/media/i2c/imx219.c#L1159 Can we get a link to the receiver driver you're using in your kernel ? Thanks j > > -- > Best regards, > Andrey Skvortsov