From nobody Wed Nov 27 16:43:18 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1697740035; cv=none; d=zohomail.com; s=zohoarc; b=W160FnD7JOBNAoL+BRHddMZA/B7ptuMtwpk81F1dNeNHXRJbcWQSQ82cul8WGwYCUENl/y7LofueM3H4NA2WLUSAElpWzmQEai+dw3MCoWi3VAjsVOdLlRr3c7g3Om8scG3lozU4oBB/39ZfnyEl6gylTtwWKlY1VDu4STv2WvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697740035; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=foQRLMQjVYT5y42wZUNoNj1yclA5wnMQdFvFQOR/qu8=; b=kctnW4RLYhG9f3TKGYNFUkuXePrVg5xIdafvX0rDVPFQew9ZGLiXV7vdSklllBm2AVte3uc8WWu7o+HK9hkHPxM3pm4S+Gj2qmYtmEWBeLL2v35XN4Uti5NqyjRJNcWH6gqnDrSudXiPNZ8R5hovXW5s8IK+B15VmsxwISdleQM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1697740035600693.4543386197391; Thu, 19 Oct 2023 11:27:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qtXhc-0001IB-7E; Thu, 19 Oct 2023 14:25:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtXgm-0008E7-CC for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:24:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qtXgk-0001q0-DA for qemu-devel@nongnu.org; Thu, 19 Oct 2023 14:24:08 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-679-GuXC9MzuPtimQOA_wdsQGQ-1; Thu, 19 Oct 2023 14:23:59 -0400 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3fe1521678fso58019235e9.1 for ; Thu, 19 Oct 2023 11:23:59 -0700 (PDT) Received: from redhat.com ([2a06:c701:73d2:bf00:e379:826:5137:6b23]) by smtp.gmail.com with ESMTPSA id q19-20020a05600c46d300b0040836519dd9sm213078wmo.25.2023.10.19.11.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 11:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697739845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=foQRLMQjVYT5y42wZUNoNj1yclA5wnMQdFvFQOR/qu8=; b=CwSEAxMbnAoReyBY33ZdcfVDm4zd+yM/BuVt5wyvPNvKAWUgHPBWC0olKLmq/u72PLtaqI Kv0/RjDF9kTtsVU7geC96kbAmF8NGABLuNDvNTPlQYl0cRF9A1MJ2qfE2mq3Kz56AdAmsT nCF2ArXYvXZFK5zYKwjlnK8UmNai6uM= X-MC-Unique: GuXC9MzuPtimQOA_wdsQGQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697739837; x=1698344637; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=foQRLMQjVYT5y42wZUNoNj1yclA5wnMQdFvFQOR/qu8=; b=RHxGdPD21X2qeL0Ig9gu1Qrdts0baxl+j2nOAonwCcUf5Z/wf5k0xa5jBofvpgbODt KkZkASIJSnsj3UyEhgb0k0jLfm902fvjH6DzSGLIrkd3NZz/5HsMvrmRJMaTrro2G58u GfOT/YxCNceuuvH5tCkHeWO7Ha3CFzaqkA/+tqyrl1TQFwTR+/3cTlLRNM7G0lg0STWg 7VjzCgO1wK7/dKCPZZVOI7XvooY3pjkmzVWaz2pBHbUQ6GLC+RHpCAZxQC4lFbwuxQui 1S6dGKE7aMRwUippzsjI22xGPtFVeqnsyB1ZUWKtTH4lJqdYa0rSBghmirAAsKXesZUM Fhqg== X-Gm-Message-State: AOJu0YwkcezdEMS5w8lbOOAXUu+FZwmylRfGxb7h4gXW8HMCcq3GYHee 6Vi4nXkiC4URuskgN4gDRsIGdFcZCV6b8a0pejdnQSTbkZXmwi1Q3rz36NJRSrzyHKwgFx7IUsq LrSL1Yt9mc7Ja2quz61T8OrsWbiUeDrbDWQTorfMl0xloc4fly22t5TM9JZM1aCZOYr/I X-Received: by 2002:a05:600c:1d23:b0:404:7462:1f6f with SMTP id l35-20020a05600c1d2300b0040474621f6fmr2441646wms.8.1697739837275; Thu, 19 Oct 2023 11:23:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IErtbANUZbzFyYLPiepqcALKc+MFHwjuCksr9uEpYgZmSn0bOEb3QceUn64+9ghxlK/84gYFw== X-Received: by 2002:a05:600c:1d23:b0:404:7462:1f6f with SMTP id l35-20020a05600c1d2300b0040474621f6fmr2441625wms.8.1697739836901; Thu, 19 Oct 2023 11:23:56 -0700 (PDT) Date: Thu, 19 Oct 2023 14:23:54 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , =?utf-8?B?SGVydsOp?= Poussineau , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Aurelien Jarno Subject: [PULL v2 61/78] hw/isa/piix: Reuse PIIX3 base class' realize method in PIIX4 Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1697740037732100003 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Bernhard Beschow Resolves duplicate code. Also makes PIIX4 respect the PIIX3 properties whic= h get added, too. This allows for using PIIX4 in the PC machine. Signed-off-by: Bernhard Beschow Message-Id: <20231007123843.127151-25-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/isa/piix.c | 80 ++++++------------------------------------------- hw/mips/malta.c | 5 ++-- 2 files changed, 12 insertions(+), 73 deletions(-) diff --git a/hw/isa/piix.c b/hw/isa/piix.c index 8f7d6c56a8..2ab799b95e 100644 --- a/hw/isa/piix.c +++ b/hw/isa/piix.c @@ -315,7 +315,8 @@ static const MemoryRegionOps rcr_ops =3D { }, }; =20 -static void pci_piix3_realize(PCIDevice *dev, Error **errp) +static void pci_piix_realize(PCIDevice *dev, const char *uhci_type, + Error **errp) { PIIXState *d =3D PIIX_PCI_DEVICE(dev); PCIBus *pci_bus =3D pci_get_bus(dev); @@ -374,8 +375,7 @@ static void pci_piix3_realize(PCIDevice *dev, Error **e= rrp) =20 /* USB */ if (d->has_usb) { - object_initialize_child(OBJECT(dev), "uhci", &d->uhci, - TYPE_PIIX3_USB_UHCI); + object_initialize_child(OBJECT(dev), "uhci", &d->uhci, uhci_type); qdev_prop_set_int32(DEVICE(&d->uhci), "addr", dev->devfn + 2); if (!qdev_realize(DEVICE(&d->uhci), BUS(pci_bus), errp)) { return; @@ -426,7 +426,7 @@ static void pci_piix_init(Object *obj) object_initialize_child(obj, "rtc", &d->rtc, TYPE_MC146818_RTC); } =20 -static Property pci_piix3_props[] =3D { +static Property pci_piix_props[] =3D { DEFINE_PROP_UINT32("smb_io_base", PIIXState, smb_io_base, 0), DEFINE_PROP_BOOL("has-acpi", PIIXState, has_acpi, true), DEFINE_PROP_BOOL("has-pic", PIIXState, has_pic, true), @@ -452,6 +452,7 @@ static void pci_piix_class_init(ObjectClass *klass, voi= d *data) * pc_piix.c's pc_init1() */ dc->user_creatable =3D false; + device_class_set_props(dc, pci_piix_props); adevc->build_dev_aml =3D build_pci_isa_aml; } =20 @@ -475,7 +476,7 @@ static void piix3_realize(PCIDevice *dev, Error **errp) PIIXState *piix3 =3D PIIX_PCI_DEVICE(dev); PCIBus *pci_bus =3D pci_get_bus(dev); =20 - pci_piix3_realize(dev, errp); + pci_piix_realize(dev, TYPE_PIIX3_USB_UHCI, errp); if (*errp) { return; } @@ -501,7 +502,6 @@ static void piix3_class_init(ObjectClass *klass, void *= data) /* 82371SB PIIX3 PCI-to-ISA bridge (Step A1) */ k->device_id =3D PCI_DEVICE_ID_INTEL_82371SB_0; dc->vmsd =3D &vmstate_piix3; - device_class_set_props(dc, pci_piix3_props); } =20 static const TypeInfo piix3_info =3D { @@ -513,72 +513,15 @@ static const TypeInfo piix3_info =3D { =20 static void piix4_realize(PCIDevice *dev, Error **errp) { + ERRP_GUARD(); PIIXState *s =3D PIIX_PCI_DEVICE(dev); PCIBus *pci_bus =3D pci_get_bus(dev); - ISABus *isa_bus; - qemu_irq *i8259_out_irq; - qemu_irq *i8259; - size_t i; =20 - isa_bus =3D isa_bus_new(DEVICE(dev), pci_address_space(dev), - pci_address_space_io(dev), errp); - if (!isa_bus) { + pci_piix_realize(dev, TYPE_PIIX4_USB_UHCI, errp); + if (*errp) { return; } =20 - qdev_init_gpio_out_named(DEVICE(dev), &s->cpu_intr, - "intr", 1); - - memory_region_init_io(&s->rcr_mem, OBJECT(dev), &rcr_ops, s, - "piix-reset-control", 1); - memory_region_add_subregion_overlap(pci_address_space_io(dev), - PIIX_RCR_IOPORT, &s->rcr_mem, 1); - - /* initialize i8259 pic */ - i8259_out_irq =3D qemu_allocate_irqs(piix_request_i8259_irq, s, 1); - i8259 =3D i8259_init(isa_bus, *i8259_out_irq); - - for (i =3D 0; i < ISA_NUM_IRQS; i++) { - s->isa_irqs_in[i] =3D i8259[i]; - } - - g_free(i8259); - - /* initialize ISA irqs */ - isa_bus_register_input_irqs(isa_bus, s->isa_irqs_in); - - /* initialize pit */ - i8254_pit_init(isa_bus, 0x40, 0, NULL); - - /* DMA */ - i8257_dma_init(isa_bus, 0); - - /* RTC */ - qdev_prop_set_int32(DEVICE(&s->rtc), "base_year", 2000); - if (!qdev_realize(DEVICE(&s->rtc), BUS(isa_bus), errp)) { - return; - } - s->rtc.irq =3D isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq); - - /* IDE */ - qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1); - if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { - return; - } - - /* USB */ - qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2); - if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) { - return; - } - - /* ACPI controller */ - qdev_prop_set_int32(DEVICE(&s->pm), "addr", dev->devfn + 3); - if (!qdev_realize(DEVICE(&s->pm), BUS(pci_bus), errp)) { - return; - } - qdev_connect_gpio_out(DEVICE(&s->pm), 0, s->isa_irqs_in[9]); - pci_bus_irqs(pci_bus, piix4_set_irq, s, PIIX_NUM_PIRQS); } =20 @@ -587,11 +530,6 @@ static void piix4_init(Object *obj) PIIXState *s =3D PIIX_PCI_DEVICE(obj); =20 object_initialize_child(obj, "ide", &s->ide, TYPE_PIIX4_IDE); - object_initialize_child(obj, "uhci", &s->uhci, TYPE_PIIX4_USB_UHCI); - - object_initialize_child(obj, "pm", &s->pm, TYPE_PIIX4_PM); - qdev_prop_set_uint32(DEVICE(&s->pm), "smb_io_base", 0x1100); - qdev_prop_set_bit(DEVICE(&s->pm), "smm-enabled", 0); } =20 static void piix4_class_init(ObjectClass *klass, void *data) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index dac27fad9d..155f3c1cc8 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -1238,8 +1238,9 @@ void mips_malta_init(MachineState *machine) pci_bus_map_irqs(pci_bus, malta_pci_slot_get_pirq); =20 /* Southbridge */ - piix4 =3D pci_create_simple_multifunction(pci_bus, PIIX4_PCI_DEVFN, - TYPE_PIIX4_PCI_DEVICE); + piix4 =3D pci_new_multifunction(PIIX4_PCI_DEVFN, TYPE_PIIX4_PCI_DEVICE= ); + qdev_prop_set_uint32(DEVICE(piix4), "smb_io_base", 0x1100); + pci_realize_and_unref(piix4, pci_bus, &error_fatal); isa_bus =3D ISA_BUS(qdev_get_child_bus(DEVICE(piix4), "isa.0")); =20 dev =3D DEVICE(object_resolve_path_component(OBJECT(piix4), "ide")); --=20 MST