From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Helge Deller" <deller@gmx.de>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 2/7] hw/pci-host/astro: Re-use generic pci_host_data_le_ops MemoryRegionOps
Date: Mon, 27 Oct 2025 17:52:58 +0100 [thread overview]
Message-ID: <20251027165304.98296-3-philmd@linaro.org> (raw)
In-Reply-To: <20251027165304.98296-1-philmd@linaro.org>
Avoid duplicating code, clear the "config-reg-check-high-bit"
property in .instance_init() in order to re-use the generic
pci_host_data_le_ops MemoryRegionOps.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/pci-host/astro.c | 35 ++++++++---------------------------
hw/pci-host/trace-events | 2 --
2 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/hw/pci-host/astro.c b/hw/pci-host/astro.c
index 0bd66ab3de3..72e625c2508 100644
--- a/hw/pci-host/astro.c
+++ b/hw/pci-host/astro.c
@@ -230,32 +230,6 @@ static const MemoryRegionOps elroy_chip_ops = {
};
-/* Unlike pci_config_data_le_ops, no check of high bit set in config_reg. */
-
-static uint64_t elroy_config_data_read(void *opaque, hwaddr addr, unsigned len)
-{
- uint64_t val;
-
- PCIHostState *s = opaque;
- val = pci_data_read(s->bus, s->config_reg | (addr & 3), len);
- trace_elroy_pci_config_data_read(s->config_reg | (addr & 3), len, val);
- return val;
-}
-
-static void elroy_config_data_write(void *opaque, hwaddr addr,
- uint64_t val, unsigned len)
-{
- PCIHostState *s = opaque;
- pci_data_write(s->bus, s->config_reg | (addr & 3), val, len);
- trace_elroy_pci_config_data_write(s->config_reg | (addr & 3), len, val);
-}
-
-static const MemoryRegionOps elroy_config_data_ops = {
- .read = elroy_config_data_read,
- .write = elroy_config_data_write,
- .endianness = DEVICE_LITTLE_ENDIAN,
-};
-
static uint64_t elroy_config_addr_read(void *opaque, hwaddr addr, unsigned len)
{
ElroyState *s = opaque;
@@ -424,6 +398,12 @@ static void elroy_reset(DeviceState *dev)
}
}
+static void elroy_pcihost_instance_init(Object *obj)
+{
+ object_property_set_bool(obj, "config-reg-check-high-bit", false,
+ &error_fatal);
+}
+
static void elroy_pcihost_realize(DeviceState *dev, Error **errp)
{
ElroyState *s = ELROY_PCI_HOST_BRIDGE(dev);
@@ -440,7 +420,7 @@ static void elroy_pcihost_realize(DeviceState *dev, Error **errp)
&elroy_config_addr_ops, dev,
"pci-conf-idx", 8);
memory_region_init_io(&phb->data_mem, obj,
- &elroy_config_data_ops, dev,
+ &pci_host_data_le_ops, phb,
"pci-conf-data", 8);
memory_region_add_subregion(&s->this_mem, 0x40,
&phb->conf_mem);
@@ -497,6 +477,7 @@ static const TypeInfo elroy_pcihost_info = {
.name = TYPE_ELROY_PCI_HOST_BRIDGE,
.parent = TYPE_PCI_HOST_BRIDGE,
.instance_size = sizeof(ElroyState),
+ .instance_init = elroy_pcihost_instance_init,
.class_init = elroy_pcihost_class_init,
};
diff --git a/hw/pci-host/trace-events b/hw/pci-host/trace-events
index a6fd88c2c46..792ab25729b 100644
--- a/hw/pci-host/trace-events
+++ b/hw/pci-host/trace-events
@@ -76,7 +76,5 @@ astro_chip_read(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d
astro_chip_write(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64
elroy_read(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64
elroy_write(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64
-elroy_pci_config_data_read(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64
-elroy_pci_config_data_write(uint64_t addr, int size, uint64_t val) "addr 0x%"PRIx64" size %d val 0x%"PRIx64
iosapic_reg_write(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64
iosapic_reg_read(uint64_t reg_select, int size, uint64_t val) "reg_select 0x%"PRIx64" size %d val 0x%"PRIx64
--
2.51.0
next prev parent reply other threads:[~2025-10-27 16:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 16:52 [PATCH v2 0/7] hw/pci-host: Re-use generic pci_host_data_le_ops MemoryRegionOps Philippe Mathieu-Daudé
2025-10-27 16:52 ` [PATCH v2 1/7] hw/pci/pci_host: Add 'config-reg-check-high-bit' property Philippe Mathieu-Daudé
2025-10-27 17:28 ` Peter Maydell
2025-10-28 7:35 ` Marc-André Lureau
2025-10-27 16:52 ` Philippe Mathieu-Daudé [this message]
2025-10-27 16:52 ` [PATCH v2 3/7] hw/pci-host/dino: Re-use generic pci_host_data_le_ops MemoryRegionOps Philippe Mathieu-Daudé
2025-10-27 16:53 ` [PATCH v2 4/7] hw/pci-host/sabre: Remove pointless OBJECT() cast Philippe Mathieu-Daudé
2025-10-27 16:53 ` [PATCH v2 5/7] hw/pci-host/sabre: Include 'host' in host bridge method names Philippe Mathieu-Daudé
2025-10-27 16:53 ` [PATCH v2 6/7] hw/pci-host/sabre: Re-use generic pci_host_data_le_ops MemoryRegionOps Philippe Mathieu-Daudé
2025-10-27 17:00 ` Philippe Mathieu-Daudé
2025-10-27 16:53 ` [PATCH v2 7/7] hw/pci-host/typhoon: " Philippe Mathieu-Daudé
2025-10-27 16:59 ` Philippe Mathieu-Daudé
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=20251027165304.98296-3-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=deller@gmx.de \
--cc=marcel.apfelbaum@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).