From nobody Fri Dec 19 13:21:56 2025 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=1689030487; cv=none; d=zohomail.com; s=zohoarc; b=EHWqe8c2OYEtzntER41sEcIUJCUZ7WVXg/ettEWNAK1FyVuT1jdpuWmelHJtO62U7IugmBl9KzcX6wUkz6fs3PzQoDj8lowFtGchooCzzJWrWEIj2sJZqpYMx9s5FH43QaS8+fyQfRXFOSB3FQ7DId+MzVCVru79nUPe9qq/l68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1689030487; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zBihUDmGB6uFtH/AkcYIicM5fh04EulaKYLbdQ/QMSU=; b=nYdOPab4QA7W/RAX2oNtGmJ+3jvpMKN5C9hqwdPMi1CC56wtqhPIAX18q4A2y2GHJ9N2htqiMIpbE7SxS5LuvYPIkAP+OF7MaU+TLsFuvRD5lp60B7Qwkch9GhJnh83ky/4cjgbkMT4+wVGUqvaA7tBh6YKQbkHc85OnIOgjCFc= 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 1689030487880358.1435631944181; Mon, 10 Jul 2023 16:08:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIzvR-0007gI-Nz; Mon, 10 Jul 2023 19:04:15 -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 1qIzvK-0007ZD-Mc for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIzvI-0004Rr-Hz for qemu-devel@nongnu.org; Mon, 10 Jul 2023 19:04:06 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-d7LU3e7PNs6zqPjbiB52ug-1; Mon, 10 Jul 2023 19:04:01 -0400 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-3fbb0fdd060so31133165e9.0 for ; Mon, 10 Jul 2023 16:04:00 -0700 (PDT) Received: from redhat.com ([2.52.3.112]) by smtp.gmail.com with ESMTPSA id f4-20020a5d4dc4000000b0031424f4ef1dsm601118wru.19.2023.07.10.16.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 16:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689030244; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zBihUDmGB6uFtH/AkcYIicM5fh04EulaKYLbdQ/QMSU=; b=OvKdYC2wsf9M78Ou00YBqkL8fDZkYr2G75lbWqnzsajUBTU+QSRpG/sxVnreTqBhqbkMT1 ledVWKW1Iywwd55nYvwFon7MGjwK6+2CDABKxw0/YPDCHJcAQoR+PT13JoXbPU8m4vLMWm 9hiLwq2WQTJNi5fzMHzSLU0XNWQex8c= X-MC-Unique: d7LU3e7PNs6zqPjbiB52ug-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689030239; x=1691622239; h=in-reply-to:content-transfer-encoding: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=zBihUDmGB6uFtH/AkcYIicM5fh04EulaKYLbdQ/QMSU=; b=kAzoZOlfV0njUTGO0iJCOBG00AgF1i/Iz5l8D/VfWKxMJB0IuYTzn/aVLbshDLjAMB vjDx8SWr2fzbsIQi3/hwbuCfDcPdTMjIP4n6C4muV3jtiI98DtMlsB+0//M0fitj/aAO fn6z8JmOuSa3zchLC9X8HkMTHK0kDIeOkBf0b1YTwi44nSw2/MwE1rEAcCzelayHhijT 9UunPqDV92QjAMn2rOIwpky/QBTl5WTmx3wqfpVqPhzGBHxGQT5jAZaI7faEZ8H/SaCg PzmX9pQKh9kbw96qY0Z7bDVarqG7RNbKm5XmLbvfRXpglO6U7j3/WjUNpnKbX9cYLICT TjTA== X-Gm-Message-State: ABy/qLa/nZY6k7HOBEDY63pfkZBaUlCwvFNLkyQiz19tHjUCFtbwXN5g vpdsNuZ/AfaP8TSSCNHVd97CZLNH35QPF3ZMGW75I/Ou7ITMXEG8o5T77OeI3XgRWOxTJytROs2 5JCLbZTcey2wNuj5tXSNOxSU0GSIdHjw1Xpan2f8RSsR7e7oUUbBMIYdjKTQHoPn+Y0Z4 X-Received: by 2002:a5d:410e:0:b0:315:902b:7913 with SMTP id l14-20020a5d410e000000b00315902b7913mr8570111wrp.31.1689030239489; Mon, 10 Jul 2023 16:03:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlElvc1J+xlRdlRyjYLiJgR2dAGxWK2KEPCb6Q8YoCskjj8F/t0YHQRC7R/MPt10UdfwRJBRew== X-Received: by 2002:a5d:410e:0:b0:315:902b:7913 with SMTP id l14-20020a5d410e000000b00315902b7913mr8570090wrp.31.1689030239206; Mon, 10 Jul 2023 16:03:59 -0700 (PDT) Date: Mon, 10 Jul 2023 19:03:56 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Bernhard Beschow , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 32/66] hw/pci-host/i440fx: Resolve i440fx_init() Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.133.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, T_SCC_BODY_TEXT_LINE=-0.01 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: 1689030488468100001 From: Bernhard Beschow i440fx_init() is a legacy init function. The previous patches worked towards TYPE_I440FX_PCI_HOST_BRIDGE to be instantiated the QOM way. Do this now by transforming the parameters passed to i440fx_init() into property assignmen= ts. Signed-off-by: Bernhard Beschow Message-Id: <20230630073720.21297-17-shentey@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci-host/i440fx.h | 10 ---------- hw/i386/pc_piix.c | 32 +++++++++++++++++++++----------- hw/pci-host/i440fx.c | 33 +++++---------------------------- 3 files changed, 26 insertions(+), 49 deletions(-) diff --git a/include/hw/pci-host/i440fx.h b/include/hw/pci-host/i440fx.h index 2d7bae5a45..c988f70890 100644 --- a/include/hw/pci-host/i440fx.h +++ b/include/hw/pci-host/i440fx.h @@ -34,14 +34,4 @@ struct PCII440FXState { =20 #define TYPE_IGD_PASSTHROUGH_I440FX_PCI_DEVICE "igd-passthrough-i440FX" =20 -PCIBus *i440fx_init(const char *pci_type, - DeviceState *dev, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size, - MemoryRegion *pci_memory, - MemoryRegion *ram_memory); - - #endif diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index c36783809f..62148d7636 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -126,7 +126,7 @@ static void pc_init1(MachineState *machine, MemoryRegion *rom_memory =3D system_memory; ram_addr_t lowmem; uint64_t hole64_size =3D 0; - DeviceState *i440fx_host =3D NULL; + Object *phb =3D NULL; =20 /* * Calculate ram split, for memory below and above 4G. It's a bit @@ -201,10 +201,9 @@ static void pc_init1(MachineState *machine, pci_memory =3D g_new(MemoryRegion, 1); memory_region_init(pci_memory, NULL, "pci", UINT64_MAX); rom_memory =3D pci_memory; - i440fx_host =3D qdev_new(host_type); - object_property_add_child(OBJECT(machine), "i440fx", - OBJECT(i440fx_host)); - hole64_size =3D object_property_get_uint(OBJECT(i440fx_host), + phb =3D OBJECT(qdev_new(host_type)); + object_property_add_child(OBJECT(machine), "i440fx", phb); + hole64_size =3D object_property_get_uint(phb, PCI_HOST_PROP_PCI_HOLE64_SI= ZE, &error_abort); } @@ -240,12 +239,23 @@ static void pc_init1(MachineState *machine, PIIX3State *piix3; PCIDevice *pci_dev; =20 - pci_bus =3D i440fx_init(pci_type, - i440fx_host, - system_memory, system_io, - x86ms->below_4g_mem_size, - x86ms->above_4g_mem_size, - pci_memory, ram_memory); + object_property_set_link(phb, PCI_HOST_PROP_RAM_MEM, + OBJECT(ram_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_PCI_MEM, + OBJECT(pci_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_SYSTEM_MEM, + OBJECT(system_memory), &error_fatal); + object_property_set_link(phb, PCI_HOST_PROP_IO_MEM, + OBJECT(system_io), &error_fatal); + object_property_set_uint(phb, PCI_HOST_BELOW_4G_MEM_SIZE, + x86ms->below_4g_mem_size, &error_fatal); + object_property_set_uint(phb, PCI_HOST_ABOVE_4G_MEM_SIZE, + x86ms->above_4g_mem_size, &error_fatal); + object_property_set_str(phb, I440FX_HOST_PROP_PCI_TYPE, + pci_type, &error_fatal); + sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), &error_fatal); + + pci_bus =3D PCI_BUS(qdev_get_child_bus(DEVICE(phb), "pci.0")); pci_bus_map_irqs(pci_bus, xen_enabled() ? xen_pci_slot_get_pirq : pc_pci_slot_get_pirq); diff --git a/hw/pci-host/i440fx.c b/hw/pci-host/i440fx.c index c458987405..62d6287681 100644 --- a/hw/pci-host/i440fx.c +++ b/hw/pci-host/i440fx.c @@ -249,9 +249,14 @@ static void i440fx_pcihost_initfn(Object *obj) =20 static void i440fx_pcihost_realize(DeviceState *dev, Error **errp) { + ERRP_GUARD(); I440FXState *s =3D I440FX_PCI_HOST_BRIDGE(dev); PCIHostState *phb =3D PCI_HOST_BRIDGE(dev); SysBusDevice *sbd =3D SYS_BUS_DEVICE(dev); + PCIBus *b; + PCIDevice *d; + PCII440FXState *f; + unsigned i; =20 memory_region_add_subregion(s->io_memory, 0xcf8, &phb->conf_mem); sysbus_init_ioports(sbd, 0xcf8, 4); @@ -262,36 +267,10 @@ static void i440fx_pcihost_realize(DeviceState *dev, = Error **errp) /* register i440fx 0xcf8 port as coalesced pio */ memory_region_set_flush_coalesced(&phb->data_mem); memory_region_add_coalescing(&phb->conf_mem, 0, 4); -} - -PCIBus *i440fx_init(const char *pci_type, - DeviceState *dev, - MemoryRegion *address_space_mem, - MemoryRegion *address_space_io, - ram_addr_t below_4g_mem_size, - ram_addr_t above_4g_mem_size, - MemoryRegion *pci_address_space, - MemoryRegion *ram_memory) -{ - I440FXState *s =3D I440FX_PCI_HOST_BRIDGE(dev); - PCIHostState *phb =3D PCI_HOST_BRIDGE(dev); - PCIBus *b; - PCIDevice *d; - PCII440FXState *f; - unsigned i; - - s->system_memory =3D address_space_mem; - s->io_memory =3D address_space_io; - s->pci_address_space =3D pci_address_space; - s->ram_memory =3D ram_memory; - s->below_4g_mem_size =3D below_4g_mem_size; - s->above_4g_mem_size =3D above_4g_mem_size; - s->pci_type =3D (char *)pci_type; =20 b =3D pci_root_bus_new(dev, NULL, s->pci_address_space, s->io_memory, 0, TYPE_PCI_BUS); phb->bus =3D b; - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); =20 d =3D pci_create_simple(b, 0, s->pci_type); f =3D I440FX_PCI_DEVICE(d); @@ -335,8 +314,6 @@ PCIBus *i440fx_init(const char *pci_type, d->config[I440FX_COREBOOT_RAM_SIZE] =3D ram_size; =20 i440fx_update_memory_mappings(f); - - return b; } =20 static void i440fx_class_init(ObjectClass *klass, void *data) --=20 MST