From: Caleb Schlossin <calebs@linux.ibm.com>
To: Saif Abrar <saif.abrar@linux.ibm.com>,
qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: harshpb@linux.ibm.com, clg@kaod.org, npiggin@gmail.com,
fbarrat@linux.ibm.com, mst@redhat.com,
marcel.apfelbaum@gmail.com, cohuck@redhat.com,
pbonzini@redhat.com, thuth@redhat.com, lvivier@redhat.com,
danielhb413@gmail.com, kowal@linux.ibm.com,
chalapathi.v@linux.ibm.com, milesg@linux.ibm.com,
jishnuvw@linux.ibm.com, adityag@linux.ibm.com,
amachhiw@linux.ibm.com
Subject: Re: [PATCH v6 1/9] qtest/phb5: Add testbench for PHB
Date: Wed, 30 Sep 2026 09:10:28 -0500 [thread overview]
Message-ID: <975afd00-0fbb-4538-ab5f-6b69a2ccf013@linux.ibm.com> (raw)
In-Reply-To: <20260831123005.1485518-2-saif.abrar@linux.ibm.com>
Reviewed-by: Caleb Schlossin <calebs@linux.ibm.com>
On 8/31/26 7:29 AM, Saif Abrar wrote:
> From: Saif Abrar <saif.abrar@linux.vnet.ibm.com>
>
> New qtest testbench added for PHB[345].
> Testbench reads PHB Version register and asserts that
> bits[24:31] have value 0xA3, 0xA4 and 0xA5 respectively.
>
> Signed-off-by: Saif Abrar <saif.abrar@linux.ibm.com>
> Reviewed-by: Cédric Le Goater <clg@kaod.org>
> Reviewed-by: Caleb Schlossin <calebs@linux.ibm.com>
> ---
> tests/qtest/meson.build | 1 +
> tests/qtest/pnv-host-i2c-test.c | 13 +----
> tests/qtest/pnv-phb-test.c | 100 ++++++++++++++++++++++++++++++++
> tests/qtest/pnv-qtest-common.h | 24 ++++++++
> tests/qtest/pnv-xive2-common.h | 7 +--
> 5 files changed, 127 insertions(+), 18 deletions(-)
> create mode 100644 tests/qtest/pnv-phb-test.c
> create mode 100644 tests/qtest/pnv-qtest-common.h
>
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index cbdef5a545..bfea40bdf3 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -191,6 +191,7 @@ qtests_ppc64 = \
> (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-xive2-test'] : []) + \
> (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-spi-seeprom-test'] : []) + \
> (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-host-i2c-test'] : []) + \
> + (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-phb-test'] : []) + \
> (config_all_devices.has_key('CONFIG_PSERIES') ? ['numa-test'] : []) + \
> (config_all_devices.has_key('CONFIG_PSERIES') ? ['rtas-test'] : []) + \
> (slirp.found() ? ['pxe-test'] : []) + \
> diff --git a/tests/qtest/pnv-host-i2c-test.c b/tests/qtest/pnv-host-i2c-test.c
> index 5fd54f9de7..7d3c0035f9 100644
> --- a/tests/qtest/pnv-host-i2c-test.c
> +++ b/tests/qtest/pnv-host-i2c-test.c
> @@ -11,18 +11,7 @@
> #include "hw/gpio/pca9554_regs.h"
> #include "hw/gpio/pca9552_regs.h"
> #include "pnv-xscom.h"
> -
> -#define PPC_BIT(bit) (0x8000000000000000ULL >> (bit))
> -#define PPC_BIT32(bit) (0x80000000 >> (bit))
> -#define PPC_BIT8(bit) (0x80 >> (bit))
> -#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))
> -#define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \
> - PPC_BIT32(bs))
> -
> -#define MASK_TO_LSH(m) (__builtin_ffsll(m) - 1)
> -#define GETFIELD(m, v) (((v) & (m)) >> MASK_TO_LSH(m))
> -#define SETFIELD(m, v, val) \
> - (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))
> +#include "pnv-qtest-common.h"
>
> #define PNV10_XSCOM_I2CM_BASE 0xa0000
> #define PNV10_XSCOM_I2CM_SIZE 0x1000
> diff --git a/tests/qtest/pnv-phb-test.c b/tests/qtest/pnv-phb-test.c
> new file mode 100644
> index 0000000000..a6f890ba79
> --- /dev/null
> +++ b/tests/qtest/pnv-phb-test.c
> @@ -0,0 +1,100 @@
> +/*
> + * QTest testcase for PowerNV PHB
> + *
> + * Copyright (c) 2026, IBM Corporation.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include "libqtest.h"
> +#include "hw/pci-host/pnv_phb4_regs.h"
> +#include "pnv-xscom.h"
> +#include "pnv-qtest-common.h"
> +
> +#define PHB3_PBCQ_SPCI_ASB_ADDR 0x0
> +#define PHB3_PBCQ_SPCI_ASB_DATA 0x2
> +
> +/* Index of PNV_CHIP_POWER10 in pnv_chips[] within "pnv-xscom.h" */
> +#define PHB4_XSCOM 0x40084800ull
> +
> +/* SCOM to PCBA address conversion */
> +#define SCOM_TO_PCBA(scom, addr) (((scom) >> 3) + (addr))
> +
> +/*
> + * Indirect XSCOM read::
> + * - Write 'Indirect Address Register' with register-offset to read.
> + * - Read 'Indirect Data Register' to get the value.
> + */
> +static uint64_t pnv_phb_xscom_read(QTestState *qts, const PnvChip *chip,
> + uint64_t scom, uint32_t indirect_addr, uint32_t indirect_data,
> + uint64_t reg)
> +{
> + qtest_writeq(qts, pnv_xscom_addr(chip, SCOM_TO_PCBA(scom, indirect_addr)),
> + reg);
> + return qtest_readq(qts, pnv_xscom_addr(chip, SCOM_TO_PCBA(scom,
> + indirect_data)));
> +}
> +
> +/* Assert that 'PHB - Version Register' bits[24:31] are as expected */
> +static void phb_version_test(const void *data)
> +{
> + const PnvChip *chip = (PnvChip *)data;
> + QTestState *qts;
> + const char *machine = pnv_get_machine_type(chip->chip_type);
> +
> + /* Defaults to PNV_CHIP_POWER8 */
> + uint64_t phb_xscom = 0x4809e000;
> + uint64_t reg_phb_version = PHB_VERSION;
> + uint32_t indirect_addr = PHB3_PBCQ_SPCI_ASB_ADDR;
> + uint32_t indirect_data = PHB3_PBCQ_SPCI_ASB_DATA;
> + uint32_t expected_ver = 0xA3;
> + uint64_t ver;
> +
> + if (chip->chip_type == PNV_CHIP_POWER9) {
> + phb_xscom = 0x68084800;
> + indirect_addr = PHB_SCOM_HV_IND_ADDR;
> + indirect_data = PHB_SCOM_HV_IND_DATA;
> + reg_phb_version |= PPC_BIT(0);
> + expected_ver = 0xA4;
> + } else if ((chip->chip_type == PNV_CHIP_POWER10) ||
> + (chip->chip_type == PNV_CHIP_POWER11)) {
> + phb_xscom = PHB4_XSCOM;
> + indirect_addr = PHB_SCOM_HV_IND_ADDR;
> + indirect_data = PHB_SCOM_HV_IND_DATA;
> + reg_phb_version |= PPC_BIT(0);
> + expected_ver = 0xA5;
> + }
> +
> + qts = qtest_initf("-M %s -accel tcg -cpu %s", machine, chip->cpu_model);
> +
> + ver = pnv_phb_xscom_read(qts, chip, phb_xscom,
> + indirect_addr, indirect_data, reg_phb_version);
> +
> + /* PHB Version register bits [24:31] */
> + ver = GETFIELD(PPC_BITMASK(24, 31), ver);
> + g_assert_cmpuint(ver, ==, expected_ver);
> +
> + qtest_quit(qts);
> +}
> +
> +/* Verify versions of all supported PHB's */
> +static void add_phbX_version_test(void)
> +{
> + for (int i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
> + g_autofree char *tname = g_strdup_printf("pnv-phb/%s",
> + pnv_chips[i].cpu_model);
> + qtest_add_data_func(tname, &pnv_chips[i], phb_version_test);
> + }
> +}
> +
> +int main(int argc, char **argv)
> +{
> + g_test_init(&argc, &argv, NULL);
> +
> + /* PHB[345] tests */
> + add_phbX_version_test();
> +
> + return g_test_run();
> +}
> diff --git a/tests/qtest/pnv-qtest-common.h b/tests/qtest/pnv-qtest-common.h
> new file mode 100644
> index 0000000000..c2d1bae7bb
> --- /dev/null
> +++ b/tests/qtest/pnv-qtest-common.h
> @@ -0,0 +1,24 @@
> +/*
> + * PNV QTest common definitions
> + *
> + * Copyright (c) 2026, IBM Corporation.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#ifndef TEST_PNV_QTEST_COMMON_H
> +#define TEST_PNV_QTEST_COMMON_H
> +
> +#define PPC_BIT(bit) (0x8000000000000000ULL >> (bit))
> +#define PPC_BIT32(bit) (0x80000000 >> (bit))
> +#define PPC_BIT8(bit) (0x80 >> (bit))
> +#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))
> +#define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \
> + PPC_BIT32(bs))
> +
> +#define MASK_TO_LSH(m) (__builtin_ffsll(m) - 1)
> +#define GETFIELD(m, v) (((v) & (m)) >> MASK_TO_LSH(m))
> +#define SETFIELD(m, v, val) \
> + (((v) & ~(m)) | ((((typeof(v))(val)) << MASK_TO_LSH(m)) & (m)))
> +
> +#endif
> diff --git a/tests/qtest/pnv-xive2-common.h b/tests/qtest/pnv-xive2-common.h
> index 3b84227424..4b823a57e2 100644
> --- a/tests/qtest/pnv-xive2-common.h
> +++ b/tests/qtest/pnv-xive2-common.h
> @@ -9,12 +9,7 @@
> #ifndef TEST_PNV_XIVE2_COMMON_H
> #define TEST_PNV_XIVE2_COMMON_H
>
> -#define PPC_BIT(bit) (0x8000000000000000ULL >> (bit))
> -#define PPC_BIT32(bit) (0x80000000 >> (bit))
> -#define PPC_BIT8(bit) (0x80 >> (bit))
> -#define PPC_BITMASK(bs, be) ((PPC_BIT(bs) - PPC_BIT(be)) | PPC_BIT(bs))
> -#define PPC_BITMASK32(bs, be) ((PPC_BIT32(bs) - PPC_BIT32(be)) | \
> - PPC_BIT32(bs))
> +#include "pnv-qtest-common.h"
> #include "hw/intc/pnv_xive2_regs.h"
> #include "hw/ppc/xive_regs.h"
> #include "hw/ppc/xive2_regs.h"
next prev parent reply other threads:[~2026-09-30 14:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 12:29 [PATCH v6 0/9] pnv/phb5: Update PHB4 to the latest PHB5 spec Saif Abrar
2026-08-31 12:29 ` [PATCH v6 1/9] qtest/phb5: Add testbench for PHB Saif Abrar
2026-09-03 16:52 ` Mike Kowal
2026-09-12 12:37 ` Aditya Gupta
2026-09-30 14:10 ` Caleb Schlossin [this message]
2026-08-31 12:29 ` [PATCH v6 2/9] pnv/phb5: Add reset logic to PHB5 Saif Abrar
2026-09-03 16:52 ` Mike Kowal
2026-09-12 12:39 ` Aditya Gupta
2026-09-30 14:10 ` Caleb Schlossin
2026-08-31 12:29 ` [PATCH v6 3/9] pnv/phb5: Implement sticky reset logic in PHB5 Saif Abrar
2026-09-03 16:53 ` Mike Kowal
2026-09-30 14:10 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 4/9] pnv/phb5: Implement read-only and write-only bits of registers Saif Abrar
2026-09-03 16:54 ` Mike Kowal
2026-09-30 14:11 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 5/9] pnv/phb5: Implement write-clear and return 1's on unimplemented reg read Saif Abrar
2026-09-03 16:49 ` Mike Kowal
2026-09-30 14:11 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 6/9] pnv/phb5: Set link-active status in HPSTAT and LMR registers Saif Abrar
2026-09-03 16:55 ` Mike Kowal
2026-09-12 12:41 ` Aditya Gupta
2026-09-30 14:11 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 7/9] pnv/phb5: Set link speed and width in the DLP training control register Saif Abrar
2026-09-03 16:56 ` Mike Kowal
2026-09-30 14:11 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 8/9] pnv/phb5: Implement IODA PCT table Saif Abrar
2026-09-03 16:50 ` Mike Kowal
2026-09-30 14:12 ` Caleb Schlossin
2026-08-31 12:30 ` [PATCH v6 9/9] pnv/phb5: Mask off LSI Source-ID based on number of interrupts Saif Abrar
2026-09-03 16:51 ` Mike Kowal
2026-09-30 14:12 ` Caleb Schlossin
2026-09-03 17:02 ` [PATCH v6 0/9] pnv/phb5: Update PHB4 to the latest PHB5 spec Mike Kowal
2026-09-12 12:43 ` Aditya Gupta
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=975afd00-0fbb-4538-ab5f-6b69a2ccf013@linux.ibm.com \
--to=calebs@linux.ibm.com \
--cc=adityag@linux.ibm.com \
--cc=amachhiw@linux.ibm.com \
--cc=chalapathi.v@linux.ibm.com \
--cc=clg@kaod.org \
--cc=cohuck@redhat.com \
--cc=danielhb413@gmail.com \
--cc=fbarrat@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=jishnuvw@linux.ibm.com \
--cc=kowal@linux.ibm.com \
--cc=lvivier@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=milesg@linux.ibm.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=saif.abrar@linux.ibm.com \
--cc=thuth@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.