Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4457742imw; Tue, 19 Jul 2022 07:01:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vVQ5UtFrCein0JEoA0FRKLXapUGGtBUkYZszAgkYTgSX8paBCHrGLmRgDy/cQEmeysfGS1 X-Received: by 2002:a05:6402:26ca:b0:43a:c743:7c with SMTP id x10-20020a05640226ca00b0043ac743007cmr44809871edd.227.1658239319058; Tue, 19 Jul 2022 07:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239319; cv=none; d=google.com; s=arc-20160816; b=Aqcj8eh3gPvjFW+4iK6OS6f5ALLnrLrJM2IFhkdLYkyiAxsxUrIPCaZiZu3Iijmk96 R0Llz975MLoDgyONBC9rhbu+6gDT7jjkNPz12CcCp+6Q5IipqwYHSoclJI/t5ojLTVuF 8mLLOeQQIgeVtC2ioID/3XKK9HqEr5yAWp8Z1xt5RcL47fL/0Vj0iaceQzarkAs076Co Txpkl/yOOwKpKK4xDD15POO6fRw8mE4x5mHXvxr8tRWv0qoSAFGqhVDyAr7rEazr1Q2I goJ2SyY1ntNCbiRG/zibd89T0ri4IaB5hPlDtJtTqVY8TVcgD+wTOKUEfhlawvd8hYi4 /p7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=HOTpJ+TrpYFt/wBKcehRnRNsog1n/dB+OTyTa4l57/I=; b=cszw5PAsQk8b5s+i0Apr7bhnzC9813Y62bfVmSh2aseuHJo8nHB+THJcmDyP1N7gCr r1LlQOVpI3jImSubloVCoiZLFe6FJHxFdKkqEyO/mQOQP5rjPdaN2JmnqIQC61pCe1wK X4drVVcVlwcIWUdn7eRqbWszc+W0D0ScpWGgag0kRojxQNb3RcSO34dAwaKGKZZx6sQ9 D510rw78FyrGtP7PmgCjwWdUiaZA+vdhwsJBwvdweOUdnB9x4ruB2ylGf8TIDXsqaq+/ PxxGE48Mx8V+sSHVA0wQdI3JuSzvE6hulYT6h8+iwku1Bo3EfbotGrrJjXcUQJG0sdnw jxCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=fFWWIHzE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw11-20020a170906478b00b0072f17b3722csi15186109ejc.933.2022.07.19.07.01.32; Tue, 19 Jul 2022 07:01:59 -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; dkim=pass header.i=@collabora.com header.s=mail header.b=fFWWIHzE; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238499AbiGSOAY (ORCPT + 99 others); Tue, 19 Jul 2022 10:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238027AbiGSOAJ (ORCPT ); Tue, 19 Jul 2022 10:00:09 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD394B489; Tue, 19 Jul 2022 06:11:37 -0700 (PDT) Received: from [192.168.2.145] (109-252-119-232.nat.spd-mgts.ru [109.252.119.232]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dmitry.osipenko) by madras.collabora.co.uk (Postfix) with ESMTPSA id E28C36601A83; Tue, 19 Jul 2022 14:11:34 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1658236295; bh=8YDDjVdTJy5mlkoOKTkV47AAUAvRSJpwczvJ6O253Ug=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=fFWWIHzE8lrYlDyV7WugJd5eGY+haNHF8l4lYALSoUHf5K5/hYSIijforx3Fg7zQX KbrJzMFDQ2sBB/8ptL4RB6Ky+ZasiSzJDCteKgKhPNHMvR4v5uCJrh3Rl916aOOoWJ tEHzbMgO53Yyz2k1jtZEh3tJRMq2C8wMmX2p4wMKgmhdBcEXQI4iFi57acSoD7l1eg PeEGnNK68FUro/zBlGtq5n23dF8MQZf29bZEjjCIt+UP++zxmqrPImKJsHRDJJYx3N 7qQgaSNklFplRfHmE66mp0CvT7shUYfYPMlRMlHbD/aA14DN67MPz35Q4ZqYW3PXGz 0XYYI2XkO/exA== Message-ID: <07452438-f7e7-70d7-7a38-567f0f224fa1@collabora.com> Date: Tue, 19 Jul 2022 16:11:31 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v9 2/2] iio: light: Add support for ltrf216a sensor Content-Language: en-US To: Jonathan Cameron 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 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> <20220719131808.7899acd4@jic23-huawei> From: Dmitry Osipenko In-Reply-To: <20220719131808.7899acd4@jic23-huawei> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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 7/19/22 15:19, Jonathan Cameron wrote: > 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. Alright, thank you for the review. Shreeya will address it all and prepare the v10. -- Best regards, Dmitry