From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A1DDC4332F for ; Wed, 29 Sep 2021 04:46:49 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C91526137E for ; Wed, 29 Sep 2021 04:46:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C91526137E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=93Q4EjEUXNjM8VHvhqV9zHI+rClZpg6S6i9P1CyqzYU=; b=iGXP2nbHSN7BLb rXwwV9aH4uBs3cIpi0lXLJYq9mCHcUSyawt6pgxaDgsMjLRV5eGT+RnJ3Gi4LTNiKKT7wzl7UHU5o RFiBgjlvaKuU9Kh5I9SEmsaflcRteHkciRICApVY78f7tXQGLNBCMVAn+UywR9KkS9/7lpN0TvaPs +fbOf8NWGtc+uyRr41+MBYIOivdLQNw1qrssPhZI4QQx8GkqLL5KvaGMKEhb9HLIveFJkHtvfyTN+ clix56SHrc2DAJ8eZcV1yokXX6Y36yNmh8QrsORHEw61/pOFGtFOrRfNfBc0xfL9TNKnim5swYKBL rlf3op82aYhpNSFhYy8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVRRR-009zuv-Q8; Wed, 29 Sep 2021 04:43:38 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVRQp-009ziz-EK for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 04:43:02 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 175A2580DC4; Wed, 29 Sep 2021 00:42:58 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 29 Sep 2021 00:42:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=nBAwb14NmcBdr AqnC9W+le998BEqA3ENpSMZEhHDV8s=; b=XwY8yDnGMrZu2/GE4s1VOatuLG925 E9Qxi9T6/X1OO3MTcL1Dlo/I7z++vNarJnSEGmdf/aPf6c6Jyj3YVrriL+Gl8AWS Ul4OFTKo0ySUQ4T2Fren8iEX/AZH6okvsC8mw2wkIa/T4viinkNV4JreEMX57H8v s2ZPU+C2RUUIGYEeojAiClPhG9Bfe5eb/O9GjpOXuybDeM+x/Vnh2vctIPTKv9Zm Jv/Y5bgSbQ1BTmd3Ka/q5nkoLxTUgsDJGCvDiF4+Rzfs5G2+1AUOzgDBOE3ziV3K BGkO8uhh3UZQ32S/3K8nN+5cQiE4HRCM8fd5Ocd+rkEG7yxpiQLBc2S2Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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=nBAwb14NmcBdrAqnC9W+le998BEqA3ENpSMZEhHDV8s=; b=Hjm8Gjra pFnFYHk8xStLnM0jSsqqPsvYcICjpnuWdvvcrQtozJ/dEqIsQ9gb9ah3cN2khXxE ykVJ40PhAs5vrhAEtsraFXZEhFgyUDq+tyNyaH1QTs+yuQVZPHIaslJiUS5RL5M7 AgwocBOdVOxr5QisAEyN9L9tJAdpQ+tl40rT1Whj+Kuhc9W7uFHLxMlrKp1/og3p g4/PP7pN93qJbN2mxDPn0ZpNgVvka/p2tR5oA3cpy0fSLtuIiIUjb9y3M3L+cnd0 1Sy8X3eAfdPKWKESqHb0Dync+du/9u+vILusp7cMOHRkCpNwexJXh6flcJscuZJ6 aFULWOvk/OnCQw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekuddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Sep 2021 00:42:57 -0400 (EDT) From: Samuel Holland To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Rob Herring 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, Samuel Holland Subject: [PATCH 02/10] PM / devfreq: Do not require devices to have OPPs Date: Tue, 28 Sep 2021 23:42:46 -0500 Message-Id: <20210929044254.38301-3-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210929044254.38301-1-samuel@sholland.org> References: <20210929044254.38301-1-samuel@sholland.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210928_214259_594407_C307E274 X-CRM114-Status: GOOD ( 16.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. The offending properties, scaling_min/max_freq, are only necessary if a device has OPPs; if no OPPs exist at all, OPPs cannot be dynamically enabled or disabled, so those values have no effect. Thus it is trivial to restore support for devices with freq_table only and not OPPs -- move those initializations behind the check for a valid OPP table. Since get_freq_range() uses scaling_max_freq in a min() expression, it must be initialized to the maximum possible value. scaling_min_freq is initialized as well for consistency. Fixes: ab8f58ad72c4 ("PM / devfreq: Set min/max_freq when adding the devfreq device") Signed-off-by: Samuel Holland --- drivers/devfreq/devfreq.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 7a8b022ba456..426e31e6c448 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -835,24 +835,28 @@ struct devfreq *devfreq_add_device(struct device *dev, mutex_lock(&devfreq->lock); } - devfreq->scaling_min_freq = find_available_min_freq(devfreq); - if (!devfreq->scaling_min_freq) { - mutex_unlock(&devfreq->lock); - err = -EINVAL; - goto err_dev; - } - - devfreq->scaling_max_freq = find_available_max_freq(devfreq); - if (!devfreq->scaling_max_freq) { - mutex_unlock(&devfreq->lock); - err = -EINVAL; - goto err_dev; - } - - devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev); devfreq->opp_table = dev_pm_opp_get_opp_table(dev); - if (IS_ERR(devfreq->opp_table)) + if (IS_ERR(devfreq->opp_table)) { devfreq->opp_table = NULL; + devfreq->scaling_min_freq = 0; + devfreq->scaling_max_freq = ULONG_MAX; + } else { + devfreq->scaling_min_freq = find_available_min_freq(devfreq); + if (!devfreq->scaling_min_freq) { + mutex_unlock(&devfreq->lock); + err = -EINVAL; + goto err_dev; + } + + devfreq->scaling_max_freq = find_available_max_freq(devfreq); + if (!devfreq->scaling_max_freq) { + mutex_unlock(&devfreq->lock); + err = -EINVAL; + goto err_dev; + } + + devfreq->suspend_freq = dev_pm_opp_get_suspend_opp_freq(dev); + } atomic_set(&devfreq->suspend_count, 0); -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel