* [PATCH v2 0/7] hw/ppc: SysBus simplifications
@ 2023-10-19 13:12 Philippe Mathieu-Daudé
2023-10-19 13:12 ` [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it Philippe Mathieu-Daudé
` (6 more replies)
0 siblings, 7 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:12 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
Hi,
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.
This series replaces a sequence of:
- sysbus_init_mmio()
- sysbus_mmio_map()
by a single call to memory_region_add_subregion().
Since v1:
- New "Realize SPAPR_VIO_BRIDGE device before accessing it" patch
- Added R-b tags
Philippe Mathieu-Daudé (7):
hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it
hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) ->
pnv_xscom_init()
hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init()
hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region
hw/ppc/pnv: Do not use SysBus API to map local MMIO region
hw/intc/spapr_xive: Move sysbus_init_mmio() calls around
hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
include/hw/ppc/pnv_xscom.h | 2 +-
hw/intc/spapr_xive.c | 12 ++++++------
hw/ppc/pnv.c | 26 +++++---------------------
hw/ppc/pnv_xscom.c | 5 ++---
hw/ppc/spapr_vio.c | 3 ++-
5 files changed, 16 insertions(+), 32 deletions(-)
--
2.41.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
@ 2023-10-19 13:12 ` Philippe Mathieu-Daudé
2023-10-19 15:41 ` Thomas Huth
2023-10-19 13:13 ` [PATCH v2 2/7] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init() Philippe Mathieu-Daudé
` (5 subsequent siblings)
6 siblings, 1 reply; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:12 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
qbus_new() should not be called on unrealized device.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/ppc/spapr_vio.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
index 9d4fec2c04..f8ef2b6fa8 100644
--- a/hw/ppc/spapr_vio.c
+++ b/hw/ppc/spapr_vio.c
@@ -574,13 +574,14 @@ SpaprVioBus *spapr_vio_bus_init(void)
/* Create bridge device */
dev = qdev_new(TYPE_SPAPR_VIO_BRIDGE);
- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
/* Create bus on bridge device */
qbus = qbus_new(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio");
bus = SPAPR_VIO_BUS(qbus);
bus->next_reg = SPAPR_VIO_REG_BASE;
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+
/* hcall-vio */
spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal);
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 2/7] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init()
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
2023-10-19 13:12 ` [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 3/7] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init() Philippe Mathieu-Daudé
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
pnv_xscom_realize() is not used to *realize* QDev object, rename
it as pnv_xscom_init(). The Error** argument is unused: remove it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
include/hw/ppc/pnv_xscom.h | 2 +-
hw/ppc/pnv.c | 18 +++---------------
hw/ppc/pnv_xscom.c | 2 +-
3 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h
index 9bc6463547..41671001da 100644
--- a/include/hw/ppc/pnv_xscom.h
+++ b/include/hw/ppc/pnv_xscom.h
@@ -170,7 +170,7 @@ struct PnvXScomInterfaceClass {
#define PNV10_XSCOM_PEC_PCI_BASE 0x8010800 /* index goes upwards ... */
#define PNV10_XSCOM_PEC_PCI_SIZE 0x200
-void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp);
+void pnv_xscom_init(PnvChip *chip, uint64_t size);
int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset,
uint64_t xscom_base, uint64_t xscom_size,
const char *compat, int compat_size);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index eb54f93986..456631c9dc 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1249,11 +1249,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
assert(chip8->xics);
/* XSCOM bridge is first */
- pnv_xscom_realize(chip, PNV_XSCOM_SIZE, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
+ pnv_xscom_init(chip, PNV_XSCOM_SIZE);
sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
@@ -1512,11 +1508,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
Error *local_err = NULL;
/* XSCOM bridge is first */
- pnv_xscom_realize(chip, PNV9_XSCOM_SIZE, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
+ pnv_xscom_init(chip, PNV9_XSCOM_SIZE);
sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV9_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
@@ -1727,11 +1719,7 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
Error *local_err = NULL;
/* XSCOM bridge is first */
- pnv_xscom_realize(chip, PNV10_XSCOM_SIZE, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
- return;
- }
+ pnv_xscom_init(chip, PNV10_XSCOM_SIZE);
sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV10_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index d820e05e40..af57b55863 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -221,7 +221,7 @@ const MemoryRegionOps pnv_xscom_ops = {
.endianness = DEVICE_BIG_ENDIAN,
};
-void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp)
+void pnv_xscom_init(PnvChip *chip, uint64_t size)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(chip);
char *name;
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 3/7] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init()
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
2023-10-19 13:12 ` [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 2/7] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init() Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 4/7] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
In order to make the next commit trivial, move sysbus_init_mmio()
calls just before the corresponding sysbus_mmio_map() calls.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
include/hw/ppc/pnv_xscom.h | 2 +-
hw/ppc/pnv.c | 9 +++------
hw/ppc/pnv_xscom.c | 3 ++-
3 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/include/hw/ppc/pnv_xscom.h b/include/hw/ppc/pnv_xscom.h
index 41671001da..35b19610f7 100644
--- a/include/hw/ppc/pnv_xscom.h
+++ b/include/hw/ppc/pnv_xscom.h
@@ -170,7 +170,7 @@ struct PnvXScomInterfaceClass {
#define PNV10_XSCOM_PEC_PCI_BASE 0x8010800 /* index goes upwards ... */
#define PNV10_XSCOM_PEC_PCI_SIZE 0x200
-void pnv_xscom_init(PnvChip *chip, uint64_t size);
+void pnv_xscom_init(PnvChip *chip, uint64_t size, hwaddr addr);
int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset,
uint64_t xscom_base, uint64_t xscom_size,
const char *compat, int compat_size);
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 456631c9dc..10158f7684 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1249,8 +1249,7 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp)
assert(chip8->xics);
/* XSCOM bridge is first */
- pnv_xscom_init(chip, PNV_XSCOM_SIZE);
- sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV_XSCOM_BASE(chip));
+ pnv_xscom_init(chip, PNV_XSCOM_SIZE, PNV_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
if (local_err) {
@@ -1508,8 +1507,7 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
Error *local_err = NULL;
/* XSCOM bridge is first */
- pnv_xscom_init(chip, PNV9_XSCOM_SIZE);
- sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV9_XSCOM_BASE(chip));
+ pnv_xscom_init(chip, PNV9_XSCOM_SIZE, PNV9_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
if (local_err) {
@@ -1719,8 +1717,7 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
Error *local_err = NULL;
/* XSCOM bridge is first */
- pnv_xscom_init(chip, PNV10_XSCOM_SIZE);
- sysbus_mmio_map(SYS_BUS_DEVICE(chip), 0, PNV10_XSCOM_BASE(chip));
+ pnv_xscom_init(chip, PNV10_XSCOM_SIZE, PNV10_XSCOM_BASE(chip));
pcc->parent_realize(dev, &local_err);
if (local_err) {
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index af57b55863..cf892c9fe8 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -221,7 +221,7 @@ const MemoryRegionOps pnv_xscom_ops = {
.endianness = DEVICE_BIG_ENDIAN,
};
-void pnv_xscom_init(PnvChip *chip, uint64_t size)
+void pnv_xscom_init(PnvChip *chip, uint64_t size, hwaddr addr)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(chip);
char *name;
@@ -230,6 +230,7 @@ void pnv_xscom_init(PnvChip *chip, uint64_t size)
memory_region_init_io(&chip->xscom_mmio, OBJECT(chip), &pnv_xscom_ops,
chip, name, size);
sysbus_init_mmio(sbd, &chip->xscom_mmio);
+ sysbus_mmio_map(sbd, 0, addr);
memory_region_init(&chip->xscom, OBJECT(chip), name, size);
address_space_init(&chip->xscom_as, &chip->xscom, name);
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 4/7] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2023-10-19 13:13 ` [PATCH v2 3/7] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init() Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 5/7] hw/ppc/pnv: " Philippe Mathieu-Daudé
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.
Just map it without using the SysBus API.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
hw/ppc/pnv_xscom.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/hw/ppc/pnv_xscom.c b/hw/ppc/pnv_xscom.c
index cf892c9fe8..805b1d0c87 100644
--- a/hw/ppc/pnv_xscom.c
+++ b/hw/ppc/pnv_xscom.c
@@ -223,14 +223,12 @@ const MemoryRegionOps pnv_xscom_ops = {
void pnv_xscom_init(PnvChip *chip, uint64_t size, hwaddr addr)
{
- SysBusDevice *sbd = SYS_BUS_DEVICE(chip);
char *name;
name = g_strdup_printf("xscom-%x", chip->chip_id);
memory_region_init_io(&chip->xscom_mmio, OBJECT(chip), &pnv_xscom_ops,
chip, name, size);
- sysbus_init_mmio(sbd, &chip->xscom_mmio);
- sysbus_mmio_map(sbd, 0, addr);
+ memory_region_add_subregion(get_system_memory(), addr, &chip->xscom_mmio);
memory_region_init(&chip->xscom, OBJECT(chip), name, size);
address_space_init(&chip->xscom_as, &chip->xscom, name);
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 5/7] hw/ppc/pnv: Do not use SysBus API to map local MMIO region
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2023-10-19 13:13 ` [PATCH v2 4/7] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 6/7] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 7/7] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.
Just map it without using the SysBus API.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
hw/ppc/pnv.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 10158f7684..c0e34fffbc 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1217,10 +1217,9 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
name = g_strdup_printf("icp-%x", chip->chip_id);
memory_region_init(&chip8->icp_mmio, OBJECT(chip), name, PNV_ICP_SIZE);
- sysbus_init_mmio(SYS_BUS_DEVICE(chip), &chip8->icp_mmio);
g_free(name);
-
- sysbus_mmio_map(SYS_BUS_DEVICE(chip), 1, PNV_ICP_BASE(chip));
+ memory_region_add_subregion(get_system_memory(), PNV_ICP_BASE(chip),
+ &chip8->icp_mmio);
/* Map the ICP registers for each thread */
for (i = 0; i < chip->nr_cores; i++) {
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 6/7] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2023-10-19 13:13 ` [PATCH v2 5/7] hw/ppc/pnv: " Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 7/7] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
In order to make the next commit trivial, move sysbus_init_mmio()
calls just before the corresponding sysbus_mmio_map() calls.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
hw/intc/spapr_xive.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 7f701d414b..12057ffe5b 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -316,7 +316,6 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
if (!qdev_realize(DEVICE(xsrc), NULL, errp)) {
return;
}
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
/*
* Initialize the END ESB source
@@ -328,7 +327,6 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
if (!qdev_realize(DEVICE(end_xsrc), NULL, errp)) {
return;
}
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
/* Set the mapping address of the END ESB pages after the source ESBs */
xive->end_base = xive->vc_base + xive_source_esb_len(xsrc);
@@ -347,14 +345,16 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
/* TIMA initialization */
memory_region_init_io(&xive->tm_mmio, OBJECT(xive), &spapr_xive_tm_ops,
xive, "xive.tima", 4ull << TM_SHIFT);
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xive->tm_mmio);
/*
* Map all regions. These will be enabled or disabled at reset and
* can also be overridden by KVM memory regions if active
*/
+ sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
sysbus_mmio_map(SYS_BUS_DEVICE(xive), 0, xive->vc_base);
+ sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
sysbus_mmio_map(SYS_BUS_DEVICE(xive), 1, xive->end_base);
+ sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xive->tm_mmio);
sysbus_mmio_map(SYS_BUS_DEVICE(xive), 2, xive->tm_base);
}
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2 7/7] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2023-10-19 13:13 ` [PATCH v2 6/7] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around Philippe Mathieu-Daudé
@ 2023-10-19 13:13 ` Philippe Mathieu-Daudé
6 siblings, 0 replies; 9+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-10-19 13:13 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza,
Thomas Huth, Philippe Mathieu-Daudé
There is no point in exposing an internal MMIO region via
SysBus and directly mapping it in the very same device.
Just map it without using the SysBus API.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
---
hw/intc/spapr_xive.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c
index 12057ffe5b..199c261b07 100644
--- a/hw/intc/spapr_xive.c
+++ b/hw/intc/spapr_xive.c
@@ -350,12 +350,12 @@ static void spapr_xive_realize(DeviceState *dev, Error **errp)
* Map all regions. These will be enabled or disabled at reset and
* can also be overridden by KVM memory regions if active
*/
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xsrc->esb_mmio);
- sysbus_mmio_map(SYS_BUS_DEVICE(xive), 0, xive->vc_base);
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &end_xsrc->esb_mmio);
- sysbus_mmio_map(SYS_BUS_DEVICE(xive), 1, xive->end_base);
- sysbus_init_mmio(SYS_BUS_DEVICE(xive), &xive->tm_mmio);
- sysbus_mmio_map(SYS_BUS_DEVICE(xive), 2, xive->tm_base);
+ memory_region_add_subregion(get_system_memory(), xive->vc_base,
+ &xsrc->esb_mmio);
+ memory_region_add_subregion(get_system_memory(), xive->end_base,
+ &end_xsrc->esb_mmio);
+ memory_region_add_subregion(get_system_memory(), xive->tm_base,
+ &xive->tm_mmio);
}
static int spapr_xive_get_eas(XiveRouter *xrtr, uint8_t eas_blk,
--
2.41.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it
2023-10-19 13:12 ` [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it Philippe Mathieu-Daudé
@ 2023-10-19 15:41 ` Thomas Huth
0 siblings, 0 replies; 9+ messages in thread
From: Thomas Huth @ 2023-10-19 15:41 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-ppc, Richard Henderson, Frédéric Barrat,
Harsh Prateek Bora, David Gibson, Nicholas Piggin,
Cédric Le Goater, LIU Zhiwei, Daniel Henrique Barboza
On 19/10/2023 15.12, Philippe Mathieu-Daudé wrote:
> qbus_new() should not be called on unrealized device.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> hw/ppc/spapr_vio.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ppc/spapr_vio.c b/hw/ppc/spapr_vio.c
> index 9d4fec2c04..f8ef2b6fa8 100644
> --- a/hw/ppc/spapr_vio.c
> +++ b/hw/ppc/spapr_vio.c
> @@ -574,13 +574,14 @@ SpaprVioBus *spapr_vio_bus_init(void)
>
> /* Create bridge device */
> dev = qdev_new(TYPE_SPAPR_VIO_BRIDGE);
> - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
>
> /* Create bus on bridge device */
> qbus = qbus_new(TYPE_SPAPR_VIO_BUS, dev, "spapr-vio");
> bus = SPAPR_VIO_BUS(qbus);
> bus->next_reg = SPAPR_VIO_REG_BASE;
>
> + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> +
> /* hcall-vio */
> spapr_register_hypercall(H_VIO_SIGNAL, h_vio_signal);
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-10-19 15:44 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-19 13:12 [PATCH v2 0/7] hw/ppc: SysBus simplifications Philippe Mathieu-Daudé
2023-10-19 13:12 ` [PATCH v2 1/7] hw/ppc/spapr_vio: Realize SPAPR_VIO_BRIDGE device before accessing it Philippe Mathieu-Daudé
2023-10-19 15:41 ` Thomas Huth
2023-10-19 13:13 ` [PATCH v2 2/7] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init() Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 3/7] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init() Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 4/7] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 5/7] hw/ppc/pnv: " Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 6/7] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around Philippe Mathieu-Daudé
2023-10-19 13:13 ` [PATCH v2 7/7] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region Philippe Mathieu-Daudé
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).