All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: linux-mips@vger.kernel.org
Cc: "Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Thomas Bogendoerfer" <tsbogend@alpha.franken.de>,
	"Huacai Chen" <chenhc@lemote.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Ingo Molnar" <mingo@redhat.com>,
	"Arnaldo Carvalho de Melo" <acme@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Jiri Olsa" <jolsa@redhat.com>,
	"Namhyung Kim" <namhyung@kernel.org>,
	"Florian Fainelli" <f.fainelli@gmail.com>,
	"Robert Richter" <rric@kernel.org>,
	"Sudeep Holla" <sudeep.holla@arm.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Jason Cooper" <jason@lakedaemon.net>,
	"Marc Zyngier" <maz@kernel.org>,
	"Paul Burton" <paulburton@kernel.org>,
	"Allison Randal" <allison@lohutok.net>,
	"Enrico Weigelt" <info@metux.net>,
	"Kate Stewart" <kstewart@linuxfoundation.org>,
	"Vladimir Kondratiev" <vladimir.kondratiev@intel.com>,
	"Paul Cercueil" <paul@crapouillou.net>,
	"Zhou Yanjie" <zhouyanjie@zoho.com>,
	"周琰杰 (Zhou Yanjie)" <zhouyanjie@wanyeetech.com>,
	"YunQiang Su" <syq@debian.org>, "Arnd Bergmann" <arnd@arndb.de>,
	"Serge Semin" <fancer.lancer@gmail.com>,
	"Matt Redfearn" <matt.redfearn@mips.com>,
	"Steve Winslow" <swinslow@gmail.com>,
	"Alexios Zavras" <alexios.zavras@intel.com>,
	"Richard Fontana" <rfontana@redhat.com>,
	"afzal mohammed" <afzal.mohd.ma@gmail.com>,
	"Peter Xu" <peterx@redhat.com>,
	"Mike Rapoport" <rppt@linux.ibm.com>,
	"Oleksij Rempel" <linux@rempel-privat.de>,
	"Kamal Dasu" <kdasu.kdev@gmail.com>,
	linux-kernel@vger.kernel.org,
	bcm-kernel-feedback-list@broadcom.com,
	oprofile-list@lists.sf.net
Subject: [PATCH 03/12] arch_topology: Make it avilable for MIPS
Date: Wed,  8 Apr 2020 19:34:13 +0800	[thread overview]
Message-ID: <20200408113505.2528103-4-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20200408113505.2528103-1-jiaxun.yang@flygoat.com>

Simply drop unnecessary archtecture limitions and add dummy
function for platforms without OF/COMMON_CLK support.
Also exclude functions for arm that existed in platform code.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
 drivers/base/arch_topology.c | 121 +++++++++++++++++++----------------
 1 file changed, 66 insertions(+), 55 deletions(-)

diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 4d0a0038b476..9c2405d08dae 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -143,57 +143,6 @@ void topology_normalize_cpu_scale(void)
 	}
 }
 
-bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
-{
-	struct clk *cpu_clk;
-	static bool cap_parsing_failed;
-	int ret;
-	u32 cpu_capacity;
-
-	if (cap_parsing_failed)
-		return false;
-
-	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
-				   &cpu_capacity);
-	if (!ret) {
-		if (!raw_capacity) {
-			raw_capacity = kcalloc(num_possible_cpus(),
-					       sizeof(*raw_capacity),
-					       GFP_KERNEL);
-			if (!raw_capacity) {
-				cap_parsing_failed = true;
-				return false;
-			}
-		}
-		raw_capacity[cpu] = cpu_capacity;
-		pr_debug("cpu_capacity: %pOF cpu_capacity=%u (raw)\n",
-			cpu_node, raw_capacity[cpu]);
-
-		/*
-		 * Update freq_factor for calculating early boot cpu capacities.
-		 * For non-clk CPU DVFS mechanism, there's no way to get the
-		 * frequency value now, assuming they are running at the same
-		 * frequency (by keeping the initial freq_factor value).
-		 */
-		cpu_clk = of_clk_get(cpu_node, 0);
-		if (!PTR_ERR_OR_ZERO(cpu_clk)) {
-			per_cpu(freq_factor, cpu) =
-				clk_get_rate(cpu_clk) / 1000;
-			clk_put(cpu_clk);
-		}
-	} else {
-		if (raw_capacity) {
-			pr_err("cpu_capacity: missing %pOF raw capacity\n",
-				cpu_node);
-			pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n");
-		}
-		cap_parsing_failed = true;
-		free_raw_capacity();
-	}
-
-	return !ret;
-}
-
 #ifdef CONFIG_CPU_FREQ
 static cpumask_var_t cpus_to_visit;
 static void parsing_done_workfn(struct work_struct *work);
