[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 08/17] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props()
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 08/17] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props() |
Date: |
Tue, 28 Dec 2021 16:37:57 -0300 |
We want to be able to support user creatable pnv-phb4 objects to allow
users to instantiate a powernv9 machine similar to what it is done with
powernv8.
The main difference is that pnv-phb3 devs are attached directly to the
system bus and can be created in the command line. PCI devices such as
root-ports can be explictly connected to them. This allows users to
create the phbs, assign a bus name if desired, then connect devices onto
them.
pnv-phb4 devices on the other hand are created by adding PCI Express
Controllers (PEC) that will create a certain amount of pnv-phb4 buses
depending on the PEC index used. Index 0 will create 1 phb, index 1
creates 2 phbs, index 2 creates 3 phbs. Creating all PECs from the same
chip will create 6 PHBs. This doesn't users to rename the buses, like it
is done with pnv-phb3, because there's no user control over how the
pnv-phb4 are being created - aside from the amount of phbs and in which
chips they'll reside.
This implicit relationship between PEC devices and available buses can
be tolerable for users that knows how the hardware works, but it's
annoying for Libvirt to deal with. Since there's no explicit
relationship, in the command line, between the created buses and the PCI
devices that will connect to them, the domain XML needs to make a lot of
extra assumptions regarding the relationship between regular PCI devices
and the existing PECs.
The first step to allow for user creatable pnv-phb4 devices is to
decouple the pvn-phb logic from the pnv-phb4-pec code. This patch adds a
helper called pnv_phb4_set_stack_phb_props() to remove the code from
pnv_phb4_pec.c that initiates the object properties of pnv-phb4 devices.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/pci-host/pnv_phb4.c | 27 +++++++++++++++++++++++++++
hw/pci-host/pnv_phb4_pec.c | 14 +-------------
include/hw/pci-host/pnv_phb4.h | 1 +
3 files changed, 29 insertions(+), 13 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index 6bd907f91a..0ea505cc94 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1164,6 +1164,33 @@ static AddressSpace *pnv_phb4_dma_iommu(PCIBus *bus,
void *opaque, int devfn)
return &ds->dma_as;
}
+/*
+ * Set the object properties of a phb in relation with its stack.
+ *
+ * Note: stack->pec must not be NULL.
+ */
+void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack,
+ PnvPHB4 *phb)
+{
+ PnvPhb4PecState *pec = stack->pec;
+ PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec);
+ char name[64];
+
+ snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-stack-%d-phb",
+ pec->chip_id, pec->index, stack->stack_no);
+ pnv_xscom_region_init(&stack->phb_regs_mr, OBJECT(phb),
+ &pnv_phb4_xscom_ops, phb, name, 0x40);
+
+ object_property_set_int(OBJECT(phb), "chip-id", pec->chip_id,
+ &error_fatal);
+ object_property_set_int(OBJECT(phb), "version", pecc->version,
+ &error_fatal);
+ object_property_set_int(OBJECT(phb), "device-id", pecc->device_id,
+ &error_fatal);
+ object_property_set_link(OBJECT(phb), "stack", OBJECT(stack),
+ &error_abort);
+}
+
static void pnv_phb4_instance_init(Object *obj)
{
PnvPHB4 *phb = PNV_PHB4(obj);
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 98e7ff78bd..700ee4b185 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -595,19 +595,7 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error
**errp)
PHB4_PEC_PCI_STK_REGS_COUNT);
/* PHB pass-through */
- snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci-stack-%d-phb",
- pec->chip_id, pec->index, stack->stack_no);
- pnv_xscom_region_init(&stack->phb_regs_mr, OBJECT(&stack->phb),
- &pnv_phb4_xscom_ops, &stack->phb, name, 0x40);
-
- object_property_set_int(OBJECT(&stack->phb), "chip-id", pec->chip_id,
- &error_fatal);
- object_property_set_int(OBJECT(&stack->phb), "version", pecc->version,
- &error_fatal);
- object_property_set_int(OBJECT(&stack->phb), "device-id", pecc->device_id,
- &error_fatal);
- object_property_set_link(OBJECT(&stack->phb), "stack", OBJECT(stack),
- &error_abort);
+ pnv_phb4_set_stack_phb_props(stack, &stack->phb);
if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) {
return;
}
diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h
index 629db632d9..d7838513f1 100644
--- a/include/hw/pci-host/pnv_phb4.h
+++ b/include/hw/pci-host/pnv_phb4.h
@@ -133,6 +133,7 @@ struct PnvPHB4 {
void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon);
void pnv_phb4_update_regions(PnvPhb4PecStack *stack);
+void pnv_phb4_set_stack_phb_props(PnvPhb4PecStack *stack, PnvPHB4 *phb);
extern const MemoryRegionOps pnv_phb4_xscom_ops;
/*
--
2.33.1
- [PATCH 00/17] ppc/pnv: enable pnv-phb4 user devices, Daniel Henrique Barboza, 2021/12/28
- [PATCH 01/17] pnv_phb3.c: add unique chassis and slot for pnv_phb3_root_port, Daniel Henrique Barboza, 2021/12/28
- [PATCH 02/17] pnv_phb3.c: do not set 'root-bus' as bus name, Daniel Henrique Barboza, 2021/12/28
- [PATCH 05/17] pnv.c: simplify pnv_phb_attach_root_port(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functions, Daniel Henrique Barboza, 2021/12/28
- [PATCH 03/17] pnv_phb3.h: change TYPE_PNV_PHB3_ROOT_BUS name, Daniel Henrique Barboza, 2021/12/28
- [PATCH 08/17] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props(),
Daniel Henrique Barboza <=
- [PATCH 09/17] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c, Daniel Henrique Barboza, 2021/12/28
- [PATCH 04/17] pnv_phb4.c: add unique chassis and slot for pnv_phb4_root_port, Daniel Henrique Barboza, 2021/12/28
- [PATCH 06/17] pnv_phb4.c: attach default root port in phb4 realize(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 10/17] pnv_phb4.c: introduce pnv_pec_init_stack_xscom(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 13/17] pnv_phb4.h: turn phb into a pointer in struct PnvPhb4PecStack, Daniel Henrique Barboza, 2021/12/28
- [PATCH 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb, Daniel Henrique Barboza, 2021/12/28
- [PATCH 11/17] pnv_phb4_pec.c: use pnv_pec_get_phb_id() in pnv_pec_dt_xscom(), Daniel Henrique Barboza, 2021/12/28
- [PATCH 14/17] Revert "ppc/pnv: Introduce support for user created PHB4 devices", Daniel Henrique Barboza, 2021/12/28
- [PATCH 17/17] pnv_phb4.c: change TYPE_PNV_PHB4_ROOT_BUS name, Daniel Henrique Barboza, 2021/12/28
- [PATCH 15/17] ppc/pnv: Introduce user creatable pnv-phb4 devices, Daniel Henrique Barboza, 2021/12/28