From: Alistair Francis <alistair23@gmail.com>
To: Anup Patel <anup.patel@wdc.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
"open list:RISC-V" <qemu-riscv@nongnu.org>,
Sagar Karandikar <sagark@eecs.berkeley.edu>,
Anup Patel <anup@brainfault.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Atish Patra <atish.patra@wdc.com>,
Alistair Francis <Alistair.Francis@wdc.com>,
Palmer Dabbelt <palmer@dabbelt.com>
Subject: Re: [PATCH 3/4] hw/riscv: Allow creating multiple instances of PLIC
Date: Thu, 21 May 2020 14:59:31 -0700 [thread overview]
Message-ID: <CAKmqyKNeTR7_G5KkN0sh8YALYdUp6nnXPJ+9sUrrMk-_ATtSDQ@mail.gmail.com> (raw)
In-Reply-To: <20200516063746.18296-4-anup.patel@wdc.com>
On Fri, May 15, 2020 at 11:39 PM Anup Patel <anup.patel@wdc.com> wrote:
>
> We extend PLIC emulation to allow multiple instances of PLIC in
> a QEMU RISC-V machine. To achieve this, we remove first HART id
> zero assumption from PLIC emulation.
>
> Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/sifive_e.c | 2 +-
> hw/riscv/sifive_plic.c | 24 +++++++++++++-----------
> hw/riscv/sifive_u.c | 2 +-
> hw/riscv/virt.c | 2 +-
> include/hw/riscv/sifive_plic.h | 12 +++++++-----
> 5 files changed, 23 insertions(+), 19 deletions(-)
>
> diff --git a/hw/riscv/sifive_e.c b/hw/riscv/sifive_e.c
> index 1c3b37d0ba..bd122e71ae 100644
> --- a/hw/riscv/sifive_e.c
> +++ b/hw/riscv/sifive_e.c
> @@ -152,7 +152,7 @@ static void riscv_sifive_e_soc_realize(DeviceState *dev, Error **errp)
>
> /* MMIO */
> s->plic = sifive_plic_create(memmap[SIFIVE_E_PLIC].base,
> - (char *)SIFIVE_E_PLIC_HART_CONFIG,
> + (char *)SIFIVE_E_PLIC_HART_CONFIG, 0,
> SIFIVE_E_PLIC_NUM_SOURCES,
> SIFIVE_E_PLIC_NUM_PRIORITIES,
> SIFIVE_E_PLIC_PRIORITY_BASE,
> diff --git a/hw/riscv/sifive_plic.c b/hw/riscv/sifive_plic.c
> index c1e04cbb98..f88bb48053 100644
> --- a/hw/riscv/sifive_plic.c
> +++ b/hw/riscv/sifive_plic.c
> @@ -352,6 +352,7 @@ static const MemoryRegionOps sifive_plic_ops = {
>
> static Property sifive_plic_properties[] = {
> DEFINE_PROP_STRING("hart-config", SiFivePLICState, hart_config),
> + DEFINE_PROP_UINT32("hartid-base", SiFivePLICState, hartid_base, 0),
> DEFINE_PROP_UINT32("num-sources", SiFivePLICState, num_sources, 0),
> DEFINE_PROP_UINT32("num-priorities", SiFivePLICState, num_priorities, 0),
> DEFINE_PROP_UINT32("priority-base", SiFivePLICState, priority_base, 0),
> @@ -400,10 +401,12 @@ static void parse_hart_config(SiFivePLICState *plic)
> }
> hartid++;
>
> - /* store hart/mode combinations */
> plic->num_addrs = addrid;
> + plic->num_harts = hartid;
> +
> + /* store hart/mode combinations */
> plic->addr_config = g_new(PLICAddr, plic->num_addrs);
> - addrid = 0, hartid = 0;
> + addrid = 0, hartid = plic->hartid_base;
> p = plic->hart_config;
> while ((c = *p++)) {
> if (c == ',') {
> @@ -429,8 +432,6 @@ static void sifive_plic_irq_request(void *opaque, int irq, int level)
>
> static void sifive_plic_realize(DeviceState *dev, Error **errp)
> {
> - MachineState *ms = MACHINE(qdev_get_machine());
> - unsigned int smp_cpus = ms->smp.cpus;
> SiFivePLICState *plic = SIFIVE_PLIC(dev);
> int i;
>
> @@ -451,8 +452,8 @@ static void sifive_plic_realize(DeviceState *dev, Error **errp)
> * lost a interrupt in the case a PLIC is attached. The SEIP bit must be
> * hardware controlled when a PLIC is attached.
> */
> - for (i = 0; i < smp_cpus; i++) {
> - RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(i));
> + for (i = 0; i < plic->num_harts; i++) {
> + RISCVCPU *cpu = RISCV_CPU(qemu_get_cpu(plic->hartid_base + i));
> if (riscv_cpu_claim_interrupts(cpu, MIP_SEIP) < 0) {
> error_report("SEIP already claimed");
> exit(1);
> @@ -488,16 +489,17 @@ type_init(sifive_plic_register_types)
> * Create PLIC device.
> */
> DeviceState *sifive_plic_create(hwaddr addr, char *hart_config,
> - uint32_t num_sources, uint32_t num_priorities,
> - uint32_t priority_base, uint32_t pending_base,
> - uint32_t enable_base, uint32_t enable_stride,
> - uint32_t context_base, uint32_t context_stride,
> - uint32_t aperture_size)
> + uint32_t hartid_base, uint32_t num_sources,
> + uint32_t num_priorities, uint32_t priority_base,
> + uint32_t pending_base, uint32_t enable_base,
> + uint32_t enable_stride, uint32_t context_base,
> + uint32_t context_stride, uint32_t aperture_size)
> {
> DeviceState *dev = qdev_create(NULL, TYPE_SIFIVE_PLIC);
> assert(enable_stride == (enable_stride & -enable_stride));
> assert(context_stride == (context_stride & -context_stride));
> qdev_prop_set_string(dev, "hart-config", hart_config);
> + qdev_prop_set_uint32(dev, "hartid-base", hartid_base);
> qdev_prop_set_uint32(dev, "num-sources", num_sources);
> qdev_prop_set_uint32(dev, "num-priorities", num_priorities);
> qdev_prop_set_uint32(dev, "priority-base", priority_base);
> diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c
> index 22997fbf13..69dbd7980b 100644
> --- a/hw/riscv/sifive_u.c
> +++ b/hw/riscv/sifive_u.c
> @@ -585,7 +585,7 @@ static void riscv_sifive_u_soc_realize(DeviceState *dev, Error **errp)
>
> /* MMIO */
> s->plic = sifive_plic_create(memmap[SIFIVE_U_PLIC].base,
> - plic_hart_config,
> + plic_hart_config, 0,
> SIFIVE_U_PLIC_NUM_SOURCES,
> SIFIVE_U_PLIC_NUM_PRIORITIES,
> SIFIVE_U_PLIC_PRIORITY_BASE,
> diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
> index dcb8a83b35..f40efcb193 100644
> --- a/hw/riscv/virt.c
> +++ b/hw/riscv/virt.c
> @@ -585,7 +585,7 @@ static void riscv_virt_board_init(MachineState *machine)
>
> /* MMIO */
> s->plic = sifive_plic_create(memmap[VIRT_PLIC].base,
> - plic_hart_config,
> + plic_hart_config, 0,
> VIRT_PLIC_NUM_SOURCES,
> VIRT_PLIC_NUM_PRIORITIES,
> VIRT_PLIC_PRIORITY_BASE,
> diff --git a/include/hw/riscv/sifive_plic.h b/include/hw/riscv/sifive_plic.h
> index 4421e81249..ace76d0f1b 100644
> --- a/include/hw/riscv/sifive_plic.h
> +++ b/include/hw/riscv/sifive_plic.h
> @@ -48,6 +48,7 @@ typedef struct SiFivePLICState {
> /*< public >*/
> MemoryRegion mmio;
> uint32_t num_addrs;
> + uint32_t num_harts;
> uint32_t bitfield_words;
> PLICAddr *addr_config;
> uint32_t *source_priority;
> @@ -58,6 +59,7 @@ typedef struct SiFivePLICState {
>
> /* config */
> char *hart_config;
> + uint32_t hartid_base;
> uint32_t num_sources;
> uint32_t num_priorities;
> uint32_t priority_base;
> @@ -70,10 +72,10 @@ typedef struct SiFivePLICState {
> } SiFivePLICState;
>
> DeviceState *sifive_plic_create(hwaddr addr, char *hart_config,
> - uint32_t num_sources, uint32_t num_priorities,
> - uint32_t priority_base, uint32_t pending_base,
> - uint32_t enable_base, uint32_t enable_stride,
> - uint32_t context_base, uint32_t context_stride,
> - uint32_t aperture_size);
> + uint32_t hartid_base, uint32_t num_sources,
> + uint32_t num_priorities, uint32_t priority_base,
> + uint32_t pending_base, uint32_t enable_base,
> + uint32_t enable_stride, uint32_t context_base,
> + uint32_t context_stride, uint32_t aperture_size);
>
> #endif
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2020-05-21 22:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 6:37 [PATCH 0/4] RISC-V multi-socket support Anup Patel
2020-05-16 6:37 ` [PATCH 1/4] hw/riscv: Allow creating multiple instances of CLINT Anup Patel
2020-05-19 21:21 ` Alistair Francis
2020-05-21 20:16 ` Palmer Dabbelt
2020-05-16 6:37 ` [PATCH 2/4] hw/riscv: spike: Allow creating multiple sockets Anup Patel
2020-05-21 20:16 ` Palmer Dabbelt
2020-05-22 10:09 ` Anup Patel
2020-05-27 0:38 ` Alistair Francis
2020-05-27 2:54 ` Anup Patel
2020-05-27 3:30 ` Alistair Francis
2020-05-27 3:59 ` Anup Patel
2020-05-16 6:37 ` [PATCH 3/4] hw/riscv: Allow creating multiple instances of PLIC Anup Patel
2020-05-21 20:16 ` Palmer Dabbelt
2020-05-21 21:59 ` Alistair Francis [this message]
2020-05-16 6:37 ` [PATCH 4/4] hw/riscv: virt: Allow creating multiple sockets Anup Patel
2020-05-21 20:16 ` Palmer Dabbelt
2020-05-16 11:58 ` [PATCH 0/4] RISC-V multi-socket support no-reply
2020-05-19 21:20 ` Alistair Francis
2020-05-20 8:50 ` Anup Patel
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=CAKmqyKNeTR7_G5KkN0sh8YALYdUp6nnXPJ+9sUrrMk-_ATtSDQ@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=Alistair.Francis@wdc.com \
--cc=anup.patel@wdc.com \
--cc=anup@brainfault.org \
--cc=atish.patra@wdc.com \
--cc=palmer@dabbelt.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=sagark@eecs.berkeley.edu \
/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).