All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hw/intc: Fix incorrect calculation of core in liointc_read() and liointc_write()
@ 2020-11-03  9:32 AlexChen
  2020-11-03  9:53 ` Jiaxun Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: AlexChen @ 2020-11-03  9:32 UTC (permalink / raw)
  To: chenhc, jiaxun.yang; +Cc: zhengchuan, QEMU, zhang.zhanghailiang

According to the loongson spec
(http://www.loongson.cn/uploadfile/cpu/3B1500/Loongson_3B1500_cpu_user_1.pdf)
and the macro definition(#define R_PERCORE_ISR(x) (0x40 + 0x8 * x)), we know
that the ISR size of per CORE is 8, so here we need to divide
(addr - R_PERCORE_ISR(0)) by 8, not 4.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Alex Chen <alex.chen@huawei.com>
---
 hw/intc/loongson_liointc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/intc/loongson_liointc.c b/hw/intc/loongson_liointc.c
index 30fb375b72..fbbfb57ee9 100644
--- a/hw/intc/loongson_liointc.c
+++ b/hw/intc/loongson_liointc.c
@@ -130,7 +130,7 @@ liointc_read(void *opaque, hwaddr addr, unsigned int size)

     if (addr >= R_PERCORE_ISR(0) &&
         addr < R_PERCORE_ISR(NUM_CORES)) {
-        int core = (addr - R_PERCORE_ISR(0)) / 4;
+        int core = (addr - R_PERCORE_ISR(0)) / 8;
         r = p->per_core_isr[core];
         goto out;
     }
@@ -173,7 +173,7 @@ liointc_write(void *opaque, hwaddr addr,

     if (addr >= R_PERCORE_ISR(0) &&
         addr < R_PERCORE_ISR(NUM_CORES)) {
-        int core = (addr - R_PERCORE_ISR(0)) / 4;
+        int core = (addr - R_PERCORE_ISR(0)) / 8;
         p->per_core_isr[core] = value;
         goto out;
     }
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-05  1:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  9:32 [PATCH] hw/intc: Fix incorrect calculation of core in liointc_read() and liointc_write() AlexChen
2020-11-03  9:53 ` Jiaxun Yang
2020-11-03 14:05   ` AlexChen
2020-11-03 14:26     ` Philippe Mathieu-Daudé
2020-11-03 12:28 ` Philippe Mathieu-Daudé
2020-11-03 15:40   ` Jiaxun Yang
2020-11-03 17:15     ` Philippe Mathieu-Daudé
2020-11-04  4:17       ` chen huacai
2020-11-05  1:56         ` chen huacai
2020-11-03 12:55 ` Philippe Mathieu-Daudé

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.