Skip to contentSkip to conversation

arm: Fix linux-next compile error in arch/arm/common/gic.c

PATCH In review Joerg Roedel 6 participants 7 messages Jan 2, 2012 – Jan 3, 2012 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: Fix linux-next compile error in arch/arm/common/gic.c

With CONFIG_SMP=n the following compile error occurs:

CC arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

This patch fixes the problem.

Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
---
 arch/arm/common/gic.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/common/gic.c +4 -1
index b2dc2dd..b33f6b0 100644
@@ -676,7 +676,10 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,
 		}
 
 		for_each_possible_cpu(cpu) {
-			unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+			unsigned long offset = percpu_offset;
+#ifdef CONFIG_SMP
+			offset *= cpu_logical_map(cpu);
+#endif
 			*per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset;
 			*per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset;
 		}
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 37 lines · Joerg Roedel

With CONFIG_SMP=n the following compile error occurs:

?CC ? ? ?arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

This patch fixes the problem.

Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org

---
?arch/arm/common/gic.c | ? ?5 ++++-
?1 files changed, 4 insertions(+), 1 deletions(-)

arch/arm/common/gic.c +4 -2
index b2dc2dd..b33f6b0 100644
@@ -676,7 +676,10 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,
 ? ? ? ? ? ? ? ?}
 
 ? ? ? ? ? ? ? ?for_each_possible_cpu(cpu) {
- ? ? ? ? ? ? ? ? ? ? ? unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+ ? ? ? ? ? ? ? ? ? ? ? unsigned long offset = percpu_offset;
+#ifdef CONFIG_SMP
+ ? ? ? ? ? ? ? ? ? ? ? offset *= cpu_logical_map(cpu);
+#endif
 ? ? ? ? ? ? ? ? ? ? ? ?*per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset;
 ? ? ? ? ? ? ? ? ? ? ? ?*per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset;
 ? ? ? ? ? ? ? ?}
--
Quoted 3 lines

1.7.5.4

Is this the right way to fix it? Or shall we do like this:

#ifdef CONFIG_SMP
...
#else
#define cpu_logical_map() 1
#endif

and leave the gic.c code unchanged.

Thanks,
Yang

#2 lore raw
Quoted 18 lines · Yang Bai
Quoted 6 lines · Joerg Roedel

? ? ? ? ? ? ? ?for_each_possible_cpu(cpu) {
- ? ? ? ? ? ? ? ? ? ? ? unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+ ? ? ? ? ? ? ? ? ? ? ? unsigned long offset = percpu_offset;

arch/arm/common/gic.c +3 -0
+#ifdef CONFIG_SMP
+ ? ? ? ? ? ? ? ? ? ? ? offset *= cpu_logical_map(cpu);
+#endif
Quoted 7 lines

? ? ? ? ? ? ? ? ? ? ? ?*per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset; ? ? ? ? ? ? ? ? ? ? ? ?*per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset; ? ? ? ? ? ? ? ?}
--
1.7.5.4

Is this the right way to fix it? Or shall we do like this:

Quoted 7 lines

#ifdef CONFIG_SMP
...
#else
#define cpu_logical_map() 1
#endif

and leave the gic.c code unchanged.

Well, I don't care ;) But everywhere else in this file the use of cpu_logical_map() is #ifdef'ed with CONFIG_SMP. So for consistency my proposed variant is better, no?

Joerg

#3 lore raw
In reply to Yang Bai

[Adding Will to the loop as he's the author of the logical map stuff, though I'm not sure he'll read that before next week...]

Quoted 44 lines · Yang Bai
Quoted 37 lines · Joerg Roedel

With CONFIG_SMP=n the following compile error occurs:

CC arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

This patch fixes the problem.

Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/common/gic.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/common/gic.c +4 -2
index b2dc2dd..b33f6b0 100644
@@ -676,7 +676,10 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,
               }
 
               for_each_possible_cpu(cpu) {
-                       unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+                       unsigned long offset = percpu_offset;
+#ifdef CONFIG_SMP
+                       offset *= cpu_logical_map(cpu);
+#endif
                       *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset;
                       *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset;
               }
--
Quoted 3 lines

1.7.5.4

Is this the right way to fix it? Or shall we do like this:

Quoted 7 lines

#ifdef CONFIG_SMP
...
#else
#define cpu_logical_map() 1
#endif

and leave the gic.c code unchanged.

