From: Daniel Henrique Barboza <danielhb413@gmail.com>
To: qemu-devel@nongnu.org
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au
Subject: [PATCH v3 06/10] ppc/pnv: turn 'phb' into a pointer in struct PnvPhb4PecStack
Date: Mon, 10 Jan 2022 11:33:42 -0300 [thread overview]
Message-ID: <20220110143346.455901-7-danielhb413@gmail.com> (raw)
In-Reply-To: <20220110143346.455901-1-danielhb413@gmail.com>
At this moment, stack->phb is the plain PnvPHB4 device itself instead
of a pointer to the device. This will present a problem when adding user
creatable devices because we can't deal with this struct and the
realize() callback from the user creatable device.
We can't get rid of this attribute, similar to what we did when enabling
pnv-phb3 user creatable devices, because pnv_phb4_update_regions() needs
to access stack->phb to do its job. This function is called twice in
pnv_pec_stk_update_map(), which is one of the nested xscom write
callbacks (via pnv_pec_stk_nest_xscom_write()). In fact,
pnv_pec_stk_update_map() code comment is explicit about how the order of
the unmap/map operations relates with the PHB subregions.
All of this indicates that this code is tied together in a way that we
either go on a crusade, featuring lots of refactories and redesign and
considerable pain, to decouple stack and phb mapping, or we allow stack
update_map operations to access the associated PHB as it is today even
after introducing pnv-phb4 user devices.
This patch chooses the latter. Instead of getting rid of stack->phb,
turn it into a PHB pointer. This will allow us to assign an user created
PHB to an existing stack later.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/pci-host/pnv_phb4.c | 2 +-
hw/pci-host/pnv_phb4_pec.c | 12 ++++++------
include/hw/pci-host/pnv_phb4.h | 7 +++++--
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index fb6c4f993a..1a7395772f 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1443,7 +1443,7 @@ type_init(pnv_phb4_register_types);
void pnv_phb4_update_regions(PnvPhb4PecStack *stack)
{
- PnvPHB4 *phb = &stack->phb;
+ PnvPHB4 *phb = stack->phb;
/* Unmap first always */
if (memory_region_is_mapped(&phb->mr_regs)) {
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index d2851e8040..042dc0b775 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -403,9 +403,9 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
* available here via the 'i' iterator so it's convenient to
* do it now.
*/
- object_property_set_int(OBJECT(&stack->phb), "index", phb_id,
+ object_property_set_int(OBJECT(stack->phb), "index", phb_id,
&error_abort);
- pnv_phb4_set_stack_phb_props(stack, &stack->phb);
+ pnv_phb4_set_stack_phb_props(stack, stack->phb);
if (!qdev_realize(DEVICE(stk_obj), NULL, errp)) {
return;
@@ -543,7 +543,7 @@ 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);
+ stack->phb = PNV_PHB4(qdev_new(TYPE_PNV_PHB4));
}
static void pnv_pec_stk_realize(DeviceState *dev, Error **errp)
@@ -574,10 +574,10 @@ static void pnv_pec_stk_realize(DeviceState *dev, Error **errp)
/* 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);
+ pnv_xscom_region_init(&stack->phb_regs_mr, OBJECT(stack->phb),
+ &pnv_phb4_xscom_ops, stack->phb, name, 0x40);
- if (!sysbus_realize(SYS_BUS_DEVICE(&stack->phb), errp)) {
+ if (stack->phb && !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 b2c4a6b263..2fb5e119c4 100644
--- a/include/hw/pci-host/pnv_phb4.h
+++ b/include/hw/pci-host/pnv_phb4.h
@@ -178,8 +178,11 @@ struct PnvPhb4PecStack {
/* The owner PEC */
PnvPhb4PecState *pec;
- /* The actual PHB */
- PnvPHB4 phb;
+ /*
+ * PHB4 pointer. pnv_phb4_update_regions() needs to access
+ * the PHB4 via a PnvPhb4PecStack pointer.
+ */
+ PnvPHB4 *phb;
};
struct PnvPhb4PecState {
--
2.33.1
next prev parent reply other threads:[~2022-01-10 14:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-10 14:33 [PATCH v3 00/10] user creatable pnv-phb4 devices Daniel Henrique Barboza
2022-01-10 14:33 ` [PATCH v3 01/10] pnv_phb4.c: introduce pnv_phb4_set_stack_phb_props() Daniel Henrique Barboza
2022-01-10 14:33 ` [PATCH v3 02/10] pnv_phb4_pec.c: move pnv_pec_phb_offset() to pnv_phb4.c Daniel Henrique Barboza
2022-01-10 14:33 ` [PATCH v3 03/10] pnv_phb4_pec: use pnv_phb4_pec_get_phb_id() in pnv_pec_dt_xscom() Daniel Henrique Barboza
2022-01-10 14:33 ` [PATCH v3 04/10] pnv_phb4_pec.c: remove stack 'phb-id' alias Daniel Henrique Barboza
2022-01-10 15:49 ` Cédric Le Goater
2022-01-10 16:27 ` Daniel Henrique Barboza
2022-01-10 16:42 ` Cédric Le Goater
2022-01-10 14:33 ` [PATCH v3 05/10] pnv_phb4_pec.c: move phb4 properties setup to pec_realize() Daniel Henrique Barboza
2022-01-10 15:58 ` Cédric Le Goater
2022-01-10 14:33 ` Daniel Henrique Barboza [this message]
2022-01-10 15:52 ` [PATCH v3 06/10] ppc/pnv: turn 'phb' into a pointer in struct PnvPhb4PecStack Cédric Le Goater
2022-01-10 14:33 ` [PATCH v3 07/10] ppc/pnv: move PHB4 related XSCOM init to phb4_realize() Daniel Henrique Barboza
2022-01-10 15:57 ` Cédric Le Goater
2022-01-10 16:11 ` Daniel Henrique Barboza
2022-01-10 14:33 ` [PATCH v3 08/10] pnv_phb4.c: check stack->phb not NULL in phb4_update_regions() Daniel Henrique Barboza
2022-01-10 15:59 ` Cédric Le Goater
2022-01-10 14:33 ` [PATCH v3 09/10] ppc/pnv: Introduce user creatable pnv-phb4 devices Daniel Henrique Barboza
2022-01-10 16:12 ` Cédric Le Goater
2022-01-10 14:33 ` [PATCH v3 10/10] pnv_phb4.c: change TYPE_PNV_PHB4_ROOT_BUS name Daniel Henrique Barboza
2022-01-10 16:25 ` [PATCH v3 00/10] user creatable pnv-phb4 devices Cédric Le Goater
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=20220110143346.455901-7-danielhb413@gmail.com \
--to=danielhb413@gmail.com \
--cc=clg@kaod.org \
--cc=david@gibson.dropbear.id.au \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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).