ramips: backport series of patches that ensure GCRs of other CPUs are accessed properly
[openwrt.git] / target / linux / ramips / patches-4.3 / 0058-backport-ensure-core-other-GCR-reflect-correct-core.patch
1 commit 78a54c4d8e5a7915a4ec2ba0eb461fae50590683
2 Author: Paul Burton <paul.burton@imgtec.com>
3 Date:   Tue Sep 22 11:12:18 2015 -0700
4
5     MIPS: CM, CPC: Ensure core-other GCRs reflect the correct core
6     
7     Ensure the update to which core the core-other GCR regions reflect has
8     taken place before any core-other GCRs are accessed by placing a memory
9     barrier (sync instruction) between the write to the core-other registers
10     and any such GCR accesses.
11     
12     Signed-off-by: Paul Burton <paul.burton@imgtec.com>
13     Cc: linux-mips@linux-mips.org
14     Cc: Bjorn Helgaas <bhelgaas@google.com>
15     Cc: linux-kernel@vger.kernel.org
16     Cc: Markos Chandras <markos.chandras@imgtec.com>
17     Patchwork: https://patchwork.linux-mips.org/patch/11209/
18     Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
19
20 --- a/arch/mips/kernel/mips-cm.c
21 +++ b/arch/mips/kernel/mips-cm.c
22 @@ -278,6 +278,12 @@ void mips_cm_lock_other(unsigned int cor
23         }
24  
25         write_gcr_cl_other(val);
26 +
27 +       /*
28 +        * Ensure the core-other region reflects the appropriate core &
29 +        * VP before any accesses to it occur.
30 +        */
31 +       mb();
32  }
33  
34  void mips_cm_unlock_other(void)
35 --- a/arch/mips/kernel/mips-cpc.c
36 +++ b/arch/mips/kernel/mips-cpc.c
37 @@ -76,6 +76,12 @@ void mips_cpc_lock_other(unsigned int co
38         spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core),
39                           per_cpu(cpc_core_lock_flags, curr_core));
40         write_cpc_cl_other(core << CPC_Cx_OTHER_CORENUM_SHF);
41 +
42 +       /*
43 +        * Ensure the core-other region reflects the appropriate core &
44 +        * VP before any accesses to it occur.
45 +        */
46 +       mb();
47  }
48  
49  void mips_cpc_unlock_other(void)