bmips: switch to linux 5.15
[openwrt/staging/dedeckeh.git] / target / linux / bmips / patches-5.10 / 040-v5.13-mips-smp-bmips-fix-CPU-mappings.patch
1 From c0f41a0dac1f3db6c40aabc0f3ac8868709ba6a6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= <noltari@gmail.com>
3 Date: Wed, 24 Feb 2021 08:33:36 +0100
4 Subject: [PATCH] mips: smp-bmips: fix CPU mappings
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 When booting bmips with SMP enabled on a BCM6358 running on CPU #1 instead of
10 CPU #0, the current CPU mapping code produces the following:
11 - smp_processor_id(): 0
12 - cpu_logical_map(0): 1
13 - cpu_number_map(0): 1
14
15 This is because SMP isn't supported on BCM6358 since it has a shared TLB, so
16 it is disabled and max_cpus is decreased from 2 to 1.
17
18 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
19 Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
20 Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
21 ---
22 arch/mips/kernel/smp-bmips.c | 27 +++++++++++++++++----------
23 1 file changed, 17 insertions(+), 10 deletions(-)
24
25 --- a/arch/mips/kernel/smp-bmips.c
26 +++ b/arch/mips/kernel/smp-bmips.c
27 @@ -134,17 +134,24 @@ static void __init bmips_smp_setup(void)
28 if (!board_ebase_setup)
29 board_ebase_setup = &bmips_ebase_setup;
30
31 - __cpu_number_map[boot_cpu] = 0;
32 - __cpu_logical_map[0] = boot_cpu;
33 + if (max_cpus > 1) {
34 + __cpu_number_map[boot_cpu] = 0;
35 + __cpu_logical_map[0] = boot_cpu;
36
37 - for (i = 0; i < max_cpus; i++) {
38 - if (i != boot_cpu) {
39 - __cpu_number_map[i] = cpu;
40 - __cpu_logical_map[cpu] = i;
41 - cpu++;
42 + for (i = 0; i < max_cpus; i++) {
43 + if (i != boot_cpu) {
44 + __cpu_number_map[i] = cpu;
45 + __cpu_logical_map[cpu] = i;
46 + cpu++;
47 + }
48 + set_cpu_possible(i, 1);
49 + set_cpu_present(i, 1);
50 }
51 - set_cpu_possible(i, 1);
52 - set_cpu_present(i, 1);
53 + } else {
54 + __cpu_number_map[0] = boot_cpu;
55 + __cpu_logical_map[0] = 0;
56 + set_cpu_possible(0, 1);
57 + set_cpu_present(0, 1);
58 }
59 }
60