qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: qemu-ppc@nongnu.org, danielhb413@gmail.com,
	peter.maydell@linaro.org, richard.henderson@linaro.org,
	Frederic Barrat <fbarrat@linux.ibm.com>
Subject: [PULL 10/60] ppc/pnv: turn PnvPHB4 into a PnvPHB backend
Date: Wed, 31 Aug 2022 15:49:44 -0300	[thread overview]
Message-ID: <20220831185034.23240-11-danielhb413@gmail.com> (raw)
In-Reply-To: <20220831185034.23240-1-danielhb413@gmail.com>

Change the parent type of the PnvPHB4 device to TYPE_PARENT since the
PCI bus is going to be initialized by the PnvPHB parent. Functions that
needs to access the bus via a PnvPHB4 object can do so via the
phb4->phb_base pointer.

pnv_phb4_pec now creates a PnvPHB object.

The powernv9 machine class will create PnvPHB devices with version '4'.
powernv10 will create using version '5'. Both are using global machine
properties in their class_init() to do that.

These changes will benefit us when adding PnvPHB user creatable devices
for powernv9 and powernv10.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>
Message-Id: <20220624084921.399219-6-danielhb413@gmail.com>
---
 hw/pci-host/pnv_phb4.c         | 30 +++++-------------------------
 hw/pci-host/pnv_phb4_pec.c     |  3 +--
 hw/ppc/pnv.c                   | 20 +++++++++++++++++---
 include/hw/pci-host/pnv_phb4.h |  5 ++++-
 4 files changed, 27 insertions(+), 31 deletions(-)

diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index a7425927fb..144c437025 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -33,7 +33,7 @@
 
 static PCIDevice *pnv_phb4_find_cfg_dev(PnvPHB4 *phb)
 {
-    PCIHostState *pci = PCI_HOST_BRIDGE(phb);
+    PCIHostState *pci = PCI_HOST_BRIDGE(phb->phb_base);
     uint64_t addr = phb->regs[PHB_CONFIG_ADDRESS >> 3];
     uint8_t bus, devfn;
 
@@ -129,7 +129,7 @@ static uint64_t pnv_phb4_config_read(PnvPHB4 *phb, unsigned off,
 static void pnv_phb4_rc_config_write(PnvPHB4 *phb, unsigned off,
                                      unsigned size, uint64_t val)
 {
-    PCIHostState *pci = PCI_HOST_BRIDGE(phb);
+    PCIHostState *pci = PCI_HOST_BRIDGE(phb->phb_base);
     PCIDevice *pdev;
 
     if (size != 4) {
@@ -150,7 +150,7 @@ static void pnv_phb4_rc_config_write(PnvPHB4 *phb, unsigned off,
 static uint64_t pnv_phb4_rc_config_read(PnvPHB4 *phb, unsigned off,
                                         unsigned size)
 {
-    PCIHostState *pci = PCI_HOST_BRIDGE(phb);
+    PCIHostState *pci = PCI_HOST_BRIDGE(phb->phb_base);
     PCIDevice *pdev;
     uint64_t val;
 
@@ -1558,8 +1558,6 @@ void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb)
 static void pnv_phb4_realize(DeviceState *dev, Error **errp)
 {
     PnvPHB4 *phb = PNV_PHB4(dev);
-    PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(phb->pec);
-    PCIHostState *pci = PCI_HOST_BRIDGE(dev);
     XiveSource *xsrc = &phb->xsrc;
     int nr_irqs;
     char name[32];
@@ -1573,12 +1571,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
     memory_region_init_io(&phb->mr_regs, OBJECT(phb), &pnv_phb4_reg_ops, phb,
                           name, 0x2000);
 
-    pnv_phb4_bus_init(dev, phb);
-
-    /* Add a single Root port if running with defaults */
-    pnv_phb_attach_root_port(pci, pecc->rp_model,
-                             phb->phb_id, phb->chip_id);
-
     /* Setup XIVE Source */
     if (phb->big_phb) {
         nr_irqs = PNV_PHB4_MAX_INTs;
@@ -1598,16 +1590,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
     pnv_phb4_xscom_realize(phb);
 }
 
-static const char *pnv_phb4_root_bus_path(PCIHostState *host_bridge,
-                                          PCIBus *rootbus)
-{
-    PnvPHB4 *phb = PNV_PHB4(host_bridge);
-
-    snprintf(phb->bus_path, sizeof(phb->bus_path), "00%02x:%02x",
-             phb->chip_id, phb->phb_id);
-    return phb->bus_path;
-}
-
 /*
  * Address base trigger mode (POWER10)
  *
@@ -1692,19 +1674,17 @@ static Property pnv_phb4_properties[] = {
     DEFINE_PROP_UINT32("chip-id", PnvPHB4, chip_id, 0),
     DEFINE_PROP_LINK("pec", PnvPHB4, pec, TYPE_PNV_PHB4_PEC,
                      PnvPhb4PecState *),
+    DEFINE_PROP_LINK("phb-base", PnvPHB4, phb_base, TYPE_PNV_PHB, PnvPHB *),
     DEFINE_PROP_END_OF_LIST(),
 };
 
 static void pnv_phb4_class_init(ObjectClass *klass, void *data)
 {
-    PCIHostBridgeClass *hc = PCI_HOST_BRIDGE_CLASS(klass);
     DeviceClass *dc = DEVICE_CLASS(klass);
     XiveNotifierClass *xfc = XIVE_NOTIFIER_CLASS(klass);
 
-    hc->root_bus_path   = pnv_phb4_root_bus_path;
     dc->realize         = pnv_phb4_realize;
     device_class_set_props(dc, pnv_phb4_properties);
-    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
     dc->user_creatable  = false;
 
     xfc->notify         = pnv_phb4_xive_notify;
@@ -1712,7 +1692,7 @@ static void pnv_phb4_class_init(ObjectClass *klass, void *data)
 
 static const TypeInfo pnv_phb4_type_info = {
     .name          = TYPE_PNV_PHB4,
-    .parent        = TYPE_PCIE_HOST_BRIDGE,
+    .parent        = TYPE_DEVICE,
     .instance_init = pnv_phb4_instance_init,
     .instance_size = sizeof(PnvPHB4),
     .class_init    = pnv_phb4_class_init,
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index c9aaf1c28e..4a0a9fbe8b 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -115,8 +115,7 @@ static void pnv_pec_default_phb_realize(PnvPhb4PecState *pec,
                                         int stack_no,
                                         Error **errp)
 {
-    PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec);
-    PnvPHB4 *phb = PNV_PHB4(qdev_new(pecc->phb_type));
+    PnvPHB *phb = PNV_PHB(qdev_new(TYPE_PNV_PHB));
     int phb_id = pnv_phb4_pec_get_phb_id(pec, stack_no);
 
     object_property_add_child(OBJECT(pec), "phb[*]", OBJECT(phb));
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 5b60735c7a..ae6cd14a8a 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -672,11 +672,14 @@ static void pnv_chip_power8_pic_print_info(PnvChip *chip, Monitor *mon)
 static int pnv_chip_power9_pic_print_info_child(Object *child, void *opaque)
 {
     Monitor *mon = opaque;
-    PnvPHB4 *phb4 = (PnvPHB4 *) object_dynamic_cast(child, TYPE_PNV_PHB4);
+    PnvPHB *phb =  (PnvPHB *) object_dynamic_cast(child, TYPE_PNV_PHB);
 
-    if (phb4) {
-        pnv_phb4_pic_print_info(phb4, mon);
+    if (!phb) {
+        return 0;
     }
+
+    pnv_phb4_pic_print_info(PNV_PHB4(phb->backend), mon);
+
     return 0;
 }
 
@@ -2147,8 +2150,14 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
     PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);
     static const char compat[] = "qemu,powernv9\0ibm,powernv";
 
+    static GlobalProperty phb_compat[] = {
+        { TYPE_PNV_PHB, "version", "4" },
+    };
+
     mc->desc = "IBM PowerNV (Non-Virtualized) POWER9";
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.0");
+    compat_props_add(mc->compat_props, phb_compat, G_N_ELEMENTS(phb_compat));
+
     xfc->match_nvt = pnv_match_nvt;
 
     mc->alias = "powernv";
@@ -2165,8 +2174,13 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)
     XiveFabricClass *xfc = XIVE_FABRIC_CLASS(oc);
     static const char compat[] = "qemu,powernv10\0ibm,powernv";
 
+    static GlobalProperty phb_compat[] = {
+        { TYPE_PNV_PHB, "version", "5" },
+    };
+
     mc->desc = "IBM PowerNV (Non-Virtualized) POWER10";
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power10_v2.0");
+    compat_props_add(mc->compat_props, phb_compat, G_N_ELEMENTS(phb_compat));
 
     pmc->compat = compat;
     pmc->compat_size = sizeof(compat);
diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h
index 90843ac3a9..f22253358f 100644
--- a/include/hw/pci-host/pnv_phb4.h
+++ b/include/hw/pci-host/pnv_phb4.h
@@ -18,6 +18,7 @@
 typedef struct PnvPhb4PecState PnvPhb4PecState;
 typedef struct PnvPhb4PecStack PnvPhb4PecStack;
 typedef struct PnvPHB4 PnvPHB4;
+typedef struct PnvPHB PnvPHB;
 typedef struct PnvChip PnvChip;
 
 /*
@@ -78,7 +79,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
 #define PCI_MMIO_TOTAL_SIZE        (0x1ull << 60)
 
 struct PnvPHB4 {
-    PCIExpressHost parent_obj;
+    DeviceState parent;
+
+    PnvPHB *phb_base;
 
     uint32_t chip_id;
     uint32_t phb_id;
-- 
2.37.2



  parent reply	other threads:[~2022-08-31 18:59 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31 18:49 [PULL 00/60] ppc queue Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 01/60] pseries: Update SLOF firmware image Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 02/60] target/ppc: Fix host PVR matching for KVM Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 03/60] ppc/pnv: Add initial P9/10 SBE model Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 04/60] fpu: Add rebias bool, value and operation Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 05/60] target/ppc: Bugfix FP when OE/UE are set Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 06/60] ppc/pnv: add PHB3 bus init helper Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 07/60] ppc/pnv: add PnvPHB base/proxy device Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 08/60] ppc/pnv: turn PnvPHB3 into a PnvPHB backend Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 09/60] ppc/pnv: add PHB4 bus init helper Daniel Henrique Barboza
2022-08-31 18:49 ` Daniel Henrique Barboza [this message]
2022-08-31 18:49 ` [PULL 11/60] ppc/pnv: add pnv-phb-root-port device Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 12/60] ppc/pnv: remove pnv-phb3-root-port Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 13/60] ppc/pnv: remove pnv-phb4-root-port Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 14/60] ppc/pnv: remove root port name from pnv_phb_attach_root_port() Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 15/60] ppc/pnv: remove pecc->rp_model Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 16/60] ppc/pnv: remove PnvPHB4.version Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 17/60] ppc/pnv: move attach_root_port helper to pnv-phb.c Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 18/60] ppc/pnv: add phb-id/chip-id PnvPHB3RootBus properties Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 19/60] ppc/pnv: add phb-id/chip-id PnvPHB4RootBus properties Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 20/60] ppc/pnv: set root port chassis and slot using Bus properties Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 21/60] ppc/pnv: add helpers for pnv-phb user devices Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 22/60] ppc/pnv: turn chip8->phbs[] into a PnvPHB* array Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 23/60] ppc/pnv: enable user created pnv-phb for powernv8 Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 24/60] ppc/pnv: add PHB4 helpers for user created pnv-phb Daniel Henrique Barboza
2022-08-31 18:49 ` [PULL 25/60] ppc/pnv: enable user created pnv-phb for powernv9 Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 26/60] ppc/pnv: change pnv_phb4_get_pec() to also retrieve chip10->pecs Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 27/60] ppc/pnv: user creatable pnv-phb for powernv10 Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 28/60] ppc/pnv: consolidate pnv_parent_*_fixup() helpers Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 29/60] ppc/pnv: fix QOM parenting of user creatable root ports Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 30/60] ppc/ppc405: Remove taihu machine Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 31/60] ppc/ppc405: Introduce a PPC405 generic machine Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 32/60] ppc/ppc405: Move devices under the ref405ep machine Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 33/60] ppc/ppc405: Move SRAM " Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 34/60] ppc/ppc405: Introduce a PPC405 SoC Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 35/60] ppc/ppc405: Start QOMification of the SoC Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 36/60] ppc/ppc405: QOM'ify CPU Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 37/60] ppc/ppc4xx: Introduce a DCR device model Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 38/60] ppc/ppc405: QOM'ify CPC Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 39/60] ppc/ppc405: QOM'ify GPT Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 40/60] ppc/ppc405: QOM'ify OCM Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 41/60] ppc/ppc405: QOM'ify GPIO Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 42/60] ppc/ppc405: QOM'ify DMA Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 43/60] ppc/ppc405: QOM'ify EBC Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 44/60] ppc/ppc405: QOM'ify OPBA Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 45/60] ppc/ppc405: QOM'ify POB Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 46/60] ppc/ppc405: QOM'ify PLB Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 47/60] ppc/ppc405: QOM'ify MAL Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 48/60] ppc4xx: Move PLB model to ppc4xx_devs.c Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 49/60] ppc4xx: Rename ppc405-plb to ppc4xx-plb Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 50/60] ppc4xx: Move EBC model to ppc4xx_devs.c Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 51/60] ppc4xx: Rename ppc405-ebc to ppc4xx-ebc Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 52/60] ppc/ppc405: Use an embedded PPCUIC model in SoC state Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 53/60] hw/intc/ppc-uic: Convert ppc-uic to a PPC4xx DCR device Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 54/60] ppc/ppc405: Use an explicit I2C object Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 55/60] ppc/ppc405: QOM'ify FPGA Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 56/60] ppc405: Move machine specific code to ppc405_boards.c Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 57/60] hw/ppc/sam3460ex: Remove PPC405 dependency from sam460ex Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 58/60] hw/ppc/Kconfig: Move imply before select Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 59/60] ppc/ppc4xx: Fix sdram trace events Daniel Henrique Barboza
2022-08-31 18:50 ` [PULL 60/60] ppc4xx: Fix code style problems reported by checkpatch Daniel Henrique Barboza
2022-08-31 19:37 ` [PULL 00/60] ppc queue BALATON Zoltan
2022-08-31 20:27   ` Daniel Henrique Barboza

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=20220831185034.23240-11-danielhb413@gmail.com \
    --to=danielhb413@gmail.com \
    --cc=fbarrat@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).