hw/ppc: SysBus simplifications
cover hw/ppc: SysBus simplifications
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().
Philippe Mathieu-Daudé (6):
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 ++--- 4 files changed, 14 insertions(+), 31 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/6 hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init()
pnv_xscom_realize() is not used to *realize* QDev object, rename it as pnv_xscom_init(). The Error** argument is unused: remove it.
--- 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(-)
include/hw/ppc/pnv_xscom.h +1 -1
@@ -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);
hw/ppc/pnv.c +3 -15
@@ -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);
hw/ppc/pnv_xscom.c +1 -1
@@ -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;
Signature · 1 line
2.41.0
Re: [PATCH 1/6] hw/ppc/pnv_xscom: Rename pnv_xscom_realize(Error **) -> pnv_xscom_init()
Quoted 9 lines · Philippe Mathieu-Daudé
pnv_xscom_realize()is not used to *realize* QDev object, rename it aspnv_xscom_init(). The Error** argument is unused: remove it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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(-)
PATCH 2/6 hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init()
In reply to Philippe Mathieu-DaudéIn order to make the next commit trivial, move sysbus_init_mmio() calls just before the corresponding sysbus_mmio_map() calls.
--- 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(-)
include/hw/ppc/pnv_xscom.h +1 -1
@@ -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);
hw/ppc/pnv.c +3 -6
@@ -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) {
hw/ppc/pnv_xscom.c +2 -1
@@ -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);
Signature · 1 line
2.41.0
Re: [PATCH 2/6] hw/ppc/pnv_xscom: Move sysbus_mmio_map() call within pnv_xscom_init()
Quoted 9 lines · Philippe Mathieu-Daudé
In order to make the next commit trivial, move
sysbus_init_mmio()calls just before the correspondingsysbus_mmio_map()calls.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- 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(-)
PATCH 3/6 hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region
In reply to 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.
--- hw/ppc/pnv_xscom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
hw/ppc/pnv_xscom.c +1 -3
@@ -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);
Signature · 1 line
2.41.0
Re: [PATCH 3/6] hw/ppc/pnv_xscom: Do not use SysBus API to map local MMIO region
Quoted 9 lines · 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é <[email protected]>--- hw/ppc/pnv_xscom.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
PATCH 4/6 hw/ppc/pnv: Do not use SysBus API to map local MMIO region
In reply to 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.
--- hw/ppc/pnv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +2 -3
@@ -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++) {
Signature · 1 line
2.41.0
Re: [PATCH 4/6] hw/ppc/pnv: Do not use SysBus API to map local MMIO region
Quoted 9 lines · 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é <[email protected]>--- hw/ppc/pnv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
PATCH 5/6 hw/intc/spapr_xive: Move sysbus_init_mmio() calls around
In reply to Philippe Mathieu-DaudéIn order to make the next commit trivial, move sysbus_init_mmio() calls just before the corresponding sysbus_mmio_map() calls.
--- hw/intc/spapr_xive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/intc/spapr_xive.c +3 -3
@@ -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); }
Signature · 1 line
2.41.0
Re: [PATCH 5/6] hw/intc/spapr_xive: Move sysbus_init_mmio() calls around
Quoted 7 lines · Philippe Mathieu-Daudé
In order to make the next commit trivial, move
sysbus_init_mmio()calls just before the correspondingsysbus_mmio_map()calls.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/intc/spapr_xive.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH 6/6 hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
In reply to 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.
--- hw/intc/spapr_xive.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/intc/spapr_xive.c +6 -6
@@ -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,
Signature · 1 line
2.41.0
Re: [PATCH 6/6] hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
Quoted 9 lines · 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é <[email protected]>--- hw/intc/spapr_xive.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 10 lines · 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 tomemory_region_add_subregion().
Quoted 8 lines
Philippe Mathieu-Daudé (6):
hw/ppc/pnv_xscom: Renamepnv_xscom_realize(Error **)->
pnv_xscom_init()
hw/ppc/pnv_xscom: Movesysbus_mmio_map()call withinpnv_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: Movesysbus_init_mmio()calls around hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
Cc'ing Thomas :)
Quoted 19 lines · 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 tomemory_region_add_subregion().Philippe Mathieu-Daudé (6):
hw/ppc/pnv_xscom: Renamepnv_xscom_realize(Error **)->
pnv_xscom_init()
hw/ppc/pnv_xscom: Movesysbus_mmio_map()call withinpnv_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: Movesysbus_init_mmio()calls around hw/intc/spapr_xive: Do not use SysBus API to map local MMIO region
Quoted 6 lines
include/hw/ppc/pnv_xscom.h | 2 +- hw/intc/spapr_xive.c | 12 ++++++------ hw/ppc/pnv.c | 26 +++++--------------------- hw/ppc/pnv_xscom.c | 5 ++--- 4 files changed, 14 insertions(+), 31 deletions(-)
r~
Quoted 9 lines · 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 tomemory_region_add_subregion().
Zhiwei
Quoted 16 lines
Philippe Mathieu-Daudé (6):
hw/ppc/pnv_xscom: Renamepnv_xscom_realize(Error **)->
pnv_xscom_init()
hw/ppc/pnv_xscom: Movesysbus_mmio_map()call withinpnv_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: Movesysbus_init_mmio()calls around hw/intc/spapr_xive: Do not use SysBus API to map local MMIO regioninclude/hw/ppc/pnv_xscom.h | 2 +- hw/intc/spapr_xive.c | 12 ++++++------ hw/ppc/pnv.c | 26 +++++--------------------- hw/ppc/pnv_xscom.c | 5 ++--- 4 files changed, 14 insertions(+), 31 deletions(-)