From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA2ECC4361B for ; Sat, 19 Dec 2020 14:26:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB8A321D95 for ; Sat, 19 Dec 2020 14:26:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB8A321D95 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:49938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kqdC7-0003ss-Oa for qemu-devel@archiver.kernel.org; Sat, 19 Dec 2020 09:26:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:52834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kqdAS-000327-Q8 for qemu-devel@nongnu.org; Sat, 19 Dec 2020 09:25:09 -0500 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]:45746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kqdAQ-0000eZ-IF for qemu-devel@nongnu.org; Sat, 19 Dec 2020 09:25:08 -0500 Received: by mail-qv1-xf34.google.com with SMTP id a4so2055632qvd.12 for ; Sat, 19 Dec 2020 06:25:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=U6R+D7HvrEmNvQsAbsurPQ8PG0AZSaTodOUUSRyCfzQ=; b=eoUVKNylTT748xHvjraAmbVl4mZEb3QEgBVvKjYRLTgf+uY3i/Xv6GZC08xjOwww9V PSGAsho5kahBp6jXV3pvzL8mGxKxQRJMp8397s6EE9aMSAoon7rsD8XOXdMoHxKMBBOj COUXR4D14IzJO5wONpw3j9NZvRMR5wB9dhz6U87OzJPWuZD17Hk88vgmSXbxJ++cIg+f Bqd1XUcp1G1UBIfXv47XQuAUbiy98ozr02HlqA2eWObnsbdYsnDrgxZAsfnaYR2+TiH8 N4WQe1tJQ8qa2Ojdq0oHy+q89VG7PzzM6Mb60XPjmHSzjHfq/XN1UdgxYs3fcQ1uqOjY 6SOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=U6R+D7HvrEmNvQsAbsurPQ8PG0AZSaTodOUUSRyCfzQ=; b=jTBMAcr6GZRToGdxfIFm+cGPwAh4Pw01+ohLYpQix9eLYXm8N2T7PGiejOc/knASVG UUMSvfq2hTF1T/Ktmuo1rTNHzVjk63gCc2dQI733hoe0Yxvoepna18IJozAiwkwzB19z Vlp42O7WfJlzcwy9dw3IY7Wzlkgj7MV6OXLuGdsVhDyeMgL388h3fqCZxvl2rGCkl5RY bZM9T7EIXot17aixe2QbG7/gS8PFtdV84yIDuFSjxaOYp26MA/y/Oe9oNR9JYDAm7qRM X+5lcw7tzAGSw/lq293fko2JwrvYUbK4791huEnOiamz7iFxF2jxmyxECg2VRjJMTCMc RV8w== X-Gm-Message-State: AOAM531buNTWHM8jN3UQaU33MP8RkBLTBN9mV6koWB92W0Rc8kh8Sa5/ oAgWiUuR+zIw0DT8as1x30UsG45tn2Gw3D3HpcQ= X-Google-Smtp-Source: ABdhPJygPvhyapvS8EoqHLYetFEMx/Bx/EN6dEdDnyo/bs6BkZNeFeZLNpWo5Bf6BJ2xctlJyE/GYeF3sp71/FdpAKY= X-Received: by 2002:a0c:83e1:: with SMTP id k88mr9896582qva.60.1608387905191; Sat, 19 Dec 2020 06:25:05 -0800 (PST) MIME-Version: 1.0 References: <20201219111934.5540-1-mark.cave-ayland@ilande.co.uk> In-Reply-To: <20201219111934.5540-1-mark.cave-ayland@ilande.co.uk> From: Artyom Tarasenko Date: Sat, 19 Dec 2020 15:24:52 +0100 Message-ID: Subject: Re: [PATCH] sun4m: don't connect two qemu_irqs directly to the same input To: Mark Cave-Ayland Content-Type: multipart/alternative; boundary="000000000000c003ba05b6d1fd21" Received-SPF: pass client-ip=2607:f8b0:4864:20::f34; envelope-from=a.tarasenko@gmail.com; helo=mail-qv1-xf34.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000c003ba05b6d1fd21 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D1=81=D0=B1, 19 =D0=B4=D0=B5=D0=BA. 2020 =D0=B3., 12:19 Mark Cave-Ayland <= mark.cave-ayland@ilande.co.uk>: > The sun4m board code connects both of the IRQ outputs of each ESCC to the > same slavio input qemu_irq. Connecting two qemu_irqs outputs directly to > the > same input is not valid as it produces subtly wrong behaviour (for instan= ce > if both the IRQ lines are high, and then one goes low, the PIC input will > see > this as a high-to-low transition even though the second IRQ line should > still > be holding it high). > > This kind of wiring needs an explicitly created OR gate; add one. > > Signed-off-by: Mark Cave-Ayland > Reviewed-by: Artyom Tarasenko --- > hw/sparc/Kconfig | 1 + > hw/sparc/sun4m.c | 23 ++++++++++++++++++----- > 2 files changed, 19 insertions(+), 5 deletions(-) > > diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig > index 91805afab6..8dcb10086f 100644 > --- a/hw/sparc/Kconfig > +++ b/hw/sparc/Kconfig > @@ -14,6 +14,7 @@ config SUN4M > select M48T59 > select STP2000 > select CHRP_NVRAM > + select OR_IRQ > > config LEON3 > bool > diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c > index 8686371318..c06c43be18 100644 > --- a/hw/sparc/sun4m.c > +++ b/hw/sparc/sun4m.c > @@ -50,6 +50,7 @@ > #include "hw/misc/empty_slot.h" > #include "hw/misc/unimp.h" > #include "hw/irq.h" > +#include "hw/or-irq.h" > #include "hw/loader.h" > #include "elf.h" > #include "trace.h" > @@ -848,7 +849,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef > *hwdef, > uint32_t initrd_size; > DriveInfo *fd[MAX_FD]; > FWCfgState *fw_cfg; > - DeviceState *dev; > + DeviceState *dev, *ms_kb_orgate, *serial_orgate; > SysBusDevice *s; > unsigned int smp_cpus =3D machine->smp.cpus; > unsigned int max_cpus =3D machine->smp.max_cpus; > @@ -994,10 +995,16 @@ static void sun4m_hw_init(const struct sun4m_hwdef > *hwdef, > qdev_prop_set_uint32(dev, "chnAtype", escc_kbd); > s =3D SYS_BUS_DEVICE(dev); > sysbus_realize_and_unref(s, &error_fatal); > - sysbus_connect_irq(s, 0, slavio_irq[14]); > - sysbus_connect_irq(s, 1, slavio_irq[14]); > sysbus_mmio_map(s, 0, hwdef->ms_kb_base); > > + /* Logically OR both its IRQs together */ > + ms_kb_orgate =3D DEVICE(object_new(TYPE_OR_IRQ)); > + object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, > &error_fatal); > + qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal); > + sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0)); > + sysbus_connect_irq(s, 1, qdev_get_gpio_in(ms_kb_orgate, 1)); > + qdev_connect_gpio_out(DEVICE(ms_kb_orgate), 0, slavio_irq[14]); > + > dev =3D qdev_new(TYPE_ESCC); > qdev_prop_set_uint32(dev, "disabled", 0); > qdev_prop_set_uint32(dev, "frequency", ESCC_CLOCK); > @@ -1009,10 +1016,16 @@ static void sun4m_hw_init(const struct sun4m_hwde= f > *hwdef, > > s =3D SYS_BUS_DEVICE(dev); > sysbus_realize_and_unref(s, &error_fatal); > - sysbus_connect_irq(s, 0, slavio_irq[15]); > - sysbus_connect_irq(s, 1, slavio_irq[15]); > sysbus_mmio_map(s, 0, hwdef->serial_base); > > + /* Logically OR both its IRQs together */ > + serial_orgate =3D DEVICE(object_new(TYPE_OR_IRQ)); > + object_property_set_int(OBJECT(serial_orgate), "num-lines", 2, > &error_fatal); > + qdev_realize_and_unref(serial_orgate, NULL, &error_fatal); > + sysbus_connect_irq(s, 0, qdev_get_gpio_in(serial_orgate, 0)); > + sysbus_connect_irq(s, 1, qdev_get_gpio_in(serial_orgate, 1)); > + qdev_connect_gpio_out(DEVICE(serial_orgate), 0, slavio_irq[15]); > + > if (hwdef->apc_base) { > apc_init(hwdef->apc_base, qemu_allocate_irq(cpu_halt_signal, > NULL, 0)); > } > -- > 2.20.1 > > --000000000000c003ba05b6d1fd21 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=D1=81=D0=B1, 19 =D0=B4=D0=B5=D0=BA. 2020 =D0=B3., 12:= 19 Mark Cave-Ayland <ma= rk.cave-ayland@ilande.co.uk>:
mark.cave-ayland@ilande.co.u= k>

