linux-mips
[Top] [All Lists]

[PATCH 1/2] MIPS: Loongson, add sync before target of branch between lls

To: pburton@wavecomp.com, linux-mips@vger.kernel.org
Subject: [PATCH 1/2] MIPS: Loongson, add sync before target of branch between llsc
From: YunQiang Su <syq@debian.org>
Date: Sat, 5 Jan 2019 23:00:36 +0800
Cc: chehc@lemote.com, syq@debian.org, zhangfx@lemote.com, wuzhangjin@gmail.com, linux-mips@linux-mips.org, YunQiang Su <ysu@wavecomp.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Z6QohCfjUAlpVS3+5Mx2RTATgU/q4jLJs7i4ICxN0SE=; b=NCuFJowoGxz/oUN2FbUqlGpiER9k0U4acsOGEn1h4idvzV5kG4L0iwPtjRdk4pVI/M ZyT0Jtl8Cnp+OK81ZJFKqPa1q6Knd9jMnBvzxJEkr3EUNLl4teRoorkPfF/8Qfu3stEe d4umMUOHAz8436B7ofdmPz0oqEbOvHgYNIzTnE3AAL8rTWQgtYmttMmY+Gz3AhGP8hNs kdkAGF8H4gXS5O/58nABF2Eo7G2R3033q5Rub9ro/OgalmKKFAGtCnR7CmwGKkYDFso9 y7uBcGRb1qDmHIwpA/1j+CjjN5WmwqGt/H/kN6XpBPQuRgFdklomQx4D5W7AWrmGTBei EALg==
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
From: YunQiang Su <ysu@wavecomp.com>

Loongson 2G/2H/3A/3B is quite weak sync'ed. If there is a branch,
and the target is not in the scope of ll/sc or lld/scd, a sync is
needed at the postion of target.

Loongson doesn't plan to fix this problem in future, so we add the
sync here for any condition.

This is based on the patch from Chen Huacai.

Signed-off-by: YunQiang Su <ysu@wavecomp.com>
---
 arch/mips/mm/tlbex.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/mips/mm/tlbex.c b/arch/mips/mm/tlbex.c
index 37b1cb246..08a9a66ef 100644
--- a/arch/mips/mm/tlbex.c
+++ b/arch/mips/mm/tlbex.c
@@ -932,6 +932,8 @@ build_get_pgd_vmalloc64(u32 **p, struct uasm_label **l, 
struct uasm_reloc **r,
                 * to mimic that here by taking a load/istream page
                 * fault.
                 */
+               if(current_cpu_type() == CPU_LOONGSON3)
+                       uasm_i_sync(p, 0);
                UASM_i_LA(p, ptr, (unsigned long)tlb_do_page_fault_0);
                uasm_i_jr(p, ptr);
 
@@ -1556,6 +1558,7 @@ static void build_loongson3_tlb_refill_handler(void)
 
        if (check_for_high_segbits) {
                uasm_l_large_segbits_fault(&l, p);
+               uasm_i_sync(&p, 0);
                UASM_i_LA(&p, K1, (unsigned long)tlb_do_page_fault_0);
                uasm_i_jr(&p, K1);
                uasm_i_nop(&p);
@@ -2259,6 +2262,8 @@ static void build_r4000_tlb_load_handler(void)
 #endif
 
        uasm_l_nopage_tlbl(&l, p);
+       if(current_cpu_type() == CPU_LOONGSON3)
+               uasm_i_sync(&p, 0);
        build_restore_work_registers(&p);
 #ifdef CONFIG_CPU_MICROMIPS
        if ((unsigned long)tlb_do_page_fault_0 & 1) {
@@ -2313,6 +2318,8 @@ static void build_r4000_tlb_store_handler(void)
 #endif
 
        uasm_l_nopage_tlbs(&l, p);
+       if(current_cpu_type() == CPU_LOONGSON3)
+               uasm_i_sync(&p, 0);
        build_restore_work_registers(&p);
 #ifdef CONFIG_CPU_MICROMIPS
        if ((unsigned long)tlb_do_page_fault_1 & 1) {
@@ -2368,6 +2375,8 @@ static void build_r4000_tlb_modify_handler(void)
 #endif
 
        uasm_l_nopage_tlbm(&l, p);
+       if(current_cpu_type() == CPU_LOONGSON3)
+               uasm_i_sync(&p, 0);
        build_restore_work_registers(&p);
 #ifdef CONFIG_CPU_MICROMIPS
        if ((unsigned long)tlb_do_page_fault_1 & 1) {
-- 
2.20.1


<Prev in Thread] Current Thread [Next in Thread>