* [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number
@ 2014-08-14 8:27 Juri Lelli
2014-08-15 10:07 ` Lorenzo Pieralisi
2014-08-15 16:32 ` Kevin Hilman
0 siblings, 2 replies; 4+ messages in thread
From: Juri Lelli @ 2014-08-14 8:27 UTC (permalink / raw)
To: linux
Cc: Juri Lelli, Lorenzo Pieralisi, Daniel Lezcano, Rafael J. Wysocki,
Will Deacon, Chao Xie, Stephen Warren, Sebastian Hesselbarth,
Rob Herring, Jonathan Austin, Chao Xie Linux, Juri Lelli,
linux-pm, linux-arm-kernel, linux-kernel
Commit af040ffc9ba1 ("ARM: make it easier to check the CPU part number
correctly") changed ARM_CPU_PART_X masks, and the way they are returned and
checked against. Usage of read_cpuid_part_number() is now deprecated, and
calling places updated accordingly. This actually broke cpuidle-big_little
initialization, as bl_idle_driver_init() performs a check using an hardcoded
mask on cpu_id.
Create an interface to perform the check (that is now even easier to read).
Define also a proper mask (ARM_CPU_PART_MASK) that makes this kind of checks
cleaner and helps preventing bugs in the future. Update usage accordingly.
Signed-off-by: Juri Lelli <juri.lelli@arm.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Chao Xie <chao.xie@marvell.com>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Jonathan Austin <Jonathan.Austin@arm.com>
Cc: Chao Xie Linux <xiechao.mail@gmail.com>
Cc: Juri Lelli <juri.lelli@gmail.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
---
arch/arm/include/asm/cputype.h | 3 ++-
arch/arm/include/asm/smp_plat.h | 15 +++++++++++++++
drivers/cpuidle/cpuidle-big_little.c | 13 +++----------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index 963a251..819777d 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -74,6 +74,7 @@
#define ARM_CPU_PART_CORTEX_A12 0x4100c0d0
#define ARM_CPU_PART_CORTEX_A17 0x4100c0e0
#define ARM_CPU_PART_CORTEX_A15 0x4100c0f0
+#define ARM_CPU_PART_MASK 0xff00fff0
#define ARM_CPU_XSCALE_ARCH_MASK 0xe000
#define ARM_CPU_XSCALE_ARCH_V1 0x2000
@@ -179,7 +180,7 @@ static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
*/
static inline unsigned int __attribute_const__ read_cpuid_part(void)
{
- return read_cpuid_id() & 0xff00fff0;
+ return read_cpuid_id() & ARM_CPU_PART_MASK;
}
static inline unsigned int __attribute_const__ __deprecated read_cpuid_part_number(void)
diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
index a252c0b..0ad7d49 100644
--- a/arch/arm/include/asm/smp_plat.h
+++ b/arch/arm/include/asm/smp_plat.h
@@ -8,6 +8,7 @@
#include <linux/cpumask.h>
#include <linux/err.h>
+#include <asm/cpu.h>
#include <asm/cputype.h>
/*
@@ -25,6 +26,20 @@ static inline bool is_smp(void)
#endif
}
+/**
+ * smp_cpuid_part() - return part id for a given cpu
+ * @cpu: logical cpu id.
+ *
+ * Return: part id of logical cpu passed as argument.
+ */
+static inline unsigned int smp_cpuid_part(int cpu)
+{
+ struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
+
+ return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
+ read_cpuid_part();
+}
+
/* all SMP configurations have the extended CPUID registers */
#ifndef CONFIG_MMU
#define tlb_ops_need_broadcast() 0
diff --git a/drivers/cpuidle/cpuidle-big_little.c b/drivers/cpuidle/cpuidle-big_little.c
index 344d79fa..ef94c3b 100644
--- a/drivers/cpuidle/cpuidle-big_little.c
+++ b/drivers/cpuidle/cpuidle-big_little.c
@@ -138,25 +138,18 @@ static int bl_enter_powerdown(struct cpuidle_device *dev,
return idx;
}
-static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int cpu_id)
+static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int part_id)
{
- struct cpuinfo_arm *cpu_info;
struct cpumask *cpumask;
- unsigned long cpuid;
int cpu;
cpumask = kzalloc(cpumask_size(), GFP_KERNEL);
if (!cpumask)
return -ENOMEM;
- for_each_possible_cpu(cpu) {
- cpu_info = &per_cpu(cpu_data, cpu);
- cpuid = is_smp() ? cpu_info->cpuid : read_cpuid_id();
-
- /* read cpu id part number */
- if ((cpuid & 0xFFF0) == cpu_id)
+ for_each_possible_cpu(cpu)
+ if (smp_cpuid_part(cpu) == part_id)
cpumask_set_cpu(cpu, cpumask);
- }
drv->cpumask = cpumask;
--
2.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number
2014-08-14 8:27 [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number Juri Lelli
@ 2014-08-15 10:07 ` Lorenzo Pieralisi
2014-08-15 16:32 ` Kevin Hilman
1 sibling, 0 replies; 4+ messages in thread
From: Lorenzo Pieralisi @ 2014-08-15 10:07 UTC (permalink / raw)
To: Juri Lelli
Cc: linux@arm.linux.org.uk, Daniel Lezcano, Rafael J. Wysocki,
Will Deacon, Chao Xie, Stephen Warren, Sebastian Hesselbarth,
rob.herring@calxeda.com, Jonathan Austin, Chao Xie Linux,
Juri Lelli, linux-pm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
On Thu, Aug 14, 2014 at 09:27:45AM +0100, Juri Lelli wrote:
> Commit af040ffc9ba1 ("ARM: make it easier to check the CPU part number
> correctly") changed ARM_CPU_PART_X masks, and the way they are returned and
> checked against. Usage of read_cpuid_part_number() is now deprecated, and
> calling places updated accordingly. This actually broke cpuidle-big_little
> initialization, as bl_idle_driver_init() performs a check using an hardcoded
> mask on cpu_id.
>
> Create an interface to perform the check (that is now even easier to read).
> Define also a proper mask (ARM_CPU_PART_MASK) that makes this kind of checks
> cleaner and helps preventing bugs in the future. Update usage accordingly.
If Russell does not have any additional comments you can send it to his
patch system.
Thanks,
Lorenzo
> Signed-off-by: Juri Lelli <juri.lelli@arm.com>
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
> Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Chao Xie <chao.xie@marvell.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Jonathan Austin <Jonathan.Austin@arm.com>
> Cc: Chao Xie Linux <xiechao.mail@gmail.com>
> Cc: Juri Lelli <juri.lelli@gmail.com>
> Cc: linux-pm@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-kernel@vger.kernel.org
> ---
> arch/arm/include/asm/cputype.h | 3 ++-
> arch/arm/include/asm/smp_plat.h | 15 +++++++++++++++
> drivers/cpuidle/cpuidle-big_little.c | 13 +++----------
> 3 files changed, 20 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
> index 963a251..819777d 100644
> --- a/arch/arm/include/asm/cputype.h
> +++ b/arch/arm/include/asm/cputype.h
> @@ -74,6 +74,7 @@
> #define ARM_CPU_PART_CORTEX_A12 0x4100c0d0
> #define ARM_CPU_PART_CORTEX_A17 0x4100c0e0
> #define ARM_CPU_PART_CORTEX_A15 0x4100c0f0
> +#define ARM_CPU_PART_MASK 0xff00fff0
>
> #define ARM_CPU_XSCALE_ARCH_MASK 0xe000
> #define ARM_CPU_XSCALE_ARCH_V1 0x2000
> @@ -179,7 +180,7 @@ static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
> */
> static inline unsigned int __attribute_const__ read_cpuid_part(void)
> {
> - return read_cpuid_id() & 0xff00fff0;
> + return read_cpuid_id() & ARM_CPU_PART_MASK;
> }
>
> static inline unsigned int __attribute_const__ __deprecated read_cpuid_part_number(void)
> diff --git a/arch/arm/include/asm/smp_plat.h b/arch/arm/include/asm/smp_plat.h
> index a252c0b..0ad7d49 100644
> --- a/arch/arm/include/asm/smp_plat.h
> +++ b/arch/arm/include/asm/smp_plat.h
> @@ -8,6 +8,7 @@
> #include <linux/cpumask.h>
> #include <linux/err.h>
>
> +#include <asm/cpu.h>
> #include <asm/cputype.h>
>
> /*
> @@ -25,6 +26,20 @@ static inline bool is_smp(void)
> #endif
> }
>
> +/**
> + * smp_cpuid_part() - return part id for a given cpu
> + * @cpu: logical cpu id.
> + *
> + * Return: part id of logical cpu passed as argument.
> + */
> +static inline unsigned int smp_cpuid_part(int cpu)
> +{
> + struct cpuinfo_arm *cpu_info = &per_cpu(cpu_data, cpu);
> +
> + return is_smp() ? cpu_info->cpuid & ARM_CPU_PART_MASK :
> + read_cpuid_part();
> +}
> +
> /* all SMP configurations have the extended CPUID registers */
> #ifndef CONFIG_MMU
> #define tlb_ops_need_broadcast() 0
> diff --git a/drivers/cpuidle/cpuidle-big_little.c b/drivers/cpuidle/cpuidle-big_little.c
> index 344d79fa..ef94c3b 100644
> --- a/drivers/cpuidle/cpuidle-big_little.c
> +++ b/drivers/cpuidle/cpuidle-big_little.c
> @@ -138,25 +138,18 @@ static int bl_enter_powerdown(struct cpuidle_device *dev,
> return idx;
> }
>
> -static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int cpu_id)
> +static int __init bl_idle_driver_init(struct cpuidle_driver *drv, int part_id)
> {
> - struct cpuinfo_arm *cpu_info;
> struct cpumask *cpumask;
> - unsigned long cpuid;
> int cpu;
>
> cpumask = kzalloc(cpumask_size(), GFP_KERNEL);
> if (!cpumask)
> return -ENOMEM;
>
> - for_each_possible_cpu(cpu) {
> - cpu_info = &per_cpu(cpu_data, cpu);
> - cpuid = is_smp() ? cpu_info->cpuid : read_cpuid_id();
> -
> - /* read cpu id part number */
> - if ((cpuid & 0xFFF0) == cpu_id)
> + for_each_possible_cpu(cpu)
> + if (smp_cpuid_part(cpu) == part_id)
> cpumask_set_cpu(cpu, cpumask);
> - }
>
> drv->cpumask = cpumask;
>
> --
> 2.0.4
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number
2014-08-14 8:27 [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number Juri Lelli
2014-08-15 10:07 ` Lorenzo Pieralisi
@ 2014-08-15 16:32 ` Kevin Hilman
2014-08-15 16:36 ` Juri Lelli
1 sibling, 1 reply; 4+ messages in thread
From: Kevin Hilman @ 2014-08-15 16:32 UTC (permalink / raw)
To: Juri Lelli
Cc: linux, Lorenzo Pieralisi, Daniel Lezcano, Rafael J. Wysocki,
Will Deacon, Chao Xie, Stephen Warren, Sebastian Hesselbarth,
Rob Herring, Jonathan Austin, Chao Xie Linux, Juri Lelli,
linux-pm, linux-arm-kernel, linux-kernel
Juri Lelli <juri.lelli@arm.com> writes:
> Commit af040ffc9ba1 ("ARM: make it easier to check the CPU part number
> correctly") changed ARM_CPU_PART_X masks, and the way they are returned and
> checked against. Usage of read_cpuid_part_number() is now deprecated, and
> calling places updated accordingly. This actually broke cpuidle-big_little
> initialization, as bl_idle_driver_init() performs a check using an hardcoded
> mask on cpu_id.
>
> Create an interface to perform the check (that is now even easier to read).
> Define also a proper mask (ARM_CPU_PART_MASK) that makes this kind of checks
> cleaner and helps preventing bugs in the future. Update usage accordingly.
[...]
Tested-by: Kevin Hilman <khilman@linaro.org>
FWIW, I can confirm that this patch is needed for cpuidle-big_little to
work on the Exynos5800/Chromebook2.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number
2014-08-15 16:32 ` Kevin Hilman
@ 2014-08-15 16:36 ` Juri Lelli
0 siblings, 0 replies; 4+ messages in thread
From: Juri Lelli @ 2014-08-15 16:36 UTC (permalink / raw)
To: Kevin Hilman
Cc: linux@arm.linux.org.uk, Lorenzo Pieralisi, Daniel Lezcano,
Rafael J. Wysocki, Will Deacon, Chao Xie, Stephen Warren,
Sebastian Hesselbarth, rob.herring@calxeda.com, Jonathan Austin,
Chao Xie Linux, Juri Lelli, linux-pm@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
On 15/08/14 17:32, Kevin Hilman wrote:
> Juri Lelli <juri.lelli@arm.com> writes:
>
>> Commit af040ffc9ba1 ("ARM: make it easier to check the CPU part number
>> correctly") changed ARM_CPU_PART_X masks, and the way they are returned and
>> checked against. Usage of read_cpuid_part_number() is now deprecated, and
>> calling places updated accordingly. This actually broke cpuidle-big_little
>> initialization, as bl_idle_driver_init() performs a check using an hardcoded
>> mask on cpu_id.
>>
>> Create an interface to perform the check (that is now even easier to read).
>> Define also a proper mask (ARM_CPU_PART_MASK) that makes this kind of checks
>> cleaner and helps preventing bugs in the future. Update usage accordingly.
>
> [...]
>
> Tested-by: Kevin Hilman <khilman@linaro.org>
>
Great, thanks!
> FWIW, I can confirm that this patch is needed for cpuidle-big_little to
> work on the Exynos5800/Chromebook2.
>
Ok, the patch has been already sent to Russell's patch system.
Best,
- Juri
> Kevin
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-08-15 16:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-14 8:27 [PATCH v2] cpuidle/cpuidle-big_little: fix reading cpu id part number Juri Lelli
2014-08-15 10:07 ` Lorenzo Pieralisi
2014-08-15 16:32 ` Kevin Hilman
2014-08-15 16:36 ` Juri Lelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).