Reviewed-by: Artyom Tarasenko <atar4qemu@gmail.com>

---
=C2=A0hw/sparc/Kconfig |=C2=A0 1 +
=C2=A0hw/sparc/sun4m.c | 23 ++++++++++++++++++-----
=C2=A02 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/hw/sparc/Kconfig b/hw/sparc/Kconfig
index 91805afab6..8dcb10086f 100644
--- a/hw/sparc/Kconfig
+++ b/hw/sparc/Kconfig
@@ -14,6 +14,7 @@ config SUN4M
=C2=A0 =C2=A0 =C2=A0select M48T59
=C2=A0 =C2=A0 =C2=A0select STP2000
=C2=A0 =C2=A0 =C2=A0select CHRP_NVRAM
+=C2=A0 =C2=A0 select OR_IRQ

=C2=A0config LEON3
=C2=A0 =C2=A0 =C2=A0bool
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 8686371318..c06c43be18 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -50,6 +50,7 @@
=C2=A0#include "hw/misc/empty_slot.h"
=C2=A0#include "hw/misc/unimp.h"
=C2=A0#include "hw/irq.h"
+#include "hw/or-irq.h"
=C2=A0#include "hw/loader.h"
=C2=A0#include "elf.h"
=C2=A0#include "trace.h"
@@ -848,7 +849,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwd= ef,
=C2=A0 =C2=A0 =C2=A0uint32_t initrd_size;
=C2=A0 =C2=A0 =C2=A0DriveInfo *fd[MAX_FD];
=C2=A0 =C2=A0 =C2=A0FWCfgState *fw_cfg;
-=C2=A0 =C2=A0 DeviceState *dev;
+=C2=A0 =C2=A0 DeviceState *dev, *ms_kb_orgate, *serial_orgate;
=C2=A0 =C2=A0 =C2=A0SysBusDevice *s;
=C2=A0 =C2=A0 =C2=A0unsigned int smp_cpus =3D machine->smp.cpus;
=C2=A0 =C2=A0 =C2=A0unsigned int max_cpus =3D machine->smp.max_cpus;
@@ -994,10 +995,16 @@ static void sun4m_hw_init(const struct sun4m_hwdef *h= wdef,
=C2=A0 =C2=A0 =C2=A0qdev_prop_set_uint32(dev, "chnAtype", escc_kb= d);
=C2=A0 =C2=A0 =C2=A0s =3D SYS_BUS_DEVICE(dev);
=C2=A0 =C2=A0 =C2=A0sysbus_realize_and_unref(s, &error_fatal);
-=C2=A0 =C2=A0 sysbus_connect_irq(s, 0, slavio_irq[14]);
-=C2=A0 =C2=A0 sysbus_connect_irq(s, 1, slavio_irq[14]);
=C2=A0 =C2=A0 =C2=A0sysbus_mmio_map(s, 0, hwdef->ms_kb_base);

+=C2=A0 =C2=A0 /* Logically OR both its IRQs together */
+=C2=A0 =C2=A0 ms_kb_orgate =3D DEVICE(object_new(TYPE_OR_IRQ));
+=C2=A0 =C2=A0 object_property_set_int(OBJECT(ms_kb_orgate), "num-line= s", 2, &error_fatal);
+=C2=A0 =C2=A0 qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal)= ;
+=C2=A0 =C2=A0 sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0));=
+=C2=A0 =C2=A0 sysbus_connect_irq(s, 1, qdev_get_gpio_in(ms_kb_orgate, 1));=
+=C2=A0 =C2=A0 qdev_connect_gpio_out(DEVICE(ms_kb_orgate), 0, slavio_irq[14= ]);
+
=C2=A0 =C2=A0 =C2=A0dev =3D qdev_new(TYPE_ESCC);
=C2=A0 =C2=A0 =C2=A0qdev_prop_set_uint32(dev, "disabled", 0);
=C2=A0 =C2=A0 =C2=A0qdev_prop_set_uint32(dev, "frequency", ESCC_C= LOCK);
@@ -1009,10 +1016,16 @@ static void sun4m_hw_init(const struct sun4m_hwdef = *hwdef,

=C2=A0 =C2=A0 =C2=A0s =3D SYS_BUS_DEVICE(dev);
=C2=A0 =C2=A0 =C2=A0sysbus_realize_and_unref(s, &error_fatal);
-=C2=A0 =C2=A0 sysbus_connect_irq(s, 0, slavio_irq[15]);
-=C2=A0 =C2=A0 sysbus_connect_irq(s, 1,=C2=A0 slavio_irq[15]);
=C2=A0 =C2=A0 =C2=A0sysbus_mmio_map(s, 0, hwdef->serial_base);

+=C2=A0 =C2=A0 /* Logically OR both its IRQs together */
+=C2=A0 =C2=A0 serial_orgate =3D DEVICE(object_new(TYPE_OR_IRQ));
+=C2=A0 =C2=A0 object_property_set_int(OBJECT(serial_orgate), "num-lin= es", 2, &error_fatal);
+=C2=A0 =C2=A0 qdev_realize_and_unref(serial_orgate, NULL, &error_fatal= );
+=C2=A0 =C2=A0 sysbus_connect_irq(s, 0, qdev_get_gpio_in(serial_orgate, 0))= ;
+=C2=A0 =C2=A0 sysbus_connect_irq(s, 1, qdev_get_gpio_in(serial_orgate, 1))= ;
+=C2=A0 =C2=A0 qdev_connect_gpio_out(DEVICE(serial_orgate), 0, slavio_irq[1= 5]);
+
=C2=A0 =C2=A0 =C2=A0if (hwdef->apc_base) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0apc_init(hwdef->apc_base, qemu_allocat= e_irq(cpu_halt_signal, NULL, 0));
=C2=A0 =C2=A0 =C2=A0}
--
2.20.1

--000000000000c003ba05b6d1fd21--