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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 04D39C433DB for ; Sat, 2 Jan 2021 09:59:40 +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 3B42020691 for ; Sat, 2 Jan 2021 09:59:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B42020691 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kvdhB-0004bA-VG for qemu-devel@archiver.kernel.org; Sat, 02 Jan 2021 04:59:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvdgU-0003rl-Gc for qemu-devel@nongnu.org; Sat, 02 Jan 2021 04:58:54 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:32195) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kvdgP-0003T9-Hn for qemu-devel@nongnu.org; Sat, 02 Jan 2021 04:58:52 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id B9D907470FB; Sat, 2 Jan 2021 10:58:44 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 8D8FE7470E2; Sat, 2 Jan 2021 10:58:44 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 8BF337470FA; Sat, 2 Jan 2021 10:58:44 +0100 (CET) Date: Sat, 2 Jan 2021 10:58:44 +0100 (CET) To: qemu-devel@nongnu.org Subject: qemu isa irq gpio question Message-ID: <7a65c948-b778-e829-5b22-452092fa9819@eik.bme.hu> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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: Peter Maydell , =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: BALATON Zoltan From: BALATON Zoltan via Hello, While cleaning up my VIA south bridge patches I've found that with the finished version I did not get interrupts. At the end I've found a solution in a similar device (piix4) but I don't understand why that's needed. Could someone please explain? Here's what I had originally in board code (this is from pegasos2 but fuloong2e has the same with vt82c686b instead if vt8231): dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true, "vt8231"); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(dev), "isa.0")); // "vt8231" just created an empty isa_bus with isa_bus_new() qemu_irq *i8259 = i8259_init(isa_bus, qdev_get_gpio_in_named(DEVICE(mv), "gpp", 31)); isa_bus_irqs(isa_bus, i8259); which worked but after completely moving isa_bus, PIC and other ISA devices into the vt82c686b/vt8231 model I ended up with: dev = pci_create_simple_multifunction(pci_bus, PCI_DEVFN(12, 0), true, "vt8231-isa"); qdev_connect_gpio_out(DEVICE(dev), 0, qdev_get_gpio_in_named(DEVICE(mv), "gpp", 31)); where "vt8231-isa" having this: struct ViaISAState { PCIDevice dev; qemu_irq cpu_intr; }; static void vt8231_realize(PCIDevice *d, Error **errp) { qdev_init_gpio_out(dev, &s->cpu_intr, 1); isa_bus = isa_bus_new(...); isa_bus_irqs(isa_bus, i8259_init(isa_bus, s->cpu_intr)); } this compiled without warnings but irqs were not getting to the connected end. After looking for similar code I ended up with this from piix4 which works again: static void via_isa_request_i8259_irq(void *opaque, int irq, int level) { ViaISAState *s = opaque; qemu_set_irq(s->cpu_intr, level); } static void vt8231_realize(PCIDevice *d, Error **errp) { qdev_init_gpio_out(dev, &s->cpu_intr, 1); qemu_irq *isa_irq = qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1); isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq)); } I'm not sure if this will leak the allocated irq and why is this additional function needed inbetween these in this case but this is what works so I'll go with this one for now but still curious what did I miss. Regards, BALATON Zoltan