From nobody Thu Nov 13 23:25:57 2025 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=1583018914; cv=none; d=zohomail.com; s=zohoarc; b=iv4qSDTSjxFMr3Jr/rFVxd89VqM4skTFmPbPb8G02wU9VNt/jWwSQ7o21yhhsr5uvPnBIHXECRET3u/P5RVxghXxWGj2f0bWnIxQg/twVABwJ1mjwrYRV9ZLCumgxX2rjYVXLaN2F1XfQpXJYEDtmbBY687fTQezOihDVGonRow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583018914; 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=Aty3X0Jcm4XhLyMGaQNC5kDDiGVJAlBvTqv23zwe6s8=; b=UdMraCR/kPgfUrOAMH6FQwheTmQ6/d8k/3aGGuwmreR0qODyB7CH1ISiHo7dV1wlgTnCd0NWbgMeLh5LOlYdQ/Z+tH0fVGV0FMKOdI85H8vbTso2eeM3Zdvmrj/tzSxdKiQVwUGkRPYbarqj6WYLde4KdKTmCTHOjYvumWQw1rE= 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 1583018913875350.83479314570934; Sat, 29 Feb 2020 15:28:33 -0800 (PST) Received: from localhost ([::1]:36746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8BX6-0001Uz-9t for importer@patchew.org; Sat, 29 Feb 2020 18:28:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38721) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j8BW2-0008NQ-LL for qemu-devel@nongnu.org; Sat, 29 Feb 2020 18:27:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j8BW1-0005Wt-Fo for qemu-devel@nongnu.org; Sat, 29 Feb 2020 18:27:26 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:40851) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j8BVx-0005L8-Lz; Sat, 29 Feb 2020 18:27:21 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 1242C747E01; Sun, 1 Mar 2020 00:27:12 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 8085F747E04; Sun, 1 Mar 2020 00:27:11 +0100 (CET) Message-Id: <775825dba26f6b36ab067f253e4ab5dc3a3d15dc.1583017348.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 1/2] ide: Make room for flags in PCIIDEState and add one for legacy IRQ routing Date: Sun, 01 Mar 2020 00:02:28 +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" 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/alpha/dp264.c | 2 +- hw/ide/cmd646.c | 12 ++++++------ hw/sparc64/sun4u.c | 9 ++------- include/hw/ide.h | 4 ++-- include/hw/ide/pci.h | 7 ++++++- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index 8d71a30617..e4075feaaf 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -102,7 +102,7 @@ static void clipper_init(MachineState *machine) DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; ide_drive_get(hd, ARRAY_SIZE(hd)); =20 - pci_cmd646_ide_init(pci_bus, hd, 0); + pci_cmd646_ide_init(pci_bus, hd, -1, false); } =20 /* Load PALcode. Given that this is not "real" cpu palcode, diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c index 335c060673..0be650791f 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 */ } @@ -317,20 +317,20 @@ static void pci_cmd646_ide_exitfn(PCIDevice *dev) } } =20 -void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, - int secondary_ide_enabled) +void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn, + bool secondary_ide_enabled) { PCIDevice *dev; =20 - dev =3D pci_create(bus, -1, "cmd646-ide"); - qdev_prop_set_uint32(&dev->qdev, "secondary", secondary_ide_enabled); + dev =3D pci_create(bus, devfn, "cmd646-ide"); + qdev_prop_set_bit(&dev->qdev, "secondary", secondary_ide_enabled); qdev_init_nofail(&dev->qdev); =20 pci_ide_create_devs(dev, hd_table); } =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 b7ac42f7a5..b64899300c 100644 --- a/hw/sparc64/sun4u.c +++ b/hw/sparc64/sun4u.c @@ -50,8 +50,7 @@ #include "hw/sparc/sparc64.h" #include "hw/nvram/fw_cfg.h" #include "hw/sysbus.h" -#include "hw/ide.h" -#include "hw/ide/pci.h" +#include "hw/ide/internal.h" #include "hw/loader.h" #include "hw/fw-path-provider.h" #include "elf.h" @@ -664,11 +663,7 @@ static void sun4uv_init(MemoryRegion *address_space_me= m, } =20 ide_drive_get(hd, ARRAY_SIZE(hd)); - - pci_dev =3D pci_create(pci_busA, PCI_DEVFN(3, 0), "cmd646-ide"); - qdev_prop_set_uint32(&pci_dev->qdev, "secondary", 1); - qdev_init_nofail(&pci_dev->qdev); - pci_ide_create_devs(pci_dev, hd); + pci_cmd646_ide_init(pci_busA, hd, PCI_DEVFN(3, 0), true); =20 /* Map NVRAM into I/O (ebus) space */ nvram =3D m48t59_init(NULL, 0, 0, NVRAM_SIZE, 1968, 59); diff --git a/include/hw/ide.h b/include/hw/ide.h index 28d8a06439..d88c5ee695 100644 --- a/include/hw/ide.h +++ b/include/hw/ide.h @@ -12,8 +12,8 @@ ISADevice *isa_ide_init(ISABus *bus, int iobase, int ioba= se2, int isairq, DriveInfo *hd0, DriveInfo *hd1); =20 /* ide-pci.c */ -void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, - int secondary_ide_enabled); +void pci_cmd646_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn, + bool secondary_ide_enabled); PCIDevice *pci_piix3_xen_ide_init(PCIBus *bus, DriveInfo **hd_table, int d= evfn); PCIDevice *pci_piix3_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); PCIDevice *pci_piix4_ide_init(PCIBus *bus, DriveInfo **hd_table, int devfn= ); 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