Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4445680imw; Tue, 19 Jul 2022 06:48:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uK8KZDIs8AmOqupIOnyoae7D3BVNJzf9unHCHc+KXVZSOFs7c6DJkng6ZP3QhJHOzkkQUc X-Received: by 2002:a17:907:9612:b0:72e:56bd:2b9a with SMTP id gb18-20020a170907961200b0072e56bd2b9amr27285986ejc.526.1658238495446; Tue, 19 Jul 2022 06:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238495; cv=none; d=google.com; s=arc-20160816; b=IUP3d6uNbacX+Yh4Troiy6S0IQbMUTqzPCNPoWG9+jAWNsisAW3BMnG0y2p2sINF/y 37ikhox3GTLB++2sV9J/MKPCy3x7em6FktuYa48q9udSH2MgiGxKbzJF4/pzpWC9iusC d0TvS/td57sUOE3rQifMJlBg4FnoitJAVxQGQOjQTgPYNmieMf7M1zgm2Kadn44JPaRC pK0o/Z3QdMxdIcQNmJwjK1T31gftmIzBSPmwwqEO3lmzxgkLS/oRR7/CXYjdgvVP8Q8K ate88UUB7LK67SKpcD/RB+c8p7lGf52QT/aUfIXn6IUFhyCupUZXtI2jcgIa/sjk4azK /BHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=/Zg62S23EXNbpfzLqoM7g0nyOudoirS1yqpF1GT4KSg=; b=qOZRhAG3RP3N9BrmStNy6HDBvdlo2tYDetdiw5xKBwM46yTxHPygLClc6br98iTtfz 03wmbRQxmq4gcAAU8So3RUwENSUIdwyBbOe2kqPkbmrqdSO5vjfT3SavJ/clTy8ZYj/4 N/Qzm2lmiKdWc1uPYZxGUene4qVTxQmwv/h6rEEcVP76ac7Adhco70YxODVEGm2QrpK1 v9xJh9b7aSDnuHvtlvkdtaaqCc/vxqVvCtENof6wiXX4GW018F2p5NPIsWGqlpLJu9D7 TKLOHYJNNGYmFi7Xw96PCVxOw+l297GWep0XjUGiUI0E/OmDpOYDv2G0ECZpiQ7AEauH dulw== ARC-Authentication-Results: i=1; mx.google.com; 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 j2-20020a50ed02000000b0043ad32fcc93si13076348eds.565.2022.07.19.06.47.51; Tue, 19 Jul 2022 06:48:15 -0700 (PDT) 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; 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 S240058AbiGSM1H (ORCPT + 99 others); Tue, 19 Jul 2022 08:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238011AbiGSMY5 (ORCPT ); Tue, 19 Jul 2022 08:24:57 -0400 Received: from mx2.mythic-beasts.com (mx2.mythic-beasts.com [IPv6:2a00:1098:0:82:1000:0:2:1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02B7850727; Tue, 19 Jul 2022 05:09:48 -0700 (PDT) Received: from [90.243.4.253] (port=53018 helo=jic23-huawei) by mailhub-hex-d.mythic-beasts.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1oDm2o-006mKs-1X; Tue, 19 Jul 2022 13:09:42 +0100 Date: Tue, 19 Jul 2022 13:19:28 +0100 From: Jonathan Cameron To: Dmitry Osipenko Cc: Shreeya Patel , lars@metafoo.de, robh+dt@kernel.org, Zhigang.Shi@liteon.com, krisman@collabora.com, linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, alvaro.soliverez@collabora.com, andy.shevchenko@gmail.com Subject: Re: [PATCH v9 2/2] iio: light: Add support for ltrf216a sensor Message-ID: <20220719131808.7899acd4@jic23-huawei> In-Reply-To: <1e880d3f-758b-56a8-d468-dcb06f4cbc18@collabora.com> References: <20220715111626.1066513-1-shreeya.patel@collabora.com> <20220715111626.1066513-3-shreeya.patel@collabora.com> <20220718182547.360e5cf2@jic23-huawei> <1e880d3f-758b-56a8-d468-dcb06f4cbc18@collabora.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BlackCat-Spam-Score: 19 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 On Tue, 19 Jul 2022 14:56:51 +0300 Dmitry Osipenko wrote: > On 7/18/22 20:25, Jonathan Cameron wrote: > > What turns this off again? I'd expect to see a devm_add_action_or_reset() > > to do that in the !CONFIG_PM case. > > > > This is also an unusual pattern. As far as I can tell it works. > > Normal trick for ensuring !CONFIG_PM works is to: > > > > 1) Unconditionally turn device on. > > 2) Register unconditional device off devm_callback. Very rarely harmful even if device already off > > due to runtime pm. > > If CONFIG_PM is disabled, do we really need to care about the power > management on removal? > Best effort + in general if we do something probe(), we want to do the reverse in remove(). Sure it's not super important, but it's a nice to have. This tends to get 'fixed' by people revisiting the driver after it has merged. > > 3) Then call pm_runtime_set_active() so the state tracking matches. > > We can add pm_runtime_set_active() before h/w is touched for more > consistency. On Steam Deck supplies are always enabled, but this may be > not true for other devices. Generally set it wherever you 'enable' the device as you are indicating the state after that has happened. That might be really early though. > > > 4) Call > > pm_runtime_mark_last_busy(dev); > > pm_runtime_put_autosuspend(dev); > > (here you have a function to do this anyway) > > to let runtime_pm use same path as normal to autosuspend > > > > the upshot of this is that if !CONFIG_PM 3 and 4 do nothing and device > > is left turned on. Is there something I'm missing that makes that cycle > > inappropriate here? The main reason to do this is it then looks exactly > > like any other runtime_pm calls elsewhere in the driver, so easier to review. > > It's appropriate, although caring about PM when it's disabled in kernel > config could be unnecessary, IMO. It was my suggestion to keep the h/w > enabled on driver's removal with !CONFIG_PM, minimizing the code. > For the cost of about 4-8 lines of code, I think it's worth having, but can also see why you decided against. Jonathan