From nobody Thu Jan 30 19:08:40 2025 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89A491FCFDC for ; Mon, 27 Jan 2025 09:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737970738; cv=none; b=bKgAFVobomlazQzbn91oc163yrSfmaljhuj7PFLBbCpi7uhsmTtqk4AFt7aDfGKXMWs25iIJVOm7VamL/S4hhQhj6Qd4v2Wxw1PUSLLDMLv1/bS6geXXNNEkJSr45eFHQwWkrWI1g5CYiiLqjE8t4OJ8UB0jHitirnkkYc/DTuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737970738; c=relaxed/simple; bh=oWPHlNQf3mu1WBJImjiu4i9JR9/jvzvtLgfdLnzg5g4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=eZOsOd6ulT1L4nO7Qtm2lvXZaCpCxVuGe6/Tfr1MhcWA5eyI4yHSjKgP3KKz6oUp5bR2pT072sTOn9wodwwYRnqSJz8whkphn1IQckZ0K9A4P9BnzV/mx2vH3Thpn9jsWlU5Xh1e7kUKvX2H/8mmHSz+/UpiZDsOIY6rJzj/C/w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com; spf=pass smtp.mailfrom=bytedance.com; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b=DagfbEtt; arc=none smtp.client-ip=209.85.214.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=bytedance.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bytedance.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bytedance.com header.i=@bytedance.com header.b="DagfbEtt" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-216634dd574so48465985ad.2 for ; Mon, 27 Jan 2025 01:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1737970736; x=1738575536; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nBZ4D1tJ1W6TkH10mNjcGXtl3KHxxjn0+jKOGshQuOE=; b=DagfbEttcGuFEpEfSd7eueQERQHJvzziIwUpq+ppSljkirzk4YhI8fN4LkDcJTKNXg 3FIc0JJ2IcrqBRUw/SROLhn6LDGJOt4FSYzbxQBdPg3c/mbltxWZEDh5AqBATrrkM+mH rFt4bttgs/RnedjznAG06s2IzPWkc15QntCVKqkeGcoxwNnyJow/R7MvtdwOwARinLln +0O98rkYHZEoyz4+7W+jHtkGb4ToCAex3a+lawrccQ+8NbSTVSuM98gBflu5Ll8MfXdS SzOiojSzcpzWbnVMtBBFSJdNXqVMnzKrRDzayiClAh953d3mqYWAMH84MO0rLGv+QpOx NTTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737970736; x=1738575536; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nBZ4D1tJ1W6TkH10mNjcGXtl3KHxxjn0+jKOGshQuOE=; b=AcZ/p54+ZCvUwT4feL4AoNAs1CCYhYERWTlAUdv1HcI+wt+NFpRCasYEkrXoZ7Vhkz QUMzWCvWDeAz1rBxL5mgPjKkd/wSDEbDnmwj20Plt0pOQQz1W3LAcXxihKZBxUfN3jCo RMZl8DM8fkFDE7hQuQr8kUXkEAQKsS++XBC3ExQkXGN+CFo7QgbGANhe4dRNg3FXbcCP noNmlODytjTEMpwvEUJXOwkIUmeCtFLmAmMfv/eskm+zOWycOdhs0q5zyEeJVAjzR886 p9zGwGyXocNoHoY75VSukuqEV5C2JkKPh6Mez1ln0TsmBSB9ejrcrRZv3r7tKD/84sCc hjBA== X-Forwarded-Encrypted: i=1; AJvYcCV9nJ/wVMmqNuyWw7IDVk+oZelnRIfudW7fs+XLdiqc+iuP6unzf/alkOaw8i6geyJgMbTkOl8aXEGIGtA=@vger.kernel.org X-Gm-Message-State: AOJu0YypnNnukoUKrWzlo6cWzwCfTt7h+hgMgwY+HSzqg4OZdYwrAHdf 1q2iUIJBCPMK/vcBclohnjTi2gdfUFgmy9YCFsWrPsMvnOz6d4yncWMEGZ9sgNM= X-Gm-Gg: ASbGncs8X+7p6dpGO0b9bmjqzcPWa4nyWtrQzMcOAALv3kObag81kCEEFifb5iymmG3 bGlNLixgf4+c7WUQTj7HRWwXHKo5XHqDDuM13rmzj7rxLwDXmgl+eolrJEOsxdpMxX4YcZjBOQf n4si0OI2Cp3CfBN3/bTmBepzyjCnOa+rHbqL2uxbbHBzVsvUQ98JmVKGDoG+1r4IMNgEiV04tTa r3yKIKd2bFdU0/8PeuRaiixsCQmNu7T72qiM9vuUAgghREWWMts3xNcuZZdAoP+TBiHaj2oxD4C 2D2YhdecNS4mvlDCfkC+I23Op2QexIIH5rVOCVmfmg== X-Google-Smtp-Source: AGHT+IETKwfqNE6+LUefp51bAMetIMLbA43PTxyjl4cfwvVpnzMMAYTSq2DLVQgYP2Jax1dm3aYnRQ== X-Received: by 2002:a17:903:41c3:b0:216:386e:dca with SMTP id d9443c01a7336-21c3554c994mr574535425ad.30.1737970735803; Mon, 27 Jan 2025 01:38:55 -0800 (PST) Received: from J9GPGXL7NT.bytedance.net ([139.177.225.240]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da3d9c59asm58710975ad.29.2025.01.27.01.38.51 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 27 Jan 2025 01:38:55 -0800 (PST) From: Xu Lu To: tglx@linutronix.de, anup@brainfault.org, charlie@rivosinc.com, paul.walmsley@sifive.com, palmer@dabbelt.com Cc: lihangjing@bytedance.com, xieyongji@bytedance.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Xu Lu Subject: [PATCH RESEND] irqchip: riscv: Order normal writes and IPI writes Date: Mon, 27 Jan 2025 17:38:46 +0800 Message-Id: <20250127093846.98625-1-luxu.kernel@bytedance.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISC-V distinguishes between normal memory accesses and device I/O and uses FENCE instruction to order them as viewed by othe RISC-V harts and external devices or coprocessors. The FENCE instruction can order any combination of device input(I), device output(O), memory reads(R) and memory writes(W). For example, 'fence w, o' can be used to ensure all memory writes from instructions preceding the FENCE instruction appear earlier in the global memory order than device output writes from instructions after the FENCE instruction. RISC-V issues IPI by writing certain value to IMSIC/ACLINT MMIO registers, which is regarded as device output operation. However, the existing implementation of IMSIC/ACLINT driver issues IPI via writel_relaxed(), which does not guarantee the order of device output operation and preceding memory writes. Then the hart receiving IPI may not have seen the latest data yet. This commit fixes this by replacing writel_relaxed() with writel() when issuing IPI, which will use 'fence w, o' to ensure all previous writes made by current hart are visible to other harts before they receive the IPI. Signed-off-by: Xu Lu --- drivers/irqchip/irq-riscv-imsic-early.c | 2 +- drivers/irqchip/irq-thead-c900-aclint-sswi.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-riscv-imsic-early.c b/drivers/irqchip/irq-= riscv-imsic-early.c index c5c2e6929a2f..275df5005705 100644 --- a/drivers/irqchip/irq-riscv-imsic-early.c +++ b/drivers/irqchip/irq-riscv-imsic-early.c @@ -27,7 +27,7 @@ static void imsic_ipi_send(unsigned int cpu) { struct imsic_local_config *local =3D per_cpu_ptr(imsic->global.local, cpu= ); =20 - writel_relaxed(IMSIC_IPI_ID, local->msi_va); + writel(IMSIC_IPI_ID, local->msi_va); } =20 static void imsic_ipi_starting_cpu(void) diff --git a/drivers/irqchip/irq-thead-c900-aclint-sswi.c b/drivers/irqchip= /irq-thead-c900-aclint-sswi.c index b0e366ade427..8ff6e7a1363b 100644 --- a/drivers/irqchip/irq-thead-c900-aclint-sswi.c +++ b/drivers/irqchip/irq-thead-c900-aclint-sswi.c @@ -31,7 +31,7 @@ static DEFINE_PER_CPU(void __iomem *, sswi_cpu_regs); =20 static void thead_aclint_sswi_ipi_send(unsigned int cpu) { - writel_relaxed(0x1, per_cpu(sswi_cpu_regs, cpu)); + writel(0x1, per_cpu(sswi_cpu_regs, cpu)); } =20 static void thead_aclint_sswi_ipi_clear(void) --=20 2.20.1