Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3937379rdb; Thu, 14 Sep 2023 07:16:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFpIuxxGQAEet+4HNiTZP/0Qoezy1UCYaUJthx2T1IB+/RJ5/1VlC8uqwWKD5A9LhvFUwiQ X-Received: by 2002:a05:6a20:12cc:b0:137:2f8c:fab0 with SMTP id v12-20020a056a2012cc00b001372f8cfab0mr6326009pzg.49.1694700974547; Thu, 14 Sep 2023 07:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694700974; cv=none; d=google.com; s=arc-20160816; b=NC8WFZoMTmdxHEQwa03p6fznF1zMdfQ8CJVmBIz/VwtRTrF0PowoBoocFRpATFbfkM 5JYcRZbi7A/0VgLy9CK7jGDC2/Cw7x7Lt8vthRK6V+CZd/GNg6HBMSOs0zHAUG8i2CtE 26xJa8SExx1AtRSJctKdVMl4aTciNloUIsudlZ0R28cCkNH2U06TjHGbG+03k+DZNs5u +MDN433Z3Es6meuRew29NQrED4FYGLB4yiFqRLd1mubBxIV/8oApeXpznd/aXw/EBwu3 yWnd1X6f382zg5oj41TeuI+wHSBgKGXKJlQddz9lVmFpLtJBX3E47m6DA9/pPihTKuhL YM4Q== 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=Ba7e+GhfjdL0RNzRC/R3hmRxyNFzY/ymgE82gaqOEyM=; fh=/EHFwRFgf+1tg8StlhZoCLfpMn0T1jWFjUTCjVMoyIE=; b=rZA5yGIYIGP12XCSLUsLcaXCGiY/eq7xMSAF7DIlj0eWkY1+gz9qsYJbvZqqq9kuHu kxFOZj+ghRVAwC2v+TmfF02gNCBK6XraHdA+Vk2EuG5PO21dpssjNdZMqagC5YQNiBkL TwBP5huQpa4rkQD0y6JMj10c99qFOck1t0ky+KC1kTtBhZTOtMARfsZO3ATrQS/oLXMA OxcMX2rIJ9ioeWpc8RlI4OH9yWYKUc4oauGKCvTSVN6d8cby//rH7UweChybq2W4VoyQ W6DQxfUtth8KHl9uzlsbVr37LnFNOm2pkKInPwTgONZwVE2OGTNBeamhaM/OewjkWn86 S7hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UCnN+yUw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id kp3-20020a170903280300b001b55070e154si1764962plb.96.2023.09.14.07.16.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 07:16:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=UCnN+yUw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 67DB78067AF7; Thu, 14 Sep 2023 02:55:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237357AbjINJzf (ORCPT + 99 others); Thu, 14 Sep 2023 05:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236178AbjINJzf (ORCPT ); Thu, 14 Sep 2023 05:55:35 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65BF083; Thu, 14 Sep 2023 02:55:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694685331; x=1726221331; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=/Fu99T9/XDJUIk7rTU/0AQiev26FduZXA7d84BlqrDA=; b=UCnN+yUwkknq/C/WCPmYEcPiZ6+0dB9T/elWiQjMndu4jkQ/RiWFLE7x 8bcETK2Rq0dr/tmCotIzhBmQA2tW7xlar3Vr9QUInnPN5lyjRcQ20ULUU Bu+/ZRsUoKTYbq1Cn+c24/09DG68MPi1NuGO8DHWpCV7a5QFzamIeXMkW DhEMy93Vj77kzUUt+gYHSMol6/3AEOCqxsiUk9TrZRU5rDXKAXZPOHqLc HjFHx33+mnVtTY348mVFq4Wwyx+CI5Do/TwaPOv4E5YHWXd/ZkLgoXu5P p3xYXpsDgCdKBxLUT5k01PNKio4/taVssyvnxgmYGPE5j6kBA96Nma12u A==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="409860996" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="409860996" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 02:55:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="834696678" X-IronPort-AV: E=Sophos;i="6.02,145,1688454000"; d="scan'208";a="834696678" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2023 02:55:28 -0700 Received: from kekkonen.localdomain (localhost [127.0.0.1]) by kekkonen.fi.intel.com (Postfix) with SMTP id 6F4AF11FB8E; Thu, 14 Sep 2023 12:55:25 +0300 (EEST) Date: Thu, 14 Sep 2023 09:55:25 +0000 From: Sakari Ailus To: Laurent Pinchart Cc: Jacopo Mondi , Andrey Skvortsov , Sakari Ailus , Steve Longerbeam , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Jarrah Gosbell , Arnaud Ferraris Subject: Re: [PATCH] media: ov5640: use pm_runtime_force_suspend/resume for system suspend Message-ID: References: <20230818173416.2467832-1-andrej.skvortzov@gmail.com> <20230914090241.GA2504@pendragon.ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230914090241.GA2504@pendragon.ideasonboard.com> 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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:55:39 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 agentk.vger.email Hi Laurent, On Thu, Sep 14, 2023 at 12:02:41PM +0300, Laurent Pinchart wrote: > On Thu, Sep 14, 2023 at 10:54:40AM +0200, Jacopo Mondi wrote: > > On Wed, Sep 13, 2023 at 11:48:13PM +0300, Andrey Skvortsov wrote: > > > On 23-09-13 15:27, Sakari Ailus wrote: > > > > 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 ? > > device_link() should handle this. See mxc_isi_async_notifier_bound() in > drivers/media/platform/nxp/imx8-isi/imx8-isi-core.c. > > It would be nice if this could be done in the V4L2 core. I haven't > checked if that's possible. I can't see why it wouldn't be, and it seems easy, too. We're still early in the cycle so if someone writes the patches, I can't see why we couldn't get them for 6.7. -- Regards, Sakari Ailus