From: Frederic Barrat <fbarrat@linux.ibm.com>
To: clg@kaod.org, danielhb413@gmail.com, qemu-ppc@nongnu.org,
qemu-devel@nongnu.org
Subject: [PATCH 3/3] ppc/pnv: Fix PEC lookup function for POWER10
Date: Thu, 10 Mar 2022 16:51:01 +0100 [thread overview]
Message-ID: <20220310155101.294568-4-fbarrat@linux.ibm.com> (raw)
In-Reply-To: <20220310155101.294568-1-fbarrat@linux.ibm.com>
The PEC array used when looking for the PEC hosting a PHB is stored in
the chip structure. The array is at a different offset in Pnv9Chip and
Pnv10Chip. The lookup function was therefore not working properly on
POWER10.
This patch fixes it by introducing a class method to get the correct
PEC pointer based on the chip object and PEC index.
Fixes: 623575e16cd5 ("ppc/pnv: Add model for POWER10 PHB5 PCIe Host bridge")
Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
---
hw/pci-host/pnv_phb4.c | 5 ++---
hw/ppc/pnv.c | 14 ++++++++++++++
include/hw/ppc/pnv.h | 1 +
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index d1a911f988..4732633833 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1548,7 +1548,6 @@ static void pnv_phb4_instance_init(Object *obj)
static PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB4 *phb,
Error **errp)
{
- Pnv9Chip *chip9 = PNV9_CHIP(chip);
int chip_id = phb->chip_id;
int index = phb->phb_id;
int i, j;
@@ -1556,9 +1555,9 @@ static PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB4 *phb,
for (i = 0; i < chip->num_pecs; i++) {
/*
* For each PEC, check the amount of phbs it supports
- * and see if the given phb4 index matches an index.
+ * and see if the given phb index matches an index.
*/
- PnvPhb4PecState *pec = &chip9->pecs[i];
+ PnvPhb4PecState *pec = PNV_CHIP_GET_CLASS(chip)->get_pec(chip, i);
for (j = 0; j < pec->num_phbs; j++) {
if (index == pnv_phb4_pec_get_phb_id(pec, j)) {
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index df58403a3a..3a676cd570 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1561,6 +1561,12 @@ static uint32_t pnv_chip_power9_xscom_pcba(PnvChip *chip, uint64_t addr)
return addr >> 3;
}
+static PnvPhb4PecState *pnv_chip_power9_get_pec(PnvChip *chip, uint32_t index)
+{
+ Pnv9Chip *chip9 = PNV9_CHIP(chip);
+ return &chip9->pecs[index];
+}
+
static void pnv_chip_power9_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1580,6 +1586,7 @@ static void pnv_chip_power9_class_init(ObjectClass *klass, void *data)
k->xscom_pcba = pnv_chip_power9_xscom_pcba;
dc->desc = "PowerNV Chip POWER9";
k->num_pecs = PNV9_CHIP_MAX_PEC;
+ k->get_pec = pnv_chip_power9_get_pec;
device_class_set_parent_realize(dc, pnv_chip_power9_realize,
&k->parent_realize);
@@ -1769,6 +1776,12 @@ static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip, uint64_t addr)
return addr >> 3;
}
+static PnvPhb4PecState *pnv_chip_power10_get_pec(PnvChip *chip, uint32_t index)
+{
+ Pnv10Chip *chip10 = PNV10_CHIP(chip);
+ return &chip10->pecs[index];
+}
+
static void pnv_chip_power10_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -1788,6 +1801,7 @@ static void pnv_chip_power10_class_init(ObjectClass *klass, void *data)
k->xscom_pcba = pnv_chip_power10_xscom_pcba;
dc->desc = "PowerNV Chip POWER10";
k->num_pecs = PNV10_CHIP_MAX_PEC;
+ k->get_pec = pnv_chip_power10_get_pec;
device_class_set_parent_realize(dc, pnv_chip_power10_realize,
&k->parent_realize);
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index 1e34ddd502..282f76ba08 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -163,6 +163,7 @@ struct PnvChipClass {
void (*pic_print_info)(PnvChip *chip, Monitor *mon);
uint64_t (*xscom_core_base)(PnvChip *chip, uint32_t core_id);
uint32_t (*xscom_pcba)(PnvChip *chip, uint64_t addr);
+ PnvPhb4PecState *(*get_pec)(PnvChip *chip, uint32_t index);
};
#define PNV_CHIP_TYPE_SUFFIX "-" TYPE_PNV_CHIP
--
2.35.1
next prev parent reply other threads:[~2022-03-10 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-10 15:50 [PATCH 0/3] Fix user-created PHB devices on POWER10 Frederic Barrat
2022-03-10 15:50 ` [PATCH 1/3] ppc/pnv: Introduce a pnv-phb5 device to match root port Frederic Barrat
2022-03-10 16:16 ` Cédric Le Goater
2022-03-10 15:51 ` [PATCH 2/3] ppc/pnv: Fixes for user-created pnv-phb5 devices Frederic Barrat
2022-03-10 16:16 ` Cédric Le Goater
2022-03-10 15:51 ` Frederic Barrat [this message]
2022-03-10 16:17 ` [PATCH 3/3] ppc/pnv: Fix PEC lookup function for POWER10 Cédric Le Goater
2022-03-14 15:21 ` [PATCH 0/3] Fix user-created PHB devices on POWER10 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=20220310155101.294568-4-fbarrat@linux.ibm.com \
--to=fbarrat@linux.ibm.com \
--cc=clg@kaod.org \
--cc=danielhb413@gmail.com \
--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).