Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp275585pxb; Fri, 3 Sep 2021 01:42:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwySTsaSr1iwxTOx7gc/aknzoJhDXfgScfvlHCbvEiZ3VfCIcHz8DICAenrdoGHCMF530+G X-Received: by 2002:a17:906:6dc1:: with SMTP id j1mr2986760ejt.324.1630658535812; Fri, 03 Sep 2021 01:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630658535; cv=none; d=google.com; s=arc-20160816; b=gEvqEMryALjOhtCC9ihODZiIhR4BAVjLKf6kSkTOW+1Kb8JYvyvyG/mijY1aTToeIW X2cqc1UsR2ZKClYPm077yQuYpI0XiY5W0RjgCUKVRCDVGxlQUcNuzzw0RsjyER4dwrKE V+O4uYhWaLiJ0dKtZnFIFf7oTwO64iLwW2pR0/5gIBbQ17pLOTj/6ajIWx42XOm9Ni4/ hv7kxQWsLUkA04TJcE+GAwKtcon4cMZETJS0jN+6pEunnMq9sNNnnVCA62ilVEDj9zzE RtDeTbGoOVoSGxY7PD9j9L5f/JeNQL7/NZDDiWg+8BSmV0dIfu9EUMo+c94Uhe9Yl21O Asuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=tqijeWuLWtGfbQD6YtsRDlnrTaW+/a8yHwjDeoVVuuY=; b=oek3sB6S9QwuZPEDxrEDDBPER5BVQVM0ixJ5mqComv+MeyWPIHNe6GOgoOqNBRmHHG dVyjB/JXmNipTqgI1oVz+9R9aKfRXiYmCdGVODFp4HPXYybG+RGz8JwKIBQx75dPUr2d +jU1ZUvJ5P5FkdZNQOXZDspfnzf1//Lf6aVMZgHY9cqYp4/odNy1F0nHCRXkp6cA0OvD PPYNo8HWhFk79p3A3USFqaLZL1h5pyqBuipOHsUTBp4fGTRovMqPd7zToZ8v4jyKadXM vaz+3gOUUEWOIS1S1DEdGe5EUlXePqx3TlugV7MJIN3IslZDXDz2l4O7tdAQPtdTwzbe boeQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga39si2899160ejc.235.2021.09.03.01.41.50; Fri, 03 Sep 2021 01:42: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348397AbhICIkm (ORCPT + 99 others); Fri, 3 Sep 2021 04:40:42 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:59624 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1348384AbhICIki (ORCPT ); Fri, 3 Sep 2021 04:40:38 -0400 X-UUID: 5ea3d511595442a6aa666ecce0ce417d-20210903 X-UUID: 5ea3d511595442a6aa666ecce0ce417d-20210903 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 746758546; Fri, 03 Sep 2021 16:39:35 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs06n1.mediatek.inc (172.21.101.129) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 3 Sep 2021 16:39:30 +0800 Received: from mtkswgap22.mediatek.inc (172.21.77.33) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 3 Sep 2021 16:39:30 +0800 From: Hector Yuan To: , , , "Rafael J. Wysocki" , Viresh Kumar , Rob Herring , CC: , , Subject: [PATCH v15 2/3] cpufreq: Add of_perf_domain_get_sharing_cpumask Date: Fri, 3 Sep 2021 16:39:23 +0800 Message-ID: <1630658364-6192-3-git-send-email-hector.yuan@mediatek.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1630658364-6192-1-git-send-email-hector.yuan@mediatek.com> References: <1630658364-6192-1-git-send-email-hector.yuan@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Hector.Yuan" Add of_perf_domain_get_sharing_cpumask function to group cpu to specific performance domain. Signed-off-by: Hector.Yuan --- include/linux/cpufreq.h | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index 9fd7194..0246144 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include #include @@ -995,6 +997,43 @@ static inline int cpufreq_table_count_valid_entries(const struct cpufreq_policy return count; } + +static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name, + const char *cell_name, struct cpumask *cpumask) +{ + struct device_node *cpu_np; + struct of_phandle_args args; + int target_idx; + int cpu, ret; + + cpu_np = of_cpu_device_node_get(pcpu); + of_parse_phandle_with_args(cpu_np, list_name, + cell_name, 0, &args); + of_node_put(cpu_np); + target_idx = args.args[0]; + + for_each_possible_cpu(cpu) { + if (cpu == pcpu) + continue; + + cpu_np = of_cpu_device_node_get(cpu); + if (!cpu_np) + continue; + + ret = of_parse_phandle_with_args(cpu_np, list_name, + cell_name, 0, + &args); + + of_node_put(cpu_np); + if (ret < 0) + continue; + + if (target_idx == args.args[0]) + cpumask_set_cpu(cpu, cpumask); + } + + return target_idx; +} #else static inline int cpufreq_boost_trigger_state(int state) { @@ -1014,6 +1053,12 @@ static inline bool policy_has_boost_freq(struct cpufreq_policy *policy) { return false; } + +static inline int of_perf_domain_get_sharing_cpumask(int pcpu, const char *list_name, + const char *cell_name, struct cpumask *cpumask) +{ + return -EOPNOTSUPP; +} #endif #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL) @@ -1035,7 +1080,6 @@ void arch_set_freq_scale(const struct cpumask *cpus, { } #endif - /* the following are really really optional */ extern struct freq_attr cpufreq_freq_attr_scaling_available_freqs; extern struct freq_attr cpufreq_freq_attr_scaling_boost_freqs; -- 1.7.9.5