From patchwork Sat Feb 12 11:35:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1591997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Hwmquy1K; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwpQT5Rkkz9sFn for ; Sat, 12 Feb 2022 22:38:24 +1100 (AEDT) Received: from localhost ([::1]:40614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIqjN-0006lo-7j for incoming@patchwork.ozlabs.org; Sat, 12 Feb 2022 06:38:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIqgo-0006k2-9d for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:42 -0500 Received: from [2a00:1450:4864:20::531] (port=43936 helo=mail-ed1-x531.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIqgl-0005aU-SH for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:42 -0500 Received: by mail-ed1-x531.google.com with SMTP id y17so18127863edd.10 for ; Sat, 12 Feb 2022 03:35:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w/QEA3vpbqNw5CdBdibl2CpJhZKNEJ4ZR8ZvEBjklts=; b=Hwmquy1KSTIC8jVO9GVRaGXZqduHR5olfCN3Xmh3JRBU5MXli9Le7fL6GPJ/Gn1IAd QwPP9eYITLFX69H6BjN928wd9RSoI0AX4OhdPkoUcjJq9B96rekrZCwtk8r9wZtE0fWs ekV8nPY7WvyZ52mJEYQVNbz4tCs72A35qCkzRK5r87SGKgNYDM1C0tqezVgT27v9+MNv tSlCScgIO4tvFSXleYDdRz+E91u3S+RkXr54khUA/ow4HwrnP8pqE/ZQ+nsapSHCRqin PiUIZMf7tWpiKMmKiDlA16rpYX0f5UL8KqKpIQglc6nHVAwFliZ4CiZS4ZK0lqAqKGJw 50XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w/QEA3vpbqNw5CdBdibl2CpJhZKNEJ4ZR8ZvEBjklts=; b=Qipc5gOuE8QZ/soSgDRYIEBHN+ShtnpP7dJKh2EPcAk/z7F6yeNTIwOUlcA1j48PGo ih+se5XX1sR7KnaejNysokvGnX6IpDtBABlHdv2GfIX+Dh86+tgEw+I9Vy2EdJJ7BFL/ ihWh/RR2qJSqxETOQ8JG5NinNa4MmhnjFtlQxIEENLcCmvSez6iXJTiu1F/63GgCd7FC sJPaGOLhfw0E9NnKntbObHQ5PDeHkyr7Bv+s5RkV1fbCtIW8dY+lb4XaP1L7K4DzrzgR zjXlzDR/Ag/odhsyzQ5+3PI+seH0/cvcIq+jnmW4odthWhgf+drpSX5X7218Ky2jCzwE 3IiQ== X-Gm-Message-State: AOAM530NnNZJigCoxVEFBk44RkLyxvLVeD0iKi8XZhFAwOwmnYblXbuh e1oo4D30EtxDGechT4MMUgkE/rmtvaZGORoSNAg= X-Google-Smtp-Source: ABdhPJxHm5/l+2BWPofsa7QLRW5ESv6MGWI3gcyZ3LO2pOAhbxikq51XrxjHXdVimNzzpqhvihYWpg== X-Received: by 2002:aa7:d40f:: with SMTP id z15mr2617094edq.357.1644665737728; Sat, 12 Feb 2022 03:35:37 -0800 (PST) Received: from osoxes.fritz.box (i577BC145.versanet.de. [87.123.193.69]) by smtp.gmail.com with ESMTPSA id z14sm889288edc.62.2022.02.12.03.35.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 03:35:37 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] malta: Move PCI interrupt handling from gt64xxx to piix4 Date: Sat, 12 Feb 2022 12:35:15 +0100 Message-Id: <20220212113519.69527-2-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212113519.69527-1-shentey@gmail.com> References: <20220212113519.69527-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::531 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=shentey@gmail.com; helo=mail-ed1-x531.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Handling PCI interrupts in piix4 increases cohesion and reduces differences between piix4 and piix3. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- hw/isa/piix4.c | 58 +++++++++++++++++++++++++++++++++++++++ hw/mips/gt64xxx_pci.c | 62 ++++-------------------------------------- hw/mips/malta.c | 6 +--- include/hw/mips/mips.h | 2 +- 4 files changed, 65 insertions(+), 63 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 0fe7b69bc4..5a86308689 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -45,6 +45,7 @@ struct PIIX4State { PCIDevice dev; qemu_irq cpu_intr; qemu_irq *isa; + qemu_irq i8259[ISA_NUM_IRQS]; RTCState rtc; /* Reset Control Register */ @@ -54,6 +55,30 @@ struct PIIX4State { OBJECT_DECLARE_SIMPLE_TYPE(PIIX4State, PIIX4_PCI_DEVICE) +static int pci_irq_levels[4]; + +static void piix4_set_irq(void *opaque, int irq_num, int level) +{ + int i, pic_irq, pic_level; + qemu_irq *pic = opaque; + + pci_irq_levels[irq_num] = level; + + /* now we change the pic irq level according to the piix irq mappings */ + /* XXX: optimize */ + pic_irq = piix4_dev->config[PIIX_PIRQCA + irq_num]; + if (pic_irq < 16) { + /* The pic level is the logical OR of all the PCI irqs mapped to it. */ + pic_level = 0; + for (i = 0; i < 4; i++) { + if (pic_irq == piix4_dev->config[PIIX_PIRQCA + i]) { + pic_level |= pci_irq_levels[i]; + } + } + qemu_set_irq(pic[pic_irq], pic_level); + } +} + static void piix4_isa_reset(DeviceState *dev) { PIIX4State *d = PIIX4_PCI_DEVICE(dev); @@ -248,8 +273,34 @@ static void piix4_register_types(void) type_init(piix4_register_types) +static int pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num) +{ + int slot; + + slot = PCI_SLOT(pci_dev->devfn); + + switch (slot) { + /* PIIX4 USB */ + case 10: + return 3; + /* AMD 79C973 Ethernet */ + case 11: + return 1; + /* Crystal 4281 Sound */ + case 12: + return 2; + /* PCI slot 1 to 4 */ + case 18 ... 21: + return ((slot - 18) + irq_num) & 0x03; + /* Unknown device, don't do any translation */ + default: + return irq_num; + } +} + DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) { + PIIX4State *s; PCIDevice *pci; DeviceState *dev; int devfn = PCI_DEVFN(10, 0); @@ -257,6 +308,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci = pci_create_simple_multifunction(pci_bus, devfn, true, TYPE_PIIX4_PCI_DEVICE); dev = DEVICE(pci); + s = PIIX4_PCI_DEVICE(pci); if (isa_bus) { *isa_bus = ISA_BUS(qdev_get_child_bus(dev, "isa.0")); } @@ -271,5 +323,11 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) NULL, 0, NULL); } + pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s->i8259, 4); + + for (int i = 0; i < ISA_NUM_IRQS; i++) { + s->i8259[i] = qdev_get_gpio_in_named(dev, "isa", i); + } + return dev; } diff --git a/hw/mips/gt64xxx_pci.c b/hw/mips/gt64xxx_pci.c index c7480bd019..9e23e32eff 100644 --- a/hw/mips/gt64xxx_pci.c +++ b/hw/mips/gt64xxx_pci.c @@ -981,56 +981,6 @@ static const MemoryRegionOps isd_mem_ops = { }, }; -static int gt64120_pci_map_irq(PCIDevice *pci_dev, int irq_num) -{ - int slot; - - slot = PCI_SLOT(pci_dev->devfn); - - switch (slot) { - /* PIIX4 USB */ - case 10: - return 3; - /* AMD 79C973 Ethernet */ - case 11: - return 1; - /* Crystal 4281 Sound */ - case 12: - return 2; - /* PCI slot 1 to 4 */ - case 18 ... 21: - return ((slot - 18) + irq_num) & 0x03; - /* Unknown device, don't do any translation */ - default: - return irq_num; - } -} - -static int pci_irq_levels[4]; - -static void gt64120_pci_set_irq(void *opaque, int irq_num, int level) -{ - int i, pic_irq, pic_level; - qemu_irq *pic = opaque; - - pci_irq_levels[irq_num] = level; - - /* now we change the pic irq level according to the piix irq mappings */ - /* XXX: optimize */ - pic_irq = piix4_dev->config[PIIX_PIRQCA + irq_num]; - if (pic_irq < 16) { - /* The pic level is the logical OR of all the PCI irqs mapped to it. */ - pic_level = 0; - for (i = 0; i < 4; i++) { - if (pic_irq == piix4_dev->config[PIIX_PIRQCA + i]) { - pic_level |= pci_irq_levels[i]; - } - } - qemu_set_irq(pic[pic_irq], pic_level); - } -} - - static void gt64120_reset(DeviceState *dev) { GT64120State *s = GT64120_PCI_HOST_BRIDGE(dev); @@ -1207,7 +1157,7 @@ static void gt64120_realize(DeviceState *dev, Error **errp) "gt64120-isd", 0x1000); } -PCIBus *gt64120_register(qemu_irq *pic) +PCIBus *gt64120_register(void) { GT64120State *d; PCIHostState *phb; @@ -1218,12 +1168,10 @@ PCIBus *gt64120_register(qemu_irq *pic) phb = PCI_HOST_BRIDGE(dev); memory_region_init(&d->pci0_mem, OBJECT(dev), "pci0-mem", 4 * GiB); address_space_init(&d->pci0_mem_as, &d->pci0_mem, "pci0-mem"); - phb->bus = pci_register_root_bus(dev, "pci", - gt64120_pci_set_irq, gt64120_pci_map_irq, - pic, - &d->pci0_mem, - get_system_io(), - PCI_DEVFN(18, 0), 4, TYPE_PCI_BUS); + phb->bus = pci_root_bus_new(dev, "pci", + &d->pci0_mem, + get_system_io(), + PCI_DEVFN(18, 0), TYPE_PCI_BUS); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); pci_create_simple(phb->bus, PCI_DEVFN(0, 0), "gt64120_pci"); diff --git a/hw/mips/malta.c b/hw/mips/malta.c index b770b8d367..13254dbc89 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -97,7 +97,6 @@ struct MaltaState { Clock *cpuclk; MIPSCPSState cps; - qemu_irq i8259[ISA_NUM_IRQS]; }; static struct _loaderparams { @@ -1391,7 +1390,7 @@ void mips_malta_init(MachineState *machine) stl_p(memory_region_get_ram_ptr(bios_copy) + 0x10, 0x00000420); /* Northbridge */ - pci_bus = gt64120_register(s->i8259); + pci_bus = gt64120_register(); /* * The whole address space decoded by the GT-64120A doesn't generate * exception when accessing invalid memory. Create an empty slot to @@ -1404,9 +1403,6 @@ void mips_malta_init(MachineState *machine) /* Interrupt controller */ qdev_connect_gpio_out_named(dev, "intr", 0, i8259_irq); - for (int i = 0; i < ISA_NUM_IRQS; i++) { - s->i8259[i] = qdev_get_gpio_in_named(dev, "isa", i); - } /* generate SPD EEPROM data */ generate_eeprom_spd(&smbus_eeprom_buf[0 * 256], ram_size); diff --git a/include/hw/mips/mips.h b/include/hw/mips/mips.h index 6c9c8805f3..ff88942e63 100644 --- a/include/hw/mips/mips.h +++ b/include/hw/mips/mips.h @@ -10,7 +10,7 @@ #include "exec/memory.h" /* gt64xxx.c */ -PCIBus *gt64120_register(qemu_irq *pic); +PCIBus *gt64120_register(void); /* bonito.c */ PCIBus *bonito_init(qemu_irq *pic); From patchwork Sat Feb 12 11:35:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1591998 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=h44tjI3x; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwpR45b8cz9sCD for ; Sat, 12 Feb 2022 22:38:56 +1100 (AEDT) Received: from localhost ([::1]:43106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIqju-0000Cp-5v for incoming@patchwork.ozlabs.org; Sat, 12 Feb 2022 06:38:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIqgr-0006l0-1R; Sat, 12 Feb 2022 06:35:47 -0500 Received: from [2a00:1450:4864:20::635] (port=42997 helo=mail-ej1-x635.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIqgo-0005ag-NF; Sat, 12 Feb 2022 06:35:44 -0500 Received: by mail-ej1-x635.google.com with SMTP id y22so15868671eju.9; Sat, 12 Feb 2022 03:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JQFl51QQ+66n1DWPb4qGXjZt3TBMtDCbGDgiim+R5aw=; b=h44tjI3xeKL8TSFkdaeaCXthT8QLVzy1f8zPApKPx9cnaeEAHpAiL0CGqbpY8olD2h gC+7QSbgzo6lBzt9jDl2AqB4WIOr9Bmpq0L90m+oEaglyHQ6d3MOsitk9KXqo+e56sws rcS3v/BQo2E9OS8eOuBlY5xcSxjWg3+UkHBkBfFMTY0RZpwpIT3M3vj6wqTNcetEb6tS 8SDf/KAkExxlmtNEYCg2VyTVtm9Elthi/rcl1PL2Ag06N9LCtmtbd3PFiUEV29+9jSbz uTywKDbEcdXR2MyD3zqsvXDKeWDNYFi5LHQjiXIwhL7dkRPWZVALqgRnZhlB97gl8trj O+lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JQFl51QQ+66n1DWPb4qGXjZt3TBMtDCbGDgiim+R5aw=; b=QdiArp7m7i2QPBPxLYmz5uOd4jfOqfoA+8vY/Hsxgexh1CX8O/GXXg//2XcOtdoVbl kNdkbMy9ppLMeS4SkcaCHMfSNpwAdeIqRN98SnuGiJhCC7960HjfkD8dXV5qGc2pSayo UlAQPzKV8+GI+QREnud6B2XvB7FiazQxqbODHtN3B0H0h8YZADhiaK+vhJem82qSld1z SBwqG4qcNOeVc/c7JphesarI0/2nzKFG+zDifYubS1vSVzKtVXmJW6IFA/qJrpxLuBg0 RI1FUAyXCdeQNAfu4H0K2nntz3NB5buJgttJGOOI9N/rm+esHmsAbL4nv+5OtyJDGime dR1A== X-Gm-Message-State: AOAM533iP8YXjqoO+uC2mkIIOhdG3xyNNJOz7SsZ+UeHDl/mt/AIgJjr PKB9HyPoiUGIpV6J4ms1TR29kTIu7HSTh63AwEU= X-Google-Smtp-Source: ABdhPJzBd/zwBoM1lVZ732S9uDORxp10isos0q315/lsJyStAdMtiVUdPK1bCRLEl6x3S47l0z+rvw== X-Received: by 2002:a17:906:73ce:: with SMTP id n14mr4449731ejl.312.1644665740649; Sat, 12 Feb 2022 03:35:40 -0800 (PST) Received: from osoxes.fritz.box (i577BC145.versanet.de. [87.123.193.69]) by smtp.gmail.com with ESMTPSA id z14sm889288edc.62.2022.02.12.03.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 03:35:40 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH v2 2/5] pci: Always pass own DeviceState to pci_map_irq_fn's Date: Sat, 12 Feb 2022 12:35:16 +0100 Message-Id: <20220212113519.69527-3-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212113519.69527-1-shentey@gmail.com> References: <20220212113519.69527-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::635 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=shentey@gmail.com; helo=mail-ej1-x635.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Yoshinori Sato , Magnus Damm , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "open list:Versatile PB" , =?utf-8?q?Herv=C3=A9_Poussi?= =?utf-8?q?neau?= , "open list:ppc4xx" , Bernhard Beschow , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Passing own DeviceState rather than just the IRQs allows for resolving global variables. Signed-off-by: Bernhard Beschow Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- hw/isa/piix4.c | 6 +++--- hw/pci-host/sh_pci.c | 6 +++--- hw/pci-host/versatile.c | 6 +++--- hw/ppc/ppc440_pcix.c | 6 +++--- hw/ppc/ppc4xx_pci.c | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 5a86308689..a31e9714cf 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -60,7 +60,7 @@ static int pci_irq_levels[4]; static void piix4_set_irq(void *opaque, int irq_num, int level) { int i, pic_irq, pic_level; - qemu_irq *pic = opaque; + PIIX4State *s = opaque; pci_irq_levels[irq_num] = level; @@ -75,7 +75,7 @@ static void piix4_set_irq(void *opaque, int irq_num, int level) pic_level |= pci_irq_levels[i]; } } - qemu_set_irq(pic[pic_irq], pic_level); + qemu_set_irq(s->i8259[pic_irq], pic_level); } } @@ -323,7 +323,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) NULL, 0, NULL); } - pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s->i8259, 4); + pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, 4); for (int i = 0; i < ISA_NUM_IRQS; i++) { s->i8259[i] = qdev_get_gpio_in_named(dev, "isa", i); diff --git a/hw/pci-host/sh_pci.c b/hw/pci-host/sh_pci.c index 719d6ca2a6..ae0aa462b3 100644 --- a/hw/pci-host/sh_pci.c +++ b/hw/pci-host/sh_pci.c @@ -111,9 +111,9 @@ static int sh_pci_map_irq(PCIDevice *d, int irq_num) static void sh_pci_set_irq(void *opaque, int irq_num, int level) { - qemu_irq *pic = opaque; + SHPCIState *s = opaque; - qemu_set_irq(pic[irq_num], level); + qemu_set_irq(s->irq[irq_num], level); } static void sh_pci_device_realize(DeviceState *dev, Error **errp) @@ -128,7 +128,7 @@ static void sh_pci_device_realize(DeviceState *dev, Error **errp) } phb->bus = pci_register_root_bus(dev, "pci", sh_pci_set_irq, sh_pci_map_irq, - s->irq, + s, get_system_memory(), get_system_io(), PCI_DEVFN(0, 0), 4, TYPE_PCI_BUS); diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c index f66384fa02..5fbcb72d7d 100644 --- a/hw/pci-host/versatile.c +++ b/hw/pci-host/versatile.c @@ -362,9 +362,9 @@ static int pci_vpb_rv_map_irq(PCIDevice *d, int irq_num) static void pci_vpb_set_irq(void *opaque, int irq_num, int level) { - qemu_irq *pic = opaque; + PCIVPBState *s = opaque; - qemu_set_irq(pic[irq_num], level); + qemu_set_irq(s->irq[irq_num], level); } static void pci_vpb_reset(DeviceState *d) @@ -422,7 +422,7 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp) mapfn = pci_vpb_map_irq; } - pci_bus_irqs(&s->pci_bus, pci_vpb_set_irq, mapfn, s->irq, 4); + pci_bus_irqs(&s->pci_bus, pci_vpb_set_irq, mapfn, s, 4); /* Our memory regions are: * 0 : our control registers diff --git a/hw/ppc/ppc440_pcix.c b/hw/ppc/ppc440_pcix.c index 788d25514a..291c1bfbe7 100644 --- a/hw/ppc/ppc440_pcix.c +++ b/hw/ppc/ppc440_pcix.c @@ -431,14 +431,14 @@ static int ppc440_pcix_map_irq(PCIDevice *pci_dev, int irq_num) static void ppc440_pcix_set_irq(void *opaque, int irq_num, int level) { - qemu_irq *pci_irq = opaque; + PPC440PCIXState *s = opaque; trace_ppc440_pcix_set_irq(irq_num); if (irq_num < 0) { error_report("%s: PCI irq %d", __func__, irq_num); return; } - qemu_set_irq(*pci_irq, level); + qemu_set_irq(s->irq, level); } static AddressSpace *ppc440_pcix_set_iommu(PCIBus *b, void *opaque, int devfn) @@ -492,7 +492,7 @@ static void ppc440_pcix_realize(DeviceState *dev, Error **errp) sysbus_init_irq(sbd, &s->irq); memory_region_init(&s->busmem, OBJECT(dev), "pci bus memory", UINT64_MAX); h->bus = pci_register_root_bus(dev, NULL, ppc440_pcix_set_irq, - ppc440_pcix_map_irq, &s->irq, &s->busmem, + ppc440_pcix_map_irq, s, &s->busmem, get_system_io(), PCI_DEVFN(0, 0), 1, TYPE_PCI_BUS); s->dev = pci_create_simple(h->bus, PCI_DEVFN(0, 0), "ppc4xx-host-bridge"); diff --git a/hw/ppc/ppc4xx_pci.c b/hw/ppc/ppc4xx_pci.c index 5df97e6d15..f6718746a1 100644 --- a/hw/ppc/ppc4xx_pci.c +++ b/hw/ppc/ppc4xx_pci.c @@ -256,11 +256,11 @@ static int ppc4xx_pci_map_irq(PCIDevice *pci_dev, int irq_num) static void ppc4xx_pci_set_irq(void *opaque, int irq_num, int level) { - qemu_irq *pci_irqs = opaque; + PPC4xxPCIState *s = opaque; trace_ppc4xx_pci_set_irq(irq_num); assert(irq_num >= 0 && irq_num < PPC4xx_PCI_NUM_DEVS); - qemu_set_irq(pci_irqs[irq_num], level); + qemu_set_irq(s->irq[irq_num], level); } static const VMStateDescription vmstate_pci_master_map = { @@ -319,7 +319,7 @@ static void ppc4xx_pcihost_realize(DeviceState *dev, Error **errp) } b = pci_register_root_bus(dev, NULL, ppc4xx_pci_set_irq, - ppc4xx_pci_map_irq, s->irq, get_system_memory(), + ppc4xx_pci_map_irq, s, get_system_memory(), get_system_io(), 0, ARRAY_SIZE(s->irq), TYPE_PCI_BUS); h->bus = b; From patchwork Sat Feb 12 11:35:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1592000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=kUbslPP6; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwpVn27xCz9sFn for ; Sat, 12 Feb 2022 22:42:09 +1100 (AEDT) Received: from localhost ([::1]:48642 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIqn0-0003uy-PJ for incoming@patchwork.ozlabs.org; Sat, 12 Feb 2022 06:42:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIqgs-0006l3-Is for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:47 -0500 Received: from [2a00:1450:4864:20::630] (port=45996 helo=mail-ej1-x630.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIqgq-0005bA-Ch for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:45 -0500 Received: by mail-ej1-x630.google.com with SMTP id h22so9716812ejl.12 for ; Sat, 12 Feb 2022 03:35:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=N2QjOGu2ArQZzdQJMMDMCb9JapaoTt59BGwaEZc+Ac8=; b=kUbslPP6+C1p5+jltnIodG2ZcZS07Pk5FUw6ReeuJjT1DfunJ+Xk3/sMCYVr47HQzI M2mG03sXEp9ZkFT76SLtzBu+lhasF6JfX60aNL/wk+XUxlTRRUwrmOY071cyB8VMZACj Yr9XXihNfR4dF5sXN/mPrauaqgV4V+CKAn4Kzgxw/My02j/wqjxhyHOQe1GfF4ay/heE WBBp5VdgSWJ0D0wC6W2yYN3q3VxPiaDbdhTe+muCW4nNEASoWiRI40Py++uMY4Ut12XI lTvu9nN2ClEP/Ap2O5NeBf+avUStx8PfHv72MGjyBMj5HFkuz4LfErdmrqosQif7JO7W vI4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=N2QjOGu2ArQZzdQJMMDMCb9JapaoTt59BGwaEZc+Ac8=; b=gLHzsdUNJMQa1Mbs4j+xIPVmkMUO388Av03R84qnJAay6su8Bp2ZnGWyYasIwwXokV s2A3iKyLStvRPAJ4dGVp2p28OMrJpi836iqhXJpoLlzwX1eKNQKwzpvjBDBI5AxgSCCl JzRrXapZ9rXYzP4zL7jqJ53XTS/Llh2OfaOqTQWX1kgRPRCLOzq5KX+hqNWW9nWS2zaO rUgyULVgJebxmywk8Tp5xXv3mor6ISkSOBEAesKMuLjBYZSVzBtsCB66JFrZ77sVU/rn RYqnS7fhWymU2XxxzCqgarEuRaQd/Z2PV3aXkOAWHU3jWn1IMQwP/7sODGMCaRSbh4rR ddWQ== X-Gm-Message-State: AOAM532I2R9ZTua44hNvN7i1zqCXS2DRtLotwv+g8PqI2VNTCGvtNOaG yprg88bYec3NTIlaTiGqr75S/tdKeUedR5vUXog= X-Google-Smtp-Source: ABdhPJw6UIzYtdQ3tVe9rt3+E3pcmhB8MxhMtokVjSzQYhbzYNR5fKtLqrI0eMqHJsszWIKZdS3Tyg== X-Received: by 2002:a17:906:7383:: with SMTP id f3mr4530792ejl.687.1644665743051; Sat, 12 Feb 2022 03:35:43 -0800 (PST) Received: from osoxes.fritz.box (i577BC145.versanet.de. [87.123.193.69]) by smtp.gmail.com with ESMTPSA id z14sm889288edc.62.2022.02.12.03.35.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 03:35:42 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH v2 3/5] isa/piix4: Resolve global variables Date: Sat, 12 Feb 2022 12:35:17 +0100 Message-Id: <20220212113519.69527-4-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212113519.69527-1-shentey@gmail.com> References: <20220212113519.69527-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::630 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::630; envelope-from=shentey@gmail.com; helo=mail-ej1-x630.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Herv=C3=A9_Poussineau?= , Bernhard Beschow , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that piix4_set_irq's opaque parameter references own PIIX4State, piix4_dev becomes redundant and pci_irq_levels can be moved into PIIX4State. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daudé --- hw/isa/piix4.c | 22 +++++++++------------- include/hw/southbridge/piix.h | 2 -- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index a31e9714cf..964e09cf7f 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -39,14 +39,14 @@ #include "sysemu/runstate.h" #include "qom/object.h" -PCIDevice *piix4_dev; - struct PIIX4State { PCIDevice dev; qemu_irq cpu_intr; qemu_irq *isa; qemu_irq i8259[ISA_NUM_IRQS]; + int pci_irq_levels[PIIX_NUM_PIRQS]; + RTCState rtc; /* Reset Control Register */ MemoryRegion rcr_mem; @@ -55,24 +55,22 @@ struct PIIX4State { OBJECT_DECLARE_SIMPLE_TYPE(PIIX4State, PIIX4_PCI_DEVICE) -static int pci_irq_levels[4]; - static void piix4_set_irq(void *opaque, int irq_num, int level) { int i, pic_irq, pic_level; PIIX4State *s = opaque; - pci_irq_levels[irq_num] = level; + s->pci_irq_levels[irq_num] = level; /* now we change the pic irq level according to the piix irq mappings */ /* XXX: optimize */ - pic_irq = piix4_dev->config[PIIX_PIRQCA + irq_num]; - if (pic_irq < 16) { + pic_irq = s->dev.config[PIIX_PIRQCA + irq_num]; + if (pic_irq < ISA_NUM_IRQS) { /* The pic level is the logical OR of all the PCI irqs mapped to it. */ pic_level = 0; - for (i = 0; i < 4; i++) { - if (pic_irq == piix4_dev->config[PIIX_PIRQCA + i]) { - pic_level |= pci_irq_levels[i]; + for (i = 0; i < PIIX_NUM_PIRQS; i++) { + if (pic_irq == s->dev.config[PIIX_PIRQCA + i]) { + pic_level |= s->pci_irq_levels[i]; } } qemu_set_irq(s->i8259[pic_irq], pic_level); @@ -223,8 +221,6 @@ static void piix4_realize(PCIDevice *dev, Error **errp) return; } isa_init_irq(ISA_DEVICE(&s->rtc), &s->rtc.irq, RTC_ISA_IRQ); - - piix4_dev = dev; } static void piix4_init(Object *obj) @@ -323,7 +319,7 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) NULL, 0, NULL); } - pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, 4); + pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS); for (int i = 0; i < ISA_NUM_IRQS; i++) { s->i8259[i] = qdev_get_gpio_in_named(dev, "isa", i); diff --git a/include/hw/southbridge/piix.h b/include/hw/southbridge/piix.h index 6387f2b612..f63f83e5c6 100644 --- a/include/hw/southbridge/piix.h +++ b/include/hw/southbridge/piix.h @@ -70,8 +70,6 @@ typedef struct PIIXState PIIX3State; DECLARE_INSTANCE_CHECKER(PIIX3State, PIIX3_PCI_DEVICE, TYPE_PIIX3_PCI_DEVICE) -extern PCIDevice *piix4_dev; - PIIX3State *piix3_create(PCIBus *pci_bus, ISABus **isa_bus); DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus); From patchwork Sat Feb 12 11:35:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1592001 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=mr/FFNd8; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwpYm4wsMz9sCD for ; Sat, 12 Feb 2022 22:44:42 +1100 (AEDT) Received: from localhost ([::1]:50840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIqpT-0005VJ-LV for incoming@patchwork.ozlabs.org; Sat, 12 Feb 2022 06:44:39 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33812) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIqgu-0006lY-9O for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:48 -0500 Received: from [2a00:1450:4864:20::52f] (port=38541 helo=mail-ed1-x52f.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIqgs-0005bW-Cf for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:47 -0500 Received: by mail-ed1-x52f.google.com with SMTP id g7so4049050edb.5 for ; Sat, 12 Feb 2022 03:35:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jayhIIJozMhMTxnS3EacI646wOAHDq5Mf0vul/q8lwg=; b=mr/FFNd8sEZXmvNKWPZOd2PJfIdIJrbjNvtxxED7GImXmmOMz8ejqGkRSFzFIF3cVS EjK94YmlcmOWvQo4YDwFlxZAL23nEjXe5eZWxJO+bYMJIUzRVwGbCg709Kps7t+75hok SdEe4QnZQcae0SGr6RAMwSGWDtoWCX41/QzwdQSQBxRSJjaTNRRjJo5m0vZUThsuhnm+ OmKYbDz1j2XXofl0EpUdRGXVeS5YAVlb4UjNFPc5AkiahEk8XTXfO41vspqgifyMsf6o i82cMI70mFivM0HGFJTKaN8qn4KXGDVoKCq/4C1fd8a2oFIO3QHvqGk1zURU/ZvvVhfu eu5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jayhIIJozMhMTxnS3EacI646wOAHDq5Mf0vul/q8lwg=; b=BUFXFOio4mopQWXfKzICm6fiS7uDhVXF54JZVMtxjp84fqSjauZKH5qlidx/z9yqi6 AizpO7Z3W1wfFAWY1WNGAla/kyfqUmNbtcIBz9efjhIit4bFJpkaZmQ2gDM9YFhHKplk MLmsMPqPtOrWa4TKi1G5S7+DIvIl4hDzIngga8eCXXDDKcPk1CtqguqhNXksOS0NzQ+W FuO/xK2lm684VPsmPNlIddd1DRuxUuY2UYWVqSFO7YsGt8dtuAc8lzEUdttcCklA0mzs tFhUyzc/kn21ND0whjLFElMivxfMeHYWhkqdSUJUCFtl+8m5Pwp39OZpc7l1HtlMocnh gFYQ== X-Gm-Message-State: AOAM531edGrH4JT/thc4SoJYvAu+Av7x3+w321iDWH5K1CyoxkXVCPQI WzTC3JZQ8iI2y4aJaIDUv3UVtDxeTiIJtocTzhA= X-Google-Smtp-Source: ABdhPJxFKLV+NfhF+a+GYZUmxzKcW0NgDJKvN+0aEUptqNF0F9D4zkXAWqHR5KEBwF6BSfaVj8po7w== X-Received: by 2002:a05:6402:2920:: with SMTP id ee32mr6310037edb.310.1644665744927; Sat, 12 Feb 2022 03:35:44 -0800 (PST) Received: from osoxes.fritz.box (i577BC145.versanet.de. [87.123.193.69]) by smtp.gmail.com with ESMTPSA id z14sm889288edc.62.2022.02.12.03.35.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 03:35:44 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] isa/piix4: Fix PCI IRQ levels to be preserved in VMState Date: Sat, 12 Feb 2022 12:35:18 +0100 Message-Id: <20220212113519.69527-5-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212113519.69527-1-shentey@gmail.com> References: <20220212113519.69527-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::52f (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::52f; envelope-from=shentey@gmail.com; helo=mail-ed1-x52f.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Now that pci_irq_levels[] is part of PIIX4State, the PCI IRQ levels can be saved and restored via the VMState mechanism. This fixes migrated VMs to start with PCI IRQ levels zeroed, which is a bug. Suggested-by: Peter Maydell Suggested-by: Philippe Mathieu-Daudé Signed-off-by: Bernhard Beschow --- hw/isa/piix4.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 964e09cf7f..a9322851db 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -45,7 +45,7 @@ struct PIIX4State { qemu_irq *isa; qemu_irq i8259[ISA_NUM_IRQS]; - int pci_irq_levels[PIIX_NUM_PIRQS]; + int32_t pci_irq_levels[PIIX_NUM_PIRQS]; RTCState rtc; /* Reset Control Register */ @@ -128,12 +128,14 @@ static int piix4_ide_post_load(void *opaque, int version_id) static const VMStateDescription vmstate_piix4 = { .name = "PIIX4", - .version_id = 3, + .version_id = 4, .minimum_version_id = 2, .post_load = piix4_ide_post_load, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(dev, PIIX4State), VMSTATE_UINT8_V(rcr, PIIX4State, 3), + VMSTATE_INT32_ARRAY_V(pci_irq_levels, PIIX4State, + PIIX_NUM_PIRQS, 4), VMSTATE_END_OF_LIST() } }; From patchwork Sat Feb 12 11:35:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1592002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=PZEO0WEd; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) 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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4JwpdL02m2z9sCD for ; Sat, 12 Feb 2022 22:47:49 +1100 (AEDT) Received: from localhost ([::1]:53348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nIqsV-0007IJ-MN for incoming@patchwork.ozlabs.org; Sat, 12 Feb 2022 06:47:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nIqgw-0006mv-3R for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:50 -0500 Received: from [2a00:1450:4864:20::535] (port=38547 helo=mail-ed1-x535.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nIqgu-0005bf-6z for qemu-devel@nongnu.org; Sat, 12 Feb 2022 06:35:49 -0500 Received: by mail-ed1-x535.google.com with SMTP id g7so4049188edb.5 for ; Sat, 12 Feb 2022 03:35:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CUEyRK4eoDUyKvcHgyF0Ay8n1k4tSI89hyDh6Del7NQ=; b=PZEO0WEdcvbjyueGhbcr1noBfo9z5jMfh7wliV0vISwdlSvOKpx1sQA/n7oETTbJOs dWI/t9uujoeSkL06OywLJHUxZ8c61b/BAeRptpC9tCk0BDgzHVI2cFckqciYcYyiwGua UJylrWpfsuqm8cYOafaBdj23dzFQM6GcoknxSjq+PZ8y1C5GJdolEbKRm9aMSDKunang Z9XATqqvte4GpB6PcuUQEFwkLwyjU10eXIO6rGXAWB+lnrkPZYUe3c2NJ3mWct7GUx6e GNkT+xE24IUrPlomAagQ9nszJizAdVxi3zsULb/qkU3CJE+vCWbczFikvPOxaoEQANhV WheQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CUEyRK4eoDUyKvcHgyF0Ay8n1k4tSI89hyDh6Del7NQ=; b=1CIWACpvqfCXiJEPd7trnaNqQ6O2vzqTU7vg0VzLnGulTcuy29pBWET/gs871cko7d T1ZhndJmjwp9KU9PJbk6DbYrUzWcG/KiFAThX7qWbbu9yUKKF0/VV4eHJXEyHpT4Ta7C F6aJxgmjouuSV74M+lDIJIlfZ59X2BqOePwTrW7TMdZuXI9+3llIklk2Bf/NlaFjw/gq 5o1D0+0/EeLRX661St8wlglBuASOLb6Eo8oAHAM+3LQNbHK3b5halDTGVcjlM4k2vBqW rH7hRPO5lS26OjGMDkEqY2rBrQWa33NWOr5HZtnuf45FATI2+2IMpKOKiiKUO1PDHhCs RLRg== X-Gm-Message-State: AOAM533TKx1joFOBUaggZPBZIXco/6rlFMoNKjB2W3NNsLbq0s+bBADB UTpgS6cuEP7N3sPsGr5tg434EtI7kbKtdO5+r4w= X-Google-Smtp-Source: ABdhPJyuz1kKXaF1sAYDmbeHXobDp8+Ehd/KIhPRj+tnu4qLYu1nnjv8O+mICbQ9MQBynnhjC3LwFA== X-Received: by 2002:a05:6402:42cd:: with SMTP id i13mr6304422edc.121.1644665746870; Sat, 12 Feb 2022 03:35:46 -0800 (PST) Received: from osoxes.fritz.box (i577BC145.versanet.de. [87.123.193.69]) by smtp.gmail.com with ESMTPSA id z14sm889288edc.62.2022.02.12.03.35.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Feb 2022 03:35:46 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] isa/piix4: Resolve redundant i8259[] attribute Date: Sat, 12 Feb 2022 12:35:19 +0100 Message-Id: <20220212113519.69527-6-shentey@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220212113519.69527-1-shentey@gmail.com> References: <20220212113519.69527-1-shentey@gmail.com> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::535 (failed) Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=shentey@gmail.com; helo=mail-ed1-x535.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Bernhard Beschow , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Aurelien Jarno Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This is a follow-up on patch "malta: Move PCI interrupt handling from gt64xxx to piix4" where i8259[] was moved from MaltaState to PIIX4State to make the code movement more obvious. However, i8259[] seems redundant to *isa, so remove it. Signed-off-by: Bernhard Beschow --- hw/isa/piix4.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index a9322851db..692fa8d1f9 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -43,7 +43,6 @@ struct PIIX4State { PCIDevice dev; qemu_irq cpu_intr; qemu_irq *isa; - qemu_irq i8259[ISA_NUM_IRQS]; int32_t pci_irq_levels[PIIX_NUM_PIRQS]; @@ -73,7 +72,7 @@ static void piix4_set_irq(void *opaque, int irq_num, int level) pic_level |= s->pci_irq_levels[i]; } } - qemu_set_irq(s->i8259[pic_irq], pic_level); + qemu_set_irq(s->isa[pic_irq], pic_level); } } @@ -323,9 +322,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbus) pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PIRQS); - for (int i = 0; i < ISA_NUM_IRQS; i++) { - s->i8259[i] = qdev_get_gpio_in_named(dev, "isa", i); - } - return dev; }