{"id":856688,"url":"http://patchwork.ozlabs.org/api/patches/856688/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20180108024558.17983-16-f4bug@amsat.org/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20180108024558.17983-16-f4bug@amsat.org>","list_archive_url":null,"date":"2018-01-08T02:45:44","name":"[15/29] piix4: add a i8259 interrupt controller as specified in datasheet","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"5428eb23cd9100954f73059797f3cceeb4efb2bd","submitter":{"id":70924,"url":"http://patchwork.ozlabs.org/api/people/70924/?format=json","name":"Philippe Mathieu-Daudé","email":"f4bug@amsat.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20180108024558.17983-16-f4bug@amsat.org/mbox/","series":[{"id":21847,"url":"http://patchwork.ozlabs.org/api/series/21847/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=21847","date":"2018-01-08T02:45:30","name":"remove i386/pc dependency: generic SuperIO, PIIX cleanup","version":1,"mbox":"http://patchwork.ozlabs.org/series/21847/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/856688/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/856688/checks/","tags":{},"related":[],"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"vQuPvif9\"; dkim-atps=neutral"],"Received":["from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3zFKxb4RDpz9s71\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon,  8 Jan 2018 14:09:23 +1100 (AEDT)","from localhost ([::1]:60272 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1eYNoP-0001TN-No\n\tfor incoming@patchwork.ozlabs.org; Sun, 07 Jan 2018 22:09:21 -0500","from eggs.gnu.org ([2001:4830:134:3::10]:51491)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1eYNSn-00078c-K8\n\tfor qemu-devel@nongnu.org; Sun, 07 Jan 2018 21:47:02 -0500","from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1eYNSm-0002gh-Jq\n\tfor qemu-devel@nongnu.org; Sun, 07 Jan 2018 21:47:01 -0500","from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]:35537)\n\tby eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)\n\t(Exim 4.71) (envelope-from <philippe.mathieu.daude@gmail.com>)\n\tid 1eYNSm-0002gT-Dd\n\tfor qemu-devel@nongnu.org; Sun, 07 Jan 2018 21:47:00 -0500","by mail-qk0-x243.google.com with SMTP id w184so4359121qka.2\n\tfor <qemu-devel@nongnu.org>; Sun, 07 Jan 2018 18:47:00 -0800 (PST)","from x1.local ([138.117.48.219]) by smtp.gmail.com with ESMTPSA id\n\td10sm7156245qkg.16.2018.01.07.18.46.56\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 07 Jan 2018 18:46:59 -0800 (PST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=R9hCFeNlG3nHUXwQYsh5pac9rVBEjIdVIAPvmOJC+lU=;\n\tb=vQuPvif9Dj1TllKprfbleZLeBssTw7/0qaa2OMMKBMhv68DGZHuKNR3CaImZL3wjiC\n\tWQ29/ySnIrkyeVB/C3HkadnRJnV/p7wdCj6sF2DnCsCE29WB8lEbJNkW+exKOx5qoN9t\n\tmT2ks3o16mLsyECUSHSlP1NyCWkLOuk0OpgeefvaVTPXf/xlpvtl6GvJw9pcG/53iVRz\n\ttItKT+D7tGXFFVmh8tOatjKx62z2ov3+X2OLxP+Cb65rzv8T0YGvE11UU//zAlw4wBPj\n\tb2pSDxWPKPrxz0GjmWMkAU5KVmombura6OhQW8sr46wiroWt7y3H6kfKjQFJBFqJpshh\n\tm5yQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=R9hCFeNlG3nHUXwQYsh5pac9rVBEjIdVIAPvmOJC+lU=;\n\tb=TwmYshZUzYGAIr6LDjDrMWkiAGz5B2Q9hsaie39KeSiqWE+amjbcTZwG5z0VTSRBl1\n\t7i1Otmn68F2MzzNP3D4eB3TDU7DrAdup6pdcpv1n6/bzPCN3ze+KUvWNaoqILdkUy0/8\n\tGrCm9vxwzTAOHMCfwU/p0agMun4Jd8yrdj5B1R4o2hFiwhYr59/bBH5YXbSM0GTmfIaE\n\tqmMu6huOAta6+t2OcnjHQSXdoNOq3baPRWa+iL10cVgK+rg+VRX2DmccvW4N1CC9R3cN\n\tLhbcxvyo3sMxprKbuAMe5TyRFadX2MBkNja8ZywHkO/2wL47Gak8FzcSwOhBxX9mDXcN\n\td1DA==","X-Gm-Message-State":"AKwxytf5dej6b6L0jKn/SLQSt26m1R5crVurHSZ1tE4fQ08llX7Fv5QN\n\t+P+f5IsmsOkUsfYALnUXtbw=","X-Google-Smtp-Source":"ACJfBos29puPJiG3MDp7Y11ekue1IF6e4z3ChmL4Dqyuz//mDrrWNG4tWLTVcYG593ZDYJ/MTQdqAg==","X-Received":"by 10.55.204.18 with SMTP id r18mr14082153qki.212.1515379619853; \n\tSun, 07 Jan 2018 18:46:59 -0800 (PST)","From":"=?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= <f4bug@amsat.org>","To":"Paolo Bonzini <pbonzini@redhat.com>,\n\t\"Michael S. Tsirkin\" <mst@redhat.com>, =?utf-8?q?Herv=C3=A9_Poussinea?=\n\t=?utf-8?q?u?= <hpoussin@reactos.org>,\n\tAurelien Jarno <aurelien@aurel32.net>, Eduardo Habkost\n\t<ehabkost@redhat.com>, Marcel Apfelbaum <marcel@redhat.com>","Date":"Sun,  7 Jan 2018 23:45:44 -0300","Message-Id":"<20180108024558.17983-16-f4bug@amsat.org>","X-Mailer":"git-send-email 2.15.1","In-Reply-To":"<20180108024558.17983-1-f4bug@amsat.org>","References":"<20180108024558.17983-1-f4bug@amsat.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-detected-operating-system":"by eggs.gnu.org: Genre and OS details not\n\trecognized.","X-Received-From":"2607:f8b0:400d:c09::243","Subject":"[Qemu-devel] [PATCH 15/29] piix4: add a i8259 interrupt controller\n\tas specified in datasheet","X-BeenThere":"qemu-devel@nongnu.org","X-Mailman-Version":"2.1.21","Precedence":"list","List-Id":"<qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<http://lists.nongnu.org/archive/html/qemu-devel/>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Cc":"Igor Mammedov <imammedo@redhat.com>, Yongbok Kim <yongbok.kim@mips.com>, \n\tqemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?=\n\t<f4bug@amsat.org>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>"},"content":"From: Hervé Poussineau <hpoussin@reactos.org>\n\nAdd ISA irqs as piix4 gpio in, and CPU interrupt request as piix4 gpio out.\nRemove i8259 instanciated in malta board, to not have it twice.\n\nWe can also remove the now unused piix4_init() function.\n\nSigned-off-by: Hervé Poussineau <hpoussin@reactos.org>\n[PMD: rebased]\nSigned-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>\n---\n include/hw/i386/pc.h |  1 -\n hw/isa/piix4.c       | 38 ++++++++++++++++++++++++++++----------\n hw/mips/mips_malta.c | 28 ++++++++++++----------------\n 3 files changed, 40 insertions(+), 27 deletions(-)","diff":"diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h\nindex 103c7a9916..d2b67e44a7 100644\n--- a/include/hw/i386/pc.h\n+++ b/include/hw/i386/pc.h\n@@ -274,7 +274,6 @@ PCIBus *i440fx_init(const char *host_type, const char *pci_type,\n PCIBus *find_i440fx(void);\n /* piix4.c */\n extern PCIDevice *piix4_dev;\n-int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn);\n \n /* pc_sysfw.c */\n void pc_system_firmware_init(MemoryRegion *rom_memory,\ndiff --git a/hw/isa/piix4.c b/hw/isa/piix4.c\nindex 13f4eaa2dd..c19aa5a74f 100644\n--- a/hw/isa/piix4.c\n+++ b/hw/isa/piix4.c\n@@ -34,6 +34,8 @@ PCIDevice *piix4_dev;\n \n typedef struct PIIX4State {\n     PCIDevice dev;\n+    qemu_irq cpu_intr;\n+    qemu_irq *isa;\n \n     /* Reset Control Register */\n     MemoryRegion rcr_mem;\n@@ -92,6 +94,18 @@ static const VMStateDescription vmstate_piix4 = {\n     }\n };\n \n+static void piix4_request_i8259_irq(void *opaque, int irq, int level)\n+{\n+    PIIX4State *s = opaque;\n+    qemu_set_irq(s->cpu_intr, level);\n+}\n+\n+static void piix4_set_i8259_irq(void *opaque, int irq, int level)\n+{\n+    PIIX4State *s = opaque;\n+    qemu_set_irq(s->isa[irq], level);\n+}\n+\n static void piix4_rcr_write(void *opaque, hwaddr addr, uint64_t val,\n                             unsigned int len)\n {\n@@ -124,27 +138,31 @@ static void piix4_realize(PCIDevice *pci_dev, Error **errp)\n {\n     DeviceState *dev = DEVICE(pci_dev);\n     PIIX4State *s = DO_UPCAST(PIIX4State, dev, pci_dev);\n+    ISABus *isa_bus;\n+    qemu_irq *i8259_out_irq;\n \n-    if (!isa_bus_new(dev, pci_address_space(pci_dev),\n-                     pci_address_space_io(pci_dev), errp)) {\n+    isa_bus = isa_bus_new(dev, pci_address_space(pci_dev),\n+                          pci_address_space_io(pci_dev), errp);\n+    if (!isa_bus) {\n         return;\n     }\n \n+    qdev_init_gpio_in_named(dev, piix4_set_i8259_irq, \"isa\", ISA_NUM_IRQS);\n+    qdev_init_gpio_out_named(dev, &s->cpu_intr, \"intr\", 1);\n+\n     memory_region_init_io(&s->rcr_mem, OBJECT(dev), &piix4_rcr_ops, s,\n                           \"reset-control\", 1);\n     memory_region_add_subregion_overlap(pci_address_space_io(pci_dev), 0xcf9,\n                                         &s->rcr_mem, 1);\n \n-    piix4_dev = pci_dev;\n-}\n+    /* initialize i8259 pic */\n+    i8259_out_irq = qemu_allocate_irqs(piix4_request_i8259_irq, s, 1);\n+    s->isa = i8259_init(isa_bus, *i8259_out_irq);\n \n-int piix4_init(PCIBus *bus, ISABus **isa_bus, int devfn)\n-{\n-    PCIDevice *d;\n+    /* initialize ISA irqs */\n+    isa_bus_irqs(isa_bus, s->isa);\n \n-    d = pci_create_simple_multifunction(bus, devfn, true, \"PIIX4\");\n-    *isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(d), \"isa.0\"));\n-    return d->devfn;\n+    piix4_dev = pci_dev;\n }\n \n static void piix4_class_init(ObjectClass *klass, void *data)\ndiff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c\nindex bfa79c374d..d31e144b70 100644\n--- a/hw/mips/mips_malta.c\n+++ b/hw/mips/mips_malta.c\n@@ -96,7 +96,7 @@ typedef struct {\n     SysBusDevice parent_obj;\n \n     MIPSCPSState *cps;\n-    qemu_irq *i8259;\n+    qemu_irq i8259[16];\n } MaltaState;\n \n static ISADevice *pit;\n@@ -1008,8 +1008,8 @@ void mips_malta_init(MachineState *machine)\n     int64_t kernel_entry, bootloader_run_addr;\n     PCIBus *pci_bus;\n     ISABus *isa_bus;\n-    qemu_irq *isa_irq;\n     qemu_irq cbus_irq, i8259_irq;\n+    PCIDevice *pci;\n     int piix4_devfn;\n     I2CBus *smbus;\n     int i;\n@@ -1185,28 +1185,24 @@ void mips_malta_init(MachineState *machine)\n     /* Board ID = 0x420 (Malta Board with CoreLV) */\n     stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420);\n \n-    /*\n-     * We have a circular dependency problem: pci_bus depends on isa_irq,\n-     * isa_irq is provided by i8259, i8259 depends on ISA, ISA depends\n-     * on piix4, and piix4 depends on pci_bus.  To stop the cycle we have\n-     * qemu_irq_proxy() adds an extra bit of indirection, allowing us\n-     * to resolve the isa_irq -> i8259 dependency after i8259 is initialized.\n-     */\n-    isa_irq = qemu_irq_proxy(&s->i8259, 16);\n-\n     /* Northbridge */\n-    pci_bus = gt64120_register(isa_irq);\n+    pci_bus = gt64120_register(s->i8259);\n \n     /* Southbridge */\n     ide_drive_get(hd, ARRAY_SIZE(hd));\n \n-    piix4_devfn = piix4_init(pci_bus, &isa_bus, 80);\n+    pci = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(10, 0),\n+                                          true, \"PIIX4\");\n+    dev = DEVICE(pci);\n+    isa_bus = ISA_BUS(qdev_get_child_bus(dev, \"isa.0\"));\n+    piix4_devfn = pci->devfn;\n \n     /* Interrupt controller */\n-    /* The 8259 is attached to the MIPS CPU INT0 pin, ie interrupt 2 */\n-    s->i8259 = i8259_init(isa_bus, i8259_irq);\n+    qdev_connect_gpio_out_named(dev, \"intr\", 0, i8259_irq);\n+    for (i = 0; i < 16; i++) {\n+        s->i8259[i] = qdev_get_gpio_in_named(dev, \"isa\", i);\n+    }\n \n-    isa_bus_irqs(isa_bus, s->i8259);\n     pci_piix4_ide_init(pci_bus, hd, piix4_devfn + 1);\n     pci_create_simple(pci_bus, piix4_devfn + 2, \"piix4-usb-uhci\");\n     smbus = piix4_pm_init(pci_bus, piix4_devfn + 3, 0x1100,\n","prefixes":["15/29"]}