tests/qtest: Add Power11 chip & machine to qtests
Previously the machines/chips tested by qtest was till Power10, update the tests to also test PowerNV11 and Power11 PNV Chip Since if-else-if ladder was common pattern to get machine type, implement pnv_get_machine_type so new processor cases can be implemented in one location in pnv_get_machine_type While at it, also add g_autofree to allocation by g_strdup_printf in modified tests Tested-by: Misbah Anjum N <misanjum@linux.ibm.com> Reviewed-by: Nikhil Kumar Singh <nikhilks@linux.ibm.com> Signed-off-by: Aditya Gupta <adityag@linux.ibm.com> Link: https://lore.kernel.org/qemu-devel/20260703085955.2318600-4-adityag@linux.ibm.com Signed-off-by: Harsh Prateek Bora <harshpb@linux.ibm.com>
Aditya Gupta committed
Jul 3, 2026 at 14:29 UTC
0e82cffd5e2f448b3aa4b7c1b0c681386e19e62e
5 files changed
+53
-31
tests/qtest/pnv-host-i2c-test.c
+4
-6
@@ -402,15 +402,14 @@ static void reset_all(QTestState *qts, const PnvChip *chip)
402
static void test_host_i2c(const void *data)
403
{
404
const PnvChip *chip = data;
405
+ const char *machine = pnv_get_machine_type(chip->chip_type);
406
QTestState *qts;
406
- const char *machine = "powernv8";
407
PnvI2cCtlr ctlr;
408
PnvI2cDev pca9552;
409
PnvI2cDev pca9554;
410
411
- if (chip->chip_type == PNV_CHIP_POWER9) {
412
- machine = "powernv9";
413
- } else if (chip->chip_type == PNV_CHIP_POWER10) {
411
+ /* i2c is initialised for rainier in case of P10 */
412
+ if (chip->chip_type == PNV_CHIP_POWER10) {
413
machine = "powernv10-rainier";
414
}
415
@@ -473,10 +472,9 @@ static void add_test(const char *name, void (*test)(const void *data))
472
int i;
473
474
for (i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
476
- char *tname = g_strdup_printf("pnv-xscom/%s/%s", name,
475
+ g_autofree char *tname = g_strdup_printf("pnv-xscom/%s/%s", name,
476
pnv_chips[i].cpu_model);
477
qtest_add_data_func(tname, &pnv_chips[i], test);
479
- g_free(tname);
478
}
479
}
480
tests/qtest/pnv-spi-seeprom-test.c
+1
-1
@@ -77,7 +77,7 @@ static void test_spi_seeprom(const void *data)
77
const PnvChip *chip = data;
78
QTestState *qts = NULL;
79
g_autofree char *tmp_path = NULL;
80
- const char *machine = "powernv10";
80
+ const char *machine = pnv_get_machine_type(chip->chip_type);
81
int ret;
82
int fd;
83
tests/qtest/pnv-xive2-test.c
+17
-4
@@ -14,6 +14,7 @@
14
#include "libqtest.h"
15
16
#include "pnv-xive2-common.h"
17
+#include "pnv-xscom.h"
18
#include "hw/intc/pnv_xive2_regs.h"
19
#include "hw/ppc/xive_regs.h"
20
#include "hw/ppc/xive2_regs.h"
@@ -544,14 +545,16 @@ static void test_hw_group_irq_backlog(QTestState *qts)
545
g_assert_cmphex(lsmfb, ==, 0xFF);
546
}
547
547
-static void test_xive(void)
548
+static void test_xive(const void *data)
549
{
550
+ const PnvChip *chip = data;
551
+ const char *machine = pnv_get_machine_type(chip->chip_type);
552
QTestState *qts;
553
551
- qts = qtest_initf("-M powernv10 -smp %d,cores=1,threads=%d -nographic "
554
+ qts = qtest_initf("-M %s -smp %d,cores=1,threads=%d -nographic "
555
"-nodefaults -serial mon:stdio -S "
556
"-d guest_errors -trace '*xive*'",
554
- SMT, SMT);
557
+ machine, SMT, SMT);
558
init_xive(qts);
559
560
test_hw_irq(qts);
@@ -580,6 +583,16 @@ static void test_xive(void)
583
int main(int argc, char **argv)
584
{
585
g_test_init(&argc, &argv, NULL);
583
- qtest_add_func("xive2", test_xive);
586
+
587
+ for (int i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
588
+ /* xive2 exists from Power10 onwards */
589
+ if (pnv_chips[i].chip_type < PNV_CHIP_POWER10) {
590
+ continue;
591
+ }
592
+
593
+ g_autofree char *tname = g_strdup_printf("pnv-xive2/%s",
594
+ pnv_chips[i].cpu_model);
595
+ qtest_add_data_func(tname, &pnv_chips[i], test_xive);
596
+ }
597
return g_test_run();
598
}
tests/qtest/pnv-xscom-test.c
+5
-17
@@ -28,15 +28,9 @@ static void test_xscom_cfam_id(QTestState *qts, const PnvChip *chip)
28
static void test_cfam_id(const void *data)
29
{
30
const PnvChip *chip = data;
31
- const char *machine = "powernv8";
31
+ const char *machine = pnv_get_machine_type(chip->chip_type);
32
QTestState *qts;
33
34
- if (chip->chip_type == PNV_CHIP_POWER9) {
35
- machine = "powernv9";
36
- } else if (chip->chip_type == PNV_CHIP_POWER10) {
37
- machine = "powernv10";
38
- }
39
-
34
qts = qtest_initf("-M %s -accel tcg -cpu %s",
35
machine, chip->cpu_model);
36
test_xscom_cfam_id(qts, chip);
@@ -57,7 +51,8 @@ static void test_cfam_id(const void *data)
51
52
static void test_xscom_core(QTestState *qts, const PnvChip *chip)
53
{
60
- if (chip->chip_type == PNV_CHIP_POWER10) {
54
+ if ((chip->chip_type == PNV_CHIP_POWER10) ||
55
+ (chip->chip_type == PNV_CHIP_POWER11)) {
56
uint32_t first_core_thread_state =
57
PNV_XSCOM_P10_EC_BASE(chip->first_core) + 0x412;
58
uint64_t thread_state;
@@ -84,14 +79,8 @@ static void test_xscom_core(QTestState *qts, const PnvChip *chip)
79
static void test_core(const void *data)
80
{
81
const PnvChip *chip = data;
82
+ const char *machine = pnv_get_machine_type(chip->chip_type);
83
QTestState *qts;
88
- const char *machine = "powernv8";
89
-
90
- if (chip->chip_type == PNV_CHIP_POWER9) {
91
- machine = "powernv9";
92
- } else if (chip->chip_type == PNV_CHIP_POWER10) {
93
- machine = "powernv10";
94
- }
84
85
qts = qtest_initf("-M %s -accel tcg -cpu %s",
86
machine, chip->cpu_model);
@@ -104,10 +93,9 @@ static void add_test(const char *name, void (*test)(const void *data))
93
int i;
94
95
for (i = 0; i < ARRAY_SIZE(pnv_chips); i++) {
107
- char *tname = g_strdup_printf("pnv-xscom/%s/%s", name,
96
+ g_autofree char *tname = g_strdup_printf("pnv-xscom/%s/%s", name,
97
pnv_chips[i].cpu_model);
98
qtest_add_data_func(tname, &pnv_chips[i], test);
110
- g_free(tname);
99
}
100
}
101
tests/qtest/pnv-xscom.h
+26
-3
@@ -17,6 +17,7 @@ typedef enum PnvChipType {
17
PNV_CHIP_POWER8NVL, /* AKA Naples */
18
PNV_CHIP_POWER9, /* AKA Nimbus */
19
PNV_CHIP_POWER10,
20
+ PNV_CHIP_POWER11,
21
} PnvChipType;
22
23
typedef struct PnvChip {
@@ -60,15 +61,23 @@ static const PnvChip pnv_chips[] = {
61
.first_core = 0x0,
62
.num_i2c = 4,
63
},
64
+ {
65
+ .chip_type = PNV_CHIP_POWER11,
66
+ .cpu_model = "Power11",
67
+ .xscom_base = 0x000603fc00000000ull,
68
+ .cfam_id = 0x220da04980000000ull,
69
+ .first_core = 0x0,
70
+ .num_i2c = 0,
71
+ },
72
};
73
74
static inline uint64_t pnv_xscom_addr(const PnvChip *chip, uint32_t pcba)
75
{
76
uint64_t addr = chip->xscom_base;
77
69
- if (chip->chip_type == PNV_CHIP_POWER10) {
70
- addr |= ((uint64_t) pcba << 3);
71
- } else if (chip->chip_type == PNV_CHIP_POWER9) {
78
+ if ((chip->chip_type == PNV_CHIP_POWER11) ||
79
+ (chip->chip_type == PNV_CHIP_POWER10) ||
80
+ (chip->chip_type == PNV_CHIP_POWER9)) {
81
addr |= ((uint64_t) pcba << 3);
82
} else {
83
addr |= (((uint64_t) pcba << 4) & ~0xffull) |
@@ -77,4 +86,18 @@ static inline uint64_t pnv_xscom_addr(const PnvChip *chip, uint32_t pcba)
86
return addr;
87
}
88
89
+static const char *pnv_get_machine_type(enum PnvChipType chip_type)
90
+{
91
+ static const char *const machine_types[] = {
92
+ [PNV_CHIP_POWER8] = "powernv8",
93
+ [PNV_CHIP_POWER9] = "powernv9",
94
+ [PNV_CHIP_POWER10] = "powernv10",
95
+ [PNV_CHIP_POWER11] = "powernv11",
96
+ };
97
+
98
+ g_assert(chip_type <= PNV_CHIP_POWER11);
99
+
100
+ return machine_types[chip_type];
101
+}
102
+
103
#endif /* PNV_XSCOM_H */