From nobody Tue Dec 16 11:35:50 2025 Delivered-To: importer@patchew.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; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1746374651023744.7239707533035; Sun, 4 May 2025 09:04:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uBbmp-0005GG-9v; Sun, 04 May 2025 12:01:51 -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 1uBbmk-00055s-KC; Sun, 04 May 2025 12:01:46 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uBbmi-0004DY-Pd; Sun, 04 May 2025 12:01:46 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 4BABE55D230; Sun, 04 May 2025 18:01:43 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id RLM8-tPklq4S; Sun, 4 May 2025 18:01:41 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 5168B55D234; Sun, 04 May 2025 18:01:41 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-ID: <2c0cea500b892a5d677547c2c8de8c268ddfff01.1746374076.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 14/16] hw/pci-host/raven: Move bus master address space creation to one place To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Artyom Tarasenko , Nicholas Piggin Date: Sun, 04 May 2025 18:01:41 +0200 (CEST) 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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-ZM-MESSAGEID: 1746374652386019000 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move the lines related to creating the bus master address space together and reduce the number of memory regions stored in the device state. These are used once to create the address space and can be tracked with their owner object so no need to keep track of them in the device state. Keep only the address space that is used later in a callback. Signed-off-by: BALATON Zoltan --- hw/pci-host/raven.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c index 476ae5bc65..68d64e3a97 100644 --- a/hw/pci-host/raven.c +++ b/hw/pci-host/raven.c @@ -46,9 +46,6 @@ struct PREPPCIState { MemoryRegion pci_discontiguous_io; MemoryRegion pci_memory; MemoryRegion pci_intack; - MemoryRegion bm; - MemoryRegion bm_ram_alias; - MemoryRegion bm_pci_memory_alias; AddressSpace bm_as; }; =20 @@ -174,7 +171,8 @@ static void raven_pcihost_realizefn(DeviceState *d, Err= or **errp) SysBusDevice *dev =3D SYS_BUS_DEVICE(d); PCIHostState *h =3D PCI_HOST_BRIDGE(dev); PREPPCIState *s =3D RAVEN_PCI_HOST_BRIDGE(dev); - MemoryRegion *mr, *address_space_mem =3D get_system_memory(); + Object *o =3D OBJECT(d); + MemoryRegion *mr, *bm, *address_space_mem =3D get_system_memory(); =20 qdev_init_gpio_in(d, raven_change_gpio, 1); =20 @@ -183,26 +181,37 @@ static void raven_pcihost_realizefn(DeviceState *d, E= rror **errp) &s->irq, &s->pci_memory, &s->pci_io, 0,= 1, TYPE_PCI_BUS); =20 - memory_region_init_io(&h->conf_mem, OBJECT(h), &pci_host_conf_le_ops, = s, + memory_region_init_io(&h->conf_mem, o, &pci_host_conf_le_ops, s, "pci-conf-idx", 4); memory_region_add_subregion(&s->pci_io, 0xcf8, &h->conf_mem); =20 - memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops, = s, + memory_region_init_io(&h->data_mem, o, &pci_host_data_le_ops, s, "pci-conf-data", 4); memory_region_add_subregion(&s->pci_io, 0xcfc, &h->data_mem); =20 mr =3D g_new0(MemoryRegion, 1); - memory_region_init_io(mr, OBJECT(h), &raven_mmcfg_ops, h->bus, + memory_region_init_io(mr, o, &raven_mmcfg_ops, h->bus, "pci-mmcfg", 8 * MiB); memory_region_add_subregion(&s->pci_io, 0x800000, mr); =20 - memory_region_init_io(&s->pci_intack, OBJECT(s), &raven_intack_ops, s, + memory_region_init_io(&s->pci_intack, o, &raven_intack_ops, s, "pci-intack", 1); memory_region_add_subregion(address_space_mem, 0xbffffff0, &s->pci_int= ack); =20 pci_create_simple(h->bus, PCI_DEVFN(0, 0), TYPE_RAVEN_PCI_DEVICE); =20 - address_space_init(&s->bm_as, &s->bm, "raven-bm"); + /* Bus master address space */ + bm =3D g_new0(MemoryRegion, 1); + memory_region_init(bm, o, "raven-bm", 4 * GiB); + mr =3D g_new0(MemoryRegion, 1); + memory_region_init_alias(mr, o, "bm-pci-memory", &s->pci_memory, 0, + memory_region_size(&s->pci_memory)); + memory_region_add_subregion(bm, 0, mr); + mr =3D g_new0(MemoryRegion, 1); + memory_region_init_alias(mr, o, "bm-system", get_system_memory(), + 0, 0x80000000); + memory_region_add_subregion(bm, 0x80000000, mr); + address_space_init(&s->bm_as, bm, "raven-bm-as"); pci_setup_iommu(h->bus, &raven_iommu_ops, s); } =20 @@ -224,16 +233,6 @@ static void raven_pcihost_initfn(Object *obj) &s->pci_discontiguous_io, 1); memory_region_set_enabled(&s->pci_discontiguous_io, false); memory_region_add_subregion(address_space_mem, 0xc0000000, &s->pci_mem= ory); - - /* Bus master address space */ - memory_region_init(&s->bm, obj, "bm-raven", 4 * GiB); - memory_region_init_alias(&s->bm_pci_memory_alias, obj, "bm-pci-memory", - &s->pci_memory, 0, - memory_region_size(&s->pci_memory)); - memory_region_init_alias(&s->bm_ram_alias, obj, "bm-system", - get_system_memory(), 0, 0x80000000); - memory_region_add_subregion(&s->bm, 0 , &s->bm_pci_memory_alia= s); - memory_region_add_subregion(&s->bm, 0x80000000, &s->bm_ram_alias); } =20 static void raven_pcihost_class_init(ObjectClass *klass, const void *data) --=20 2.41.3