From nobody Sat Feb 7 18:34:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1583867957; cv=none; d=zohomail.com; s=zohoarc; b=jbs6PTtukoRxuUFRxAbEMIUbGC5IXTf0AEp4r7QoyYvhMTSja0aEW1s4eL+OWjIJKdJ2LyuzOr5/0Nhe/QAMBLXEeQ6a7mYzXQNEZievZup4cGgVuhMHECQOoe3g1ueaMJh3xvp6gm8c0TW/UMwsHR7FjicPdarakUI/1KEyAvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583867957; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+Gig6pSaKb0uyvs6b1AxcMgSktV9PWKQrbSKbt5EI0U=; b=DHBbCdWDCBqvOmgMQ/4wxyBDMj34dzA3nenT3i1Yd06qMlIXQoNElBbkuVPHXa9mqj9x4eD/GHWy3xZ3rsldkBnnsX3uk9zbeeyi6FGRZSd29j9iNXUdvdb4v6PZPa9oVRguKZyDJU410IPPa4KZ8xk2wFCpRB2lmecc/dLLZ0I= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158386795713159.71925332585306; Tue, 10 Mar 2020 12:19:17 -0700 (PDT) Received: from localhost ([::1]:39056 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkPM-0002DC-4H for importer@patchew.org; Tue, 10 Mar 2020 15:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41826) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkO1-00018p-Hm for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:17:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBkO0-00038k-Bh for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:17:53 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:60278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBkNw-0002rM-Ad; Tue, 10 Mar 2020 15:17:49 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 92396747E03; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 0E211746383; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 1/4] ide/via: Get rid of via_init_ide() Date: Tue, 10 Mar 2020 20:06:50 +0100 To: qemu-devel@nongnu.org, qemu-block@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 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: John Snow , Mark Cave-Ayland , Aleksandar Markovic , philmd@redhat.com, Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Follow example of CMD646 and remove via_init_ide function and do it directly in board code instead. Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland --- hw/ide/via.c | 8 -------- hw/mips/mips_fulong2e.c | 5 ++++- include/hw/ide.h | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 096de8dba0..df0b352b58 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -213,14 +213,6 @@ static void via_ide_exitfn(PCIDevice *dev) } } =20 -void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn) -{ - PCIDevice *dev; - - dev =3D pci_create_simple(bus, devfn, "via-ide"); - pci_ide_create_devs(dev, hd_table); -} - static void via_ide_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 4727b1d3a4..639ba2a091 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -37,6 +37,7 @@ #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide.h" +#include "hw/ide/pci.h" #include "elf.h" #include "hw/isa/vt82c686.h" #include "hw/rtc/mc146818rtc.h" @@ -239,6 +240,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus,= int slot, qemu_irq intc, qemu_irq *i8259; ISABus *isa_bus; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; + PCIDevice *dev; =20 isa_bus =3D vt82c686b_isa_init(pci_bus, PCI_DEVFN(slot, 0)); if (!isa_bus) { @@ -256,8 +258,9 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus,= int slot, qemu_irq intc, /* Super I/O */ isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO); =20 + dev =3D pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); ide_drive_get(hd, ARRAY_SIZE(hd)); - via_ide_init(pci_bus, hd, PCI_DEVFN(slot, 1)); + pci_ide_create_devs(dev, hd); =20 pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); diff --git a/include/hw/ide.h b/include/hw/ide.h index 0c7080ed92..dea0ecf5be 100644 --- a/include/hw/ide.h +++ b/include/hw/ide.h @@ -16,7 +16,6 @@ PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo = **hd_table, int devfn); PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); int pci_piix3_xen_ide_unplug(DeviceState *dev, bool aux); -void via_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn); =20 /* ide-mmio.c */ void mmio_ide_init_drives(DeviceState *dev, DriveInfo *hd0, DriveInfo *hd1= ); --=20 2.21.1 From nobody Sat Feb 7 18:34:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1583868152; cv=none; d=zohomail.com; s=zohoarc; b=mfBgjMyly9tTgns6XK/M5IQL8gjtUJJ4eyrWTaJ5ahX7qzZvT49nYcMCxKy74ntq2hFGtUsI3vsSMuDimC8r0bKmjy/+EqEThf2vnqQmbibifvzI9pfI4KhKEJNaV7/l2NnYBcY9kSpUj+RXjg+OMjRZWbKfJMv+aP6hKwZiaZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583868152; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=TzOkE57HFTWzK7VJV9EOlbpYdxRwG5iGb2Bu7w5FNP8=; b=i7wY9mhw5UwvDapu/iMkxhIsTdjWvjFgPa5cWv8cnen7WdtVnskxY8GIAJrbKupOltxYl7q8Szn+gkAfqMMDjgsQimtjzQfP0nBFL4LoLC0aN17Xwk2Uj2M7fvUdcL1kM/ASHi2AQ+JKrykNP+S0qfTaVtxpdWabbz1VA0mYocU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583868152727954.5689525039008; Tue, 10 Mar 2020 12:22:32 -0700 (PDT) Received: from localhost ([::1]:39118 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkSV-00071X-Nw for importer@patchew.org; Tue, 10 Mar 2020 15:22:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43697) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkPq-0003EQ-Dh for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:19:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBkPp-0008Cn-Bz for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:19:46 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:60290) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBkNw-0002rQ-AY; Tue, 10 Mar 2020 15:19:43 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 96A84747E06; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1442F747DF7; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 2/4] ide: Make room for flags in PCIIDEState and add one for legacy IRQ routing Date: Tue, 10 Mar 2020 20:06:50 +0100 To: qemu-devel@nongnu.org, qemu-block@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 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: John Snow , Mark Cave-Ayland , Aleksandar Markovic , philmd@redhat.com, Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We'll need a flag for implementing some device specific behaviour in via-ide but we already have a currently CMD646 specific field that can be repurposed for this and leave room for furhter flags if needed in the future. This patch changes the "secondary" field to "flags" and define the flags for CMD646 and via-ide and change CMD646 and its users accordingly. Signed-off-by: BALATON Zoltan --- hw/ide/cmd646.c | 4 ++-- hw/sparc64/sun4u.c | 2 +- include/hw/ide/pci.h | 7 ++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index d953932104..a48141a689 100644 --- a/hw/ide/cmd646.c +++ b/hw/ide/cmd646.c @@ -256,7 +256,7 @@ static void pci_cmd646_ide_realize(PCIDevice *dev, Erro= r **errp) pci_conf[PCI_CLASS_PROG] =3D 0x8f; =20 pci_conf[CNTRL] =3D CNTRL_EN_CH0; // enable IDE0 - if (d->secondary) { + if (d->flags & BIT(PCI_IDE_SECONDARY)) { /* XXX: if not enabled, really disable the seconday IDE controller= */ pci_conf[CNTRL] |=3D CNTRL_EN_CH1; /* enable IDE1 */ } @@ -318,7 +318,7 @@ static void pci_cmd646_ide_exitfn(PCIDevice *dev) } =20 static Property cmd646_ide_properties[] =3D { - DEFINE_PROP_UINT32("secondary", PCIIDEState, secondary, 0), + DEFINE_PROP_BIT("secondary", PCIIDEState, flags, PCI_IDE_SECONDARY, fa= lse), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c index d33e84f831..92c3ebfaa9 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -666,7 +666,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, ide_drive_get(hd, ARRAY_SIZE(hd)); =20 pci_dev =3D pci_create(pci_busA, PCI_DEVFN(3, 0), "cmd646-ide"); - qdev_prop_set_uint32(&pci_dev->qdev, "secondary", 1); + qdev_prop_set_bit(&pci_dev->qdev, "secondary", true); qdev_init_nofail(&pci_dev->qdev); pci_ide_create_devs(pci_dev, hd); =20 diff --git a/include/hw/ide/pci.h b/include/hw/ide/pci.h index a9f2c33e68..21075edf16 100644 --- a/include/hw/ide/pci.h +++ b/include/hw/ide/pci.h @@ -40,6 +40,11 @@ typedef struct BMDMAState { #define TYPE_PCI_IDE "pci-ide" #define PCI_IDE(obj) OBJECT_CHECK(PCIIDEState, (obj), TYPE_PCI_IDE) =20 +enum { + PCI_IDE_SECONDARY, /* used only for cmd646 */ + PCI_IDE_LEGACY_IRQ +}; + typedef struct PCIIDEState { /*< private >*/ PCIDevice parent_obj; @@ -47,7 +52,7 @@ typedef struct PCIIDEState { =20 IDEBus bus[2]; BMDMAState bmdma[2]; - uint32_t secondary; /* used only for cmd646 */ + uint32_t flags; MemoryRegion bmdma_bar; MemoryRegion cmd_bar[2]; MemoryRegion data_bar[2]; --=20 2.21.1 From nobody Sat Feb 7 18:34:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1583868087; cv=none; d=zohomail.com; s=zohoarc; b=g6Rfk/KMICOlkHqa2u2Wt9j20moovXOj7Pum5g5VmiMmKFNosnI9FFxUP+NCRWfUuyLnTR4pByJJ8Edbx+CWqXg8yPcACQCEYFUZITTRadWXwQGarLa8EBHUKop9vmfi0PurTKRofv81U4rCpqUFLVBo5Ajg+J3wS8uJ47k0Z7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583868087; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=AS6SOEiRDvnHzBBmfT7TEfBuJ2N0QQeYfzI1fc7e7pA=; b=dMu7fkiz2EkHFxuoYPPDxL9FIpcL3WMR1FT3FnOPb+3A3NnOopxgtVyAkJVI2uKNask+nb0SZqqIZDkx3fQHFJi1NxXSlVSn3OXn3+jELXC92LKUJWDRT1LlqJh3Vs5YlvXJNGlZ0xStG7fTLjal6JyzpwVWPQNeoo1QaEeQrjo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583868087375505.0373265090901; Tue, 10 Mar 2020 12:21:27 -0700 (PDT) Received: from localhost ([::1]:39100 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkRS-0005RI-DK for importer@patchew.org; Tue, 10 Mar 2020 15:21:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43871) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkQ3-0003SJ-VB for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:20:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBkQ2-0000YW-U6 for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:19:59 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:60284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBkNw-0002rN-Ap; Tue, 10 Mar 2020 15:19:56 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 95B25747E04; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 189A6747DFE; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Message-Id: <5e372f6a73d4f45c0c18a264e986c29fc075f2d4.1583867210.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 3/4] pci: Honour wmask when resetting PCI_INTERRUPT_LINE Date: Tue, 10 Mar 2020 20:06:50 +0100 To: qemu-devel@nongnu.org, qemu-block@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 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: "Michael S. Tsirkin" , John Snow , Mark Cave-Ayland , Aleksandar Markovic , philmd@redhat.com, Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The pci_do_device_reset() function (called from pci_device_reset) clears the PCI_INTERRUPT_LINE config reg of devices on the bus but did this without taking wmask into account. We'll have a device model now that needs to set a constant value for this reg and this patch allows to do that without additional workaround in device emulation to reverse the effect of this PCI bus reset function. Suggested-by: Mark Cave-Ayland Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland Reviewed-by: Michael S. Tsirkin --- hw/pci/pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index e1ed6677e1..b5bc842fac 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -302,8 +302,11 @@ static void pci_do_device_reset(PCIDevice *dev) pci_word_test_and_clear_mask(dev->config + PCI_STATUS, pci_get_word(dev->wmask + PCI_STATUS) | pci_get_word(dev->w1cmask + PCI_STATUS)); + /* Some devices make bits of PCI_INTERRUPT_LINE read only */ + pci_byte_test_and_clear_mask(dev->config + PCI_INTERRUPT_LINE, + pci_get_word(dev->wmask + PCI_INTERRUPT_LINE= ) | + pci_get_word(dev->w1cmask + PCI_INTERRUPT_LI= NE)); dev->config[PCI_CACHE_LINE_SIZE] =3D 0x0; - dev->config[PCI_INTERRUPT_LINE] =3D 0x0; for (r =3D 0; r < PCI_NUM_REGIONS; ++r) { PCIIORegion *region =3D &dev->io_regions[r]; if (!region->size) { --=20 2.21.1 From nobody Sat Feb 7 18:34:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1583867952; cv=none; d=zohomail.com; s=zohoarc; b=nMILSXPKj1cN1ABT0QfmHQL4AvuQ/Lk6YsqsBsI62qlu/DlxTHeTxTY6FIpjD3IO1R3x1O6xyVMCTeAuPA2Y93R/0GYoCo/Sdszq9OeZlowPFf6n9LCjHYZl+l2UYCGkHUUp5HNxNoQlYPKPh8sKhzNadpUfSzjAkHgsJIg2ETk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583867952; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=MOopDhrmI6jzmUlSklQC1zrdpokRRTOGFcFLkm4Asdg=; b=ZiHx7l5sjppe8GUEWv0UxN1uaz4kxkUey2pUsoa5duyF9qA4FFI+pBlJrQ7Ob3GiKHEAJtzPiF+eb+bRUG/AOdqApFjG+CdFY6c5kEgYpGBR2cQjO1ai/DmIFIWSnmGNwRnHDBPj/1dbtqHkAoIdqwn2Iq5Y/3I1L9SnHZ3Pt5A= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1583867952255567.98432398412; Tue, 10 Mar 2020 12:19:12 -0700 (PDT) Received: from localhost ([::1]:39054 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkPH-00027p-1h for importer@patchew.org; Tue, 10 Mar 2020 15:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41824) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBkO1-00018o-FQ for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:17:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBkO0-00038X-8t for qemu-devel@nongnu.org; Tue, 10 Mar 2020 15:17:53 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:60273) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBkNx-0002rK-53; Tue, 10 Mar 2020 15:17:49 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 4B6F3747E02; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1CD41747DCF; Tue, 10 Mar 2020 20:17:46 +0100 (CET) Message-Id: <6b7af110e1576d6873777673b3e3fa01f4c9839e.1583867210.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 4/4] via-ide: Also emulate non 100% native mode Date: Tue, 10 Mar 2020 20:06:50 +0100 To: qemu-devel@nongnu.org, qemu-block@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 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: John Snow , Mark Cave-Ayland , Aleksandar Markovic , philmd@redhat.com, Artyom Tarasenko , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Some machines operate in "non 100% native mode" where interrupts are fixed at legacy IDE interrupts and some guests expect this behaviour without checking based on knowledge about hardware. Even Linux has arch specific workarounds for this that are activated on such boards so this needs to be emulated as well. Signed-off-by: BALATON Zoltan --- Notes: v2: Don't use PCI_INTERRUPT_LINE in via_ide_set_irq() v3: Patch pci.c instead of local workaround for PCI reset clearing PCI_INTERRUPT_PIN config reg hw/ide/via.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index df0b352b58..1eada23097 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -1,9 +1,10 @@ /* - * QEMU IDE Emulation: PCI VIA82C686B support. + * QEMU VIA southbridge IDE emulation (VT82C686B, VT8231) * * Copyright (c) 2003 Fabrice Bellard * Copyright (c) 2006 Openedhand Ltd. * Copyright (c) 2010 Huacai Chen + * Copyright (c) 2019-2020 BALATON Zoltan * * Permission is hereby granted, free of charge, to any person obtaining a= copy * of this software and associated documentation files (the "Software"), t= o deal @@ -25,6 +26,7 @@ */ =20 #include "qemu/osdep.h" +#include "hw/qdev-properties.h" #include "hw/pci/pci.h" #include "migration/vmstate.h" #include "qemu/module.h" @@ -111,11 +113,18 @@ static void via_ide_set_irq(void *opaque, int n, int = level) } else { d->config[0x70 + n * 8] &=3D ~0x80; } - level =3D (d->config[0x70] & 0x80) || (d->config[0x78] & 0x80); - n =3D pci_get_byte(d->config + PCI_INTERRUPT_LINE); - if (n) { - qemu_set_irq(isa_get_irq(NULL, n), level); + + /* + * Some machines operate in "non 100% native mode" where PCI_INTERRUPT= _LINE + * is not used but IDE always uses ISA IRQ 14 and 15 even in native mo= de. + * Some guest drivers expect this, often without checking. + */ + if (!(pci_get_byte(d->config + PCI_CLASS_PROG) & (n ? 4 : 1)) || + PCI_IDE(d)->flags & BIT(PCI_IDE_LEGACY_IRQ)) { + qemu_set_irq(isa_get_irq(NULL, (n ? 15 : 14)), level); + } else { + qemu_set_irq(isa_get_irq(NULL, 14), level); } } =20 @@ -169,7 +178,9 @@ static void via_ide_realize(PCIDevice *dev, Error **err= p) =20 pci_config_set_prog_interface(pci_conf, 0x8f); /* native PCI ATA mode = */ pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); - dev->wmask[PCI_INTERRUPT_LINE] =3D 0xf; + /* Bits 0 and 4 of CLASS_PROG select native mode and are writable */ + dev->wmask[PCI_CLASS_PROG] =3D 5; + dev->wmask[PCI_INTERRUPT_LINE] =3D 0; =20 memory_region_init_io(&d->data_bar[0], OBJECT(d), &pci_ide_data_le_ops, &d->bus[0], "via-ide0-data", 8); @@ -213,6 +224,12 @@ static void via_ide_exitfn(PCIDevice *dev) } } =20 +static Property via_ide_properties[] =3D { + DEFINE_PROP_BIT("legacy-irq", PCIIDEState, flags, PCI_IDE_LEGACY_IRQ, + false), + DEFINE_PROP_END_OF_LIST(), +}; + static void via_ide_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -225,6 +242,7 @@ static void via_ide_class_init(ObjectClass *klass, void= *data) k->device_id =3D PCI_DEVICE_ID_VIA_IDE; k->revision =3D 0x06; k->class_id =3D PCI_CLASS_STORAGE_IDE; + device_class_set_props(dc, via_ide_properties); set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } =20 --=20 2.21.1