Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

MIPS: Loongson64: Test register availability before use

Some global register address variable may be missing on
specific CPU type, test them before use them.

Cc: stable@vger.kernel.org
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Jiaxun Yang and committed by
Thomas Bogendoerfer
c04366b1 da3f6246

+21 -2
+21 -2
arch/mips/loongson64/smp.c
··· 466 466 static void __init loongson3_smp_setup(void) 467 467 { 468 468 int i = 0, num = 0; /* i: physical id, num: logical id */ 469 + int max_cpus = 0; 469 470 470 471 init_cpu_possible(cpu_none_mask); 472 + 473 + for (i = 0; i < ARRAY_SIZE(smp_group); i++) { 474 + if (!smp_group[i]) 475 + break; 476 + max_cpus += loongson_sysconf.cores_per_node; 477 + } 478 + 479 + if (max_cpus < loongson_sysconf.nr_cpus) { 480 + pr_err("SMP Groups are less than the number of CPUs\n"); 481 + loongson_sysconf.nr_cpus = max_cpus ? max_cpus : 1; 482 + } 471 483 472 484 /* For unified kernel, NR_CPUS is the maximum possible value, 473 485 * loongson_sysconf.nr_cpus is the really present value 474 486 */ 487 + i = 0; 475 488 while (i < loongson_sysconf.nr_cpus) { 476 489 if (loongson_sysconf.reserved_cpus_mask & (1<<i)) { 477 490 /* Reserved physical CPU cores */ ··· 505 492 __cpu_logical_map[num] = -1; 506 493 num++; 507 494 } 508 - 509 495 csr_ipi_probe(); 510 496 ipi_set0_regs_init(); 511 497 ipi_clear0_regs_init(); 512 498 ipi_status0_regs_init(); 513 499 ipi_en0_regs_init(); 514 500 ipi_mailbox_buf_init(); 515 - ipi_write_enable(0); 501 + if (smp_group[0]) 502 + ipi_write_enable(0); 516 503 517 504 cpu_set_core(&cpu_data[0], 518 505 cpu_logical_map(0) % loongson_sysconf.cores_per_package); ··· 831 818 uint64_t core_id = cpu_core(&cpu_data[cpu]); 832 819 uint64_t package_id = cpu_data[cpu].package; 833 820 821 + if (!loongson_chipcfg[package_id] || !loongson_freqctrl[package_id]) 822 + return 0; 823 + 834 824 if ((read_c0_prid() & PRID_REV_MASK) == PRID_REV_LOONGSON3A_R1) { 835 825 LOONGSON_CHIPCFG(package_id) &= ~(1 << (12 + core_id)); 836 826 } else { ··· 847 831 { 848 832 uint64_t core_id = cpu_core(&cpu_data[cpu]); 849 833 uint64_t package_id = cpu_data[cpu].package; 834 + 835 + if (!loongson_chipcfg[package_id] || !loongson_freqctrl[package_id]) 836 + return 0; 850 837 851 838 if ((read_c0_prid() & PRID_REV_MASK) == PRID_REV_LOONGSON3A_R1) { 852 839 LOONGSON_CHIPCFG(package_id) |= 1 << (12 + core_id);