From: Bernhard Beschow <shentey@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
qemu-arm@nongnu.org, Bernhard Beschow <shentey@gmail.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: [PATCH 01/10] hw/pci-host/designware: Eliminate some helper variables
Date: Wed, 20 Aug 2025 23:19:23 +0200 [thread overview]
Message-ID: <20250820211932.27302-2-shentey@gmail.com> (raw)
In-Reply-To: <20250820211932.27302-1-shentey@gmail.com>
In the next step, code gets moved around where the helper variables aren't used
any longer. Eliminate them now to make the code movement clearer.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/pci-host/designware.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c
index f6e49ce9b8..3a10dc9f99 100644
--- a/hw/pci-host/designware.c
+++ b/hw/pci-host/designware.c
@@ -390,8 +390,6 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
{
DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev);
DesignwarePCIEHost *host = designware_pcie_root_to_host(root);
- MemoryRegion *host_mem = get_system_memory();
- MemoryRegion *address_space = &host->pci.memory;
PCIBridge *br = PCI_BRIDGE(dev);
DesignwarePCIEViewport *viewport;
/*
@@ -419,7 +417,6 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
msi_init(dev, 0x50, 32, true, true, &error_fatal);
for (i = 0; i < DESIGNWARE_PCIE_NUM_VIEWPORTS; i++) {
- MemoryRegion *source, *destination, *mem;
const char *direction;
char *name;
@@ -430,20 +427,18 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
viewport->limit = UINT32_MAX;
viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM;
- source = &host->pci.address_space_root;
- destination = host_mem;
direction = "Inbound";
/*
* Configure MemoryRegion implementing PCI -> CPU memory
* access
*/
- mem = &viewport->mem;
name = designware_pcie_viewport_name(direction, i, "MEM");
- memory_region_init_alias(mem, OBJECT(root), name, destination,
- dummy_offset, dummy_size);
- memory_region_add_subregion_overlap(source, dummy_offset, mem, -1);
- memory_region_set_enabled(mem, false);
+ memory_region_init_alias(&viewport->mem, OBJECT(root), name,
+ get_system_memory(), dummy_offset, dummy_size);
+ memory_region_add_subregion_overlap(&host->pci.address_space_root,
+ dummy_offset, &viewport->mem, -1);
+ memory_region_set_enabled(&viewport->mem, false);
g_free(name);
viewport = &root->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i];
@@ -454,33 +449,31 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
viewport->limit = UINT32_MAX;
viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM;
- destination = &host->pci.memory;
direction = "Outbound";
- source = host_mem;
/*
* Configure MemoryRegion implementing CPU -> PCI memory
* access
*/
- mem = &viewport->mem;
name = designware_pcie_viewport_name(direction, i, "MEM");
- memory_region_init_alias(mem, OBJECT(root), name, destination,
- dummy_offset, dummy_size);
- memory_region_add_subregion(source, dummy_offset, mem);
- memory_region_set_enabled(mem, false);
+ memory_region_init_alias(&viewport->mem, OBJECT(root), name,
+ &host->pci.memory, dummy_offset, dummy_size);
+ memory_region_add_subregion(get_system_memory(), dummy_offset,
+ &viewport->mem);
+ memory_region_set_enabled(&viewport->mem, false);
g_free(name);
/*
* Configure MemoryRegion implementing access to configuration
* space
*/
- mem = &viewport->cfg;
name = designware_pcie_viewport_name(direction, i, "CFG");
memory_region_init_io(&viewport->cfg, OBJECT(root),
&designware_pci_host_conf_ops,
viewport, name, dummy_size);
- memory_region_add_subregion(source, dummy_offset, mem);
- memory_region_set_enabled(mem, false);
+ memory_region_add_subregion(get_system_memory(), dummy_offset,
+ &viewport->cfg);
+ memory_region_set_enabled(&viewport->cfg, false);
g_free(name);
}
@@ -506,7 +499,8 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp)
* in designware_pcie_root_update_msi_mapping() as a part of
* initialization done by guest OS
*/
- memory_region_add_subregion(address_space, dummy_offset, &root->msi.iomem);
+ memory_region_add_subregion(&host->pci.memory, dummy_offset,
+ &root->msi.iomem);
memory_region_set_enabled(&root->msi.iomem, false);
}
--
2.50.1
next prev parent reply other threads:[~2025-08-20 21:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 21:19 [PATCH 00/10] Designware PCIe host fixes Bernhard Beschow
2025-08-20 21:19 ` Bernhard Beschow [this message]
2025-08-20 21:19 ` [PATCH 02/10] hw/pci-host/designware: Create viewport memory regions on demand Bernhard Beschow
2025-09-02 9:46 ` Peter Maydell
2025-08-20 21:19 ` [PATCH 03/10] hw/pci-host/designware: Determine PCIDevice of configuration region once Bernhard Beschow
2025-08-20 21:19 ` [PATCH 04/10] hw/pci-host/designware: Distinguish stronger between viewport memory types Bernhard Beschow
2025-08-20 21:19 ` [PATCH 05/10] hw/pci-host/designware: Implement I/O space Bernhard Beschow
2025-08-20 21:19 ` [PATCH 06/10] hw/pci-host/designware: Fix I/O range Bernhard Beschow
2025-09-02 9:53 ` Peter Maydell
2025-08-20 21:19 ` [PATCH 07/10] hw/pci-host/designware: Don't map PCI memory space into PCI inbound window Bernhard Beschow
2025-08-20 21:19 ` [PATCH 08/10] hw/pci-host/designware: Fix default inbound viewport mapping Bernhard Beschow
2025-08-20 21:19 ` [PATCH 09/10] hw/pci-host/designware: Implement device reset Bernhard Beschow
2025-08-20 21:19 ` [PATCH 10/10] hw/arm/fsl-imx8mp: Do not map PCI window as unimplemented Bernhard Beschow
2025-08-21 3:36 ` [PATCH 00/10] Designware PCIe host fixes Guenter Roeck
2025-08-21 10:24 ` Bernhard Beschow
2025-08-21 15:38 ` Guenter Roeck
2025-08-22 23:09 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250820211932.27302-2-shentey@gmail.com \
--to=shentey@gmail.com \
--cc=andrew.smirnov@gmail.com \
--cc=linux@roeck-us.net \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).