Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1484003ybj; Fri, 8 May 2020 02:21:15 -0700 (PDT) X-Google-Smtp-Source: APiQypLSVwiLkEBUrvBGPpaqDJgmJML8NaQ0WZ7PKIxu4u4Uho3In/omieR7X0TuoQwM8IePu26C X-Received: by 2002:a05:6402:1d89:: with SMTP id dk9mr1283338edb.382.1588929675013; Fri, 08 May 2020 02:21:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588929675; cv=none; d=google.com; s=arc-20160816; b=EwJQd3xd8i70cnMBdB9LJ3ce32bF4qMbXfq8mvJrcR+lo/HidjOf4MH+tlz7/v5BEU IfUDC2KmK06fmweqEKRwP1z7skLcvr0v+3zZWpU/6gDbkrZmUMRBxWEV3PtGInDiwUjB O6mjcwNSidoyHi4twxHCynaDhKz/giW8D8LAV+nvxpyHuTR73XK5GGVjKYfxNZ8sQ63I 57EaWaFzDgDf2v0QrtPsBw9BVmBgFgCCWeYsEKCnHcM0sgsRwQbGECZ+I8cVqyHRFq5q F0y2L/PUES0oviR/6Uy8g0TsRyTYEKlpswKu0sMik+TWNfAFVdNZSxdW4tZsFWKCg3IK Mwsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=u9c3qDq2Rb5uZy13x6DA5l+lDQZeAtyU8JgY+cy3f6I=; b=cL3qv9aeOnC2MPJ8TPnjX66fq9Dk/dJrq1lBpMbM13pgikvCxKM710WmJjo+RhZ/7z Hs1lFewXxMwLCXIHtOfTq+7eTsSKo0+1RmF3zJgn9e4ir4LZWV3g1moFCOjRDePSrhem IJn2EwcWF4DxeVbL6/2Q0B7+i08c/O7O5jUiC2wiio6bjaLFnjders+90N+ahLbN6k+r 2ywL7F0J2tGnjVQnzVjUFaq3g8P4IC5pmbG9eqm7iEU4wDHJ+ZK4BYj3dC6wmkAm2fLH gvC1VfOTOtaWW6r+FblI80phmviRSCyjnmO5nGo66sgpw11/oTHdSr7P8IlsKrnZkWCj Neaw== ARC-Authentication-Results: i=1; mx.google.com; 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 n16si709672ejl.134.2020.05.08.02.20.51; Fri, 08 May 2020 02:21:15 -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; 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 S1726885AbgEHJRa (ORCPT + 99 others); Fri, 8 May 2020 05:17:30 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4297 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725379AbgEHJR3 (ORCPT ); Fri, 8 May 2020 05:17:29 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BE68A22B3D822B2B4BE1; Fri, 8 May 2020 17:17:26 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Fri, 8 May 2020 17:17:19 +0800 From: Xiongfeng Wang To: , , , CC: , , , , , , Subject: [RFC PATCH 2/3] cpufreq: Add SW BOOST support for drivers without frequency table Date: Fri, 8 May 2020 17:11:03 +0800 Message-ID: <1588929064-30270-3-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1588929064-30270-1-git-send-email-wangxiongfeng2@huawei.com> References: <1588929064-30270-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Software-managed BOOST get the boost frequency by check the flag CPUFREQ_BOOST_FREQ at driver's frequency table. But some cpufreq driver don't have frequency table and use other methods to get the frequency range, such CPPC cpufreq driver. To add SW BOOST support for drivers without frequency table, we add members in 'cpufreq_policy.cpufreq_cpuinfo' to record the max frequency of boost mode and non-boost mode. The cpufreq driver initialize these two members when probing. Signed-off-by: Xiongfeng Wang --- drivers/cpufreq/cpufreq.c | 23 +++++++++++++++-------- include/linux/cpufreq.h | 2 ++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 475fb1b..a299426 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2508,15 +2508,22 @@ static int cpufreq_boost_set_sw(int state) int ret = -EINVAL; for_each_active_policy(policy) { - if (!policy->freq_table) - continue; - - ret = cpufreq_frequency_table_cpuinfo(policy, + if (policy->freq_table) { + ret = cpufreq_frequency_table_cpuinfo(policy, policy->freq_table); - if (ret) { - pr_err("%s: Policy frequency update failed\n", - __func__); - break; + if (ret) { + pr_err("%s: Policy frequency update failed\n", + __func__); + break; + } + } else if (policy->cpuinfo.boost_max_freq) { + if (state) + policy->max = policy->cpuinfo.boost_max_freq; + else + policy->max = policy->cpuinfo.nonboost_max_freq; + policy->cpuinfo.max_freq = policy->max; + } else { + continue; } ret = freq_qos_update_request(policy->max_freq_req, policy->max); diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 018dce8..c3449e6 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -43,6 +43,8 @@ enum cpufreq_table_sorting { struct cpufreq_cpuinfo { unsigned int max_freq; unsigned int min_freq; + unsigned int boost_max_freq; + unsigned int nonboost_max_freq; /* in 10^(-9) s = nanoseconds */ unsigned int transition_latency; -- 1.7.12.4