Skip to content

Commit 255b465

Browse files
committed
LoongArch: Fix the !CONFIG_SMP build
1, We assume arch/loongarch/include/asm/smp.h be included in include/ linux/smp.h is valid and the reverse inclusion isn't. So remove the <linux/smp.h> in arch/loongarch/include/asm/smp.h. 2, arch/loongarch/include/asm/smp.h is only needed when CONFIG_SMP, and setup.c include it only because it need plat_smp_setup(). So, reorganize setup.c & smp.h, and then remove <asm/smp.h> in setup.c. 3, Fix cacheinfo.c and percpu.h build error by adding the missing header files when !CONFIG_SMP. 4, Fix acpi.c build error by adding CONFIG_SMP guards. 5, Move irq_stat definition from smp.c to irq.c and fix its declaration. 6, Select CONFIG_SMP for CONFIG_NUMA, similar as other architectures do. Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent f2906aa commit 255b465

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

arch/loongarch/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ config NR_CPUS
343343

344344
config NUMA
345345
bool "NUMA Support"
346+
select SMP
346347
select ACPI_NUMA if ACPI
347348
help
348349
Say Y to compile the kernel with NUMA (Non-Uniform Memory Access)

arch/loongarch/include/asm/hardirq.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919
unsigned int __softirq_pending;
2020
} ____cacheline_aligned irq_cpustat_t;
2121

22-
DECLARE_PER_CPU_ALIGNED(irq_cpustat_t, irq_stat);
22+
DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
2323

2424
#define __ARCH_IRQ_STAT
2525

arch/loongarch/include/asm/percpu.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define __ASM_PERCPU_H
77

88
#include <asm/cmpxchg.h>
9+
#include <asm/loongarch.h>
910

1011
/* Use r21 for fast access */
1112
register unsigned long __my_cpu_offset __asm__("$r21");

arch/loongarch/include/asm/smp.h

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@
99
#include <linux/atomic.h>
1010
#include <linux/bitops.h>
1111
#include <linux/linkage.h>
12-
#include <linux/smp.h>
1312
#include <linux/threads.h>
1413
#include <linux/cpumask.h>
1514

15+
extern int smp_num_siblings;
16+
extern int num_processors;
17+
extern int disabled_cpus;
18+
extern cpumask_t cpu_sibling_map[];
19+
extern cpumask_t cpu_core_map[];
20+
extern cpumask_t cpu_foreign_map[];
21+
1622
void loongson3_smp_setup(void);
1723
void loongson3_prepare_cpus(unsigned int max_cpus);
1824
void loongson3_boot_secondary(int cpu, struct task_struct *idle);
@@ -25,26 +31,11 @@ int loongson3_cpu_disable(void);
2531
void loongson3_cpu_die(unsigned int cpu);
2632
#endif
2733

28-
#ifdef CONFIG_SMP
29-
3034
static inline void plat_smp_setup(void)
3135
{
3236
loongson3_smp_setup();
3337
}
3438

35-
#else /* !CONFIG_SMP */
36-
37-
static inline void plat_smp_setup(void) { }
38-
39-
#endif /* !CONFIG_SMP */
40-
41-
extern int smp_num_siblings;
42-
extern int num_processors;
43-
extern int disabled_cpus;
44-
extern cpumask_t cpu_sibling_map[];
45-
extern cpumask_t cpu_core_map[];
46-
extern cpumask_t cpu_foreign_map[];
47-
4839
static inline int raw_smp_processor_id(void)
4940
{
5041
#if defined(__VDSO__)

arch/loongarch/kernel/acpi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ void __init acpi_boot_table_init(void)
138138
}
139139
}
140140

141+
#ifdef CONFIG_SMP
141142
static int set_processor_mask(u32 id, u32 flags)
142143
{
143144

@@ -166,15 +167,18 @@ static int set_processor_mask(u32 id, u32 flags)
166167

167168
return cpu;
168169
}
170+
#endif
169171

170172
static void __init acpi_process_madt(void)
171173
{
174+
#ifdef CONFIG_SMP
172175
int i;
173176

174177
for (i = 0; i < NR_CPUS; i++) {
175178
__cpu_number_map[i] = -1;
176179
__cpu_logical_map[i] = -1;
177180
}
181+
#endif
178182

179183
loongson_sysconf.nr_cpus = num_processors;
180184
}

arch/loongarch/kernel/cacheinfo.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
* Copyright (C) 2020-2022 Loongson Technology Corporation Limited
66
*/
7+
#include <asm/cpu-info.h>
78
#include <linux/cacheinfo.h>
89

910
/* Populates leaf and increments to next leaf */

arch/loongarch/kernel/irq.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include <asm/setup.h>
2323

2424
DEFINE_PER_CPU(unsigned long, irq_stack);
25+
DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
26+
EXPORT_PER_CPU_SYMBOL(irq_stat);
2527

2628
struct irq_domain *cpu_domain;
2729
struct irq_domain *liointc_domain;
@@ -56,8 +58,11 @@ int arch_show_interrupts(struct seq_file *p, int prec)
5658

5759
void __init init_IRQ(void)
5860
{
59-
int i, r, ipi_irq;
61+
int i;
62+
#ifdef CONFIG_SMP
63+
int r, ipi_irq;
6064
static int ipi_dummy_dev;
65+
#endif
6166
unsigned int order = get_order(IRQ_STACK_SIZE);
6267
struct page *page;
6368

arch/loongarch/kernel/setup.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include <asm/pgalloc.h>
4040
#include <asm/sections.h>
4141
#include <asm/setup.h>
42-
#include <asm/smp.h>
4342
#include <asm/time.h>
4443

4544
#define SMBIOS_BIOSSIZE_OFFSET 0x09
@@ -349,8 +348,6 @@ static void __init prefill_possible_map(void)
349348

350349
nr_cpu_ids = possible;
351350
}
352-
#else
353-
static inline void prefill_possible_map(void) {}
354351
#endif
355352

356353
void __init setup_arch(char **cmdline_p)
@@ -367,8 +364,10 @@ void __init setup_arch(char **cmdline_p)
367364
arch_mem_init(cmdline_p);
368365

369366
resource_init();
367+
#ifdef CONFIG_SMP
370368
plat_smp_setup();
371369
prefill_possible_map();
370+
#endif
372371

373372
paging_init();
374373
}

arch/loongarch/kernel/smp.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ static cpumask_t cpu_core_setup_map;
6666

6767
struct secondary_data cpuboot_data;
6868
static DEFINE_PER_CPU(int, cpu_state);
69-
DEFINE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat);
70-
EXPORT_PER_CPU_SYMBOL(irq_stat);
7169

7270
enum ipi_msg_type {
7371
IPI_RESCHEDULE,

0 commit comments

Comments
 (0)