On 26/06/17 04:50AM, Saif Abrar wrote:
> From: Saif Abrar <[email protected]>
>
> 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 <[email protected]>
> Reviewed-by: Cédric Le Goater <[email protected]>
> Reviewed-by: Harsh Prateek Bora <[email protected]>
> Reviewed-by: Aditya Gupta <[email protected]>
> Reviewed-by: Jishnu Warrier <[email protected]>
Thanks for the patches !
> <...snip...>
> +/* 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 = "powernv8";
> + 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) {
> + machine = "powernv9";
> + 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) {
> + machine = "powernv10";
> + 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;
> + }
We are adding PNV_CHIP_POWER11 in qtests in
https://lore.kernel.org/qemu-devel/[email protected]/T/#m5ccc85c90fce585b11ec4a89317c21bc6504b10e
fwiw, depending on which series is merged first, we will have to update
this in future, just keeping a note
> +
> + 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 = (ver & PPC_BITMASK(24, 31)) >> (63 - 31);
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++) {
> + char *tname = g_strdup_printf("pnv-phb/%s",
> + pnv_chips[i].cpu_model);
> + qtest_add_data_func(tname, &pnv_chips[i], phb_version_test);
> + g_free(tname);
can use g_autofree:
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);
Thanks,
- Aditya G