Linux-PM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/2] ARM: vexpress: Set-up shared OPP table instead of individual for each CPU
@ 2019-11-28 10:15 Sudeep Holla
  2019-11-28 10:15 ` [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing Sudeep Holla
  0 siblings, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2019-11-28 10:15 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Rafael J . Wysocki, Liviu Dudau, Viresh Kumar,
	Dietmar Eggemann, Lorenzo Pieralisi, Morten Rasmussen,
	Lukasz Luba

Currently we add individual copy of same OPP table for each CPU within
the cluster. This is redundant and doesn't reflect the reality.

We can't use core cpumask to set policy->cpus in ve_spc_cpufreq_init()
anymore as it gets called via cpuhp_cpufreq_online()->cpufreq_online()
->cpufreq_driver->init() and the cpumask gets updated upon CPU hotplug
operations. It also may cause issues when the vexpress_spc_cpufreq
driver is built as a module.

Since ve_spc_clk_init is built-in device initcall, we should be able to
use the same topology_core_cpumask to set the opp sharing cpumask via
dev_pm_opp_set_sharing_cpus and use the same later in the driver via
dev_pm_opp_get_sharing_cpus.

Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 arch/arm/mach-vexpress/spc.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
index 354e0e7025ae..1da11bdb1dfb 100644
--- a/arch/arm/mach-vexpress/spc.c
+++ b/arch/arm/mach-vexpress/spc.c
@@ -551,8 +551,9 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
 
 static int __init ve_spc_clk_init(void)
 {
-	int cpu;
+	int cpu, cluster;
 	struct clk *clk;
+	bool init_opp_table[MAX_CLUSTERS] = { false };
 
 	if (!info)
 		return 0; /* Continue only if SPC is initialised */
@@ -578,8 +579,17 @@ static int __init ve_spc_clk_init(void)
 			continue;
 		}
 
+		cluster = topology_physical_package_id(cpu_dev->id);
+		if (init_opp_table[cluster])
+			continue;
+
 		if (ve_init_opp_table(cpu_dev))
 			pr_warn("failed to initialise cpu%d opp table\n", cpu);
+		else if (dev_pm_opp_set_sharing_cpus(cpu_dev,
+			 topology_core_cpumask(cpu_dev->id)))
+			pr_warn("failed to mark OPPs shared for cpu%d\n", cpu);
+		else
+			init_opp_table[cluster] = true;
 	}
 
 	platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing
  2019-11-28 10:15 [PATCH 1/2] ARM: vexpress: Set-up shared OPP table instead of individual for each CPU Sudeep Holla
@ 2019-11-28 10:15 ` Sudeep Holla
  2019-11-29 11:49   ` Sudeep Holla
  0 siblings, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2019-11-28 10:15 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel, linux-kernel
  Cc: Sudeep Holla, Rafael J . Wysocki, Liviu Dudau, Viresh Kumar,
	Dietmar Eggemann, Lorenzo Pieralisi, Morten Rasmussen,
	Lukasz Luba

Since commit ca74b316df96 ("arm: Use common cpu_topology structure and
functions.") the core cpumask has to be modified during cpu hotplug
operations. So using them to set up cpufreq policy cpumask may be
incorrect as it may contain only cpus that are online at that instance.

Instead, we can use the cpumask setup by OPP library that contains all
the cpus sharing OPP table using dev_pm_opp_get_sharing_cpus.

Cc: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
 drivers/cpufreq/vexpress-spc-cpufreq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpufreq/vexpress-spc-cpufreq.c b/drivers/cpufreq/vexpress-spc-cpufreq.c
index 506e3f2bf53a..83c85d3d67e3 100644
--- a/drivers/cpufreq/vexpress-spc-cpufreq.c
+++ b/drivers/cpufreq/vexpress-spc-cpufreq.c
@@ -434,7 +434,7 @@ static int ve_spc_cpufreq_init(struct cpufreq_policy *policy)
 	if (cur_cluster < MAX_CLUSTERS) {
 		int cpu;
 
-		cpumask_copy(policy->cpus, topology_core_cpumask(policy->cpu));
+		dev_pm_opp_get_sharing_cpus(cpu_dev, policy->cpus);
 
 		for_each_cpu(cpu, policy->cpus)
 			per_cpu(physical_cluster, cpu) = cur_cluster;
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing
  2019-11-28 10:15 ` [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing Sudeep Holla
@ 2019-11-29 11:49   ` Sudeep Holla
  2019-12-02  2:01     ` Viresh Kumar
  0 siblings, 1 reply; 5+ messages in thread
From: Sudeep Holla @ 2019-11-29 11:49 UTC (permalink / raw)
  To: linux-pm, linux-arm-kernel, linux-kernel
  Cc: Rafael J . Wysocki, Liviu Dudau, Viresh Kumar, Dietmar Eggemann,
	Lorenzo Pieralisi, Morten Rasmussen, Lukasz Luba

Hi Viresh, Rafael,

On Thu, Nov 28, 2019 at 10:15:47AM +0000, Sudeep Holla wrote:
> Since commit ca74b316df96 ("arm: Use common cpu_topology structure and
> functions.") the core cpumask has to be modified during cpu hotplug
> operations. So using them to set up cpufreq policy cpumask may be
> incorrect as it may contain only cpus that are online at that instance.
>
> Instead, we can use the cpumask setup by OPP library that contains all
> the cpus sharing OPP table using dev_pm_opp_get_sharing_cpus.
>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>

This can go independently via PM tree and I can take 1/2 via SoC tree
(as the file is being moved). The problem will be fixed only after both
lands, but this alone won't break the build. Or if you guys provide
Ack, I can take both together via ARM SoC team. Let me know.

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing
  2019-11-29 11:49   ` Sudeep Holla
@ 2019-12-02  2:01     ` Viresh Kumar
  2019-12-02 11:11       ` Sudeep Holla
  0 siblings, 1 reply; 5+ messages in thread
From: Viresh Kumar @ 2019-12-02  2:01 UTC (permalink / raw)
  To: Sudeep Holla
  Cc: linux-pm, linux-arm-kernel, linux-kernel, Rafael J . Wysocki,
	Liviu Dudau, Dietmar Eggemann, Lorenzo Pieralisi,
	Morten Rasmussen, Lukasz Luba

On 29-11-19, 11:49, Sudeep Holla wrote:
> Hi Viresh, Rafael,
> 
> On Thu, Nov 28, 2019 at 10:15:47AM +0000, Sudeep Holla wrote:
> > Since commit ca74b316df96 ("arm: Use common cpu_topology structure and
> > functions.") the core cpumask has to be modified during cpu hotplug
> > operations. So using them to set up cpufreq policy cpumask may be
> > incorrect as it may contain only cpus that are online at that instance.
> >
> > Instead, we can use the cpumask setup by OPP library that contains all
> > the cpus sharing OPP table using dev_pm_opp_get_sharing_cpus.
> >
> > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> 
> This can go independently via PM tree and I can take 1/2 via SoC tree
> (as the file is being moved). The problem will be fixed only after both
> lands, but this alone won't break the build.

Yes, but it will break cpufreq for sure as shared-cpus won't be set by anyone.

> Or if you guys provide
> Ack, I can take both together via ARM SoC team. Let me know.

I was planning to take them through cpufreq tree, but that fine if you can do
that.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing
  2019-12-02  2:01     ` Viresh Kumar
@ 2019-12-02 11:11       ` Sudeep Holla
  0 siblings, 0 replies; 5+ messages in thread
From: Sudeep Holla @ 2019-12-02 11:11 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: linux-pm, linux-arm-kernel, linux-kernel, Rafael J . Wysocki,
	Liviu Dudau, Dietmar Eggemann, Lorenzo Pieralisi,
	Morten Rasmussen, Lukasz Luba, Sudeep Holla

On Mon, Dec 02, 2019 at 07:31:46AM +0530, Viresh Kumar wrote:
> On 29-11-19, 11:49, Sudeep Holla wrote:
> > Hi Viresh, Rafael,
> >
> > On Thu, Nov 28, 2019 at 10:15:47AM +0000, Sudeep Holla wrote:
> > > Since commit ca74b316df96 ("arm: Use common cpu_topology structure and
> > > functions.") the core cpumask has to be modified during cpu hotplug
> > > operations. So using them to set up cpufreq policy cpumask may be
> > > incorrect as it may contain only cpus that are online at that instance.
> > >
> > > Instead, we can use the cpumask setup by OPP library that contains all
> > > the cpus sharing OPP table using dev_pm_opp_get_sharing_cpus.
> > >
> > > Cc: Viresh Kumar <viresh.kumar@linaro.org>
> >
> > This can go independently via PM tree and I can take 1/2 via SoC tree
> > (as the file is being moved). The problem will be fixed only after both
> > lands, but this alone won't break the build.
>
> Yes, but it will break cpufreq for sure as shared-cpus won't be set by anyone.
>

It's already broke on hotplug :) but yes works on boot at-least.

> > Or if you guys provide
> > Ack, I can take both together via ARM SoC team. Let me know.
>
> I was planning to take them through cpufreq tree, but that fine if you can do
> that.
>

Arnd moved and compressed few folders in arch/arm/mach-*, and vexpress
was merged into versatile. Not sure if it's planned for v5.5, so to be
cautious, I preferred to take it via ARM SoC.

> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

Thanks, I will take them together via ARM SoC

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28 10:15 [PATCH 1/2] ARM: vexpress: Set-up shared OPP table instead of individual for each CPU Sudeep Holla
2019-11-28 10:15 ` [PATCH 2/2] cpufreq: vexpress-spc: Switch cpumask from topology core to OPP sharing Sudeep Holla
2019-11-29 11:49   ` Sudeep Holla
2019-12-02  2:01     ` Viresh Kumar
2019-12-02 11:11       ` Sudeep Holla

Linux-PM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-pm/0 linux-pm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-pm linux-pm/ https://lore.kernel.org/linux-pm \
		linux-pm@vger.kernel.org
	public-inbox-index linux-pm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-pm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git