Well, both patches are wrong. In the UP case (and assuming we're running on physical CPU 0), offset should be 0.

The second patch would be my favorite approach, except that cpu_logical_map(x) should return either "x" or 0. And I'm not sure how to handle the (unlikely?) case of running a UP kernel on a secondary CPU...

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw
Quoted 55 lines · Marc Zyngier

[Adding Will to the loop as he's the author of the logical map stuff, though I'm not sure he'll read that before next week...]

Quoted 51 lines · Yang Bai
Quoted 37 lines · Joerg Roedel

With CONFIG_SMP=n the following compile error occurs:

CC arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

This patch fixes the problem.

Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Rob Herring <[email protected]>
Cc linux-arm-kernel at lists.infradead.org
Cc linux-kernel at vger.kernel.org
---
 arch/arm/common/gic.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/common/gic.c +4 -2
index b2dc2dd..b33f6b0 100644
@@ -676,7 +676,10 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,
               }
 
               for_each_possible_cpu(cpu) {
-                       unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+                       unsigned long offset = percpu_offset;
+#ifdef CONFIG_SMP
+                       offset *= cpu_logical_map(cpu);
+#endif
                       *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset;
                       *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset;
               }
--
Quoted 3 lines

1.7.5.4

Is this the right way to fix it? Or shall we do like this:

#ifdef CONFIG_SMP
...
#else
#define cpu_logical_map() 1
#endif

and leave the gic.c code unchanged.

IIRC, part of the problem is asm/smp.h is only included by linux/smp.h for CONFIG_SMP, so this would have to change. Doing that could easily break other arches.

Quoted 7 lines

Well, both patches are wrong. In the UP case (and assuming we're running on physical CPU 0), offset should be 0.

The second patch would be my favorite approach, except that cpu_logical_map(x) should return either "x" or 0. And I'm not sure how to handle the (unlikely?) case of running a UP kernel on a secondary CPU...

Wouldn't this be the case with 2 AMP instances of Linux running?

Rob

#5 lore raw
Quoted 57 lines · Rob Herring
Quoted 54 lines · Marc Zyngier

[Adding Will to the loop as he's the author of the logical map stuff, though I'm not sure he'll read that before next week...]

Quoted 50 lines · Yang Bai
Quoted 37 lines · Joerg Roedel

With CONFIG_SMP=n the following compile error occurs:

CC arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

This patch fixes the problem.

Cc Marc Zyngier <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Santosh Shilimkar <[email protected]>
Cc Rob Herring <[email protected]>
---
 arch/arm/common/gic.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
arch/arm/common/gic.c +4 -2
index b2dc2dd..b33f6b0 100644
@@ -676,7 +676,10 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start,
               }
 
               for_each_possible_cpu(cpu) {
-                       unsigned long offset = percpu_offset * cpu_logical_map(cpu);
+                       unsigned long offset = percpu_offset;
+#ifdef CONFIG_SMP
+                       offset *= cpu_logical_map(cpu);
+#endif
                       *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset;
                       *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset;
               }
--
Quoted 3 lines

1.7.5.4

Is this the right way to fix it? Or shall we do like this:

#ifdef CONFIG_SMP
...
#else
#define cpu_logical_map() 1
#endif

Quoted 5 lines
Quoted 1 line
Quoted 1 line

and leave the gic.c code unchanged.

IIRC, part of the problem is asm/smp.h is only included by linux/smp.h for CONFIG_SMP, so this would have to change. Doing that could easily break other arches.

Ah... good point.

Quoted 9 lines
Quoted 7 lines

Well, both patches are wrong. In the UP case (and assuming we're running on physical CPU 0), offset should be 0.

The second patch would be my favorite approach, except that cpu_logical_map(x) should return either "x" or 0. And I'm not sure how to handle the (unlikely?) case of running a UP kernel on a secondary CPU...

Wouldn't this be the case with 2 AMP instances of Linux running?

Yes, or kexec-ing a UP kernel on a secondary CPU. It really looks like we ought to make this cpu_logical_map() independent from CONFIG_SMP.

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#6 lore raw
Quoted 8 lines · Marc Zyngier
Quoted 7 lines · Rob Herring
Quoted 7 lines
Quoted 7 lines · Joerg Roedel
Quoted 6 lines

With CONFIG_SMP=n the following compile error occurs:

CC arch/arm/common/gic.o
arch/arm/common/gic.c: In function 'gic_init_bases':
arch/arm/common/gic.c:679:4: error: implicit declaration of function 'cpu_logical_map' [-Werror=implicit-function-declaration]
cc1: some warnings being treated as errors

[...]

Quoted 5 lines
Quoted 3 lines

IIRC, part of the problem is asm/smp.h is only included by linux/smp.h for CONFIG_SMP, so this would have to change. Doing that could easily break other arches.

Ah... good point.

We could probably move smp_setup_processor_id out of smp.c if we need to as it seems as though you can provide a definition of that function even when !CONFIG_SMP.

Quoted 9 lines
Quoted 9 lines
Quoted 7 lines

Well, both patches are wrong. In the UP case (and assuming we're running on physical CPU 0), offset should be 0.

The second patch would be my favorite approach, except that cpu_logical_map(x) should return either "x" or 0. And I'm not sure how to handle the (unlikely?) case of running a UP kernel on a secondary CPU...

Wouldn't this be the case with 2 AMP instances of Linux running?

In this configuration, I think returning 0 would probably be the right thing to do. If it's anything else, there's the implication that both of your kernels are hanging off the same GIC distributor / SCU / L2 Cache etc. and so you would need a single SMP kernel (or some funky message passing that we don't yet have).

The bit we're currently missing is the notion of a cluster ID, but both CPU IDs should be 0 for AMP.

Quoted 2 lines

Yes, or kexec-ing a UP kernel on a secondary CPU. It really looks like we ought to make this cpu_logical_map() independent from CONFIG_SMP.

We could always prevent this from happening by hacking kexec / kexec-tools but I think that booting a UP kernel on a CPU other than 0 is rather silly :)

So I'd be inclined to simply move the existing smp_setup_processor_id implementation (and the map declaration) into somewhere like kernel/setup.c and I think things should work.

Will