All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, Jia Liu <proljc@gmail.com>
Subject: Re: [PATCH 1/3] hw/openrisc/openrisc_sim: Use IRQ splitter when connecting IRQ to multiple CPUs
Date: Sun, 29 Nov 2020 20:59:11 +0900	[thread overview]
Message-ID: <20201129115911.GD3168563@lianli.shorne-pla.net> (raw)
In-Reply-To: <20201127225127.14770-2-peter.maydell@linaro.org>

On Fri, Nov 27, 2020 at 10:51:25PM +0000, Peter Maydell wrote:
> openrisc_sim_net_init() attempts to connect the IRQ line from the
> ethernet device to both CPUs in an SMP configuration by simply caling
> sysbus_connect_irq() for it twice.  This doesn't work, because the
> second connection simply overrides the first.
> 
> Fix this by creating a TYPE_SPLIT_IRQ to split the IRQ in the SMP
> case.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  hw/openrisc/openrisc_sim.c | 13 +++++++++++--
>  hw/openrisc/Kconfig        |  1 +
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
> index d752282e675..a8adf6b70d7 100644
> --- a/hw/openrisc/openrisc_sim.c
> +++ b/hw/openrisc/openrisc_sim.c
> @@ -34,6 +34,7 @@
>  #include "hw/sysbus.h"
>  #include "sysemu/qtest.h"
>  #include "sysemu/reset.h"
> +#include "hw/core/split-irq.h"
>  
>  #define KERNEL_LOAD_ADDR 0x100
>  
> @@ -64,8 +65,16 @@ static void openrisc_sim_net_init(hwaddr base, hwaddr descriptors,
>  
>      s = SYS_BUS_DEVICE(dev);
>      sysbus_realize_and_unref(s, &error_fatal);
> -    for (i = 0; i < num_cpus; i++) {
> -        sysbus_connect_irq(s, 0, cpu_irqs[i][irq_pin]);
> +    if (num_cpus > 1) {
> +        DeviceState *splitter = qdev_new(TYPE_SPLIT_IRQ);
> +        qdev_prop_set_uint32(splitter, "num-lines", num_cpus);
> +        qdev_realize_and_unref(splitter, NULL, &error_fatal);
> +        for (i = 0; i < num_cpus; i++) {
> +            qdev_connect_gpio_out(splitter, i, cpu_irqs[i][irq_pin]);
> +        }
> +        sysbus_connect_irq(s, 0, qdev_get_gpio_in(splitter, 0));
> +    } else {
> +        sysbus_connect_irq(s, 0, cpu_irqs[0][irq_pin]);
>      }
>      sysbus_mmio_map(s, 0, base);
>      sysbus_mmio_map(s, 1, descriptors);
> diff --git a/hw/openrisc/Kconfig b/hw/openrisc/Kconfig
> index 6c1e86884e2..8f284f3ba04 100644
> --- a/hw/openrisc/Kconfig
> +++ b/hw/openrisc/Kconfig
> @@ -3,3 +3,4 @@ config OR1K_SIM
>      select SERIAL
>      select OPENCORES_ETH
>      select OMPIC
> +    select SPLIT_IRQ
> -- 
> 2.20.1


This looks good to me, I don't think I ever tested networking with SMP.  Thanks
for the fix!

Reviewed-by: Stafford Horne <shorne@gmail.com>

Can you help merge the patch? I am not working a queue right now.


  reply	other threads:[~2020-11-29 12:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-27 22:51 [PATCH 0/3] target/openrisc: Move pic_cpu code into CPU object Peter Maydell
2020-11-27 22:51 ` [PATCH 1/3] hw/openrisc/openrisc_sim: Use IRQ splitter when connecting IRQ to multiple CPUs Peter Maydell
2020-11-29 11:59   ` Stafford Horne [this message]
2020-11-27 22:51 ` [PATCH 2/3] hw/openrisc/openrisc_sim: Abstract out "get IRQ x of CPU y" Peter Maydell
2020-11-29 12:01   ` Stafford Horne
2020-11-27 22:51 ` [PATCH 3/3] target/openrisc: Move pic_cpu code into CPU object proper Peter Maydell
2020-11-29 12:03   ` Stafford Horne
2020-12-11 13:57 ` [PATCH 0/3] target/openrisc: Move pic_cpu code into CPU object Peter Maydell

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=20201129115911.GD3168563@lianli.shorne-pla.net \
    --to=shorne@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=proljc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /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 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.