diff mbox series

[v2,01/12] arch: Export cpu_logical_map to modules

Message ID 20210928022715.369160-2-f.fainelli@gmail.com (mailing list archive)
State Superseded
Headers show
Series Modular Broadcom irqchip drivers | expand

Commit Message

Florian Fainelli Sept. 28, 2021, 2:27 a.m. UTC
In order to allow drivers/irqchip/irq-bcm7038-l1.c to be built as a
module and usable in GKI, export cpu_logical_map or __cpu_logical_map
towards the modules. This follows what MIPS has been doing since
2dc2ae344e0e ("MIPS: Export __cpu_number_map and __cpu_logical_map.")

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 arch/arm/kernel/setup.c   | 1 +
 arch/arm64/kernel/setup.c | 1 +
 arch/sh/kernel/smp.c      | 1 +
 3 files changed, 3 insertions(+)

Comments

Christoph Hellwig Sept. 28, 2021, 5:08 a.m. UTC | #1
On Mon, Sep 27, 2021 at 07:27:04PM -0700, Florian Fainelli wrote:
> In order to allow drivers/irqchip/irq-bcm7038-l1.c to be built as a
> module and usable in GKI, export cpu_logical_map or __cpu_logical_map
> towards the modules. This follows what MIPS has been doing since
> 2dc2ae344e0e ("MIPS: Export __cpu_number_map and __cpu_logical_map.")

This seems like a pretty bad idea.  For one you should export an
accessor instead of the data structure.  And this probably should be an
EXPORT_SYMBOL_GPL.
Florian Fainelli Sept. 28, 2021, 4:30 p.m. UTC | #2
On 9/27/21 10:08 PM, Christoph Hellwig wrote:
> On Mon, Sep 27, 2021 at 07:27:04PM -0700, Florian Fainelli wrote:
>> In order to allow drivers/irqchip/irq-bcm7038-l1.c to be built as a
>> module and usable in GKI, export cpu_logical_map or __cpu_logical_map
>> towards the modules. This follows what MIPS has been doing since
>> 2dc2ae344e0e ("MIPS: Export __cpu_number_map and __cpu_logical_map.")
> 
> This seems like a pretty bad idea.  For one you should export an
> accessor instead of the data structure.  And this probably should be an
> EXPORT_SYMBOL_GPL.

In hindsight, we should not need that change, and the use of
cpu_logical_map[] within drivers/irqchip/irq-bcm7038-l1.c should be
restricted to a MIPS build where the driver is a level 1 interrupt
controller and there are multiple per-cpu register copies.

In an ARM/ARM64 configuration that driver is always used as a second
level interrupt controller whereby it is hanging off the ARM GIC
interrupt controller, and the intc->cpus[] array will only be 1 element.
Fortunately since you cannot re-parent a L2 interrupt controller's
interrupt handler to a different CPU, "it just happens to work".

Thanks!
diff mbox series

Patch

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 284a80c0b6e1..abd5c999bdb2 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -585,6 +585,7 @@  void notrace cpu_init(void)
 }
 
 u32 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
+EXPORT_SYMBOL(__cpu_logical_map);
 
 void __init smp_setup_processor_id(void)
 {
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index be5f85b0a24d..d8f796ae13c4 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -290,6 +290,7 @@  u64 cpu_logical_map(unsigned int cpu)
 {
 	return __cpu_logical_map[cpu];
 }
+EXPORT_SYMBOL(cpu_logical_map);
 
 void __init __no_sanitize_address setup_arch(char **cmdline_p)
 {
diff --git a/arch/sh/kernel/smp.c b/arch/sh/kernel/smp.c
index 65924d9ec245..8f16cfaad238 100644
--- a/arch/sh/kernel/smp.c
+++ b/arch/sh/kernel/smp.c
@@ -30,6 +30,7 @@ 
 
 int __cpu_number_map[NR_CPUS];		/* Map physical to logical */
 int __cpu_logical_map[NR_CPUS];		/* Map logical to physical */
+EXPORT_SYMBOL(__cpu_logical_map);
 
 struct plat_smp_ops *mp_ops = NULL;