@@ -275,7 +224,64 @@ static void parsing_done_workfn(struct work_struct *work)
 core_initcall(free_raw_capacity);
 #endif
 
-#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
+#if defined(CONFIG_OF) && !defined(CONFIG_ARM)
+#if defined(CONFIG_COMMON_CLK)
+bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
+{
+	struct clk *cpu_clk;
+	static bool cap_parsing_failed;
+	int ret;
+	u32 cpu_capacity;
+
+	if (cap_parsing_failed)
+		return false;
+
+	ret = of_property_read_u32(cpu_node, "capacity-dmips-mhz",
+				   &cpu_capacity);
+	if (!ret) {
+		if (!raw_capacity) {
+			raw_capacity = kcalloc(num_possible_cpus(),
+					       sizeof(*raw_capacity),
+					       GFP_KERNEL);
+			if (!raw_capacity) {
+				cap_parsing_failed = true;
+				return false;
+			}
+		}
+		raw_capacity[cpu] = cpu_capacity;
+		pr_debug("cpu_capacity: %pOF cpu_capacity=%u (raw)\n",
+			cpu_node, raw_capacity[cpu]);
+
+		/*
+		 * Update freq_factor for calculating early boot cpu capacities.
+		 * For non-clk CPU DVFS mechanism, there's no way to get the
+		 * frequency value now, assuming they are running at the same
+		 * frequency (by keeping the initial freq_factor value).
+		 */
+		cpu_clk = of_clk_get(cpu_node, 0);
+		if (!PTR_ERR_OR_ZERO(cpu_clk)) {
+			per_cpu(freq_factor, cpu) =
+				clk_get_rate(cpu_clk) / 1000;
+			clk_put(cpu_clk);
+		}
+	} else {
+		if (raw_capacity) {
+			pr_err("cpu_capacity: missing %pOF raw capacity\n",
+				cpu_node);
+			pr_err("cpu_capacity: partial information: fallback to 1024 for all CPUs\n");
+		}
+		cap_parsing_failed = true;
+		free_raw_capacity();
+	}
+
+	return !ret;
+}
+#else
+bool __init topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu)
+{
+		return false;
+}
+#endif /* CONFIG_COMMON_CLK */
 /*
  * This function returns the logic cpu number of the node.
  * There are basically three kinds of return values:
@@ -461,7 +467,12 @@ static int __init parse_dt_topology(void)
 	of_node_put(cn);
 	return ret;
 }
-#endif
+#else
+static int __init parse_dt_topology(void)
+{
+	return 0;
+}
+#endif /* CONFIG_OF & !CONFIG_ARM */
 
 /*
  * cpu topology table
@@ -562,7 +573,7 @@ __weak int __init parse_acpi_topology(void)
 	return 0;
 }
 
-#if defined(CONFIG_ARM64) || defined(CONFIG_RISCV)
+#if !defined(CONFIG_ARM)
 void __init init_cpu_topology(void)
 {
 	reset_cpu_topology();
@@ -576,4 +587,4 @@ void __init init_cpu_topology(void)
 	else if (of_have_populated_dt() && parse_dt_topology())
 		reset_cpu_topology();
 }
-#endif
+#endif /* !CONFIG_ARM */
-- 
2.26.0.rc2



  parent reply	other threads:[~2020-04-08 11:43 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-08 11:34 [PATCH 00/12] MIPS: Topology & DeviceTree CPU rework Jiaxun Yang
2020-04-08 11:34 ` [PATCH 01/12] MIPS: setup: Drop prefill_possible_map Jiaxun Yang
2020-04-08 11:34 ` [PATCH 02/12] MIPS: prom: Add helper to parse CPU node in dt Jiaxun Yang
2020-04-08 11:34 ` Jiaxun Yang [this message]
2020-04-08 18:23   ` [PATCH 03/12] arch_topology: Make it avilable for MIPS Valentin Schneider
2020-04-09  0:54   ` kbuild test robot
2020-04-09  0:54     ` kbuild test robot
2020-04-09 10:13   ` Sudeep Holla
2020-04-08 11:34 ` [PATCH 04/12] arch_topology: Reset all cpus in reset_cpu_topology Jiaxun Yang
2020-04-08 18:23   ` Valentin Schneider
2020-04-09 10:19   ` Sudeep Holla
2020-04-08 11:34 ` [PATCH 05/12] MIPS: Switch to arch_topology Jiaxun Yang
2020-04-08 23:36   ` kbuild test robot
2020-04-08 23:36     ` kbuild test robot
2020-04-09 10:31   ` Sudeep Holla
     [not found]     ` <C2794910-48A0-4472-953A-13F40BA39423@flygoat.com>
2020-04-09 10:58       ` Sudeep Holla
2020-04-09 11:07         ` Jiaxun Yang
2020-04-09 12:53           ` Sudeep Holla
2020-04-09 13:14             ` Jiaxun Yang
2020-04-09 12:23         ` Jiaxun Yang
2020-04-08 12:59 ` [PATCH 06/12] MIPS: Kernel: Switch to new topology interface Jiaxun Yang
2020-04-08 12:59 ` [PATCH 07/12] MIPS: CPS & MT: " Jiaxun Yang
2020-04-09  5:26   ` kbuild test robot
2020-04-08 12:59 ` [PATCH 08/12] irqchip: mips-cpu: " Jiaxun Yang
2020-04-08 12:59 ` [PATCH 09/12] MIPS: bmips: " Jiaxun Yang
2020-04-08 12:59 ` [PATCH 10/12] MIPS: nlm: " Jiaxun Yang
2020-04-08 12:59 ` [PATCH 11/12] MIPS: Loongson64: " Jiaxun Yang
2020-04-08 12:59 ` [PATCH 12/12] MIPS: ip27: Fix includes Jiaxun Yang
2020-04-09  9:19   ` Mike Rapoport
2020-04-09  9:38     ` Jiaxun Yang
2020-04-09 10:07       ` Mike Rapoport

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200408113505.2528103-4-jiaxun.yang@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=acme@kernel.org \
    --cc=afzal.mohd.ma@gmail.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexios.zavras@intel.com \
    --cc=allison@lohutok.net \
    --cc=arnd@arndb.de \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=chenhc@lemote.com \
    --cc=f.fainelli@gmail.com \
    --cc=fancer.lancer@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=info@metux.net \
    --cc=jason@lakedaemon.net \
    --cc=jolsa@redhat.com \
    --cc=kdasu.kdev@gmail.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=mark.rutland@arm.com \
    --cc=matt.redfearn@mips.com \
    --cc=maz@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=oprofile-list@lists.sf.net \
    --cc=paul@crapouillou.net \
    --cc=paulburton@kernel.org \
    --cc=peterx@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rafael@kernel.org \
    --cc=rfontana@redhat.com \
    --cc=rppt@linux.ibm.com \
    --cc=rric@kernel.org \
    --cc=sudeep.holla@arm.com \
    --cc=swinslow@gmail.com \
    --cc=syq@debian.org \
    --cc=tglx@linutronix.de \
    --cc=tsbogend@alpha.franken.de \
    --cc=vladimir.kondratiev@intel.com \
    --cc=zhouyanjie@wanyeetech.com \
    --cc=zhouyanjie@zoho.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.