diff mbox series

[01/17] ppc/pnv: use PHB4 obj in pnv_pec_stk_pci_xscom_ops

Message ID 20220113192952.911188-2-danielhb413@gmail.com
State New
Headers show
Series remove PnvPhb4PecStack from Powernv9 | expand

Commit Message

Daniel Henrique Barboza Jan. 13, 2022, 7:29 p.m. UTC
The current relationship between PnvPhb4PecStack and PnvPHB4 objects is
overly complex. Recent work done in pnv_phb4.c and pnv_phb4_pec.c shows
that the stack obj role in the overall design is more of a placeholder for
its 'phb' object, having no atributes that stand on its own. This became
clearer after pnv-phb4 user creatable devices were implemented.

What remains now are a lot of stack->phb and phb->stack pointers
throughout .read and .write callbacks of MemoryRegionOps that are being
initialized in phb4_realize() time. stk_realize() is a no-op if the
machine is being run with -nodefaults.

The first step of trying to decouple the stack and phb relationship is
to move the MemoryRegionOps that belongs to PnvPhb4PecStack to PhbPHB4.
Unfortunately this can't be done  without some preliminary steps to
change the usage of 'stack' and replace it with 'phb' in these
read/write callbacks.

This patch starts this process by using a PnvPHB4 opaque in
pnv_pec_stk_pci_xscom_ops instead of PnvPhb4PecStack.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 hw/pci-host/pnv_phb4.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Cédric Le Goater Jan. 14, 2022, 10:36 a.m. UTC | #1
On 1/13/22 20:29, Daniel Henrique Barboza wrote:
> The current relationship between PnvPhb4PecStack and PnvPHB4 objects is
> overly complex. Recent work done in pnv_phb4.c and pnv_phb4_pec.c shows
> that the stack obj role in the overall design is more of a placeholder for
> its 'phb' object, having no atributes that stand on its own. This became
> clearer after pnv-phb4 user creatable devices were implemented.
> 
> What remains now are a lot of stack->phb and phb->stack pointers
> throughout .read and .write callbacks of MemoryRegionOps that are being
> initialized in phb4_realize() time. stk_realize() is a no-op if the
> machine is being run with -nodefaults.
> 
> The first step of trying to decouple the stack and phb relationship is
> to move the MemoryRegionOps that belongs to PnvPhb4PecStack to PhbPHB4.
> Unfortunately this can't be done  without some preliminary steps to
> change the usage of 'stack' and replace it with 'phb' in these
> read/write callbacks.
> 
> This patch starts this process by using a PnvPHB4 opaque in
> pnv_pec_stk_pci_xscom_ops instead of PnvPhb4PecStack.
> 
> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.
diff mbox series

Patch

diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index a7b638831e..e010572376 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1071,7 +1071,7 @@  static const MemoryRegionOps pnv_pec_stk_nest_xscom_ops = {
 static uint64_t pnv_pec_stk_pci_xscom_read(void *opaque, hwaddr addr,
                                            unsigned size)
 {
-    PnvPhb4PecStack *stack = PNV_PHB4_PEC_STACK(opaque);
+    PnvPhb4PecStack *stack = PNV_PHB4(opaque)->stack;
     uint32_t reg = addr >> 3;
 
     /* TODO: add list of allowed registers and error out if not */
@@ -1081,7 +1081,7 @@  static uint64_t pnv_pec_stk_pci_xscom_read(void *opaque, hwaddr addr,
 static void pnv_pec_stk_pci_xscom_write(void *opaque, hwaddr addr,
                                         uint64_t val, unsigned size)
 {
-    PnvPhb4PecStack *stack = PNV_PHB4_PEC_STACK(opaque);
+    PnvPhb4PecStack *stack = PNV_PHB4(opaque)->stack;
     uint32_t reg = addr >> 3;
 
     switch (reg) {
@@ -1475,10 +1475,10 @@  static void pnv_phb4_xscom_realize(PnvPHB4 *phb)
                           &pnv_pec_stk_nest_xscom_ops, stack, name,
                           PHB4_PEC_NEST_STK_REGS_COUNT);
 
-    snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-stack-%d",
+    snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-phb-%d",
              pec->chip_id, pec->index, stack->stack_no);
-    pnv_xscom_region_init(&stack->pci_regs_mr, OBJECT(stack),
-                          &pnv_pec_stk_pci_xscom_ops, stack, name,
+    pnv_xscom_region_init(&stack->pci_regs_mr, OBJECT(phb),
+                          &pnv_pec_stk_pci_xscom_ops, phb, name,
                           PHB4_PEC_PCI_STK_REGS_COUNT);
 
     /* PHB pass-through */