[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb |
Date: |
Tue, 28 Dec 2021 16:38:01 -0300 |
The next step before enabling user creatable pnv-phb4 devices is to
decople the init of the stack->phb object from
pnv_pec_stk_instance_init().
First, use 'defaults_enabled()' inside pnv_pec_realize() to create the
stack->phb object, while removing the equivalent object_initiate_child()
call from stk_instance_init(). Create a new "phb" stack property link so
we can assign stack->phb in an idiomatic manner.
Then we need to handle stack->phb->index assignment. The value is
retrieved with pnv_pec_get_phd_id() and, until this patch, this was
being assigned to a 'phb-id' stack link to phb->index. It is simpler to
assign this directly given that now we need to interact with the PnvPHB4
object directly to set its other attributes. Assign phb->index directly
with the value of pnv_pec_get_phb_id(), and remove the now unused link.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/pci-host/pnv_phb4_pec.c | 29 +++++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 56ffd446ab..031e98f1f4 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -19,6 +19,7 @@
#include "hw/pci/pci_bus.h"
#include "hw/ppc/pnv.h"
#include "hw/qdev-properties.h"
+#include "sysemu/sysemu.h"
#include <libfdt.h>
@@ -409,11 +410,29 @@ static void pnv_pec_realize(DeviceState *dev, Error
**errp)
for (i = 0; i < pec->num_stacks; i++) {
PnvPhb4PecStack *stack = &pec->stacks[i];
Object *stk_obj = OBJECT(stack);
- int phb_id = pnv_pec_get_phb_id(pec, i);
object_property_set_int(stk_obj, "stack-no", i, &error_abort);
- object_property_set_int(stk_obj, "phb-id", phb_id, &error_abort);
object_property_set_link(stk_obj, "pec", OBJECT(pec), &error_abort);
+
+ /* Create and realize the default stack->phb */
+ if (defaults_enabled()) {
+ PnvPHB4 *phb = PNV_PHB4(qdev_new(TYPE_PNV_PHB4));
+ int phb_id = pnv_pec_get_phb_id(pec, i);
+
+ object_property_set_int(OBJECT(phb), "index",
+ phb_id, &error_abort);
+ object_property_set_link(OBJECT(phb), "stack",
+ stk_obj, &error_abort);
+
+ pnv_phb4_set_stack_phb_props(stack, phb);
+ if (!sysbus_realize_and_unref(SYS_BUS_DEVICE(phb), errp)) {
+ return;
+ }
+
+ object_property_set_link(stk_obj, "phb", OBJECT(phb),
+ &error_abort);
+ }
+
if (!qdev_realize(DEVICE(stk_obj), NULL, errp)) {
return;
}
@@ -549,10 +568,6 @@ static const TypeInfo pnv_pec_type_info = {
static void pnv_pec_stk_instance_init(Object *obj)
{
- PnvPhb4PecStack *stack = PNV_PHB4_PEC_STACK(obj);
-
- object_initialize_child(obj, "phb", &stack->phb, TYPE_PNV_PHB4);
- object_property_add_alias(obj, "phb-id", OBJECT(&stack->phb), "index");
}
static void pnv_pec_stk_realize(DeviceState *dev, Error **errp)
@@ -589,6 +604,8 @@ static Property pnv_pec_stk_properties[] = {
DEFINE_PROP_UINT32("stack-no", PnvPhb4PecStack, stack_no, 0),
DEFINE_PROP_LINK("pec", PnvPhb4PecStack, pec, TYPE_PNV_PHB4_PEC,
PnvPhb4PecState *),
+ DEFINE_PROP_LINK("phb", PnvPhb4PecStack, phb, TYPE_PNV_PHB4,
+ PnvPHB4 *),
DEFINE_PROP_END_OF_LIST(),
};
--
2.33.1
- [PATCH 07/17] pnv_phb4.c: check if root port exists in rc_config functions, (continued)
- [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, 2021/12/28
- [PATCH 09/17] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c, Daniel Henrique Barboza, 2021/12/28
- [PATCH 05/17] pnv.c: simplify pnv_phb_attach_root_port(), 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 13/17] pnv_phb4.h: turn phb into a pointer in struct PnvPhb4PecStack, 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 15/17] ppc/pnv: Introduce user creatable pnv-phb4 devices, 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 12/17] pnv_phb4_pec.c: use 'default_enabled()' to init stack->phb,
Daniel Henrique Barboza <=
- [PATCH 16/17] pnv_phb4.c: do not set 'root-bus' as bus name, 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