From: Richard Henderson <richard.henderson@linaro.org>
To: Xiaojuan Yang <yangxiaojuan@loongson.cn>, qemu-devel@nongnu.org
Cc: mark.cave-ayland@ilande.co.uk, Song Gao <gaosong@loongson.cn>
Subject: Re: [RFC PATCH v7 19/29] hw/intc: Add LoongArch extioi interrupt controller(EIOINTC)
Date: Mon, 28 Mar 2022 16:43:14 -0600 [thread overview]
Message-ID: <620e7d20-8e6a-0b9e-1f3e-022f405bfa92@linaro.org> (raw)
In-Reply-To: <20220328125749.2918087-20-yangxiaojuan@loongson.cn>
On 3/28/22 06:57, Xiaojuan Yang wrote:
> This patch realize the EIOINTC interrupt controller.
>
> Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
> hw/intc/Kconfig | 3 +
> hw/intc/loongarch_extioi.c | 408 +++++++++++++++++++++++++++++
> hw/intc/meson.build | 1 +
> hw/intc/trace-events | 11 +
> hw/loongarch/Kconfig | 1 +
> include/hw/intc/loongarch_extioi.h | 77 ++++++
> 6 files changed, 501 insertions(+)
> create mode 100644 hw/intc/loongarch_extioi.c
> create mode 100644 include/hw/intc/loongarch_extioi.h
>
> diff --git a/hw/intc/Kconfig b/hw/intc/Kconfig
> index 71c04c328e..28bd1f185d 100644
> --- a/hw/intc/Kconfig
> +++ b/hw/intc/Kconfig
> @@ -96,3 +96,6 @@ config LOONGARCH_PCH_MSI
> select MSI_NONBROKEN
> bool
> select UNIMP
> +
> +config LOONGARCH_EXTIOI
> + bool
> diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c
> new file mode 100644
> index 0000000000..af28e8d6e9
> --- /dev/null
> +++ b/hw/intc/loongarch_extioi.c
> @@ -0,0 +1,408 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Loongson 3A5000 ext interrupt controller emulation
> + *
> + * Copyright (C) 2021 Loongson Technology Corporation Limited
> + */
> +
> +#include "qemu/osdep.h"
> +#include "qemu/module.h"
> +#include "qemu/log.h"
> +#include "hw/irq.h"
> +#include "hw/sysbus.h"
> +#include "hw/loongarch/loongarch.h"
> +#include "hw/qdev-properties.h"
> +#include "exec/address-spaces.h"
> +#include "hw/intc/loongarch_extioi.h"
> +#include "migration/vmstate.h"
> +#include "trace.h"
> +
> +static void extioi_update_irq(void *opaque, int irq_num, int level)
> +{
> + LoongArchExtIOI *s = LOONGARCH_EXTIOI(opaque);
I think this is not opaque anymore; you've already resolved it in the caller.
I think level should be 'bool'.
> + uint8_t ipnum, cpu;
> + unsigned long found1, found2;
> +
> + ipnum = s->sw_ipmap[irq_num];
> + cpu = s->sw_coremap[irq_num];
> + if (level == 1) {
Just if (level).
> + if (test_bit(irq_num, (void *)s->enable) == false) {
This, and every other cast you're using for bitops.h functions, is wrong. You would need
to declare these bitmaps properly as 'unsigned long name[BITS_TO_LONGS(N)];'.
That said, I would definitely use uint64_t, because that matches up with the description
of these registers in the manual.
> + return;
> + }
> + bitmap_set((void *)s->coreisr[cpu], irq_num, 1);
> + found1 = find_next_bit((void *)&(s->sw_ipisr[cpu][ipnum]),
> + EXTIOI_IRQS, 0);
find_next_bit with offset=0 is find_first_bit...
> + bitmap_set((void *)&(s->sw_ipisr[cpu][ipnum]), irq_num, 1);
> +
> + if (found1 >= EXTIOI_IRQS) {
> + qemu_set_irq(s->parent_irq[cpu][ipnum], level);
> + }
... but what's the bitmap search doing? It appears to be checking that there are *no*
bits set between 0 and EXTIOI_IRQS, and then raising the irq if no bits set. That seems
wrong.
> + } else {
> + bitmap_clear((void *)s->coreisr[cpu], irq_num, 1);
> + found1 = find_next_bit((void *)&(s->sw_ipisr[cpu][ipnum]),
> + EXTIOI_IRQS, 0);
> + bitmap_clear((void *)&(s->sw_ipisr[cpu][ipnum]), irq_num, 1);
> + found2 = find_next_bit((void *)&(s->sw_ipisr[cpu][ipnum]),
> + EXTIOI_IRQS, 0);
> +
> + if ((found1 < EXTIOI_IRQS) && (found2 >= EXTIOI_IRQS)) {
> + qemu_set_irq(s->parent_irq[cpu][ipnum], level);
> + }
> + }
> +}
It *seems* like all of this should be
uint64_t sum = 0;
s->isr[ipnum / 64] = deposit64(s->isr[ipnum / 64], ipnum % 64, 1, level);
for (int i = 0; i < ARRAY_SIZE(s->isr); i++) {
sum |= s->isr[i] & s->ena[i];
}
qemu_set_irq(parent, sum != 0);
If that's not the case, you need many more comments.
r~
next prev parent reply other threads:[~2022-03-28 22:50 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-28 12:57 [RFC PATCH v7 00/29] Add LoongArch softmmu support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 01/29] target/loongarch: Add system emulation introduction Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 02/29] target/loongarch: Add CSRs definition Xiaojuan Yang
2022-03-28 19:16 ` Richard Henderson
2022-03-30 10:04 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 03/29] target/loongarch: Add basic vmstate description of CPU Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 04/29] target/loongarch: Implement qmp_query_cpu_definitions() Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 05/29] target/loongarch: Add constant timer support Xiaojuan Yang
2022-03-28 19:46 ` Richard Henderson
2022-03-31 0:59 ` yangxiaojuan
2022-03-28 20:58 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 06/29] target/loongarch: Add MMU support for LoongArch CPU Xiaojuan Yang
2022-03-28 20:06 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 07/29] target/loongarch: Add LoongArch CSR instruction Xiaojuan Yang
2022-03-28 18:34 ` Richard Henderson
2022-03-30 10:01 ` yangxiaojuan
2022-03-30 13:46 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 08/29] target/loongarch: Add LoongArch IOCSR instruction Xiaojuan Yang
2022-03-28 18:55 ` Richard Henderson
2022-03-30 10:02 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 09/29] target/loongarch: Add TLB instruction support Xiaojuan Yang
2022-03-28 20:12 ` Richard Henderson
2022-03-31 1:09 ` yangxiaojuan
2022-03-28 22:50 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 10/29] target/loongarch: Add other core instructions support Xiaojuan Yang
2022-03-28 20:16 ` Richard Henderson
2022-03-31 1:22 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 11/29] target/loongarch: Add LoongArch interrupt and exception handle Xiaojuan Yang
2022-03-28 20:19 ` Richard Henderson
2022-03-31 1:29 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 12/29] target/loongarch: Add timer related instructions support Xiaojuan Yang
2022-03-28 20:33 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 13/29] target/loongarch: Add gdb support Xiaojuan Yang
2022-03-28 20:35 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 14/29] hw/loongarch: Add support loongson3 virt machine type Xiaojuan Yang
2022-03-28 20:49 ` Richard Henderson
2022-03-28 21:02 ` Mark Cave-Ayland
2022-04-15 7:52 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 15/29] hw/loongarch: Add LoongArch cpu interrupt support(CPUINTC) Xiaojuan Yang
2022-03-28 20:57 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 16/29] hw/loongarch: Add LoongArch ipi interrupt support(IPI) Xiaojuan Yang
2022-03-28 20:15 ` Mark Cave-Ayland
2022-03-31 1:16 ` yangxiaojuan
2022-03-28 22:04 ` Richard Henderson
2022-03-28 22:06 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 17/29] hw/intc: Add LoongArch ls7a interrupt controller support(PCH-PIC) Xiaojuan Yang
2022-03-28 20:18 ` Mark Cave-Ayland
2022-03-31 1:25 ` yangxiaojuan
2022-03-28 12:57 ` [RFC PATCH v7 18/29] hw/intc: Add LoongArch ls7a msi interrupt controller support(PCH-MSI) Xiaojuan Yang
2022-03-28 20:22 ` Mark Cave-Ayland
2022-03-28 12:57 ` [RFC PATCH v7 19/29] hw/intc: Add LoongArch extioi interrupt controller(EIOINTC) Xiaojuan Yang
2022-03-28 20:27 ` Mark Cave-Ayland
2022-03-28 22:43 ` Richard Henderson [this message]
2022-03-31 12:28 ` yangxiaojuan
2022-03-28 22:46 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 20/29] hw/loongarch: Add irq hierarchy for the system Xiaojuan Yang
2022-03-28 23:16 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 21/29] Enable common virtio pci support for LoongArch Xiaojuan Yang
2022-03-28 23:18 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 22/29] hw/loongarch: Add some devices support for 3A5000 Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 23/29] hw/loongarch: Add LoongArch ls7a rtc device support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 24/29] hw/loongarch: Add default bios startup support Xiaojuan Yang
2022-03-29 3:27 ` Richard Henderson
2022-03-28 12:57 ` [RFC PATCH v7 25/29] hw/loongarch: Add -kernel and -initrd options support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 26/29] hw/loongarch: Add LoongArch smbios support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 27/29] hw/loongarch: Add LoongArch acpi support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 28/29] hw/loongarch: Add fdt support Xiaojuan Yang
2022-03-28 12:57 ` [RFC PATCH v7 29/29] tests/tcg/loongarch64: Add hello/memory test in loongarch64 system Xiaojuan Yang
2022-03-29 3:29 ` Richard Henderson
2022-03-28 18:13 ` [RFC PATCH v7 00/29] Add LoongArch softmmu support Richard Henderson
2022-03-30 9:34 ` yangxiaojuan
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=620e7d20-8e6a-0b9e-1f3e-022f405bfa92@linaro.org \
--to=richard.henderson@linaro.org \
--cc=gaosong@loongson.cn \
--cc=mark.cave-ayland@ilande.co.uk \
--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).