Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp210961pxb; Mon, 2 Nov 2020 19:17:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJzipV85X5OH44fmJmyt0QfuRR4lm8VOqQ6gkA6NrRFOGnTtvlsbivUYFPm7IL6Df+E3T8cL X-Received: by 2002:aa7:d4d8:: with SMTP id t24mr20137364edr.247.1604373427210; Mon, 02 Nov 2020 19:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604373427; cv=none; d=google.com; s=arc-20160816; b=u2/enZ9ARZtSkIjAki3+IIX/gE6TzbekqRvXXrTxDdcNqNcL5Bz0XNsjhWLWTxabsv bolpJ4cwLkTuCsv9skEa/im/aaXgehFi168dg4hXKUIXT8xuSj40Jn5oOl17mftWiHiy b0oLeJABnbsaiz1bDwfTJmAwu2Hiq7LcWemb7vt5WD2nTJpYbxecr2VeHuGY8pAJJ4En kYNMKWMgbncOOpb+NKm4kEnBtbpivXGymG3ZPe+NMsuzr+bCYuNzm/pBEPz2NEcMV4AQ OOq/oZU2caIUuR0vN8IybUXEluhVF49Kgsbdvww3tTyMckmuECDIldvs1GhDuM48iXnN v/aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=QoWRG17wXHxJIiaYw0H/epqCHzQ/2rPGjFATjYjwI1A=; b=ybLZF8cTKela7TmKh4tZxv+AN1Eecb0IZIsdM1rncxvg1mzJkidqKbRm7iB/QUr2se xEaH+kT7XZuAxPJCEGcRMvm1yMJ5+C2OAdJ2u2udxtd1gW6iGsHM5knyyTrA0QT0vHPM v+p5vH/qoAIDL6VoLBywLKEO52NObIcU0WwYnVYjWjI/LFmcp+3S5pJ9e6buS/NxvxdF r5wt85qNkGseqMLNOLUvqvttTPiL3X1192yYbvWhtjs46NGgfze3nk7yUTzA06DB95TC oh82UyrrUYmU41nIHPCyHVJgVZqDP6IuK+FF/pV/c55wGD1uUMqArx5ce5xocz2IqtLJ uC+A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc22si461287edb.558.2020.11.02.19.16.45; Mon, 02 Nov 2020 19:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727300AbgKCDPW (ORCPT + 99 others); Mon, 2 Nov 2020 22:15:22 -0500 Received: from mail.loongson.cn ([114.242.206.163]:47116 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727120AbgKCDPV (ORCPT ); Mon, 2 Nov 2020 22:15:21 -0500 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dx7387y6BfU3sEAA--.3657S7; Tue, 03 Nov 2020 11:15:16 +0800 (CST) From: Tiezhu Yang To: Thomas Bogendoerfer , Huacai Chen , Jiaxun Yang Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li , Lu Zeng , Jun Yi Subject: [PATCH v2 5/6] MIPS: Loongson64: Make sure the PC address is correct when 3A4000+ CPU hotplug Date: Tue, 3 Nov 2020 11:15:05 +0800 Message-Id: <1604373306-3599-6-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1604373306-3599-1-git-send-email-yangtiezhu@loongson.cn> References: <1604373306-3599-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANS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0x vEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU3fHbUUUUU= X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In loongson3_type3_play_dead(), in order to make sure the PC address is correct, use lw to read the low 32 bits first, if the result is not zero, then use ld to read the whole 64 bits, otherwise there maybe exists atomic problem due to write high 32 bits first and then low 32 bits, like this: high 32 bits (write done) -- only read high 32-bits which is wrong low 32 bits (not yet write done) This problem is especially for Loongson 3A4000+ CPU due to using Mail_Send register which can only send 32 bits data one time. Although it is hard to reproduce, we can do something at the software level to avoid the risks for 3A4000+ CPU, this change has no influence on the other Loongson CPUs. Signed-off-by: Lu Zeng Signed-off-by: Jun Yi Signed-off-by: Tiezhu Yang --- v2: No changes arch/mips/loongson64/smp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/mips/loongson64/smp.c b/arch/mips/loongson64/smp.c index 736e98d..e32b46e 100644 --- a/arch/mips/loongson64/smp.c +++ b/arch/mips/loongson64/smp.c @@ -764,9 +764,10 @@ static void loongson3_type3_play_dead(int *state_addr) "1: li %[count], 0x100 \n" /* wait for init loop */ "2: bnez %[count], 2b \n" /* limit mailbox access */ " addiu %[count], -1 \n" - " ld %[initfunc], 0x20(%[base]) \n" /* get PC via mailbox */ + " lw %[initfunc], 0x20(%[base]) \n" /* get PC (low 32 bits) via mailbox */ " beqz %[initfunc], 1b \n" " nop \n" + " ld %[initfunc], 0x20(%[base]) \n" /* get PC (whole 64 bits) via mailbox */ " ld $sp, 0x28(%[base]) \n" /* get SP via mailbox */ " ld $gp, 0x30(%[base]) \n" /* get GP via mailbox */ " ld $a1, 0x38(%[base]) \n" -- 2.1.0