From: Richard Henderson <richard.henderson@linaro.org>
To: Xiaojuan Yang <yangxiaojuan@loongson.cn>, qemu-devel@nongnu.org
Cc: gaosong@loongson.cn, maobibo@loongson.cn,
mark.cave-ayland@ilande.co.uk, f4bug@amsat.org,
peter.maydell@linaro.org, "Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [PATCH v2 2/3] hw/intc: Fix LoongArch extioi function
Date: Wed, 28 Sep 2022 19:38:51 -0700 [thread overview]
Message-ID: <7c449174-f07a-79e8-d280-ac7cd869d064@linaro.org> (raw)
In-Reply-To: <20220927061225.3566554-3-yangxiaojuan@loongson.cn>
On 9/26/22 23:12, Xiaojuan Yang wrote:
> 1.When cpu read or write extioi COREISR reg, it should access
> the reg belonged to itself, so the index of 's->coreisr' is
> current cpu number.
> 2.Remove the unused extioi system memory region and we only
> support the extioi iocsr memory region now.
>
> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> ---
> hw/intc/loongarch_extioi.c | 17 ++++++++++-------
> 1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c
> index 22803969bc..b89ec2e2a6 100644
> --- a/hw/intc/loongarch_extioi.c
> +++ b/hw/intc/loongarch_extioi.c
> @@ -17,6 +17,12 @@
> #include "migration/vmstate.h"
> #include "trace.h"
>
> +static inline int get_current_cpu(void)
> +{
> + int cpu_id = current_cpu ? current_cpu->cpu_index : 0;
> +
> + return cpu_id;
> +}
I wouldn't want to introduce another instance of current_cpu right now. Please see Alex's
work to remove this from Arm hardware.
https://lore.kernel.org/qemu-devel/20220927141504.3886314-1-alex.bennee@linaro.org/
r~
>
> static void extioi_update_irq(LoongArchExtIOI *s, int irq, int level)
> {
> @@ -92,8 +98,8 @@ static uint64_t extioi_readw(void *opaque, hwaddr addr, unsigned size)
> ret = s->bounce[index];
> break;
> case EXTIOI_COREISR_START ... EXTIOI_COREISR_END - 1:
> - index = ((offset - EXTIOI_COREISR_START) & 0x1f) >> 2;
> - cpu = ((offset - EXTIOI_COREISR_START) >> 8) & 0x3;
> + index = (offset - EXTIOI_COREISR_START) >> 2;
> + cpu = get_current_cpu();
> ret = s->coreisr[cpu][index];
> break;
> case EXTIOI_COREMAP_START ... EXTIOI_COREMAP_END - 1:
> @@ -183,8 +189,8 @@ static void extioi_writew(void *opaque, hwaddr addr,
> s->bounce[index] = val;
> break;
> case EXTIOI_COREISR_START ... EXTIOI_COREISR_END - 1:
> - index = ((offset - EXTIOI_COREISR_START) & 0x1f) >> 2;
> - cpu = ((offset - EXTIOI_COREISR_START) >> 8) & 0x3;
> + index = (offset - EXTIOI_COREISR_START) >> 2;
> + cpu = get_current_cpu();
> old_data = s->coreisr[cpu][index];
> s->coreisr[cpu][index] = old_data & ~val;
> /* write 1 to clear interrrupt */
> @@ -284,9 +290,6 @@ static void loongarch_extioi_instance_init(Object *obj)
> qdev_init_gpio_out(DEVICE(obj), &s->parent_irq[cpu][pin], 1);
> }
> }
> - memory_region_init_io(&s->extioi_system_mem, OBJECT(s), &extioi_ops,
> - s, "extioi_system_mem", 0x900);
> - sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->extioi_system_mem);
> }
>
> static void loongarch_extioi_class_init(ObjectClass *klass, void *data)
next prev parent reply other threads:[~2022-09-29 2:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 6:12 [PATCH v2 0/3] Add memmap and fix bugs for LoongArch Xiaojuan Yang
2022-09-27 6:12 ` [PATCH v2 1/3] hw/loongarch: Add memmap for LoongArch virt machine Xiaojuan Yang
2022-09-29 2:25 ` Richard Henderson
2022-09-27 6:12 ` [PATCH v2 2/3] hw/intc: Fix LoongArch extioi function Xiaojuan Yang
2022-09-29 2:38 ` Richard Henderson [this message]
2022-09-27 6:12 ` [PATCH v2 3/3] hw/intc: Fix LoongArch ipi device emulation Xiaojuan Yang
2022-09-29 2:42 ` Richard Henderson
2022-09-29 3:23 ` yangxiaojuan
2022-09-29 4:12 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7c449174-f07a-79e8-d280-ac7cd869d064@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=f4bug@amsat.org \
--cc=gaosong@loongson.cn \
--cc=maobibo@loongson.cn \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=yangxiaojuan@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).