Skip to contentSkip to conversation

riscv: andes_plic: Fix riscv_get_ipi() mask

PATCH Superseded Bin Meng 2 participants 3 messages Jun 9, 2021 – Jun 15, 2021 1 message not in the archive RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/1 riscv: andes_plic: Fix riscv_get_ipi() mask

Current logic in riscv_get_ipi() for Andes PLICSW does not look good to me. The mask to test IPI pending bits for a hart should be left shifted by (8 * gd->arch.boot_hart), just the same as what is done in riscv_send_ipi().

---
It looks there is no datasheet released from Andes that describes how PLICSW works, and its register fields. I can only get an understanding from current U-Boot and OpenSBI PLICSW driver.

This requires testing on Andes hardware, which I don't have access to.

 arch/riscv/lib/andes_plic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/lib/andes_plic.c +3 -1
index 221a5fe324..5e113ee8c9 100644
@@ -105,9 +105,11 @@ int riscv_clear_ipi(int hart)
 
 int riscv_get_ipi(int hart, int *pending)
 {
+	unsigned int ipi = (SEND_IPI_TO_HART(hart) << (8 * gd->arch.boot_hart));
+
 	*pending = readl((void __iomem *)PENDING_REG(gd->arch.plic,
 						     gd->arch.boot_hart));
-	*pending = !!(*pending & SEND_IPI_TO_HART(hart));
+	*pending = !!(*pending & ipi);
 
 	return 0;
 }
Signature · 1 line
2.25.1
author
#1 lore raw
Quoted 13 lines · Bin Meng

Current logic in riscv_get_ipi() for Andes PLICSW does not look good to me. The mask to test IPI pending bits for a hart should be left shifted by (8 * gd->arch.boot_hart), just the same as what is done in riscv_send_ipi().

---
It looks there is no datasheet released from Andes that describes how PLICSW works, and its register fields. I can only get an understanding from current U-Boot and OpenSBI PLICSW driver.

Quoted 5 lines

This requires testing on Andes hardware, which I don't have access to.

 arch/riscv/lib/andes_plic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Ping?

A message that is not in the archive (sent off-list or not yet received): [email protected]

Tested-by Reviewed-by
#3 lore raw

Hi Bin

Quoted 19 lines

From: Bin Meng <[email protected]>
Sent: Monday, June 14, 2021 11:48 AM
To: Rick Jian-Zhi Chen(陳建志) <[email protected]>; Leo Yu-Chi Liang(梁育齊) <[email protected]>; U-Boot Mailing List <[email protected]>
Subject: Re: [RFT PATCH] riscv: andes_plic: Fix riscv_get_ipi() mask

Quoted 13 lines · Bin Meng

Current logic in riscv_get_ipi() for Andes PLICSW does not look good to me. The mask to test IPI pending bits for a hart should be left shifted by (8 * gd->arch.boot_hart), just the same as what is done in riscv_send_ipi().

---
It looks there is no datasheet released from Andes that describes how PLICSW works, and its register fields. I can only get an understanding from current U-Boot and OpenSBI PLICSW driver.

Quoted 7 lines
Quoted 5 lines

This requires testing on Andes hardware, which I don't have access to.

 arch/riscv/lib/andes_plic.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Ping?

Though there will be only one hart will jump to U-Boot proper currently, and this delay loop seem to be unnecessary.
But it is still a good catch.

Thanks,
Rick