Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp819036pxb; Thu, 30 Sep 2021 18:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuBeQbTPcz/7R2YGE0hqRBb9u4cKdzPhu3nmxKtNAOPcmFepSQWsovM6tBlNCK+IF+jk6l X-Received: by 2002:a17:902:f693:b0:13e:161a:f172 with SMTP id l19-20020a170902f69300b0013e161af172mr7037459plg.30.1633053071521; Thu, 30 Sep 2021 18:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633053071; cv=none; d=google.com; s=arc-20160816; b=SX1sJCZ0qvo1i7UTyGyDc2HAcPw5+JRQJ7dgICdYlQoyBEXguSRmVs7p3ju1240lcG ikq293CGo/+Jilo1cJOX2Xrtc4g+EaTRCjxnzOxGxQJ31Jz+dz3U/cm8UUEMj82lKZYH eafpM0OdRJZI80mX+oQJqrEMRk9ZTnmZAiXXRVDhHgKUFZUOYNyitAMnW3llcHkkVi23 KIUfzXZcKOlLNZA7Vyq3q+k5fizcDNhCLS/tYE46AcLW/SB614i+fwEmx7X1/9UWXiYC DNHU2nEKMpBx1F0KPKOBwvia4gBvs2dqOJPQwIRLiDCluESmLk7gU9Zh7TfP0SXz/Ss3 QT2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-signature; bh=vOdoat0J6oK40pz/pIFwU3UMSzNN+QQ5EnZGqlGFHak=; b=bUkrcCvZUz94IXWshUjp9/OX1f88cJEAPZD5Nezh4eaMMFaZRPCW3+06r+fxAz019F 5OCxeLQp9gyRr2l8tqqY1EIh5ku2evAzB2orhakyb6iR9HDuuxM9WIbr2D+fVENBWqJK 5TacBfjs0CKkv7eSWbSRHECMXcTPwspDovrrm6Vk/xjX5ZYz40ZOGCLuyCKApsX/JkQL P3qfjFQncjO80CWj0ph1+pmVQ0unmeHyijRUBzCGHs5fD+NB3zn7CS+v0fYRuBHzweH0 RmerbPJPKNBPckZuxix7ASaDS4eB6aoTxQT592KvNPy1vqYt7tzUtCo2b1naRuKlxjeq 07dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=gQmCA3rj; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HEdTYRJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si6230933pgs.639.2021.09.30.18.50.56; Thu, 30 Sep 2021 18:51:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@sholland.org header.s=fm3 header.b=gQmCA3rj; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=HEdTYRJg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351429AbhJABr2 (ORCPT + 99 others); Thu, 30 Sep 2021 21:47:28 -0400 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]:34825 "EHLO wnew2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351220AbhJABr1 (ORCPT ); Thu, 30 Sep 2021 21:47:27 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id E17062B00262; Thu, 30 Sep 2021 21:45:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 30 Sep 2021 21:45:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=v Odoat0J6oK40pz/pIFwU3UMSzNN+QQ5EnZGqlGFHak=; b=gQmCA3rjtz3PfoW/C hQUSW3jnbYvySDgW/Ltfhsf2zmDcf7sbSkGHDLOnHgd8CNRKe7Q5/MOV48arJvfZ bnmnOolkxCVlSoWvGgi7hldvleOjJWxqbBb9FlQYbWp+dLPQcAwuIuSgyyaEQ7HU Omzbl65IxjvsT/lm0jt3KK3tGcTK2ZDVMIouCq1Q1pa4LVRnOYfgB2AcHGmY7F06 4QcvlcrYFi2mDmBlMSKtEmAB7BN+p6DhRBdwl3KhZiA0bWDwWYcu8rMpIUIklptf Lzk8YD0Kwhl5oEXBEbOFq/o781In3cw6DXV+tc4FD1Pjx4pTgn10Qh6SayOrcHq7 qcK8A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=vOdoat0J6oK40pz/pIFwU3UMSzNN+QQ5EnZGqlGFH ak=; b=HEdTYRJg1zvGFpz6zaSCEe6OCgmzV/sA1VVSbHtFk+YJkPNcGVDSnzv/D yNU5UvgKCIVH7XMpnRReUFK09bSv2HD6eT153H/Ch8p5lO5wyWIHGNFIe3kUaW3A DenQF9S5xZvpkYLPKCsfIdLWIsLr4h34b6A9DtBGgk1tFfJseU70k4kAMS3TdZGc i3gzGfuAQl1IjvQdGY2br5s7c5INeyhQHLa70yChBjpbnq3Dc6oLZxg66YmobVFb Bwxe31mozgSTUBiWZVDNm++iVzBS5FoT+YGtr6jIYlNaT4OgqZpctWrohfWw+ekv q6PrwYQ71fjxUCzqiCfg2PqMMJs9w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekhedggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomhepufgrmhhu vghlucfjohhllhgrnhguuceoshgrmhhuvghlsehshhholhhlrghnugdrohhrgheqnecugg ftrfgrthhtvghrnhepgfevffetleehffejueekvdekvdeitdehveegfeekheeuieeiueet uefgtedtgeegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homhepshgrmhhuvghlsehshhholhhlrghnugdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 30 Sep 2021 21:45:33 -0400 (EDT) Subject: Re: [PATCH 02/10] PM / devfreq: Do not require devices to have OPPs To: Chanwoo Choi , MyungJoo Ham , Kyungmin Park Cc: Michael Turquette , Stephen Boyd , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Rob Herring References: <20210929044254.38301-1-samuel@sholland.org> <20210929044254.38301-3-samuel@sholland.org> <114afa7e-6218-6b1f-f87e-84690f10029c@samsung.com> <7d404f89-6567-61e6-7964-d2ca578ed652@samsung.com> From: Samuel Holland Message-ID: <7107eea6-f2ca-fb7c-5975-569066ba21a7@sholland.org> Date: Thu, 30 Sep 2021 20:45:33 -0500 User-Agent: Mozilla/5.0 (X11; Linux ppc64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 MIME-Version: 1.0 In-Reply-To: <7d404f89-6567-61e6-7964-d2ca578ed652@samsung.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/30/21 8:59 PM, Chanwoo Choi wrote: > On 9/30/21 8:37 PM, Samuel Holland wrote: >> On 9/29/21 11:19 PM, Chanwoo Choi wrote: >>> Hi Samuel, >>> >>> >>> On 9/29/21 1:42 PM, Samuel Holland wrote: >>>> Since commit ea572f816032 ("PM / devfreq: Change return type of >>>> devfreq_set_freq_table()"), all devfreq devices are required to have a >>>> valid freq_table. If freq_table is not provided by the driver, it will >>>> be filled in by set_freq_table() from the OPPs; if that fails, >>>> devfreq_add_device() will return an error. >>>> >>>> However, since commit ab8f58ad72c4 ("PM / devfreq: Set min/max_freq when >>>> adding the devfreq device"), devfreq devices are _also_ required to have >>>> an OPP table, even if they provide freq_table. devfreq_add_device() >>>> requires dev_pm_opp_find_freq_ceil() and dev_pm_opp_find_freq_floor() to >>>> return successfully, specifically to initialize scaling_min/max_freq. >>>> >>>> Not all drivers need an OPP table. For example, a driver where all >>>> frequencies are determined dynamically could work by filling out only >>>> freq_table. But with the current code it must call dev_pm_opp_add() on >>>> every freq_table entry to probe successfully. >>> >>> As you commented, if device has no opp table, it should call dev_pm_opp_add(). >>> The devfreq have to use OPP for controlling the frequency/regulator. >>> >>> Actually, I want that all devfreq driver uses the OPP as default way. >> >> The current code/documentation implies that an OPP table is intended to >> be optional. For example: >> >> * struct devfreq - Device devfreq structure >> ... >> * @opp_table: Reference to OPP table of dev.parent, if one exists. >> >> So this should be updated if an OPP table is no longer optional. > > Right. Need to update it. > >> >>> Are there any reason why don't use the OPP table? >> >> dev_pm_opp_add() takes a voltage, and assumes the existence of some >> voltage regulator, but there is none involved here. The only way to have >> an OPP table without regulators is to use a static table in the >> devicetree. But that also doesn't make much sense, because the OPPs >> aren't actually customizable; they are integer dividers from a fixed >> base clock. > > You can use OPP for only clock control without regulator. OPP already > provides them. OPP already provides the helpful function which > implement the functions to handle the clock/regulator or power doamin. > It is useful framework to control clock/regulator. > > If the standard framework in Linux kernel, it is best to use > this framework in order to remove the duplicate codes on multiple > device drivers. It is one of advantage of Linux kernel. > > Also, if OPP doesn't support the some requirement of you, > you can contribute and update the OPP. > > And adding a fixed OPP table to each board would be a lot of >> work to replace a trivial loop in the driver. So it seems to be the >> wrong abstraction. > > I don't understand. As I commented for patch 10, you can add > the OPP entry of the clock without the fixed OPP table in devicetree. > >> >> Using an OPP table adds extra complexity (memory allocations, error >> cases), just to duplicate the list of frequencies that already has to >> exist in freq_table. And the driver works fine without any of that. > > 'freq_table' of devfreq was developed before of adding OPP interface to Linux kernel as I knew. Actually, I prefer to use the OPP interface > instead of initializing the freq_table directly by device driver. > I just keep the 'freq_table' for preventing the build/working issue > for older device driver. I think OPP is enough to control frequency/voltage > and it provides the various helper funcitons for user of OPP. Thanks for the explanation. I will convert the driver to use dev_pm_opp_add(), and I will drop patches 2 and 4. I think patch 3 is still worth considering. Regards, Samuel