Skip to content

Commit 9559d58

Browse files
committed
LoongArch: Increase max supported CPUs up to 2048
Increase max supported CPUs up to 2048, including: 1. Increase CSR.CPUID register's effective width; 2. Define MAX_CORE_PIC (a.k.a. max physical ID) to 2048; 3. Allow NR_CPUS (a.k.a. max logical ID) to be as large as 2048; 4. Introduce acpi_numa_x2apic_affinity_init() to handle ACPI SRAT for CPUID >= 256. Note: The reason of increasing to 2048 rather than 4096/8192 is because the IPI hardware can only support 2048 as a maximum. Reviewed-by: Yanteng Si <si.yanteng@linux.dev> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
1 parent a45728f commit 9559d58

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

arch/loongarch/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ config HOTPLUG_CPU
496496
Say N if you want to disable CPU hotplug.
497497

498498
config NR_CPUS
499-
int "Maximum number of CPUs (2-256)"
500-
range 2 256
499+
int "Maximum number of CPUs (2-2048)"
500+
range 2 2048
501+
default "2048"
501502
depends on SMP
502-
default "64"
503503
help
504504
This allows you to specify the maximum number of CPUs which this
505505
kernel will support.

arch/loongarch/include/asm/acpi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static inline bool acpi_has_cpu_in_madt(void)
3333
return true;
3434
}
3535

36-
#define MAX_CORE_PIC 256
36+
#define MAX_CORE_PIC 2048
3737

3838
extern struct list_head acpi_wakeup_device_list;
3939
extern struct acpi_madt_core_pic acpi_core_pic[MAX_CORE_PIC];

arch/loongarch/include/asm/loongarch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@
411411

412412
/* Config CSR registers */
413413
#define LOONGARCH_CSR_CPUID 0x20 /* CPU core id */
414-
#define CSR_CPUID_COREID_WIDTH 9
415-
#define CSR_CPUID_COREID _ULCAST_(0x1ff)
414+
#define CSR_CPUID_COREID_WIDTH 11
415+
#define CSR_CPUID_COREID _ULCAST_(0x7ff)
416416

417417
#define LOONGARCH_CSR_PRCFG1 0x21 /* Config1 */
418418
#define CSR_CONF1_VSMAX_SHIFT 12

arch/loongarch/kernel/acpi.c

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,6 @@ void __init acpi_boot_table_init(void)
244244

245245
#ifdef CONFIG_ACPI_NUMA
246246

247-
static __init int setup_node(int pxm)
248-
{
249-
return acpi_map_pxm_to_node(pxm);
250-
}
251-
252247
void __init numa_set_distance(int from, int to, int distance)
253248
{
254249
if ((u8)distance != distance || (from == to && distance != LOCAL_DISTANCE)) {
@@ -280,7 +275,41 @@ acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
280275
pxm |= (pa->proximity_domain_hi[1] << 16);
281276
pxm |= (pa->proximity_domain_hi[2] << 24);
282277
}
283-
node = setup_node(pxm);
278+
node = acpi_map_pxm_to_node(pxm);
279+
if (node < 0) {
280+
pr_err("SRAT: Too many proximity domains %x\n", pxm);
281+
bad_srat();
282+
return;
283+
}
284+
285+
if (pa->apic_id >= CONFIG_NR_CPUS) {
286+
pr_info("SRAT: PXM %u -> CPU 0x%02x -> Node %u skipped apicid that is too big\n",
287+
pxm, pa->apic_id, node);
288+
return;
289+
}
290+
291+
early_numa_add_cpu(pa->apic_id, node);
292+
293+
set_cpuid_to_node(pa->apic_id, node);
294+
node_set(node, numa_nodes_parsed);
295+
pr_info("SRAT: PXM %u -> CPU 0x%02x -> Node %u\n", pxm, pa->apic_id, node);
296+
}
297+
298+
void __init
299+
acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
300+
{
301+
int pxm, node;
302+
303+
if (srat_disabled())
304+
return;
305+
if (pa->header.length < sizeof(struct acpi_srat_x2apic_cpu_affinity)) {
306+
bad_srat();
307+
return;
308+
}
309+
if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
310+
return;
311+
pxm = pa->proximity_domain;
312+
node = acpi_map_pxm_to_node(pxm);
284313
if (node < 0) {
285314
pr_err("SRAT: Too many proximity domains %x\n", pxm);
286315
bad_srat();

0 commit comments

Comments
 (0)