cpufreq: Get rid of cpufreq-dt's platform data
Subsystems (9)
Viresh Kumar
maintainerv2 cover cpufreq: Get rid of cpufreq-dt's platform data
Hi Guys,
The aim of the series is to kill the users of cpufreq-dt's platform data, i.e. mvebu. And because that required a new API to the OPP core, this just became a mix of cpufreq and OPP patches.
V2:
- New patch 2/7.
- Use -ENOTSUPP instead of -ENOSYS or -EINVAL for unimplemented APIs.
- Moved mvebu code to drivers/cpufreq and the same file creates the platform device now for maintaining ordering.
- Not cast required to drop 'const' for cpumask *.
Viresh Kumar (7):
PM / OPP: -ENOSYS is applicable only to syscalls
PM / OPP: Mark cpumask as const in dev_pm_opp_set_sharing_cpus() PM / OPP: Add dev_pm_opp_get_sharing_cpus()
cpufreq: dt: Identify cpu-sharing for platforms without
operating-points-v2
mvebu: Use dev_pm_opp_set_sharing_cpus() to mark OPP tables as shared
cpufreq: dt: Kill platform-data
cpufreq: mvebu: Move cpufreq code into drivers/cpufreq/
MAINTAINERS | 1 + arch/arm/mach-mvebu/pmsu.c | 85 ------------------------------- drivers/base/power/opp/cpu.c | 48 +++++++++++++++++- drivers/cpufreq/Makefile | 1 + drivers/cpufreq/cpufreq-dt.c | 22 ++++----- drivers/cpufreq/mvebu-cpufreq.c | 107 ++++++++++++++++++++++++++++++++++++++++ include/linux/cpufreq-dt.h | 24 --------- include/linux/pm_opp.h | 36 ++++++++------ 8 files changed, 187 insertions(+), 137 deletions(-) create mode 100644 drivers/cpufreq/mvebu-cpufreq.c delete mode 100644 include/linux/cpufreq-dt.h
Signature · 1 line
2.7.1.410.g6faf27b
Viresh Kumar
maintainerPATCH v2 1/7 PM / OPP: -ENOSYS is applicable only to syscalls
Some of the routines have used -ENOSYS for the cases where the functionality isn't implemented in the kernel. But ENOSYS is supposed to be used only for syscalls.
Replace that with -ENOTSUPP, which specifically means that the operation isn't supported.
While at it, replace exiting -EINVAL errors for similar cases to -ENOTSUPP.
--- include/linux/pm_opp.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
include/linux/pm_opp.h +13 -13
@@ -110,25 +110,25 @@ static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev)static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact (struct device *dev,unsigned long freq,bool available) { -return ERR_PTR (-EINVAL ); +return ERR_PTR (-ENOTSUPP ); }static inline struct dev_pm_opp *dev_pm_opp_find_freq_floor (struct device *dev,unsigned long *freq) { -return ERR_PTR (-EINVAL ); +return ERR_PTR (-ENOTSUPP ); }static inline struct dev_pm_opp *dev_pm_opp_find_freq_ceil (struct device *dev,unsigned long *freq) { -return ERR_PTR (-EINVAL ); +return ERR_PTR (-ENOTSUPP ); }static inline int dev_pm_opp_add (struct device *dev,unsigned long freq,unsigned long u_volt) { -return -EINVAL ; +return -ENOTSUPP ; }static inline void dev_pm_opp_remove (struct device *dev,unsigned long freq)
@@ -148,40 +148,40 @@ static inline int dev_pm_opp_disable(struct device *dev, unsigned long freq)static inline struct srcu_notifier_head *dev_pm_opp_get_notifier (struct device *dev) { -return ERR_PTR (-EINVAL ); +return ERR_PTR (-ENOTSUPP ); }static inline int dev_pm_opp_set_supported_hw (struct device *dev,const u32 *versions,unsigned int count) { -return -EINVAL ; +return -ENOTSUPP ; }static inline void dev_pm_opp_put_supported_hw (struct device *dev) {}static inline int dev_pm_opp_set_prop_name (struct device *dev,const char *name) { -return -EINVAL ; +return -ENOTSUPP ; }static inline void dev_pm_opp_put_prop_name (struct device *dev) {}static inline int dev_pm_opp_set_regulator (struct device *dev,const char *name) { -return -EINVAL ; +return -ENOTSUPP ; }static inline void dev_pm_opp_put_regulator (struct device *dev) {}static inline int dev_pm_opp_set_rate (struct device *dev,unsigned long target_freq) { -return -EINVAL ; +return -ENOTSUPP ; }static inline int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) { -return -ENOSYS ; +return -ENOTSUPP ; }#endif /* CONFIG_PM_OPP */
@@ -195,7 +195,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask#else static inline int dev_pm_opp_of_add_table (struct device *dev) { -return -EINVAL ; +return -ENOTSUPP ; }static inline void dev_pm_opp_of_remove_table (struct device *dev)
@@ -204,7 +204,7 @@ static inline void dev_pm_opp_of_remove_table(struct device *dev)static inline int dev_pm_opp_of_cpumask_add_table (cpumask_var_t cpumask) { -return -ENOSYS ; +return -ENOTSUPP ; }static inline void dev_pm_opp_of_cpumask_remove_table (cpumask_var_t cpumask)
@@ -213,7 +213,7 @@ static inline void dev_pm_opp_of_cpumask_remove_table(cpumask_var_t cpumask)static inline int dev_pm_opp_of_get_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) { -return -ENOSYS ; +return -ENOTSUPP ; }#endif
Signature · 1 line
2.7.1.410.g6faf27b
Re: [PATCH V2 1/7] PM / OPP: -ENOSYS is applicable only to syscalls
Quoted 4 lines · Viresh Kumar
Some of the routines have used
-ENOSYSfor the cases where the functionality isn't implemented in the kernel. But ENOSYS is supposed to be used only for syscalls.
Quoted 8 lines
Replace that with
-ENOTSUPP, which specifically means that the operation isn't supported.While at it, replace exiting
-EINVALerrors for similar cases to-ENOTSUPP.Signed-off-by Viresh Kumar <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Viresh Kumar
maintainerPATCH v2 2/7 PM / OPP: Mark cpumask as const in dev_pm_opp_set_sharing_cpus()
In reply to Viresh Kumardev_pm_opp_set_sharing_cpus() isn't supposed to update the cpumask passed as its parameter, and so it should always have been marked 'const'.
Do it now.
--- drivers/base/power/opp/cpu.c | 3 ++- include/linux/pm_opp.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/base/power/opp/cpu.c +2 -1
@@ -287,7 +287,8 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_sharing_cpus);* that this function is *NOT* called under RCU protection or in contexts where * mutex cannot be locked. */ -int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) +int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev, +const cpumask_var_t cpumask) {struct opp_device *opp_dev;struct opp_table *opp_table;
include/linux/pm_opp.h +2 -2
@@ -65,7 +65,7 @@ void dev_pm_opp_put_prop_name(struct device *dev);int dev_pm_opp_set_regulator (struct device *dev,const char *name);void dev_pm_opp_put_regulator (struct device *dev);int dev_pm_opp_set_rate (struct device *dev,unsigned long target_freq); -int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask); +int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,const cpumask_var_t cpumask);#else static inline unsigned long dev_pm_opp_get_voltage (struct dev_pm_opp *opp) {
@@ -179,7 +179,7 @@ static inline int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freturn -ENOTSUPP ; } -static inline int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) +static inline int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,const cpumask_var_t cpumask) {return -ENOTSUPP ; }
Signature · 1 line
2.7.1.410.g6faf27b
Re: [PATCH V2 2/7] PM / OPP: Mark cpumask as const in dev_pm_opp_set_sharing_cpus()
Quoted 8 lines · Viresh Kumar
dev_pm_opp_set_sharing_cpus()isn't supposed to update the cpumask passed as its parameter, and so it should always have been marked 'const'.Do it now.
Signed-off-by Viresh Kumar <[email protected]>---
I'm ignoring cpumask_var_t usage.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Viresh Kumar
maintainerRe: [PATCH V2 2/7] PM / OPP: Mark cpumask as const in dev_pm_opp_set_sharing_cpus()
Quoted 5 lines · Stephen Boyd
Quoted 4 lines · Viresh Kumar
dev_pm_opp_set_sharing_cpus()isn't supposed to update the cpumask passed as its parameter, and so it should always have been marked 'const'.
Quoted 8 lines
Quoted 4 lines
Do it now.
Signed-off-by Viresh Kumar <[email protected]>---
Reviewed-by Stephen Boyd <[email protected]>I'm ignoring
cpumask_var_tusage.
Yeah, this is already merged by Rafael and Arnd's patch applies over it.
Signature · 1 line
viresh
Viresh Kumar
maintainerPATCH v2 3/7 PM / OPP: Add dev_pm_opp_get_sharing_cpus()
In reply to Viresh KumarOPP core allows a platform to mark OPP table as shared, when the platform isn't using operating-points-v2 bindings.
And, so there should be a non DT way of finding out if the OPP table is shared or not.
This patch adds dev_pm_opp_get_sharing_cpus(), which first tries to get OPP sharing information from the opp-table (in case it is already marked as shared), otherwise it uses the existing DT way of finding sharing information.
--- drivers/base/power/opp/cpu.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 51 insertions(+)
drivers/base/power/opp/cpu.c +45 -0
@@ -330,3 +330,48 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev,return ret; }EXPORT_SYMBOL_GPL (dev_pm_opp_set_sharing_cpus); + +/** +* dev_pm_opp_get_sharing_cpus() - Get cpumask of CPUs sharing OPPs with @cpu_dev +* @cpu_dev: CPU device for which we do this operation +* @cpumask: cpumask to update with information of sharing CPUs +* +* This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev. +* +* Returns -ENODEV if OPP table isn't already present. +* +* Locking: The internal opp_table and opp structures are RCU protected. +* Hence this function internally uses RCU updater strategy with mutex locks +* to keep the integrity of the internal data structures. Callers should ensure +* that this function is *NOT* called under RCU protection or in contexts where +* mutex cannot be locked. +*/ +int dev_pm_opp_get_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) +{ +struct opp_device *opp_dev; +struct opp_table *opp_table; +int ret =0 ; + +mutex_lock (&opp_table_lock); + + opp_table =_find_opp_table (cpu_dev); +if (IS_ERR (opp_table)) { + ret =PTR_ERR (opp_table); + goto unlock; + } + +cpumask_clear (cpumask); + +if (opp_table->shared_opp) { +list_for_each_entry (opp_dev, &opp_table->dev_list, node) +cpumask_set_cpu (opp_dev->dev->id, cpumask); + }else { +cpumask_set_cpu (cpu_dev->id, cpumask); + } + +unlock: +mutex_unlock (&opp_table_lock); + +return ret; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_get_sharing_cpus);
include/linux/pm_opp.h +6 -0
@@ -66,6 +66,7 @@ int dev_pm_opp_set_regulator(struct device *dev, const char *name);void dev_pm_opp_put_regulator (struct device *dev);int dev_pm_opp_set_rate (struct device *dev,unsigned long target_freq);int dev_pm_opp_set_sharing_cpus (struct device *cpu_dev,const cpumask_var_t cpumask); +int dev_pm_opp_get_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask);#else static inline unsigned long dev_pm_opp_get_voltage (struct dev_pm_opp *opp) {
@@ -184,6 +185,11 @@ static inline int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, const cpum return -ENOTSUPP; } +static inline int dev_pm_opp_get_sharing_cpus (struct device *cpu_dev,cpumask_var_t cpumask) +{ +return -EINVAL ; +} +#endif /* CONFIG_PM_OPP */ #if defined(CONFIG_PM_OPP ) && defined(CONFIG_OF )
Signature · 1 line
2.7.1.410.g6faf27b
Re: [PATCH V2 3/7] PM / OPP: Add dev_pm_opp_get_sharing_cpus()
Quoted 6 lines · Viresh Kumar
OPP core allows a platform to mark OPP table as shared, when the platform isn't using operating-points-v2 bindings.
And, so there should be a non DT way of finding out if the OPP table is shared or not.
Quoted 7 lines
This patch adds
dev_pm_opp_get_sharing_cpus(), which first tries to get OPP sharing information from the opp-table (in case it is already marked as shared), otherwise it uses the existing DT way of finding sharing information.Signed-off-by Viresh Kumar <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Viresh Kumar
maintainerPATCH v2 4/7 cpufreq: dt: Identify cpu-sharing for platforms without operating-points-v2
In reply to Viresh KumarExisting platforms, which do not support operating-points-v2, can explicitly tell the opp core that some of the CPUs share opp tables, with help of dev_pm_opp_set_sharing_cpus().
For such platforms, explicitly ask the opp core to provide list of CPUs sharing the opp table with current cpu device, before falling back to platform data.
--- drivers/cpufreq/cpufreq-dt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/cpufreq/cpufreq-dt.c +9 -7
@@ -147,7 +147,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)struct clk *cpu_clk;struct dev_pm_opp *suspend_opp;unsigned int transition_latency; -bool opp_v1 = false; +bool fallback = false;const char *name;int ret;
@@ -167,14 +167,16 @@ static int cpufreq_init(struct cpufreq_policy *policy)/* Get OPP-sharing information from "operating-points-v2" bindings */ ret =dev_pm_opp_of_get_sharing_cpus (cpu_dev, policy->cpus);if (ret) { +if (ret != -ENOENT ) + goto out_put_clk; +/* * operating-points-v2 not supported, fallback to old method of -* finding shared-OPPs for backward compatibility. +* finding shared-OPPs for backward compatibility if the +* platform hasn't set sharing CPUs. */ -if (ret == -ENOENT ) - opp_v1 = true; -else - goto out_put_clk; +if (dev_pm_opp_get_sharing_cpus (cpu_dev, policy->cpus)) + fallback = true; }/*
@@ -214,7 +216,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) goto out_free_opp; } -if (opp_v1) { +if (fallback) {struct cpufreq_dt_platform_data *pd =cpufreq_get_driver_data ();if (!pd || !pd->independent_clocks)
Signature · 1 line
2.7.1.410.g6faf27b
Re: [PATCH V2 4/7] cpufreq: dt: Identify cpu-sharing for platforms without operating-points-v2
Quoted 10 lines · Viresh Kumar
Existing platforms, which do not support operating-points-v2, can explicitly tell the opp core that some of the CPUs share opp tables, with help of
dev_pm_opp_set_sharing_cpus().For such platforms, explicitly ask the opp core to provide list of CPUs sharing the opp table with current cpu device, before falling back to platform data.
Signed-off-by Viresh Kumar <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Viresh Kumar
maintainerPATCH v2 5/7 mvebu: Use dev_pm_opp_set_sharing_cpus() to mark OPP tables as shared
In reply to Viresh KumarThat will allow us to avoid using cpufreq-dt platform data.
--- arch/arm/mach-mvebu/pmsu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/arm/mach-mvebu/pmsu.c +7 -7
@@ -20,7 +20,6 @@#include <linux/clk.h> #include <linux/cpu_pm.h> -#include <linux/cpufreq-dt.h> #include <linux/delay.h> #include <linux/init.h> #include <linux/io.h>
@@ -609,10 +608,6 @@ int mvebu_pmsu_dfs_request(int cpu)return 0 ; } -struct cpufreq_dt_platform_data cpufreq_dt_pd = { - .independent_clocks = true, -}; -static int __init armada_xp_pmsu_cpufreq_init (void ) {struct device_node *np;
@@ -683,10 +678,15 @@ static int __init armada_xp_pmsu_cpufreq_init(void)clk_put (clk);return ret; } + + ret =dev_pm_opp_set_sharing_cpus (cpu_dev, +cpumask_of (cpu_dev->id)); +if (ret) +dev_err (cpu_dev,"%s: failed to mark OPPs as shared: %d\n" , + __func__, ret); } -platform_device_register_data (NULL ,"cpufreq-dt" ,-1 , - &cpufreq_dt_pd,sizeof (cpufreq_dt_pd)); +platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 );return 0 ; }
Signature · 1 line
2.7.1.410.g6faf27b
Re: [PATCH V2 5/7] mvebu: Use dev_pm_opp_set_sharing_cpus() to mark OPP tables as shared
Quoted 9 lines · Viresh Kumar
That will allow us to avoid using cpufreq-dt platform data.
Cc Thomas Petazzoni <[email protected]>Cc Jason Cooper <[email protected]>Cc Andrew Lunn <[email protected]>Cc Gregory Clement <[email protected]>Cc Sebastian Hesselbarth <[email protected]>Signed-off-by Viresh Kumar <[email protected]>---
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Viresh Kumar
maintainerPATCH v2 6/7 cpufreq: dt: Kill platform-data
In reply to Viresh KumarThere are no more users of platform-data for cpufreq-dt driver, get rid of it.
--- drivers/cpufreq/cpufreq-dt.c | 6 +----- include/linux/cpufreq-dt.h | 24 ------------------------ 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 include/linux/cpufreq-dt.h
drivers/cpufreq/cpufreq-dt.c +1 -5
@@ -15,7 +15,6 @@#include <linux/cpu.h> #include <linux/cpu_cooling.h> #include <linux/cpufreq.h> -#include <linux/cpufreq-dt.h> #include <linux/cpumask.h> #include <linux/err.h> #include <linux/module.h>
@@ -217,10 +216,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) }if (fallback) { -struct cpufreq_dt_platform_data *pd =cpufreq_get_driver_data (); - -if (!pd || !pd->independent_clocks) -cpumask_setall (policy->cpus); +cpumask_setall (policy->cpus);/* * OPP tables are initialized only for policy->cpu, do it for
include/linux/cpufreq-dt.h deleted +0 -24
@@ -1,24 +0,0 @@ -/* -* Copyright (C) 2014 Marvell -* Thomas Petazzoni <[email protected]> -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License version 2 as -* published by the Free Software Foundation. -*/ - -#ifndef __CPUFREQ_DT_H__ -#define __CPUFREQ_DT_H__ - -#include <linux/types.h> - -struct cpufreq_dt_platform_data { -/* -* True when each CPU has its own clock to control its -* frequency, false when all CPUs are controlled by a single -* clock. -*/ -bool independent_clocks; -}; - -#endif /* __CPUFREQ_DT_H__ */
Signature · 1 line
2.7.1.410.g6faf27b
Viresh Kumar
maintainerPATCH v2 7/7 cpufreq: mvebu: Move cpufreq code into drivers/cpufreq/
In reply to Viresh KumarMove cpufreq bits for mvebu into drivers/cpufreq/ directory, that's where they really belong to.
Compiled tested only.
--- MAINTAINERS | 1 + arch/arm/mach-mvebu/pmsu.c | 85 ------------------------------- drivers/cpufreq/Makefile | 1 + drivers/cpufreq/mvebu-cpufreq.c | 107 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 85 deletions(-) create mode 100644 drivers/cpufreq/mvebu-cpufreq.c
MAINTAINERS +1 -0
@@ -1322,6 +1322,7 @@ F: drivers/rtc/rtc-armada38x.c F: arch/arm/boot/dts/armada* F: arch/arm/boot/dts/kirkwood* F: arch/arm64/boot/dts/marvell/armada* +F: drivers/cpufreq/mvebu-cpufreq.c ARM/Marvell Berlin SoC support
arch/arm/mach-mvebu/pmsu.c +0 -85
94 lines not on this page · raw message
drivers/cpufreq/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o +obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o ##################################################################################
drivers/cpufreq/mvebu-cpufreq.c new file +107 -0
107 lines not on this page · raw message
Signature · 1 line
2.7.1.410.g6faf27b
Quoted 6 lines · On Wednesday 27 April 2016 08:52:20 Viresh Kumar wrote:
Hi Guys,
The aim of the series is to kill the users of cpufreq-dt's platform data, i.e. mvebu. And because that required a new API to the OPP core, this just became a mix of cpufreq and OPP patches.