From d2704eb3fd5093224fb14ecbfdc916d42d42416b Mon Sep 17 00:00:00 2001 From: Daniel Henrique Barboza Date: Tue, 18 Jan 2022 12:56:31 +0100 Subject: [PATCH] ppc/pnv: introduce PnvPHB4 'pec' property MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This property will track the owner PEC of this PHB. For now it's redundant since we can retrieve the PEC via phb->stack->pec but it will not be redundant when we get rid of the stack device. Reviewed-by: Cédric Le Goater Signed-off-by: Daniel Henrique Barboza Message-Id: <20220114180719.52117-2-danielhb413@gmail.com> Signed-off-by: Cédric Le Goater --- hw/pci-host/pnv_phb4.c | 19 +++++++++++++------ hw/pci-host/pnv_phb4_pec.c | 2 ++ include/hw/pci-host/pnv_phb4.h | 3 +++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index b5045fca64..2658ef2d84 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -895,7 +895,7 @@ static void pnv_phb4_update_regions(PnvPHB4 *phb) static void pnv_pec_stk_update_map(PnvPHB4 *phb) { PnvPhb4PecStack *stack = phb->stack; - PnvPhb4PecState *pec = stack->pec; + PnvPhb4PecState *pec = phb->pec; MemoryRegion *sysmem = get_system_memory(); uint64_t bar_en = phb->nest_regs[PEC_NEST_STK_BAR_EN]; uint64_t bar, mask, size; @@ -969,7 +969,7 @@ static void pnv_pec_stk_update_map(PnvPHB4 *phb) bar = phb->nest_regs[PEC_NEST_STK_INT_BAR] >> 8; size = PNV_PHB4_MAX_INTs << 16; snprintf(name, sizeof(name), "pec-%d.%d-phb-%d-int", - stack->pec->chip_id, stack->pec->index, stack->stack_no); + phb->pec->chip_id, phb->pec->index, stack->stack_no); memory_region_init(&phb->intbar, OBJECT(phb), name, size); memory_region_add_subregion(sysmem, bar, &phb->intbar); } @@ -982,7 +982,7 @@ static void pnv_pec_stk_nest_xscom_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { PnvPHB4 *phb = PNV_PHB4(opaque); - PnvPhb4PecState *pec = phb->stack->pec; + PnvPhb4PecState *pec = phb->pec; uint32_t reg = addr >> 3; switch (reg) { @@ -1459,7 +1459,7 @@ static AddressSpace *pnv_phb4_dma_iommu(PCIBus *bus, void *opaque, int devfn) static void pnv_phb4_xscom_realize(PnvPHB4 *phb) { PnvPhb4PecStack *stack = phb->stack; - PnvPhb4PecState *pec = stack->pec; + PnvPhb4PecState *pec = phb->pec; PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); uint32_t pec_nest_base; uint32_t pec_pci_base; @@ -1568,8 +1568,13 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp) return; } - /* All other phb properties but 'version' are already set */ - pecc = PNV_PHB4_PEC_GET_CLASS(phb->stack->pec); + /* + * All other phb properties but 'pec' ad 'version' are + * already set. + */ + object_property_set_link(OBJECT(phb), "pec", OBJECT(phb->stack->pec), + &error_abort); + pecc = PNV_PHB4_PEC_GET_CLASS(phb->pec); object_property_set_int(OBJECT(phb), "version", pecc->version, &error_fatal); @@ -1682,6 +1687,8 @@ static Property pnv_phb4_properties[] = { DEFINE_PROP_UINT64("version", PnvPHB4, version, 0), DEFINE_PROP_LINK("stack", PnvPHB4, stack, TYPE_PNV_PHB4_PEC_STACK, PnvPhb4PecStack *), + DEFINE_PROP_LINK("pec", PnvPHB4, pec, TYPE_PNV_PHB4_PEC, + PnvPhb4PecState *), DEFINE_PROP_END_OF_LIST(), }; diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 7fe7f1f007..22194b8de2 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -285,6 +285,8 @@ static void pnv_pec_stk_default_phb_realize(PnvPhb4PecStack *stack, stack->phb = PNV_PHB4(qdev_new(TYPE_PNV_PHB4)); + object_property_set_link(OBJECT(stack->phb), "pec", OBJECT(pec), + &error_abort); object_property_set_int(OBJECT(stack->phb), "chip-id", pec->chip_id, &error_fatal); object_property_set_int(OBJECT(stack->phb), "index", phb_id, diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 6968efaba8..1d27e4c0cb 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -84,6 +84,9 @@ struct PnvPHB4 { uint64_t version; + /* The owner PEC */ + PnvPhb4PecState *pec; + char bus_path[8]; /* Main register images */ -- 2.11.4.GIT