From: Juri Lelli <juri.lelli@arm.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>
Cc: Lorenzo Pieralisi <Lorenzo.Pieralisi@arm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Juri Lelli <juri.lelli@gmail.com>
Subject: Re: [PATCH] cpuidle/cpuidle-big_little: fix reading cpu id part number
Date: Wed, 13 Aug 2014 12:14:40 +0100 [thread overview]
Message-ID: <53EB48A0.3040204@arm.com> (raw)
In-Reply-To: <20140813104431.GJ30401@n2100.arm.linux.org.uk>
On 13/08/14 11:44, Russell King - ARM Linux wrote:
> On Wed, Aug 13, 2014 at 11:04:13AM +0100, Juri Lelli wrote:
>> Thanks a lot for the comment. Does what below address it?
>
> Yes, thanks, but a few of nitpicks though.
>
>> +/*
>> + * smp_cpuid_part() - return part id for a given cpu
>> + *
>> + * @cpu: logical cpu id
>> + *
>> + * Return: part id of logical cpu passed as argument
>> + *
>> + */
>
> If this is supposed to be a kerneldoc-compatible comment, please read
> Documentation/kernel-doc-nano-HOWTO.txt for the correct format.
>
>> +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) :
>
> Parens are not required, and there's a double space before &.
>
> The BNF for the ?: operator is:
>
> cond-expr:
> log-or-expr ? expr : cond-expr
>
> So the compiler knows that whatever is between the ? and : is a single
> expression, and the parens are surplus.
>
>> -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 match_id)
>
> If we're changing the name, "part_id" would probably be better than the
> opaque "match_id" here.
>
Right, thanks! What follows has those fixed. Should I send it as a new post?
Thanks,
- Juri
>From 61b88de0f021213f894e843c8e4673203f953ca9 Mon Sep 17 00:00:00 2001
From: Juri Lelli <juri.lelli@arm.com>
Date: Thu, 7 Aug 2014 17:26:54 +0100
Subject: [PATCH] cpuidle/cpuidle-big_little: fix reading cpu id part number
Commit af040ffc9ba1e079ee4c0748aff64fa3d4716fa5 by Russell King 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 and 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>
---
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
WARNING: multiple messages have this Message-ID (diff)
From: juri.lelli@arm.com (Juri Lelli)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] cpuidle/cpuidle-big_little: fix reading cpu id part number
Date: Wed, 13 Aug 2014 12:14:40 +0100 [thread overview]
Message-ID: <53EB48A0.3040204@arm.com> (raw)
In-Reply-To: <20140813104431.GJ30401@n2100.arm.linux.org.uk>
On 13/08/14 11:44, Russell King - ARM Linux wrote:
> On Wed, Aug 13, 2014 at 11:04:13AM +0100, Juri Lelli wrote:
>> Thanks a lot for the comment. Does what below address it?
>
> Yes, thanks, but a few of nitpicks though.
>
>> +/*
>> + * smp_cpuid_part() - return part id for a given cpu
>> + *
>> + * @cpu: logical cpu id
>> + *
>> + * Return: part id of logical cpu passed as argument
>> + *
>> + */
>
> If this is supposed to be a kerneldoc-compatible comment, please read
> Documentation/kernel-doc-nano-HOWTO.txt for the correct format.
>
>> +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) :
>
> Parens are not required, and there's a double space before &.
>
> The BNF for the ?: operator is:
>
> cond-expr:
> log-or-expr ? expr : cond-expr
>
> So the compiler knows that whatever is between the ? and : is a single
> expression, and the parens are surplus.
>
>> -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 match_id)
>
> If we're changing the name, "part_id" would probably be better than the
> opaque "match_id" here.
>
Right, thanks! What follows has those fixed. Should I send it as a new post?
Thanks,
- Juri
>From 61b88de0f021213f894e843c8e4673203f953ca9 Mon Sep 17 00:00:00 2001
From: Juri Lelli <juri.lelli@arm.com>
Date: Thu, 7 Aug 2014 17:26:54 +0100
Subject: [PATCH] cpuidle/cpuidle-big_little: fix reading cpu id part number
Commit af040ffc9ba1e079ee4c0748aff64fa3d4716fa5 by Russell King 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 and 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>
---
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
next prev parent reply other threads:[~2014-08-13 11:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-08 12:42 [PATCH] cpuidle/cpuidle-big_little: fix reading cpu id part number Juri Lelli
2014-08-08 12:42 ` Juri Lelli
2014-08-08 13:21 ` Russell King - ARM Linux
2014-08-08 13:21 ` Russell King - ARM Linux
2014-08-08 16:47 ` Lorenzo Pieralisi
2014-08-08 16:47 ` Lorenzo Pieralisi
2014-08-13 10:04 ` Juri Lelli
2014-08-13 10:04 ` Juri Lelli
2014-08-13 10:44 ` Russell King - ARM Linux
2014-08-13 10:44 ` Russell King - ARM Linux
2014-08-13 11:14 ` Juri Lelli [this message]
2014-08-13 11:14 ` Juri Lelli
2014-08-13 22:25 ` Lorenzo Pieralisi
2014-08-13 22:25 ` Lorenzo Pieralisi
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=53EB48A0.3040204@arm.com \
--to=juri.lelli@arm.com \
--cc=Lorenzo.Pieralisi@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=juri.lelli@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=rjw@rjwysocki.net \
/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.