From nobody Mon Nov 23 04:26:29 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094364; cv=none; d=zohomail.com; s=zohoarc; b=ErSQD2tmF1WryaTDYTuuBWHoG1As8tUCm89OFkBo9X7yWdJ76eyHKLBjUG1S9lIxnBbSE1PdZY1ImlRcRCK1aGcIa/FZj3i4xc4h3R82sHPDAAWMR2M6w6YD4LENVVguItvxb6QuOogvDO8SsKLY27UZqjExtzlva4kRlMMwIKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094364; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Pw2Jd3kFfWEzw4CvcwbzJPOnbknKylT0X2wi0lbBODY=; b=H9ChRh1a0zdbtW+kZpzOhwvIaPCY5WVcXz5vXn310k0e/Yp6oF5JA4GDx9vpOiHEbDn2O/TfBklil1lrgXjr75we1v3F29j9X5ucb6uSotUJ9AMAM8I7jZGKyvZZ9U1Ybc8lB3bl86aUBNFAcnQYMXSOwadp6oyCICZvpDhayMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17930943646591001.1071807436346; Tue, 27 Oct 2026 02:46:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjK-0000Ti-Ci; Tue, 27 Oct 2026 05:44:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjH-0000QW-JA; Tue, 27 Oct 2026 05:44:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjE-0001P9-VG; Tue, 27 Oct 2026 05:44:27 -0400 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5iL4A1504072; Tue, 27 Oct 2026 09:44:15 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmd6xn7h-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:14 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5npXN3687782; Tue, 27 Oct 2026 09:44:13 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh7cvj8ct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:13 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iCiC16515662 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:12 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 95E6E5805E; Tue, 27 Oct 2026 09:44:12 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B02058052; Tue, 27 Oct 2026 09:44:11 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:11 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Pw2Jd3 kFfWEzw4CvcwbzJPOnbknKylT0X2wi0lbBODY=; b=sLStdktyFLev4csmxUK3ef XjsR6l9A82TEQh0RiQeJ41fMwZR4UTgegVkG9UHfK4Ys9OgDJAuARnKeuEJgL4SR 5UgtnBcNVPp+lWeiHUxRKP9JblSI2mY94tcnMSzkR7wtMwmLKPhBvP6Kpx5P3Ccy qMKGhxQgvujJE/xCZdzmdoGn3Q2q57kSjT0juqDTvt/HCjoBesGv/JmRc8tHa1qx PQhMwo9SDC5NaTlOZwWFOR8GeZ8QLqpCigzaGVkLYn4bWVwvRZrErbBBDg74znHs VFQYY3O0bbtKh73GSGy2R4aU++TS7tKqOAWJI64W7EVrV3dJngzrxyw7fd5yUUmg == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 1/9] qtest/phb5: Add testbench for PHB Date: Tue, 27 Oct 2026 04:43:42 -0500 Message-ID: <20261027094350.3645085-2-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=ZYOIpcVA c=1 sm=1 tr=0 ts=6ae0726f cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=zHMdCkDpksyigQT-iYMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX6BKJtsVRDoi4 vpiOy/Sy+338hLAYmVauV0XUWyqAZuoNQMfqOWy+qelq01chqqQWDAn35fSxk9bY2W3+eePjn5O Vv/Nl390ZfUBidxkwaBYXtZ4330xGGVtxH/tKP9rDNzSpI400vQIS/s1HptcKzi5L9lWCBeUSql uC5z8f1Xs0i/rjyKYNT61W519BdC4iV+gZrqgq6ClvM7cVPITwROCzCjn8FyHpwBQxmxp8mytyP LAi15E2RAnbdWM4A6sA6w/opUo33ld7uzwbkd7xuzVfMB8YTf5WPqOAn2kt5wCiqpgSdOf0Ibmz C/2K9NsiBTZO5qnAcVLOZjZzaZ5GHswBqTX8YUyeF6hvQNq+hrK+/RkHnZjL7pVwmwASbYh9IhA 7hwgmklnJAI3/JG341YMdxYHFYoh3Kan/Uvx07R2h8n6RrNLo/ecRkfjYVSsPw9kKeR+dVj+Xv4 zM0NAxcBaElTev/FhNw== X-Proofpoint-GUID: 73mqtU_XwdAqnfyMCf7f6xQtf_EgsyQn X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX8PrpvVhNv8Fh ejabmFqurpPs20/+zKj5CvQk5ueuVgOh5JqQq4dmhYDQI4Jgiev/inP/vAzcvWXtfomHP4s546u q+hgzv+r92UJkG3xAj3GxexEU6s8l+k= X-Proofpoint-ORIG-GUID: 0TuA31Vp3mK6w_D_UTv6uHGuwYa8_dcv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 suspectscore=0 phishscore=0 clxscore=1015 bulkscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=saif.abrar@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094366506158500 From: Saif Abrar 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 Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Caleb Schlossin Reviewed-by: Michael Kowal Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal --- tests/qtest/meson.build | 1 + tests/qtest/pnv-host-i2c-test.c | 13 +---- tests/qtest/pnv-phb-test.c | 99 +++++++++++++++++++++++++++++++++ tests/qtest/pnv-qtest-common.h | 24 ++++++++ tests/qtest/pnv-xive2-common.h | 7 +-- 5 files changed, 126 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 46685d6d46..6078366eb4 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -197,6 +197,7 @@ qtests_ppc64 =3D \ (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-tes= t.c index f97f6f65ee..176e7365da 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" =20 #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..b4d75a1229 --- /dev/null +++ b/tests/qtest/pnv-phb-test.c @@ -0,0 +1,99 @@ +/* + * 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 + +#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_add= r)), + reg); + return qtest_readq(qts, pnv_xscom_addr(chip, SCOM_TO_PCBA(scom, + indirect_dat= a))); +} + +/* Assert that 'PHB - Version Register' bits[24:31] are as expected */ +static void phb_version_test(const void *data) +{ + const PnvChip *chip =3D (PnvChip *)data; + QTestState *qts; + const char *machine =3D pnv_get_machine_type(chip->chip_type); + + /* Defaults to PNV_CHIP_POWER8 */ + uint64_t phb_xscom =3D 0x4809e000; + uint64_t reg_phb_version =3D PHB_VERSION; + uint32_t indirect_addr =3D PHB3_PBCQ_SPCI_ASB_ADDR; + uint32_t indirect_data =3D PHB3_PBCQ_SPCI_ASB_DATA; + uint32_t expected_ver =3D 0xA3; + uint64_t ver; + + if (chip->chip_type =3D=3D PNV_CHIP_POWER9) { + phb_xscom =3D 0x68084800; + indirect_addr =3D PHB_SCOM_HV_IND_ADDR; + indirect_data =3D PHB_SCOM_HV_IND_DATA; + reg_phb_version |=3D PPC_BIT(0); + expected_ver =3D 0xA4; + } else if ((chip->chip_type =3D=3D PNV_CHIP_POWER10) || + (chip->chip_type =3D=3D PNV_CHIP_POWER11)) { + phb_xscom =3D PHB4_XSCOM; + indirect_addr =3D PHB_SCOM_HV_IND_ADDR; + indirect_data =3D PHB_SCOM_HV_IND_DATA; + reg_phb_version |=3D PPC_BIT(0); + expected_ver =3D 0xA5; + } + + qts =3D qtest_initf("-M %s -accel tcg -cpu %s", machine, chip->cpu_mod= el); + + ver =3D pnv_phb_xscom_read(qts, chip, phb_xscom, + indirect_addr, indirect_data, reg_phb_vers= ion); + + /* PHB Version register bits [24:31] */ + ver =3D GETFIELD(PPC_BITMASK(24, 31), ver); + g_assert_cmpuint(ver, =3D=3D, expected_ver); + + qtest_quit(qts); +} + +/* Verify versions of all supported PHB's */ +static void add_phbX_version_test(void) +{ + for (int i =3D 0; i < ARRAY_SIZE(pnv_chips); i++) { + g_autofree char *tname =3D 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 =20 -#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" --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094302; cv=none; d=zohomail.com; s=zohoarc; b=iOWWiNsJTk6Ln5krnUb6AImroI3OQaB22CMCWhN06OYVLJ3OqJuVbx2YYx1mXUYNPxTsPJyZYTp0Hm56gBIZT5HcHhEddHuAb3zMAiRqlHQukvYA68OTLg7G7yGsX/ybZDjr7NhpjP85Xqs6twpeZirEItT5phFYahqT0DnUzss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094302; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2jhXElf7ETstk3JuMzE54TFo4ucB9BO7FL9J1Pp33+U=; b=ZQ49W7rTr/hPnSgZNSf8w6KY7Nns7xymYuiP9drsn8MqhF6uNp6EaFERXrB11iDohXAF667btO5AmyIK+kz5C8zD7AdegMipMcYmy3JjxdTMrOiKEtKLGGXOqRN4+dSlxK1gcGylKRKnNqX2XUsoftggXadsrDZi1ZVW9JhhcUs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094302867710.0287901035035; Tue, 27 Oct 2026 02:45:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjI-0000S9-JT; Tue, 27 Oct 2026 05:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjH-0000Qh-M7; Tue, 27 Oct 2026 05:44:27 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjE-0001PB-OI; Tue, 27 Oct 2026 05:44:27 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5iZpK1525449; Tue, 27 Oct 2026 09:44:16 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmave7r1-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:15 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5Z2WD3644099; Tue, 27 Oct 2026 09:44:14 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh80jj44a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:14 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iD7Z22675984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:13 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A23BE5805A; Tue, 27 Oct 2026 09:44:13 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8A2258052; Tue, 27 Oct 2026 09:44:12 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:12 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=2jhXEl f7ETstk3JuMzE54TFo4ucB9BO7FL9J1Pp33+U=; b=DMjI+K2NIFtRHCw/Xk6X0/ AN/vJjgzaqCWAVnWV2MJpfmuf+XnjBIfhSZ5hFbnmLxvtje1dghHhMSsobPP2rQg uM0hA2A8dRAG8RfRlOiCuhM+pDIuFRX9vhINA8GvyK56ARvqVKSI8WZLWpNSFQJX Ne1ecdft8jr1OzEFKrYNJ5aEZTYl5KRa0QhBL+y3cSjPMdBpoFGjntVGHXXitvsk u4CV1bItLMz2CeJbhmVwcrxc8+sChk1QnEpDS6iTOPdUm2s0ZlnzVg7vosfHYTiO IsnfRwE65sTyBpoIqtDJPhBYReIjIy3HRpniDgY4yvuZj0SyPMjwx4eegOTEGB4w == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 2/9] pnv/phb5: Add reset logic to PHB5 Date: Tue, 27 Oct 2026 04:43:43 -0500 Message-ID: <20261027094350.3645085-3-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=P8SvFSAu c=1 sm=1 tr=0 ts=6ae0726f cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=20KFwNOVAAAA:8 a=7NgIpF3WJFelaHDZircA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: knN4dmkcQb-faLq93aurSRP2Dybzc2pP X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX/i50Vs+B80gM T8Lx82DEtEfExHphq2JKuBvZl8ClPbRh20zy1+b7t1SGwuQhSQZVPY0OTDGEsJwU4zYRQQww10m 1plqCj67NcnxRygIlnpcNTKSS6Cc9uU= X-Proofpoint-ORIG-GUID: tTxFxFQ52QaYZOBa-CywdhOJpSJP0gMl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX2oeZ97+pc1Is SrHP6r3ryUSinem6ANoEb3ltf/2Tolo3rdJO/66P3ESgsikreV2M0lf/gYqxeD68oIQr/+mL7j7 jBtAjiXXb1Iq6KpLRj85m9LDzMVOYiBIAMlbrAOz7guSrQx2b1HMUb4HWeS28pON627h/lFVHgF 79YC39JMr2bbNB4y43PbMH6PiB2Lxfq+RM8KdYw2Od7Hw8sLrLCUfNdXUqXRr6vt44wZRxI22xr CdFa0uVM3MCnZjgXqkT80ds0xHhHMD0/f5JToJcHVxdfKYXqnUI1BRmmH4ZWayLvqgn3CHRs5OC nQaHKz4CQpYrjy8LL9NTG9DoLmwwag1AdpMUeyKR21Nt1uca36HT8AxA3yrgWrCOhdtRUMmkzqE lEFWBUe/i5BaCx82VtQ+Na2FzCbIZefz1w7u3crupLqLTNWYYWLP7cx6wY5+NEp2C4jKkHbLauI GZ4jNRAzHV1heZ1Vpow== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094304055158500 From: Saif Abrar Add a method to be invoked on QEMU reset. Also add CFG and PBL core-blocks reset logic using appropriate bits of PHB_PCIE_CRESET register. Tested by reading the reset value of a register. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Michael S. Tsirkin Reviewed-by: Caleb Schlossin Reviewed-by: Michael Kowal Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb.c | 20 +++--- hw/pci-host/pnv_phb4.c | 58 +++++++++++++++- hw/pci-host/pnv_phb4_pec.c | 2 +- hw/pci-host/pnv_phb5.c | 103 ++++++++++++++++++++++++++++ hw/pci-host/pnv_phb5_pec.c | 1 + hw/ppc/pnv.c | 1 + include/hw/pci-host/pnv_phb4.h | 14 +--- include/hw/pci-host/pnv_phb4_regs.h | 11 ++- include/hw/pci-host/pnv_phb5.h | 44 ++++++++++++ tests/qtest/pnv-phb-test.c | 33 ++++++++- 10 files changed, 257 insertions(+), 30 deletions(-) create mode 100644 include/hw/pci-host/pnv_phb5.h diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c index 0b556d1bf5..75f8b2a549 100644 --- a/hw/pci-host/pnv_phb.c +++ b/hw/pci-host/pnv_phb.c @@ -14,6 +14,7 @@ #include "hw/pci-host/pnv_phb.h" #include "hw/pci-host/pnv_phb3.h" #include "hw/pci-host/pnv_phb4.h" +#include "hw/pci-host/pnv_phb5.h" #include "hw/ppc/pnv.h" #include "hw/core/qdev-properties.h" #include "qom/object.h" @@ -210,7 +211,6 @@ static void pnv_phb_root_port_reset_hold(Object *obj, R= esetType type) PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(obj); PnvPHBRootPort *phb_rp =3D PNV_PHB_ROOT_PORT(obj); PCIDevice *d =3D PCI_DEVICE(obj); - uint8_t *conf =3D d->config; =20 if (rpc->parent_phases.hold) { rpc->parent_phases.hold(obj, type); @@ -221,17 +221,13 @@ static void pnv_phb_root_port_reset_hold(Object *obj,= ResetType type) } =20 /* PHB4 and later requires these extra reset steps */ - pci_byte_test_and_set_mask(conf + PCI_IO_BASE, - PCI_IO_RANGE_MASK & 0xff); - pci_byte_test_and_clear_mask(conf + PCI_IO_LIMIT, - PCI_IO_RANGE_MASK & 0xff); - pci_set_word(conf + PCI_MEMORY_BASE, 0); - pci_set_word(conf + PCI_MEMORY_LIMIT, 0xfff0); - pci_set_word(conf + PCI_PREF_MEMORY_BASE, 0x1); - pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, 0xfff1); - pci_set_long(conf + PCI_PREF_BASE_UPPER32, 0x1); /* Hack */ - pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0xffffffff); - pci_config_set_interrupt_pin(conf, 0); + pnv_phb4_cfg_core_reset(d); + + if (phb_rp->version =3D=3D 4) { + return; + } + + pnv_phb5_cfg_core_reset(d); } =20 static void pnv_phb_root_port_realize(DeviceState *dev, Error **errp) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 9acaf4c0c2..5aea5409a3 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1,7 +1,7 @@ /* * QEMU PowerPC PowerNV (POWER9) PHB4 model * - * Copyright (c) 2018-2020, IBM Corporation. + * Copyright (c) 2018-2026, IBM Corporation. * * This code is licensed under the GPL version 2 or later. See the * COPYING file in the top-level directory. @@ -22,6 +22,7 @@ #include "hw/core/qdev-properties.h" #include "qom/object.h" #include "trace.h" +#include "system/reset.h" =20 #define phb_error(phb, fmt, ...) \ qemu_log_mask(LOG_GUEST_ERROR, "phb4[%d:%d]: " fmt "\n", \ @@ -499,6 +500,37 @@ static void pnv_phb4_update_xsrc(PnvPHB4 *phb) } } =20 +void pnv_phb4_cfg_core_reset(PCIDevice *d) +{ + uint8_t *conf =3D d->config; + + pci_byte_test_and_set_mask(conf + PCI_IO_BASE, + PCI_IO_RANGE_MASK & 0xff); + pci_byte_test_and_clear_mask(conf + PCI_IO_LIMIT, + PCI_IO_RANGE_MASK & 0xff); + pci_set_word(conf + PCI_MEMORY_BASE, 0); + pci_set_word(conf + PCI_MEMORY_LIMIT, 0xfff0); + pci_set_word(conf + PCI_PREF_MEMORY_BASE, 0x1); + pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, 0xfff1); + pci_set_long(conf + PCI_PREF_BASE_UPPER32, 0x1); /* Hack */ + pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0xffffffff); + pci_config_set_interrupt_pin(conf, 0); +} + +static void pnv_phb4_pbl_core_reset(PnvPHB4 *phb) +{ + /* Zero all PBL registers initially */ + for (int i =3D PHB_PBL_CONTROL ; i <=3D PHB_PBL_ERR1_STATUS_MASK ; i += =3D 8) { + phb->regs[i >> 3] =3D 0x0; + } + + /* Set PHB4 specific register values */ + phb->regs[PHB_PBL_CONTROL >> 3] =3D 0xC00000000000000; + phb->regs[PHB_PBL_TIMEOUT_CTRL >> 3] =3D 0x2020000000000000; + phb->regs[PHB_PBL_NPTAG_ENABLE >> 3] =3D 0xFF00000000000000; + phb->regs[PHB_PBL_SYS_LINK_INIT >> 3] =3D 0x80088B4642470000; +} + static void pnv_phb4_reg_write(void *opaque, hwaddr off, uint64_t val, unsigned size) { @@ -612,6 +644,18 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr of= f, uint64_t val, pnv_phb4_update_xsrc(phb); break; =20 + /* Reset core blocks */ + case PHB_PCIE_CRESET: + if (val & PHB_PCIE_CRESET_CFG_CORE) { + PCIHostState *pci =3D PCI_HOST_BRIDGE(phb->phb_base); + + pnv_phb4_cfg_core_reset(pci_find_device(pci->bus, 0, 0)); + } + if (val & PHB_PCIE_CRESET_PBL) { + pnv_phb4_pbl_core_reset(phb); + } + break; + /* Silent simple writes */ case PHB_ASN_CMPM: case PHB_CONFIG_ADDRESS: @@ -1532,6 +1576,13 @@ static PCIIOMMUOps pnv_phb4_iommu_ops =3D { .get_address_space =3D pnv_phb4_dma_iommu, }; =20 +static void pnv_phb4_reset(Object *obj, ResetType type) +{ + PnvPHB4 *phb =3D PNV_PHB4(obj); + + pnv_phb4_pbl_core_reset(phb); +} + static void pnv_phb4_instance_init(Object *obj) { PnvPHB4 *phb =3D PNV_PHB4(obj); @@ -1608,6 +1659,8 @@ static void pnv_phb4_realize(DeviceState *dev, Error = **errp) phb->qirqs =3D qemu_allocate_irqs(xive_source_set_irq, xsrc, xsrc->nr_= irqs); =20 pnv_phb4_xscom_realize(phb); + + qemu_register_resettable(OBJECT(dev)); } =20 /* @@ -1701,12 +1754,15 @@ static void pnv_phb4_class_init(ObjectClass *klass,= const void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); XiveNotifierClass *xfc =3D XIVE_NOTIFIER_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 dc->realize =3D pnv_phb4_realize; device_class_set_props(dc, pnv_phb4_properties); dc->user_creatable =3D false; =20 xfc->notify =3D pnv_phb4_xive_notify; + + rc->phases.enter =3D pnv_phb4_reset; } =20 static const TypeInfo pnv_phb4_type_info =3D { diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index ee5cdc3e45..8f9eab8fff 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -13,6 +13,7 @@ #include "hw/ppc/fdt.h" #include "hw/pci-host/pnv_phb4_regs.h" #include "hw/pci-host/pnv_phb4.h" +#include "hw/pci-host/pnv_phb5.h" #include "hw/ppc/pnv_xscom.h" #include "hw/pci/pci_bridge.h" #include "hw/pci/pci_bus.h" @@ -20,7 +21,6 @@ #include "hw/ppc/pnv_chip.h" #include "hw/core/qdev-properties.h" #include "system/system.h" - #include =20 #define phb_pec_error(pec, fmt, ...) \ diff --git a/hw/pci-host/pnv_phb5.c b/hw/pci-host/pnv_phb5.c index c3f2e16ce6..decfd2ba68 100644 --- a/hw/pci-host/pnv_phb5.c +++ b/hw/pci-host/pnv_phb5.c @@ -7,12 +7,115 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/log.h" +#include "qemu/bswap.h" +#include "qapi/visitor.h" +#include "qapi/error.h" +#include "target/ppc/cpu.h" +#include "hw/pci-host/pnv_phb4_regs.h" #include "hw/pci-host/pnv_phb4.h" +#include "hw/pci-host/pnv_phb5.h" +#include "hw/pci/pcie_host.h" +#include "hw/pci/pcie_port.h" +#include "hw/ppc/pnv.h" +#include "hw/ppc/pnv_xscom.h" +#include "hw/core/irq.h" +#include "hw/core/qdev-properties.h" +#include "qom/object.h" +#include "trace.h" +#include "system/reset.h" + +/* + * Get the PCI-E capability offset from the root-port + */ +static uint32_t get_exp_offset(PCIDevice *pdev) +{ + PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(pdev); + + return rpc->exp_offset; +} + +void pnv_phb5_cfg_core_reset(PCIDevice *d) +{ + uint8_t *conf =3D d->config; + uint32_t exp_offset =3D get_exp_offset(d); + + pci_set_word(conf + PCI_COMMAND, PCI_COMMAND_SERR); + pci_set_word(conf + PCI_STATUS, PCI_STATUS_CAP_LIST); + pci_set_long(conf + PCI_CLASS_REVISION, 0x06040000); + pci_set_long(conf + PCI_CACHE_LINE_SIZE, BIT(16)); + pci_set_word(conf + PCI_MEMORY_BASE, BIT(4)); + pci_set_word(conf + PCI_PREF_MEMORY_BASE, BIT(0) | BIT(4)); + pci_set_word(conf + PCI_PREF_MEMORY_LIMIT, PCI_PREF_RANGE_TYPE_64); + pci_set_long(conf + PCI_CAPABILITY_LIST, BIT(6)); + pci_set_word(conf + PCI_BRIDGE_CONTROL, PCI_BRIDGE_CTL_SERR); + pci_set_long(conf + PCI_BRIDGE_CONTROL + PCI_PM_PMC, 0xC8034801); + + pci_set_long(conf + exp_offset, 0x420010); + pci_set_long(conf + exp_offset + PCI_EXP_DEVCAP, 0x8022); + pci_set_long(conf + exp_offset + PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_EXT_TAG + | PCI_EXP_DEVCTL_PAYLOAD_512= B); + pci_set_long(conf + exp_offset + PCI_EXP_LNKCAP, PCI_EXP_LNKCAP_LBNC + | PCI_EXP_LNKCAP_DLLLARC | BIT(8) | PCI_EXP_LNKCAP_SLS_32= _0GB); + pci_set_word(conf + exp_offset + PCI_EXP_LNKCTL, PCI_EXP_LNKCTL_RCB); + pci_set_long(conf + exp_offset + PCI_EXP_SLTCTL, + PCI_EXP_SLTCTL_ASPL_DIS= ABLE); + pci_set_long(conf + exp_offset + PCI_EXP_DEVCAP2, BIT(16) + | PCI_EXP_DEVCAP2_ARI | PCI_EXP_DEVCAP2_COMP_TMOUT_DIS |= 0xF); + pci_set_long(conf + exp_offset + PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_ARI); + pci_set_long(conf + exp_offset + PCI_EXP_LNKCAP2, BIT(23) + | PCI_EXP_LNKCAP2_SLS_32_0GB + | PCI_EXP_LNKCAP2_SLS_16_0GB | PCI_EXP_LNKCAP2_SLS_= 8_0GB + | PCI_EXP_LNKCAP2_SLS_5_0GB | PCI_EXP_LNKCAP2_SLS_2= _5GB); + pci_set_long(conf + PHB_AER_ECAP, PCI_EXT_CAP(0x1, 0x1, 0x148)); + pci_set_long(conf + PHB_SEC_ECAP, (0x1A0 << 20) | BIT(16) + | PCI_EXT_CAP_ID_SE= CPCI); + pci_set_long(conf + PHB_LMR_ECAP, 0x1E810027); + /* LMR - Margining Lane Control / Status Register # 2 to 16 */ + for (int i =3D PHB_LMR_CTLSTA_2 ; i <=3D PHB_LMR_CTLSTA_16 ; i +=3D 4)= { + pci_set_long(conf + i, 0x9C38); + } + + pci_set_long(conf + PHB_DLF_ECAP, 0x1F410025); + pci_set_long(conf + PHB_DLF_CAP, 0x80000001); + pci_set_long(conf + P16_ECAP, 0x22410026); + pci_set_long(conf + P32_ECAP, 0x1002A); + pci_set_long(conf + P32_CAP, 0x103); +} + +static void pnv_phb5_pbl_core_reset(PnvPHB4 *phb) +{ + /* Zero all PBL registers initially */ + for (int i =3D PHB_PBL_CONTROL ; i <=3D PHB_PBL_ERR1_STATUS_MASK ; i += =3D 8) { + phb->regs[i >> 3] =3D 0x0; + } + + /* Set PHB5 specific register values */ + phb->regs[PHB_PBL_CONTROL >> 3] =3D 0xC009000000000000; + phb->regs[PHB_PBL_TIMEOUT_CTRL >> 3] =3D 0x2020000000000000; + phb->regs[PHB_PBL_NPTAG_ENABLE >> 3] =3D 0xFFFFFFFF00000000; + phb->regs[PHB_PBL_SYS_LINK_INIT >> 3] =3D 0x80088B4642473000; +} + +static void pnv_phb5_reset(Object *obj, ResetType type) +{ + PnvPHB4 *phb =3D PNV_PHB4(obj); + + pnv_phb5_pbl_core_reset(phb); +} + +static void pnv_phb5_class_init(ObjectClass *klass, const void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + rc->phases.enter =3D pnv_phb5_reset; +} =20 static const TypeInfo pnv_phb5_type_info =3D { .name =3D TYPE_PNV_PHB5, .parent =3D TYPE_PNV_PHB4, .instance_size =3D sizeof(PnvPHB4), + .class_init =3D pnv_phb5_class_init }; =20 static void pnv_phb5_register_types(void) diff --git a/hw/pci-host/pnv_phb5_pec.c b/hw/pci-host/pnv_phb5_pec.c index 488ccbfb12..f30d8b772c 100644 --- a/hw/pci-host/pnv_phb5_pec.c +++ b/hw/pci-host/pnv_phb5_pec.c @@ -8,6 +8,7 @@ =20 #include "qemu/osdep.h" #include "hw/pci-host/pnv_phb4.h" +#include "hw/pci-host/pnv_phb5.h" #include "hw/ppc/pnv_xscom.h" =20 #define XPEC_PCI_CPLT_OFFSET 0x1000000ULL diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index f0413639f9..f9478545ff 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -49,6 +49,7 @@ #include "hw/pci-host/pnv_phb.h" #include "hw/pci-host/pnv_phb3.h" #include "hw/pci-host/pnv_phb4.h" +#include "hw/pci-host/pnv_phb5.h" =20 #include "hw/ppc/xics.h" #include "hw/core/qdev-properties.h" diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index de996e718b..0d558f0c55 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -160,6 +160,7 @@ void pnv_phb4_pic_print_info(PnvPHB4 *phb, GString *buf= ); int pnv_phb4_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); PnvPhb4PecState *pnv_pec_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp); void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb); +void pnv_phb4_cfg_core_reset(PCIDevice *d); extern const MemoryRegionOps pnv_phb4_xscom_ops; =20 /* @@ -214,18 +215,5 @@ struct PnvPhb4PecClass { const uint32_t *num_phbs; }; =20 -/* - * POWER10 definitions - */ - -#define TYPE_PNV_PHB5 "pnv-phb5" -#define PNV_PHB5(obj) \ - OBJECT_CHECK(PnvPhb4, (obj), TYPE_PNV_PHB5) - -#define PNV_PHB5_VERSION 0x000000a500000002ull - -#define TYPE_PNV_PHB5_PEC "pnv-phb5-pec" -#define PNV_PHB5_PEC(obj) \ - OBJECT_CHECK(PnvPhb4PecState, (obj), TYPE_PNV_PHB5_PEC) =20 #endif /* PCI_HOST_PNV_PHB4_H */ diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index bea96f4d91..d756b6bb4f 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -343,6 +343,15 @@ #define PHB_RC_CONFIG_BASE 0x1000 #define PHB_RC_CONFIG_SIZE 0x800 =20 +#define PHB_AER_ECAP 0x100 +#define PHB_AER_CAPCTRL 0x118 +#define PHB_SEC_ECAP 0x148 +#define PHB_LMR_ECAP 0x1A0 +#define PHB_LMR_CTLSTA_2 0x1AC +#define PHB_LMR_CTLSTA_16 0x1E4 +#define PHB_DLF_ECAP 0x1E8 +#define PHB_DLF_CAP 0x1EC + /* PHB4 REGB registers */ =20 /* PBL core */ @@ -368,7 +377,7 @@ #define PHB_PCIE_SCR 0x1A00 #define PHB_PCIE_SCR_SLOT_CAP PPC_BIT(15) #define PHB_PCIE_SCR_MAXLINKSPEED PPC_BITMASK(32, 35) - +#define PHB_PCIE_BNR 0x1A08 =20 #define PHB_PCIE_CRESET 0x1A10 #define PHB_PCIE_CRESET_CFG_CORE PPC_BIT(0) diff --git a/include/hw/pci-host/pnv_phb5.h b/include/hw/pci-host/pnv_phb5.h new file mode 100644 index 0000000000..a1d0b4d2b0 --- /dev/null +++ b/include/hw/pci-host/pnv_phb5.h @@ -0,0 +1,44 @@ +/* + * QEMU PowerPC PowerNV (POWER10) PHB5 model + * + * Copyright (c) 2018-2026, IBM Corporation. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef PCI_HOST_PNV_PHB5_H +#define PCI_HOST_PNV_PHB5_H + +#include "hw/pci-host/pnv_phb.h" +#include "hw/pci/pci_bus.h" +#include "hw/ppc/pnv.h" +#include "hw/ppc/pnv_nest_pervasive.h" +#include "hw/ppc/xive.h" +#include "qom/object.h" + +void pnv_phb5_cfg_core_reset(PCIDevice *d); + +/* + * POWER10 definitions + */ + +#define TYPE_PNV_PHB5 "pnv-phb5" +#define PNV_PHB5(obj) \ + OBJECT_CHECK(PnvPHB4, (obj), TYPE_PNV_PHB5) + +#define PNV_PHB5_VERSION 0x000000a500000002ull + +#define TYPE_PNV_PHB5_PEC "pnv-phb5-pec" +#define PNV_PHB5_PEC(obj) \ + OBJECT_CHECK(PnvPhb4PecState, (obj), TYPE_PNV_PHB5_PEC) + +/* New registers in PHB5 from PHB4 */ +#define P16_ECAP 0x1F4 +#define P32_ECAP 0x224 +#define P32_CAP 0x228 + +#define PHB_PCIE_PHY_RXEQ_STAT_G3_00_03 0x1B40 +#define PHB_PCIE_PHY_RXEQ_STAT_G5_12_15 0x1B98 + + +#endif /* PCI_HOST_PNV_PHB5_H */ diff --git a/tests/qtest/pnv-phb-test.c b/tests/qtest/pnv-phb-test.c index b4d75a1229..762046338b 100644 --- a/tests/qtest/pnv-phb-test.c +++ b/tests/qtest/pnv-phb-test.c @@ -16,7 +16,10 @@ #define PHB3_PBCQ_SPCI_ASB_ADDR 0x0 #define PHB3_PBCQ_SPCI_ASB_DATA 0x2 =20 -#define PHB4_XSCOM 0x40084800ull +#define PHB5_XSCOM 0x40084800ull + +/* Index of PNV_CHIP_POWER10 in pnv_chips[] within "pnv-xscom.h" */ +#define PNV_P10_CHIP_INDEX 2 =20 /* SCOM to PCBA address conversion */ #define SCOM_TO_PCBA(scom, addr) (((scom) >> 3) + (addr)) @@ -36,6 +39,29 @@ static uint64_t pnv_phb_xscom_read(QTestState *qts, cons= t PnvChip *chip, indirect_dat= a))); } =20 +#define PHB5_XSCOM_READ(a) pnv_phb_xscom_read(qts, \ + &pnv_chips[PNV_P10_CHIP_INDEX], PHB5_XS= COM, \ + PHB_SCOM_HV_IND_ADDR, PHB_SCOM_HV_IND_D= ATA, \ + PPC_BIT(0) | (a)) + +/* Assert that 'PHB PBL Control' register has correct reset value */ +static void phb5_reset_test(QTestState *qts) +{ + g_assert_cmpuint(PHB5_XSCOM_READ(PHB_PBL_CONTROL), =3D=3D, 0xC00900000= 0000000); +} + +static void phb5_tests(void) +{ + QTestState *qts =3D NULL; + + qts =3D qtest_initf("-machine powernv10 -accel tcg"); + + /* Check reset value of a register */ + phb5_reset_test(qts); + + qtest_quit(qts); +} + /* Assert that 'PHB - Version Register' bits[24:31] are as expected */ static void phb_version_test(const void *data) { @@ -59,7 +85,7 @@ static void phb_version_test(const void *data) expected_ver =3D 0xA4; } else if ((chip->chip_type =3D=3D PNV_CHIP_POWER10) || (chip->chip_type =3D=3D PNV_CHIP_POWER11)) { - phb_xscom =3D PHB4_XSCOM; + phb_xscom =3D PHB5_XSCOM; indirect_addr =3D PHB_SCOM_HV_IND_ADDR; indirect_data =3D PHB_SCOM_HV_IND_DATA; reg_phb_version |=3D PPC_BIT(0); @@ -95,5 +121,8 @@ int main(int argc, char **argv) /* PHB[345] tests */ add_phbX_version_test(); =20 + /* PHB5 specific tests */ + qtest_add_func("phb5", phb5_tests); + return g_test_run(); } --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094310; cv=none; d=zohomail.com; s=zohoarc; b=kLkf1b4uTE0Q4Zy5g7CwwJjnMYALPLSNMPpEWAQ+n4uaos0gWOZtOrduPzwJsgJnE5FVWEl1qp+/dhjCPYARz4GkFNTj1RUGtG2Iv/pcvOvWcHPJB0dDkuwfl9CbCZjOtoY6kKyhXwuyjlv7FLKe5tTIjLBySIfc4DveS6ZwLNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094310; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IMsQIZRB09BJdo5zUbLTP9MvWwJwwlvZSD08cWVfBr8=; b=XMc1LuAQy2AZ2n/7wlJpWZSPRiehfeqcUzlTKGRCgrpeZeJXy3niszt7ViRIwGndyoE15EgSUXJtDT1SHhonIDMy3t6mc1H01xEQVFIhoYiHPEFoxUT0T5frWvCQj7R5k8Y6qPe8cacvLdTQCFK7vUKp8OqHJZNcxu6irCENbU0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094310468237.95046188691072; Tue, 27 Oct 2026 02:45:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjI-0000SQ-Mm; Tue, 27 Oct 2026 05:44:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjF-0000OX-OG; Tue, 27 Oct 2026 05:44:25 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjC-0001OZ-LB; Tue, 27 Oct 2026 05:44:25 -0400 Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5j5lM1625224; Tue, 27 Oct 2026 09:44:17 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgm63xqek-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:16 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5YxUD2510929; Tue, 27 Oct 2026 09:44:15 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hh97gsx7x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:15 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iEUH13238788 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:14 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACD8358056; Tue, 27 Oct 2026 09:44:14 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B4B9458052; Tue, 27 Oct 2026 09:44:13 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:13 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=IMsQIZRB09BJdo5zU bLTP9MvWwJwwlvZSD08cWVfBr8=; b=e7U4OlirnVETnKlmV0jR20X+ndG/skrQS jHuFkgg99n2g02UPtz8sYUzIbg903NJRW5hGlsV4iapApWCXzePiuAC0xP+TKpYK tU+R9+88mP+NG3i06oRxzqyKk7GwoGbpjBHl/9atQ/gLGumH0SNdigRi/L4hXcan 5hPLnu17ojWRK9/ehKhzo6xnuiQ2qSNQSfclxyYFRXuM8JllH5Ho/k0VyuHKGJ5h 3ODoqEwESUwdyCBsSLFIQcUU58wjeQf76h57+5BxegdtzhD1g3ZieezG1GT51ntT UZwkTOYYEP+JeEz/RsFOt2EMBD/MHEmr8dXmwEDq9dSMD5dxkp8gg== From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 3/9] pnv/phb5: Implement sticky reset logic in PHB5 Date: Tue, 27 Oct 2026 04:43:44 -0500 Message-ID: <20261027094350.3645085-4-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX3KtMxUokmCNi MkCErvcxBcVeOrayQOt4EV7w4m+aiTUXpoWzl5yLejWDFFtGEbdC0UKvkeKh0AKNEsf0ocV5j/s i3jAaPV8A5ssnrm/tPmYMq4CAhm1aNI= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX0+n1xRqHxJev R6NYUWclHtptX+aUpt4/isrkngSN331hhHddxn1fRQkcxwD8OuOAhZXotprBx/VF19ud1+dOwOC uhibbToVP3kA6d9maBPNXMTZH/GATdxn1cIdPK2OAywpZHOZ2qGRxDu3AqvgFMG+NdLPWV1PhMd 4KqqQ9HMj+feT4F2kNKEw1qc/+0do+mtl8zwVm1jJxUGao0+5K83AdBFgefttx4Y8BeI6OYW7WA ceUvFe/xJJOIFa0lkS2BqWNeVCu5UQwbFc58ciFpTxE/VxzH6CS6VKI60YplDpknWVA+x89YbzU yPq6F0JuZa1ukXgsS4JL87TrzlZpLdsRxg3TAprpiMF9lAR1y6dgW/3wB4AW40MKO4XNAH5cIpR LmkTu0FtVQ90Pgz8RbKjtwl/P+5irzYAeSAiySQc3XdwaY3qJHBbwZGcEAIg6q264nXMhV7pZJV jYooz0RmqpWM7r9jbxg== X-Proofpoint-ORIG-GUID: YcC36FFYxbvM2pZEzFeu5mjZgOurPbuw X-Authority-Analysis: v=2.4 cv=Uu32pOwB c=1 sm=1 tr=0 ts=6ae07270 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=_OqsxZwj8_jexw0pSn4A:9 X-Proofpoint-GUID: QPzq8BrKtAMNqqfsPAhrs6MhSkx6EQfL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 impostorscore=0 priorityscore=1501 spamscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=saif.abrar@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094312179158500 Content-Type: text/plain; charset="utf-8" From: Saif Abrar Sticky bits retain their values on reset and are not overwritten with the reset value. Added sticky reset logic for all required registers, i.e. CFG core, PBL core, PHB error registers, PCIE stack registers and REGB error registers. Tested by writing all 1's to the reg PHB_PBL_ERR_INJECT. This will set the bits in the reg PHB_PBL_ERR_STATUS. Reset the PBL core by setting PHB_PCIE_CRESET_PBL in reg PHB_PCIE_CRESET. Verify that the sticky bits in the PHB_PBL_ERR_STATUS reg are still set. Signed-off-by: Saif Abrar Reviewed-by: Caleb Schlossin Reviewed-by: Michael Kowal Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 114 +++++++++++++++++++++++++++- hw/pci-host/pnv_phb5.c | 19 +++-- include/hw/pci-host/pnv_phb4.h | 17 +++++ include/hw/pci-host/pnv_phb4_regs.h | 13 +++- include/hw/pci-host/pnv_phb5.h | 7 +- tests/qtest/pnv-phb-test.c | 41 ++++++++++ 6 files changed, 196 insertions(+), 15 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 5aea5409a3..e675caee01 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -500,9 +500,17 @@ static void pnv_phb4_update_xsrc(PnvPHB4 *phb) } } =20 +uint32_t get_exp_offset(PCIDevice *pdev) +{ + PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(pdev); + + return rpc->exp_offset; +} + void pnv_phb4_cfg_core_reset(PCIDevice *d) { uint8_t *conf =3D d->config; + uint32_t exp_offset =3D get_exp_offset(d); =20 pci_byte_test_and_set_mask(conf + PCI_IO_BASE, PCI_IO_RANGE_MASK & 0xff); @@ -515,14 +523,51 @@ void pnv_phb4_cfg_core_reset(PCIDevice *d) pci_set_long(conf + PCI_PREF_BASE_UPPER32, 0x1); /* Hack */ pci_set_long(conf + PCI_PREF_LIMIT_UPPER32, 0xffffffff); pci_config_set_interrupt_pin(conf, 0); + + /* Sticky reset */ + RC_CONFIG_STICKY_RESET(exp_offset + PCI_EXP_LNKCTL2, + PCI_EXP_LNKCTL2_TLS_16_0GT, 0xFE= FFBF); + RC_CONFIG_STICKY_RESET(PHB_AER_UERR, 0, 0x1FF030); + RC_CONFIG_STICKY_RESET(PHB_AER_UERR_MASK, 0, 0x1FF030); + RC_CONFIG_STICKY_RESET(PHB_AER_CERR, 0, 0x11C1); + RC_CONFIG_STICKY_RESET(PHB_AER_ECAP + PCI_ERR_CAP, (PCI_ERR_CAP_ECRC_C= HKC + | PCI_ERR_CAP_ECRC_GENC), 0= x15F); + RC_CONFIG_STICKY_RESET(PHB_AER_HLOG_1, 0, 0xFFFFFFFF); + RC_CONFIG_STICKY_RESET(PHB_AER_HLOG_2, 0, 0xFFFFFFFF); + RC_CONFIG_STICKY_RESET(PHB_AER_HLOG_3, 0, 0xFFFFFFFF); + RC_CONFIG_STICKY_RESET(PHB_AER_HLOG_4, 0, 0xFFFFFFFF); + RC_CONFIG_STICKY_RESET(PHB_AER_RERR, 0, 0x7F); + RC_CONFIG_STICKY_RESET(PHB_AER_ESID, 0, 0xFFFFFFFF); + RC_CONFIG_STICKY_RESET(PHB_DLF_STAT, 0, 0x807FFFFF); } =20 +/* Apply sticky-mask to the reset-value and write to the reg-address */ +#define STICKY_RST(addr, rst_val, sticky_mask) (phb->regs[addr >> 3] =3D \ + ((phb->regs[addr >> 3] & sticky_mask) | (rst_val & ~sticky_mas= k))) + static void pnv_phb4_pbl_core_reset(PnvPHB4 *phb) { - /* Zero all PBL registers initially */ + /* + * Zero all PBL registers initially, + * with sticky reset of certain registers. + */ for (int i =3D PHB_PBL_CONTROL ; i <=3D PHB_PBL_ERR1_STATUS_MASK ; i += =3D 8) { - phb->regs[i >> 3] =3D 0x0; + switch (i) { + case PHB_PBL_ERR_STATUS: + break; + case PHB_PBL_ERR1_STATUS: + case PHB_PBL_ERR_LOG_0: + case PHB_PBL_ERR_LOG_1: + case PHB_PBL_ERR_STATUS_MASK: + case PHB_PBL_ERR1_STATUS_MASK: + STICKY_RST(i, 0, PPC_BITMASK(0, 63)); + break; + default: + phb->regs[i >> 3] =3D 0x0; + } } + STICKY_RST(PHB_PBL_ERR_STATUS, 0, \ + (PPC_BITMASK(0, 9) | PPC_BITMASK(12, 63))); =20 /* Set PHB4 specific register values */ phb->regs[PHB_PBL_CONTROL >> 3] =3D 0xC00000000000000; @@ -656,6 +701,17 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr of= f, uint64_t val, } break; =20 + /* + * Writing bits to a 1 in this register will inject the error correspo= nding + * to the bit that is written. The bits will automatically clear to 0 = after + * the error is injected. The corresponding bit in the Error Status Reg + * should also be set automatically when the error occurs. + */ + case PHB_PBL_ERR_INJECT: + phb->regs[PHB_PBL_ERR_STATUS >> 3] =3D phb->regs[off >> 3]; + phb->regs[off >> 3] =3D 0; + break; + /* Silent simple writes */ case PHB_ASN_CMPM: case PHB_CONFIG_ADDRESS: @@ -1576,11 +1632,65 @@ static PCIIOMMUOps pnv_phb4_iommu_ops =3D { .get_address_space =3D pnv_phb4_dma_iommu, }; =20 +static void pnv_phb4_err_reg_reset(PnvPHB4 *phb) +{ + STICKY_RST(PHB_ERR_STATUS, 0, PPC_BITMASK(0, 33)); + STICKY_RST(PHB_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + + STICKY_RST(PHB_TXE_ERR_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_TXE_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_TXE_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_TXE_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + + STICKY_RST(PHB_RXE_ARB_ERR_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_ARB_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_ARB_ERR_LOG_0, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_ARB_ERR_LOG_1, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_ARB_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_ARB_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + + STICKY_RST(PHB_RXE_MRG_ERR_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_MRG_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_MRG_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_MRG_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + + STICKY_RST(PHB_RXE_TCE_ERR_STATUS, 0, PPC_BITMASK(0, 35)); + STICKY_RST(PHB_RXE_TCE_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_TCE_ERR_LOG_0, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_TCE_ERR_LOG_1, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_TCE_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_RXE_TCE_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); +} + +static void pnv_phb4_pcie_stack_reg_reset(PnvPHB4 *phb) +{ + STICKY_RST(PHB_PCIE_CRESET, 0xE000000000000000, \ + (PHB_PCIE_CRESET_PERST_N | PHB_PCIE_CRESET_REFCLK_= N)); + STICKY_RST(PHB_PCIE_DLP_ERRLOG1, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_PCIE_DLP_ERRLOG2, 0, PPC_BITMASK(0, 31)); + STICKY_RST(PHB_PCIE_DLP_ERR_STATUS, 0, PPC_BITMASK(0, 15)); +} + +static void pnv_phb4_regb_err_reg_reset(PnvPHB4 *phb) +{ + STICKY_RST(PHB_REGB_ERR_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_REGB_ERR1_STATUS, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_REGB_ERR_LOG_0, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_REGB_ERR_LOG_1, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_REGB_ERR_STATUS_MASK, 0, PPC_BITMASK(0, 63)); + STICKY_RST(PHB_REGB_ERR1_STATUS_MASK, 0, PPC_BITMASK(0, 63)); +} + static void pnv_phb4_reset(Object *obj, ResetType type) { PnvPHB4 *phb =3D PNV_PHB4(obj); =20 pnv_phb4_pbl_core_reset(phb); + pnv_phb4_err_reg_reset(phb); + pnv_phb4_pcie_stack_reg_reset(phb); + pnv_phb4_regb_err_reg_reset(phb); } =20 static void pnv_phb4_instance_init(Object *obj) diff --git a/hw/pci-host/pnv_phb5.c b/hw/pci-host/pnv_phb5.c index decfd2ba68..4906a82c6f 100644 --- a/hw/pci-host/pnv_phb5.c +++ b/hw/pci-host/pnv_phb5.c @@ -25,16 +25,6 @@ #include "trace.h" #include "system/reset.h" =20 -/* - * Get the PCI-E capability offset from the root-port - */ -static uint32_t get_exp_offset(PCIDevice *pdev) -{ - PCIERootPortClass *rpc =3D PCIE_ROOT_PORT_GET_CLASS(pdev); - - return rpc->exp_offset; -} - void pnv_phb5_cfg_core_reset(PCIDevice *d) { uint8_t *conf =3D d->config; @@ -81,6 +71,15 @@ void pnv_phb5_cfg_core_reset(PCIDevice *d) pci_set_long(conf + P16_ECAP, 0x22410026); pci_set_long(conf + P32_ECAP, 0x1002A); pci_set_long(conf + P32_CAP, 0x103); + + /* Sticky reset */ + RC_CONFIG_STICKY_RESET(exp_offset + PCI_EXP_LNKCTL2, + PCI_EXP_LNKCTL2_TLS_32_0GT, 0xFE= FFBF); + RC_CONFIG_STICKY_RESET(P16_STAT, 0, 0x1F); + RC_CONFIG_STICKY_RESET(P16_LDPM, 0, 0xFFFF); + RC_CONFIG_STICKY_RESET(P16_FRDPM, 0, 0xFFFF); + RC_CONFIG_STICKY_RESET(P16_SRDPM, 0, 0xFFFF); + RC_CONFIG_STICKY_RESET(P32_CTL, 0, 0x3); } =20 static void pnv_phb5_pbl_core_reset(PnvPHB4 *phb) diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 0d558f0c55..95ba26db53 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -215,5 +215,22 @@ struct PnvPhb4PecClass { const uint32_t *num_phbs; }; =20 +/* + * Get the PCI-E capability offset from the root-port + */ +uint32_t get_exp_offset(PCIDevice *pdev); + +/* + * Apply sticky-mask 's' to the reset-value 'v' and write to the address '= a'. + * RC-config space values and masks are LE. + * Method pnv_phb4_rc_config_read() returns BE, hence convert to LE. + * Compute new value in LE domain. + * New value computation using sticky-mask is in LE. + * Convert the computed value from LE to BE before writing back. + */ +#define RC_CONFIG_STICKY_RESET(a, v, s) \ + (pci_set_word(conf + (a), be16_to_cpu( \ + (be16_to_cpu(pci_get_word(conf + (a))) & (s)) | \ + ((v) & ~(s))))) =20 #endif /* PCI_HOST_PNV_PHB4_H */ diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index d756b6bb4f..59329068d3 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -344,13 +344,23 @@ #define PHB_RC_CONFIG_SIZE 0x800 =20 #define PHB_AER_ECAP 0x100 +#define PHB_AER_UERR 0x104 +#define PHB_AER_UERR_MASK 0x108 +#define PHB_AER_CERR 0x110 #define PHB_AER_CAPCTRL 0x118 +#define PHB_AER_HLOG_1 0x11C +#define PHB_AER_HLOG_2 0x120 +#define PHB_AER_HLOG_3 0x124 +#define PHB_AER_HLOG_4 0x128 +#define PHB_AER_RERR 0x130 +#define PHB_AER_ESID 0x134 #define PHB_SEC_ECAP 0x148 #define PHB_LMR_ECAP 0x1A0 #define PHB_LMR_CTLSTA_2 0x1AC #define PHB_LMR_CTLSTA_16 0x1E4 #define PHB_DLF_ECAP 0x1E8 #define PHB_DLF_CAP 0x1EC +#define PHB_DLF_STAT 0x1F0 =20 /* PHB4 REGB registers */ =20 @@ -385,8 +395,7 @@ #define PHB_PCIE_CRESET_PBL PPC_BIT(2) #define PHB_PCIE_CRESET_PERST_N PPC_BIT(3) #define PHB_PCIE_CRESET_PIPE_N PPC_BIT(4) - - +#define PHB_PCIE_CRESET_REFCLK_N PPC_BIT(8) #define PHB_PCIE_HOTPLUG_STATUS 0x1A20 #define PHB_PCIE_HPSTAT_PRESENCE PPC_BIT(10) =20 diff --git a/include/hw/pci-host/pnv_phb5.h b/include/hw/pci-host/pnv_phb5.h index a1d0b4d2b0..d76846068a 100644 --- a/include/hw/pci-host/pnv_phb5.h +++ b/include/hw/pci-host/pnv_phb5.h @@ -34,9 +34,14 @@ void pnv_phb5_cfg_core_reset(PCIDevice *d); =20 /* New registers in PHB5 from PHB4 */ #define P16_ECAP 0x1F4 +#define P16_STAT 0x200 +#define P16_LDPM 0x204 +#define P16_FRDPM 0x208 +#define P16_SRDPM 0x20C #define P32_ECAP 0x224 #define P32_CAP 0x228 - +#define P32_CTL 0x22C +#define P32_STAT 0x230 #define PHB_PCIE_PHY_RXEQ_STAT_G3_00_03 0x1B40 #define PHB_PCIE_PHY_RXEQ_STAT_G5_12_15 0x1B98 =20 diff --git a/tests/qtest/pnv-phb-test.c b/tests/qtest/pnv-phb-test.c index 762046338b..7ceb08aff4 100644 --- a/tests/qtest/pnv-phb-test.c +++ b/tests/qtest/pnv-phb-test.c @@ -24,6 +24,19 @@ /* SCOM to PCBA address conversion */ #define SCOM_TO_PCBA(scom, addr) (((scom) >> 3) + (addr)) =20 +/* + * Indirect XSCOM write: + * - Write 'Indirect Address Register' with register-offset to write. + * - Write 'Indirect Data Register' with the value. + */ +static void pnv_phb_xscom_write(QTestState *qts, const PnvChip *chip, + uint64_t scom, uint32_t indirect_addr, uint32_t indirect_data, + uint64_t reg, uint64_t val) +{ + qtest_writeq(qts, pnv_xscom_addr(chip, (scom >> 3) + indirect_addr), r= eg); + qtest_writeq(qts, pnv_xscom_addr(chip, (scom >> 3) + indirect_data), v= al); +} + /* * Indirect XSCOM read:: * - Write 'Indirect Address Register' with register-offset to read. @@ -39,6 +52,11 @@ static uint64_t pnv_phb_xscom_read(QTestState *qts, cons= t PnvChip *chip, indirect_dat= a))); } =20 +#define PHB5_XSCOM_WRITE(a, v) pnv_phb_xscom_write(qts, \ + &pnv_chips[PNV_P10_CHIP_INDEX], PHB5_XS= COM, \ + PHB_SCOM_HV_IND_ADDR, PHB_SCOM_HV_IND_D= ATA, \ + PPC_BIT(0) | (a), (v)) + #define PHB5_XSCOM_READ(a) pnv_phb_xscom_read(qts, \ &pnv_chips[PNV_P10_CHIP_INDEX], PHB5_XS= COM, \ PHB_SCOM_HV_IND_ADDR, PHB_SCOM_HV_IND_D= ATA, \ @@ -50,6 +68,26 @@ static void phb5_reset_test(QTestState *qts) g_assert_cmpuint(PHB5_XSCOM_READ(PHB_PBL_CONTROL), =3D=3D, 0xC00900000= 0000000); } =20 +/* Check sticky-reset */ +static void phb5_sticky_rst_test(QTestState *qts) +{ + uint64_t val; + + /* + * Sticky reset test of PHB_PBL_ERR_STATUS. + * + * Write all 1's to reg PHB_PBL_ERR_INJECT. + * Updated value will be copied to reg PHB_PBL_ERR_STATUS. + * + * Reset PBL core by setting PHB_PCIE_CRESET_PBL in reg PHB_PCIE_CRESE= T. + * Verify the sticky bits are still set. + */ + PHB5_XSCOM_WRITE(PHB_PBL_ERR_INJECT, PPC_BITMASK(0, 63)); + PHB5_XSCOM_WRITE(PHB_PCIE_CRESET, PHB_PCIE_CRESET_PBL); /*Reset*/ + val =3D PHB5_XSCOM_READ(PHB_PBL_ERR_STATUS); + g_assert_cmpuint(val, =3D=3D, (PPC_BITMASK(0, 9) | PPC_BITMASK(12, 63)= )); +} + static void phb5_tests(void) { QTestState *qts =3D NULL; @@ -59,6 +97,9 @@ static void phb5_tests(void) /* Check reset value of a register */ phb5_reset_test(qts); =20 + /* Check sticky reset of a register */ + phb5_sticky_rst_test(qts); + qtest_quit(qts); } =20 --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094341; cv=none; d=zohomail.com; s=zohoarc; b=CDstBIz7TYnwz3goG6qfXMhQnWQ9ws3PEq1N9dosm7YFjvtxy1hUHhK84l0sM04kftEWfox1IjNFxQJsbs0gTqz6fkqKCAE/L49rQDJW0US/FCyMBlJa96H7DgMDuRavResak4dwLdKVZ8+GO/JuxeWhcY7qEK3ZUTqBrDHfwvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094341; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ufrCGgVVrTd6c9AkMfQ6ag6OPQQo0geeSjn9bB7yafU=; b=chvSZn3hiog9omRAwo7k9iHR6ima7X7puRKF+yei06qCNL1UT88wcUUIM9hspTLVONzGAEzYG1tBkLJtURVxq5dPYtosCUGcmDPYYXM95oeHJS6nYGfzxb7v3y5Zx3aAa75bxDl45M0cI5l4pSvNxPbDZf3AuZ19thwHqzYpg9U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094341423173.47704646134503; Tue, 27 Oct 2026 02:45:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjK-0000UJ-RI; Tue, 27 Oct 2026 05:44:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjJ-0000TP-Ra; Tue, 27 Oct 2026 05:44:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjH-0001PX-5c; Tue, 27 Oct 2026 05:44:29 -0400 Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5iRPc354189; Tue, 27 Oct 2026 09:44:18 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgk3fxh8g-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:17 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5YrsJ3643708; Tue, 27 Oct 2026 09:44:17 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh80jj44c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:17 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iFO465274132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:16 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B03955805E; Tue, 27 Oct 2026 09:44:15 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFD015805A; Tue, 27 Oct 2026 09:44:14 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:14 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=ufrCGg VVrTd6c9AkMfQ6ag6OPQQo0geeSjn9bB7yafU=; b=prtGBfkV8u0DBjx7su0YXn lwGNOha3Vg7iTa7+mWarFo6NG+tzJDL98pdQeLApD8rHW/JNCEE0UMZ96ZP1oci4 avTxnrQSgSJfHWoP8qxY0JDL9jb2UjFs7wXPKfxJRw7mV6b7QqPqOVgtXUBrln2N mp6Ms38StskqyVfMzt6lGVja9tpCMMaEv9Kbhyn0N9gEJz+mvLxRePJBveNYjwWL kglT2h36jjoqmgPtC53P2TMi7a+3jinVY9kSy306ju3OBvi6Y4P/jzj1moQg5m81 V1fTc8/6St4ALKc1AZwj92Sdse2Ra54p89unW0HrfP765pAKHMgpWq8xQUFi/jWA == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 4/9] pnv/phb5: Implement read-only and write-only bits of registers Date: Tue, 27 Oct 2026 04:43:45 -0500 Message-ID: <20261027094350.3645085-5-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=BOMmP1QG c=1 sm=1 tr=0 ts=6ae07272 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=20KFwNOVAAAA:8 a=djULNIhFhI7Ibwp2e0QA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-ORIG-GUID: VovbV4-Y2v2U0XiYIfdvplCxWjbU84A0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfXz7LLgXpcxI4C 1qnD36Z7YeGap6EKqyCZ/cuBoCLJqQmAk/0PA+rAE+iPRLpsl/6NMdrIFQb4NjvXJ2bya07cddB E/GLJFsDYRcJ0iOSwrUBFalxsQu+k086F7MxHTvL8y7lVvGAEiJneM5ZNjPmou0YAImiLrilNvQ 8bR1YQCZeqyPdv4aLgiUmUVTD1Ky2MoNLeIFuY3OqjM77wzcXIyz1AX4tsHENA0946cFW0g514t 5b9npCK6ROTP4G32A3vYTQjS9iENlgOXAHaLkL1FmF9a4XvFwE5e2QldodTDhIIz6H8KI1p6OOp ynrA6VohGZPzgGVMmjyLvE+a4orcHmR3ttPm9A969ThPLedjwJiE+MglnXTFYSGcThplyTlf/An cwEnw2Gga3CA3hCKwpcTdwkYbHOmLTlxj/dXbT21CTdbjfHdcDKad09uyl4Vmu6P1QTW/yftWa1 +AOf4sgyTsBAfK1gTug== X-Proofpoint-GUID: pkmnvdvPdbj9_DwYHyPWSngJsaV8e5yp X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX9vlBW797aSmu DdS9eGj7XF5sOTQ3Mgf4ftQ0jFOWcyBHG3dqT3o0n+rNxORHQ1fVkRRdFIQJtij/MfMPmhMTZGL aqP7eTZm1uQaNLoxcXISnEcMOwZ0Wrc= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 malwarescore=0 clxscore=1015 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094342425158500 From: Saif Abrar SW cannot write the read-only(RO) bits of a register and write-only(WO) bits of a register return 0 when read. Added ro_mask[] for each register that defines which bits in that register are RO. When writing to a register, the RO-bits are not updated. When reading a register, clear the WO bits and return the updated value. Tested the registers PHB_DMA_SYNC, PHB_PCIE_HOTPLUG_STATUS, PHB_PCIE_LMR, PHB_PCIE_DLP_TRWCTL, PHB_LEM_ERROR_AND_MASK and PHB_LEM_ERROR_OR_MASK by writing all 1's and reading back the value. The WO bits in these registers should read back as 0. Add .class_size in pnv_phb4_type_info. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: "Michael S. Tsirkin" Reviewed-by: Caleb Schlossin Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 79 ++++++++++++++++++++++++++--- include/hw/pci-host/pnv_phb4.h | 13 ++++- include/hw/pci-host/pnv_phb4_regs.h | 19 +++++-- tests/qtest/pnv-phb-test.c | 63 ++++++++++++++++++++++- 4 files changed, 160 insertions(+), 14 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index e675caee01..e0330d1c2e 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -653,6 +653,12 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr of= f, uint64_t val, return; } =20 + /* Update 'val' according to the register's RO-mask */ + PnvPHB4Class *k =3D PNV_PHB4_GET_CLASS(phb); + + val =3D (phb->regs[off >> 3] & k->ro_mask[off >> 3]) | + (val & ~(k->ro_mask[off >> 3])); + /* Record whether it changed */ changed =3D phb->regs[off >> 3] !=3D val; =20 @@ -728,7 +734,7 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr off= , uint64_t val, case PHB_TCE_TAG_ENABLE: case PHB_INT_NOTIFY_ADDR: case PHB_INT_NOTIFY_INDEX: - case PHB_DMARD_SYNC: + case PHB_DMA_SYNC: break; =20 /* Noise on anything else */ @@ -766,7 +772,7 @@ static uint64_t pnv_phb4_reg_read(void *opaque, hwaddr = off, unsigned size) case PHB_VERSION: return PNV_PHB4_PEC_GET_CLASS(phb->pec)->version; =20 - /* Read-only */ + /* Read-only */ case PHB_PHB4_GEN_CAP: return 0xe4b8000000000000ull; case PHB_PHB4_TCE_CAP: @@ -776,18 +782,49 @@ static uint64_t pnv_phb4_reg_read(void *opaque, hwadd= r off, unsigned size) case PHB_PHB4_EEH_CAP: return phb->big_phb ? 0x2000000000000000ull : 0x1000000000000000ul= l; =20 + /* Write-only, read will return zeros */ + case PHB_LEM_ERROR_AND_MASK: + case PHB_LEM_ERROR_OR_MASK: + return 0; + case PHB_PCIE_DLP_TRWCTL: + val &=3D ~PHB_PCIE_DLP_TRWCTL_WREN; + return val; /* IODA table accesses */ case PHB_IODA_DATA0: return pnv_phb4_ioda_read(phb); =20 + /* + * DMA sync: make it look like it's complete, + * clear write-only read/write start sync bits. + */ + case PHB_DMA_SYNC: + val =3D PHB_DMA_SYNC_RD_COMPLETE | + ~(PHB_DMA_SYNC_RD_START | PHB_DMA_SYNC_WR_START); + return val; + + /* + * PCI-E Stack registers + */ + case PHB_PCIE_SCR: + val |=3D PHB_PCIE_SCR_PLW_X16; /* RO bit */ + break; + /* Link training always appears trained */ case PHB_PCIE_DLP_TRAIN_CTL: /* TODO: Do something sensible with speed ? */ - return PHB_PCIE_DLP_INBAND_PRESENCE | PHB_PCIE_DLP_TL_LINKACT; + val |=3D PHB_PCIE_DLP_INBAND_PRESENCE | PHB_PCIE_DLP_TL_LINKACT; + return val; + + case PHB_PCIE_HOTPLUG_STATUS: + /* Clear write-only bit */ + val &=3D ~PHB_PCIE_HPSTAT_RESAMPLE; + return val; =20 - /* DMA read sync: make it look like it's complete */ - case PHB_DMARD_SYNC: - return PHB_DMARD_SYNC_COMPLETE; + /* Link Management Register */ + case PHB_PCIE_LMR: + /* These write-only bits always read as 0 */ + val &=3D ~(PHB_PCIE_LMR_CHANGELW | PHB_PCIE_LMR_RETRAINLINK); + return val; =20 /* Silent simple reads */ case PHB_LSI_SOURCE_ID: @@ -1632,6 +1669,30 @@ static PCIIOMMUOps pnv_phb4_iommu_ops =3D { .get_address_space =3D pnv_phb4_dma_iommu, }; =20 +static void pnv_phb4_ro_mask_init(PnvPHB4Class *phb4c) +{ + /* + * Set register specific RO-masks + */ + + /* PBL - Error Injection Register (0x1910) */ + phb4c->ro_mask[PHB_PBL_ERR_INJECT >> 3] =3D + PPC_BITMASK(0, 23) | PPC_BITMASK(28, 35) | PPC_BIT(38) | PPC_BIT(4= 6) | + PPC_BITMASK(49, 51) | PPC_BITMASK(55, 63); + + /* Reserved bits[60:63] */ + phb4c->ro_mask[PHB_TXE_ERR_LEM_ENABLE >> 3] =3D + phb4c->ro_mask[PHB_TXE_ERR_AIB_FENCE_ENABLE >> 3] =3D PPC_BITMASK(60, = 63); + /* Reserved bits[36:63] */ + phb4c->ro_mask[PHB_RXE_TCE_ERR_LEM_ENABLE >> 3] =3D + phb4c->ro_mask[PHB_RXE_TCE_ERR_AIB_FENCE_ENABLE >> 3] =3D PPC_BITMASK(= 36, 63); + /* Reserved bits[40:63] */ + phb4c->ro_mask[PHB_ERR_LEM_ENABLE >> 3] =3D + phb4c->ro_mask[PHB_ERR_AIB_FENCE_ENABLE >> 3] =3D PPC_BITMASK(40, 63); + + /* TODO: Add more RO-masks as regs are implemented in the model */ +} + static void pnv_phb4_err_reg_reset(PnvPHB4 *phb) { STICKY_RST(PHB_ERR_STATUS, 0, PPC_BITMASK(0, 33)); @@ -1691,6 +1752,7 @@ static void pnv_phb4_reset(Object *obj, ResetType typ= e) pnv_phb4_err_reg_reset(phb); pnv_phb4_pcie_stack_reg_reset(phb); pnv_phb4_regb_err_reg_reset(phb); + phb->regs[PHB_PCIE_CRESET >> 3] =3D 0xE000000000000000; } =20 static void pnv_phb4_instance_init(Object *obj) @@ -1865,6 +1927,7 @@ static void pnv_phb4_class_init(ObjectClass *klass, c= onst void *data) DeviceClass *dc =3D DEVICE_CLASS(klass); XiveNotifierClass *xfc =3D XIVE_NOTIFIER_CLASS(klass); ResettableClass *rc =3D RESETTABLE_CLASS(klass); + PnvPHB4Class *phb4c =3D PNV_PHB4_CLASS(klass); =20 dc->realize =3D pnv_phb4_realize; device_class_set_props(dc, pnv_phb4_properties); @@ -1873,6 +1936,9 @@ static void pnv_phb4_class_init(ObjectClass *klass, c= onst void *data) xfc->notify =3D pnv_phb4_xive_notify; =20 rc->phases.enter =3D pnv_phb4_reset; + + /* Initialize RO-mask of registers */ + pnv_phb4_ro_mask_init(phb4c); } =20 static const TypeInfo pnv_phb4_type_info =3D { @@ -1880,6 +1946,7 @@ static const TypeInfo pnv_phb4_type_info =3D { .parent =3D TYPE_DEVICE, .instance_init =3D pnv_phb4_instance_init, .instance_size =3D sizeof(PnvPHB4), + .class_size =3D sizeof(PnvPHB4Class), .class_init =3D pnv_phb4_class_init, .interfaces =3D (const InterfaceInfo[]) { { TYPE_XIVE_NOTIFIER }, diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 95ba26db53..567a3e6e95 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -19,7 +19,7 @@ =20 =20 #define TYPE_PNV_PHB4 "pnv-phb4" -OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4) +OBJECT_DECLARE_TYPE(PnvPHB4, PnvPHB4Class, PNV_PHB4) =20 typedef struct PnvPhb4PecStack PnvPhb4PecStack; =20 @@ -156,6 +156,17 @@ struct PnvPHB4 { QLIST_HEAD(, PnvPhb4DMASpace) dma_spaces; }; =20 +typedef struct PnvPHB4Class { + DeviceClass parent_class; + + /* + * Read-only bitmask for registers + * Bit value: 1 =3D> RO bit + * 0 =3D> RW bit + */ + uint64_t ro_mask[PNV_PHB4_NUM_REGS]; +} PnvPHB4Class; + void pnv_phb4_pic_print_info(PnvPHB4 *phb, GString *buf); int pnv_phb4_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); PnvPhb4PecState *pnv_pec_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp); diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index 59329068d3..d0962c1607 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -180,9 +180,11 @@ #define PHB_M64_AOMASK 0x1d0 #define PHB_M64_UPPER_BITS 0x1f0 #define PHB_NXLATE_PREFIX 0x1f8 -#define PHB_DMARD_SYNC 0x200 -#define PHB_DMARD_SYNC_START PPC_BIT(0) -#define PHB_DMARD_SYNC_COMPLETE PPC_BIT(1) +#define PHB_DMA_SYNC 0x200 +#define PHB_DMA_SYNC_RD_START PPC_BIT(0) +#define PHB_DMA_SYNC_RD_COMPLETE PPC_BIT(1) +#define PHB_DMA_SYNC_WR_START PPC_BIT(2) +#define PHB_DMA_SYNC_WR_COMPLETE PPC_BIT(3) #define PHB_RTC_INVALIDATE 0x208 #define PHB_RTC_INVALIDATE_ALL PPC_BIT(0) #define PHB_RTC_INVALIDATE_RID PPC_BITMASK(16, 31) @@ -387,8 +389,8 @@ #define PHB_PCIE_SCR 0x1A00 #define PHB_PCIE_SCR_SLOT_CAP PPC_BIT(15) #define PHB_PCIE_SCR_MAXLINKSPEED PPC_BITMASK(32, 35) +#define PHB_PCIE_SCR_PLW_X16 PPC_BIT(41) /* x16 */ #define PHB_PCIE_BNR 0x1A08 - #define PHB_PCIE_CRESET 0x1A10 #define PHB_PCIE_CRESET_CFG_CORE PPC_BIT(0) #define PHB_PCIE_CRESET_TLDLP PPC_BIT(1) @@ -397,7 +399,14 @@ #define PHB_PCIE_CRESET_PIPE_N PPC_BIT(4) #define PHB_PCIE_CRESET_REFCLK_N PPC_BIT(8) #define PHB_PCIE_HOTPLUG_STATUS 0x1A20 +#define PHB_PCIE_HPSTAT_SIMDIAG PPC_BIT(3) +#define PHB_PCIE_HPSTAT_RESAMPLE PPC_BIT(9) #define PHB_PCIE_HPSTAT_PRESENCE PPC_BIT(10) +#define PHB_PCIE_HPSTAT_LINKACTIVE PPC_BIT(12) +#define PHB_PCIE_LMR 0x1A30 +#define PHB_PCIE_LMR_CHANGELW PPC_BIT(0) +#define PHB_PCIE_LMR_RETRAINLINK PPC_BIT(1) +#define PHB_PCIE_LMR_LINKACTIVE PPC_BIT(8) =20 #define PHB_PCIE_DLP_TRAIN_CTL 0x1A40 #define PHB_PCIE_DLP_LINK_WIDTH PPC_BITMASK(30, 35) @@ -425,7 +434,7 @@ =20 #define PHB_PCIE_DLP_TRWCTL 0x1A80 #define PHB_PCIE_DLP_TRWCTL_EN PPC_BIT(0) - +#define PHB_PCIE_DLP_TRWCTL_WREN PPC_BIT(1) #define PHB_PCIE_DLP_ERRLOG1 0x1AA0 #define PHB_PCIE_DLP_ERRLOG2 0x1AA8 #define PHB_PCIE_DLP_ERR_STATUS 0x1AB0 diff --git a/tests/qtest/pnv-phb-test.c b/tests/qtest/pnv-phb-test.c index 7ceb08aff4..7e9127f81e 100644 --- a/tests/qtest/pnv-phb-test.c +++ b/tests/qtest/pnv-phb-test.c @@ -77,7 +77,8 @@ static void phb5_sticky_rst_test(QTestState *qts) * Sticky reset test of PHB_PBL_ERR_STATUS. * * Write all 1's to reg PHB_PBL_ERR_INJECT. - * Updated value will be copied to reg PHB_PBL_ERR_STATUS. + * RO-only bits will not be written and + * updated value will be copied to reg PHB_PBL_ERR_STATUS. * * Reset PBL core by setting PHB_PCIE_CRESET_PBL in reg PHB_PCIE_CRESE= T. * Verify the sticky bits are still set. @@ -85,7 +86,62 @@ static void phb5_sticky_rst_test(QTestState *qts) PHB5_XSCOM_WRITE(PHB_PBL_ERR_INJECT, PPC_BITMASK(0, 63)); PHB5_XSCOM_WRITE(PHB_PCIE_CRESET, PHB_PCIE_CRESET_PBL); /*Reset*/ val =3D PHB5_XSCOM_READ(PHB_PBL_ERR_STATUS); - g_assert_cmpuint(val, =3D=3D, (PPC_BITMASK(0, 9) | PPC_BITMASK(12, 63)= )); + g_assert_cmpuint(val, =3D=3D, (PPC_BITMASK(24, 27) | PPC_BITMASK(36, 3= 7) | + PPC_BITMASK(39, 45) | PPC_BITMASK(47, 48) | + PPC_BITMASK(52, 54))); + +} + +/* Check that write-only bits/regs return 0 when read */ +static void phb4_writeonly_read_test(QTestState *qts) +{ + uint64_t val; + + /* + * Set all bits of PHB_DMA_SYNC, + * bits 0 and 2 are write-only and should be read as 0. + */ + PHB5_XSCOM_WRITE(PHB_DMA_SYNC, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_DMA_SYNC); + g_assert_cmpuint(val & PPC_BIT(0), =3D=3D, 0x0); + g_assert_cmpuint(val & PPC_BIT(2), =3D=3D, 0x0); + + /* + * Set all bits of PHB_PCIE_HOTPLUG_STATUS, + * bit 9 is write-only and should be read as 0. + */ + PHB5_XSCOM_WRITE(PHB_PCIE_HOTPLUG_STATUS, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_PCIE_HOTPLUG_STATUS); + g_assert_cmpuint(val & PPC_BIT(9), =3D=3D, 0x0); + + /* + * Set all bits of PHB_PCIE_LMR, + * bits 0 and 1 are write-only and should be read as 0. + */ + PHB5_XSCOM_WRITE(PHB_PCIE_LMR, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_PCIE_LMR); + g_assert_cmpuint(val & PPC_BIT(0), =3D=3D, 0x0); + g_assert_cmpuint(val & PPC_BIT(1), =3D=3D, 0x0); + + /* + * Set all bits of PHB_PCIE_DLP_TRWCTL, + * write-only bit-1 should be read as 0. + */ + PHB5_XSCOM_WRITE(PHB_PCIE_DLP_TRWCTL, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_PCIE_DLP_TRWCTL); + g_assert_cmpuint(val & PPC_BIT(1), =3D=3D, 0x0); + + /* + * Set all bits of PHB_LEM_ERROR_AND_MASK, PHB_LEM_ERROR_OR_MASK, + * both regs are write-only and should be read as 0. + */ + PHB5_XSCOM_WRITE(PHB_LEM_ERROR_AND_MASK, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_LEM_ERROR_AND_MASK); + g_assert_cmpuint(val, =3D=3D, 0x0); + + PHB5_XSCOM_WRITE(PHB_LEM_ERROR_OR_MASK, PPC_BITMASK(0, 63)); + val =3D PHB5_XSCOM_READ(PHB_LEM_ERROR_OR_MASK); + g_assert_cmpuint(val, =3D=3D, 0x0); } =20 static void phb5_tests(void) @@ -100,6 +156,9 @@ static void phb5_tests(void) /* Check sticky reset of a register */ phb5_sticky_rst_test(qts); =20 + /* Check write-only logic */ + phb4_writeonly_read_test(qts); + qtest_quit(qts); } =20 --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094340; cv=none; d=zohomail.com; s=zohoarc; b=hDNuPyfEX/v2cPOzfRD8N5CTkcPbLutd83SiuE3as/i8uhd5ri/2tI15sVboQ7POlt2r9iosSd2mgc1l6Phgio6MuiRcmfqM7DrrXSKFb0M9wsstz+Bw1KwKv31Dw3Tee9WfTHT0EQfiij0i9150t/Ye1G/fC3TcDA/RX2OO4I4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094340; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IFwp4oXFmxaDz2aAKyeDAdNFb9Fxjnv/MP6lD7pnYyI=; b=UzYlOATeiqxR4OBWCltnEPfcqdHP9BZveSfvDT7nLNKwxuZZXui0PJVV/uWiSgVEjAXyZsheltdF50Y3Og+ippZhk7Wq/4VpdW8rPBlRA7EnW/pmUbtseuqy/bdktQAkV+pZqHcuapqymv4/0fhbcqn/YTeqZEd3xLGcIxtMHMI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094340917822.2581399993832; Tue, 27 Oct 2026 02:45:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjd-0000rt-Tm; Tue, 27 Oct 2026 05:44:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdja-0000mj-MA; Tue, 27 Oct 2026 05:44:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjX-0001RV-1q; Tue, 27 Oct 2026 05:44:46 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5ikgL1527596; Tue, 27 Oct 2026 09:44:20 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmave7rd-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:19 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5YrUs3747093; Tue, 27 Oct 2026 09:44:18 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hh9py9vcw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:18 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iGnK28639900 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:17 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC72B58056; Tue, 27 Oct 2026 09:44:16 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C336658052; Tue, 27 Oct 2026 09:44:15 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:15 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=IFwp4o XFmxaDz2aAKyeDAdNFb9Fxjnv/MP6lD7pnYyI=; b=A0ucG7YXCev77GJgawiBGT xJVDl+POhWVwKuANd6Xz1CdrDqTKkfaFa6+MWrB9fyb6pUvtvpPF4S3TYCyf7UUf LN3F02g79IUQfMcgWDgGd2JybJfGMiIor8C+z5V5ld+V/4oZWuNPGqMGI/IdyRs9 aswBdcynDrk0iSt09dsR/A2RbvpZihgw5CzjdDlsUGKer/KXs3JRpwomXWVjwMm+ iKsdnsetxRPFVTS+B7BRUyCLX1BMkh0v5YPMxy6t4MaXmbsYrjEvKaiCS8viVn1a A+wVy/eruapMAQmagMaLgJEalPt6N7Whxpul3zXG7VX/K27MMU9EHZ+yPvvN8dkg == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 5/9] pnv/phb5: Implement write-clear and return 1's on unimplemented reg read Date: Tue, 27 Oct 2026 04:43:46 -0500 Message-ID: <20261027094350.3645085-6-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=P8SvFSAu c=1 sm=1 tr=0 ts=6ae07273 cx=c_pps a=aDMHemPKRhS1OARIsFnwRA==:117 a=aDMHemPKRhS1OARIsFnwRA==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=5RaDrMxcQoNUQC0trd8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: 15XfNO2mYfP-d-UqVovnrXBSemsx7wvY X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX51Cj2tWZtQlU g3b7hrC8QZNMkzFlgWgkq9/2Jo+ECEHTwuBS9Yza/kRVZbfmsCd8awCjOr/LhgSaCe96fEgEnJM EWiDi9gNSjF1/j9wyH98OzWc1X63G4E= X-Proofpoint-ORIG-GUID: YsxyRE6JMH5TTw-yX-mpfMo55JS48XfN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX9VEMwnilQLj5 J+G1hNxJviuoMWAMr7+FRJI5Shb1P3JFTPdEhsE5uRENLgYLqe+pOj0zal5Rw8RKlUxmSD1MtmZ fPT94w4P+K6f0TGsNmKaBCHR8H0Lmn3427LEjm3T8fVmXe6t7k76AIncmvjqDRcVe/ljANCgHsD luLTP8m7sLDnCIr2I0CCl6kzMlALyPtCONoZ7AyNCDuxgdkDJtZ0NVbx2u9+oMOmituFZH0naOi BL229v9W3TS/J6V06gsKV+yMOIeiDzLg8kRjgk4LnTqEPMVvQOoUxQ3SJy/85IN5BeyyYPPSnHZ Xs3vgk4VJFtOt2NDGF7NuPl/1DbWUO5GMGh+y3KzOCmzfKBBKcR+uUJFuyIxir/S5PFsF9FeaKA O+3ljBocPcz4a99YZ5ZzEBbOKfD2GqX/LqmwT0QeYEvkTv8GnKEi2vBL3LAEqv2dYNs0jgTPr4g EIQ1UeJyoteIwHTRVgA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094342331158500 From: Saif Abrar Implement write-1-to-clear and write-X-to-clear logic. Update registers with silent simple read and write. Return all 1's when an unimplemented/reserved register is read. Test that reading address 0x0 returns all 1's (i.e. -1). Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Caleb Schlossin Reviewed-by: Michael Kowal Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 201 ++++++++++++++++++++++------ hw/pci-host/pnv_phb5.c | 110 ++++++++++++++- include/hw/pci-host/pnv_phb4.h | 3 + include/hw/pci-host/pnv_phb4_regs.h | 14 +- include/hw/pci-host/pnv_phb5.h | 17 ++- tests/qtest/pnv-phb-test.c | 14 +- 6 files changed, 304 insertions(+), 55 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index e0330d1c2e..378870268a 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -1,7 +1,7 @@ /* * QEMU PowerPC PowerNV (POWER9) PHB4 model * - * Copyright (c) 2018-2026, IBM Corporation. + * Copyright (c) 2018-2025, IBM Corporation. * * This code is licensed under the GPL version 2 or later. See the * COPYING file in the top-level directory. @@ -539,6 +539,10 @@ void pnv_phb4_cfg_core_reset(PCIDevice *d) RC_CONFIG_STICKY_RESET(PHB_AER_RERR, 0, 0x7F); RC_CONFIG_STICKY_RESET(PHB_AER_ESID, 0, 0xFFFFFFFF); RC_CONFIG_STICKY_RESET(PHB_DLF_STAT, 0, 0x807FFFFF); + RC_CONFIG_STICKY_RESET(P16_STAT, 0, 0x1F); + RC_CONFIG_STICKY_RESET(P16_LDPM, 0, 0xFFFF); + RC_CONFIG_STICKY_RESET(P16_FRDPM, 0, 0xFFFF); + RC_CONFIG_STICKY_RESET(P16_SRDPM, 0, 0xFFFF); } =20 /* Apply sticky-mask to the reset-value and write to the reg-address */ @@ -576,7 +580,7 @@ static void pnv_phb4_pbl_core_reset(PnvPHB4 *phb) phb->regs[PHB_PBL_SYS_LINK_INIT >> 3] =3D 0x80088B4642470000; } =20 -static void pnv_phb4_reg_write(void *opaque, hwaddr off, uint64_t val, +void pnv_phb4_reg_write(void *opaque, hwaddr off, uint64_t val, unsigned size) { PnvPHB4 *phb =3D PNV_PHB4(opaque); @@ -601,8 +605,41 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr of= f, uint64_t val, return; } =20 - /* Handle masking */ + /* Handle RO, W1C, WxC and masking */ switch (off) { + /* W1C: Write-1-to-Clear registers */ + case PHB_TXE_ERR_STATUS: + case PHB_RXE_ARB_ERR_STATUS: + case PHB_RXE_MRG_ERR_STATUS: + case PHB_RXE_TCE_ERR_STATUS: + case PHB_ERR_STATUS: + case PHB_REGB_ERR_STATUS: + case PHB_PCIE_DLP_ERRLOG1: + case PHB_PCIE_DLP_ERRLOG2: + case PHB_PCIE_DLP_ERR_STATUS: + case PHB_PBL_ERR_STATUS: + phb->regs[off >> 3] &=3D ~val; + return; + + /* WxC: Clear register on any write */ + case PHB_PBL_ERR1_STATUS: + case PHB_PBL_ERR_LOG_0 ... PHB_PBL_ERR_LOG_1: + case PHB_REGB_ERR1_STATUS: + case PHB_REGB_ERR_LOG_0 ... PHB_REGB_ERR_LOG_1: + case PHB_TXE_ERR1_STATUS: + case PHB_TXE_ERR_LOG_0 ... PHB_TXE_ERR_LOG_1: + case PHB_RXE_ARB_ERR1_STATUS: + case PHB_RXE_ARB_ERR_LOG_0 ... PHB_RXE_ARB_ERR_LOG_1: + case PHB_RXE_MRG_ERR1_STATUS: + case PHB_RXE_MRG_ERR_LOG_0 ... PHB_RXE_MRG_ERR_LOG_1: + case PHB_RXE_TCE_ERR1_STATUS: + case PHB_RXE_TCE_ERR_LOG_0 ... PHB_RXE_TCE_ERR_LOG_1: + case PHB_ERR1_STATUS: + case PHB_ERR_LOG_0 ... PHB_ERR_LOG_1: + phb->regs[off >> 3] =3D 0; + return; + + /* Write value updated by masks */ case PHB_LSI_SOURCE_ID: val &=3D PHB_LSI_SRC_ID; break; @@ -641,7 +678,6 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr off= , uint64_t val, case PHB_LEM_WOF: val =3D 0; break; - /* TODO: More regs ..., maybe create a table with masks... */ =20 /* Read only registers */ case PHB_CPU_LOADSTORE_STATUS: @@ -650,6 +686,11 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr of= f, uint64_t val, case PHB_PHB4_TCE_CAP: case PHB_PHB4_IRQ_CAP: case PHB_PHB4_EEH_CAP: + case PHB_VERSION: + case PHB_DMA_CHAN_STATUS: + case PHB_TCE_TAG_STATUS: + case PHB_PBL_BUF_STATUS: + case PHB_PCIE_BNR: return; } =20 @@ -672,6 +713,7 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr off= , uint64_t val, pnv_phb4_update_all_msi_regions(phb); } break; + case PHB_M32_START_ADDR: case PHB_M64_UPPER_BITS: if (changed) { @@ -719,32 +761,69 @@ static void pnv_phb4_reg_write(void *opaque, hwaddr o= ff, uint64_t val, break; =20 /* Silent simple writes */ - case PHB_ASN_CMPM: - case PHB_CONFIG_ADDRESS: - case PHB_IODA_ADDR: - case PHB_TCE_KILL: - case PHB_TCE_SPEC_CTL: - case PHB_PEST_BAR: - case PHB_PELTV_BAR: + + /* PHB Fundamental register set A */ + case PHB_CONFIG_DATA ... PHB_LOCK1: case PHB_RTT_BAR: - case PHB_LEM_FIR_ACCUM: - case PHB_LEM_ERROR_MASK: - case PHB_LEM_ACTION0: - case PHB_LEM_ACTION1: - case PHB_TCE_TAG_ENABLE: + case PHB_PELTV_BAR: + case PHB_PEST_BAR: + case PHB_CRW_BAR ... PHB_ASN_CMPM: + case PHB_CAPI_CMPM ... PHB_M64_AOMASK: + case PHB_NXLATE_PREFIX ... PHB_DMA_SYNC: + case PHB_TCE_KILL ... PHB_IODA_ADDR: + case PHB_PAPR_ERR_INJ_CTL ... PHB_PAPR_ERR_INJ_MASK: case PHB_INT_NOTIFY_ADDR: case PHB_INT_NOTIFY_INDEX: - case PHB_DMA_SYNC: - break; + /* Fundamental register set B */ + case PHB_AIB_FENCE_CTRL ... PHB_Q_DMA_R: + /* FIR & Error registers */ + case PHB_LEM_FIR_ACCUM: + case PHB_LEM_ERROR_MASK: + case PHB_LEM_ACTION0 ... PHB_LEM_WOF: + case PHB_ERR_INJECT ... PHB_ERR_AIB_FENCE_ENABLE: + case PHB_ERR_STATUS_MASK ... PHB_ERR1_STATUS_MASK: + case PHB_TXE_ERR_INJECT ... PHB_TXE_ERR_AIB_FENCE_ENABLE: + case PHB_TXE_ERR_STATUS_MASK ... PHB_TXE_ERR1_STATUS_MASK: + case PHB_RXE_ARB_ERR_INJECT ... PHB_RXE_ARB_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_ARB_ERR_STATUS_MASK ... PHB_RXE_ARB_ERR1_STATUS_MASK: + case PHB_RXE_MRG_ERR_INJECT ... PHB_RXE_MRG_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_MRG_ERR_STATUS_MASK ... PHB_RXE_MRG_ERR1_STATUS_MASK: + case PHB_RXE_TCE_ERR_INJECT ... PHB_RXE_TCE_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_TCE_ERR_STATUS_MASK ... PHB_RXE_TCE_ERR1_STATUS_MASK: + /* Performance monitor & Debug registers */ + case PHB_TRACE_CONTROL ... PHB_PERFMON_CTR1: + /* REGB Registers */ + /* PBL core */ + case PHB_PBL_CONTROL: + case PHB_PBL_TIMEOUT_CTRL: + case PHB_PBL_NPTAG_ENABLE: + case PHB_PBL_SYS_LINK_INIT: + case PHB_PBL_ERR_INF_ENABLE ... PHB_PBL_ERR_FAT_ENABLE: + case PHB_PBL_ERR_STATUS_MASK ... PHB_PBL_ERR1_STATUS_MASK: + /* PCI-E stack */ + case PHB_PCIE_SCR: + case PHB_PCIE_DLP_STR ... PHB_PCIE_HOTPLUG_STATUS: + case PHB_PCIE_LMR ... PHB_PCIE_DLP_LSR: + case PHB_PCIE_DLP_LANEZEROCTL ... PHB_PCIE_DLP_TRCRDDATA: + case PHB_PCIE_DLP_ERR_COUNTERS: + case PHB_PCIE_DLP_EIC ... PHB_PCIE_LANE_EQ_CNTL23: + case PHB_PCIE_TRACE_CTRL: + case PHB_PCIE_MISC_STRAP: + /* Error registers */ + case PHB_REGB_ERR_INJECT: + case PHB_REGB_ERR_INF_ENABLE ... PHB_REGB_ERR_FAT_ENABLE: + case PHB_REGB_ERR_STATUS_MASK ... PHB_REGB_ERR1_STATUS_MASK: + break; =20 /* Noise on anything else */ default: - qemu_log_mask(LOG_UNIMP, "phb4: reg_write 0x%"PRIx64"=3D%"PRIx64"\= n", + qemu_log_mask(LOG_UNIMP, + "phb4: unimplemented reg_write 0x%"PRIx64"=3D%"PRIx6= 4"\n", off, val); } } =20 -static uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size) +uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size) { PnvPHB4 *phb =3D PNV_PHB4(opaque); uint64_t val; @@ -827,36 +906,74 @@ static uint64_t pnv_phb4_reg_read(void *opaque, hwadd= r off, unsigned size) return val; =20 /* Silent simple reads */ + /* PHB Fundamental register set A */ case PHB_LSI_SOURCE_ID: + case PHB_DMA_CHAN_STATUS: case PHB_CPU_LOADSTORE_STATUS: - case PHB_ASN_CMPM: + case PHB_CONFIG_DATA ... PHB_LOCK1: case PHB_PHB4_CONFIG: + case PHB_RTT_BAR: + case PHB_PELTV_BAR: case PHB_M32_START_ADDR: - case PHB_CONFIG_ADDRESS: - case PHB_IODA_ADDR: - case PHB_RTC_INVALIDATE: - case PHB_TCE_KILL: - case PHB_TCE_SPEC_CTL: case PHB_PEST_BAR: - case PHB_PELTV_BAR: - case PHB_RTT_BAR: + case PHB_CRW_BAR ... PHB_ASN_CMPM: + case PHB_CAPI_CMPM: + case PHB_M64_AOMASK: case PHB_M64_UPPER_BITS: - case PHB_CTRLR: - case PHB_LEM_FIR_ACCUM: - case PHB_LEM_ERROR_MASK: - case PHB_LEM_ACTION0: - case PHB_LEM_ACTION1: - case PHB_TCE_TAG_ENABLE: + case PHB_NXLATE_PREFIX: + case PHB_RTC_INVALIDATE ... PHB_IODA_ADDR: + case PHB_PAPR_ERR_INJ_CTL ... PHB_ETU_ERR_SUMMARY: case PHB_INT_NOTIFY_ADDR: case PHB_INT_NOTIFY_INDEX: - case PHB_Q_DMA_R: - case PHB_ETU_ERR_SUMMARY: - break; - - /* Noise on anything else */ + /* Fundamental register set B */ + case PHB_CTRLR: + case PHB_AIB_FENCE_CTRL ... PHB_Q_DMA_R: + case PHB_TCE_TAG_STATUS: + /* FIR & Error registers */ + case PHB_LEM_FIR_ACCUM ... PHB_LEM_ERROR_MASK: + case PHB_LEM_ACTION0 ... PHB_LEM_WOF: + case PHB_ERR_STATUS ... PHB_ERR_AIB_FENCE_ENABLE: + case PHB_ERR_LOG_0 ... PHB_ERR1_STATUS_MASK: + case PHB_TXE_ERR_STATUS ... PHB_TXE_ERR_AIB_FENCE_ENABLE: + case PHB_TXE_ERR_LOG_0 ... PHB_TXE_ERR1_STATUS_MASK: + case PHB_RXE_ARB_ERR_STATUS ... PHB_RXE_ARB_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_ARB_ERR_LOG_0 ... PHB_RXE_ARB_ERR1_STATUS_MASK: + case PHB_RXE_MRG_ERR_STATUS ... PHB_RXE_MRG_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_MRG_ERR_LOG_0 ... PHB_RXE_MRG_ERR1_STATUS_MASK: + case PHB_RXE_TCE_ERR_STATUS ... PHB_RXE_TCE_ERR_AIB_FENCE_ENABLE: + case PHB_RXE_TCE_ERR_LOG_0 ... PHB_RXE_TCE_ERR1_STATUS_MASK: + /* Performance monitor & Debug registers */ + case PHB_TRACE_CONTROL ... PHB_PERFMON_CTR1: + /* REGB Registers */ + /* PBL core */ + case PHB_PBL_CONTROL: + case PHB_PBL_TIMEOUT_CTRL: + case PHB_PBL_NPTAG_ENABLE: + case PHB_PBL_SYS_LINK_INIT: + case PHB_PBL_BUF_STATUS: + case PHB_PBL_ERR_STATUS ... PHB_PBL_ERR_INJECT: + case PHB_PBL_ERR_INF_ENABLE ... PHB_PBL_ERR_FAT_ENABLE: + case PHB_PBL_ERR_LOG_0 ... PHB_PBL_ERR1_STATUS_MASK: + /* PCI-E stack */ + case PHB_PCIE_BNR ... PHB_PCIE_DLP_STR: + case PHB_PCIE_DLP_LSR: + case PHB_PCIE_DLP_LANEZEROCTL ... PHB_PCIE_DLP_CTL: + case PHB_PCIE_DLP_TRCRDDATA: + case PHB_PCIE_DLP_ERRLOG1 ... PHB_PCIE_DLP_ERR_COUNTERS: + case PHB_PCIE_DLP_EIC ... PHB_PCIE_LANE_EQ_CNTL23: + case PHB_PCIE_TRACE_CTRL: + case PHB_PCIE_MISC_STRAP: + /* Error registers */ + case PHB_REGB_ERR_STATUS ... PHB_REGB_ERR_INJECT: + case PHB_REGB_ERR_INF_ENABLE ... PHB_REGB_ERR_FAT_ENABLE: + case PHB_REGB_ERR_LOG_0 ... PHB_REGB_ERR1_STATUS_MASK: + break; + + /* Noise on unimplemented read, return all 1's */ default: - qemu_log_mask(LOG_UNIMP, "phb4: reg_read 0x%"PRIx64"=3D%"PRIx64"\n= ", - off, val); + qemu_log_mask(LOG_UNIMP, "phb4: unimplemented reg_read 0x%"PRIx64"= \n", + off); + val =3D ~0ull; } return val; } @@ -1798,7 +1915,7 @@ void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb) pci->bus->flags |=3D PCI_BUS_EXTENDED_CONFIG_SPACE; } =20 -static void pnv_phb4_realize(DeviceState *dev, Error **errp) +void pnv_phb4_realize(DeviceState *dev, Error **errp) { PnvPHB4 *phb =3D PNV_PHB4(dev); XiveSource *xsrc =3D &phb->xsrc; diff --git a/hw/pci-host/pnv_phb5.c b/hw/pci-host/pnv_phb5.c index 4906a82c6f..b09351f69f 100644 --- a/hw/pci-host/pnv_phb5.c +++ b/hw/pci-host/pnv_phb5.c @@ -103,10 +103,117 @@ static void pnv_phb5_reset(Object *obj, ResetType ty= pe) pnv_phb5_pbl_core_reset(phb); } =20 +static uint64_t pnv_phb5_reg_read(void *opaque, hwaddr off, unsigned size) +{ + PnvPHB4 *phb =3D PNV_PHB4(opaque); + + uint64_t val =3D ~0ull; + + switch (off) { + /* Registers removed in PHB5 from PHB4, return all 1's on read */ + case PHB_CRW_BAR ... PHB_ASN_CMPM: + case PHB_PERFMON_CTR2 ... PHB_PERFMON_CTR3: + case P16_ECAP ... P16_SRDPM: + case PHB_PBL_NBW_CMP_MASK: + qemu_log_mask(LOG_GUEST_ERROR, "phb5: read from reserved offset 0x= %" + PRIx64"\n", off); + return ~0ULL; + + /* New registers in PHB5 from PHB4 */ + case P16_LDPM_PHB5 ... P16_SRDPM_PHB5: + case P32_ECAP ... P32_STAT: + case PHB_PCIE_DLP_LANE_PWR: + case PHB_PCIE_DLP_RXMGN: + case PHB_PCIE_DLP_LZC: + case PHB_PCIE_DLP_LEC0 ... PHB_PCIE_DLP_LEC1: + case PHB_PCIE_PHY_EQ_CTL: + case PHB_PCIE_PHY_RXEQ_STAT_G3_00_03 ... PHB_PCIE_PHY_RXEQ_STAT_G5_12_= 15: + val =3D phb->regs[off >> 3]; + break; + + default: + val =3D pnv_phb4_reg_read(opaque, off, size); + } + + return val; +} + +static void pnv_phb5_reg_write(void *opaque, hwaddr off, uint64_t val, + unsigned size) +{ + PnvPHB4 *phb =3D PNV_PHB4(opaque); + + switch (off) { + /* Registers removed in PHB5 from PHB4 */ + case PHB_CRW_BAR ... PHB_ASN_CMPM: + case PHB_PERFMON_CTR2 ... PHB_PERFMON_CTR3: + case P16_ECAP ... P16_SRDPM: + case PHB_PBL_NBW_CMP_MASK: + qemu_log_mask(LOG_GUEST_ERROR, "phb5: write to reserved offset 0x%" + PRIx64"\n", off); + return; + + /* New registers in PHB5 from PHB4 */ + + /* W1C: Write-1-to-Clear registers */ + case P16_STAT_PHB5 ... P16_SRDPM_PHB5: + phb->regs[off >> 3] &=3D ~val; + break; + + /* Read only registers */ + case P16_ECAP_PHB5: + case P32_ECAP: + case P32_STAT: + case PHB_PCIE_PHY_RXEQ_STAT_G3_00_03 ... PHB_PCIE_PHY_RXEQ_STAT_G5_12_= 15: + return; + + /* Simple write */ + case P32_CTL: + case PHB_PCIE_DLP_LANE_PWR: + case PHB_PCIE_DLP_RXMGN: + case PHB_PCIE_DLP_LZC: + case PHB_PCIE_DLP_LEC0 ... PHB_PCIE_DLP_LEC1: + case PHB_PCIE_PHY_EQ_CTL: + phb->regs[off >> 3] =3D val; + break; + + default: + pnv_phb4_reg_write(opaque, off, val, size); + } +} + +static const MemoryRegionOps pnv_phb5_reg_ops =3D { + .read =3D pnv_phb5_reg_read, + .write =3D pnv_phb5_reg_write, + .valid.min_access_size =3D 1, + .valid.max_access_size =3D 8, + .impl.min_access_size =3D 1, + .impl.max_access_size =3D 8, + .endianness =3D DEVICE_BIG_ENDIAN, +}; + +static void pnv_phb5_realize(DeviceState *dev, Error **errp) +{ + PnvPHB4 *phb =3D PNV_PHB4(dev); + char name[32]; + + pnv_phb4_realize(dev, errp); + + /* Controller Registers */ + snprintf(name, sizeof(name), "phb5-%d.%d-regs", phb->chip_id, + phb->phb_id); + memory_region_init_io(&phb->mr_regs, OBJECT(phb), &pnv_phb5_reg_ops, p= hb, + name, 0x2000); +} + static void pnv_phb5_class_init(ObjectClass *klass, const void *data) { + DeviceClass *dc =3D DEVICE_CLASS(klass); ResettableClass *rc =3D RESETTABLE_CLASS(klass); =20 + dc->realize =3D pnv_phb5_realize; + dc->user_creatable =3D false; + rc->phases.enter =3D pnv_phb5_reset; } =20 @@ -114,7 +221,8 @@ static const TypeInfo pnv_phb5_type_info =3D { .name =3D TYPE_PNV_PHB5, .parent =3D TYPE_PNV_PHB4, .instance_size =3D sizeof(PnvPHB4), - .class_init =3D pnv_phb5_class_init + .class_init =3D pnv_phb5_class_init, + .class_size =3D sizeof(PnvPHB4Class) }; =20 static void pnv_phb5_register_types(void) diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 567a3e6e95..33e11a3fe8 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -173,6 +173,9 @@ PnvPhb4PecState *pnv_pec_add_phb(PnvChip *chip, PnvPHB = *phb, Error **errp); void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb); void pnv_phb4_cfg_core_reset(PCIDevice *d); extern const MemoryRegionOps pnv_phb4_xscom_ops; +uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size); +void pnv_phb4_reg_write(void *opaque, hwaddr off, uint64_t val, unsigned s= ize); +void pnv_phb4_realize(DeviceState *dev, Error **errp); =20 /* * PHB4 PEC (PCI Express Controller) diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index d0962c1607..9ad6713d37 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -173,6 +173,7 @@ #define PHB_PEST_BAR 0x1a8 #define PHB_PEST_BAR_ENABLE PPC_BIT(0) #define PHB_PEST_BASE_ADDRESS PPC_BITMASK(8, 51) +#define PHB_CRW_BAR 0x1B0 #define PHB_ASN_CMPM 0x1C0 #define PHB_ASN_CMPM_ENABLE PPC_BIT(63) #define PHB_CAPI_CMPM 0x1C8 @@ -357,6 +358,11 @@ #define PHB_AER_RERR 0x130 #define PHB_AER_ESID 0x134 #define PHB_SEC_ECAP 0x148 +#define P16_ECAP 0x174 +#define P16_STAT 0x180 +#define P16_LDPM 0x184 +#define P16_FRDPM 0x188 +#define P16_SRDPM 0x18C #define PHB_LMR_ECAP 0x1A0 #define PHB_LMR_CTLSTA_2 0x1AC #define PHB_LMR_CTLSTA_16 0x1E4 @@ -398,6 +404,7 @@ #define PHB_PCIE_CRESET_PERST_N PPC_BIT(3) #define PHB_PCIE_CRESET_PIPE_N PPC_BIT(4) #define PHB_PCIE_CRESET_REFCLK_N PPC_BIT(8) +#define PHB_PCIE_DLP_STR 0x1A18 #define PHB_PCIE_HOTPLUG_STATUS 0x1A20 #define PHB_PCIE_HPSTAT_SIMDIAG PPC_BIT(3) #define PHB_PCIE_HPSTAT_RESAMPLE PPC_BIT(9) @@ -427,18 +434,20 @@ #define PHB_PCIE_DLP_DL_PGRESET PPC_BIT(22) #define PHB_PCIE_DLP_TRAINING PPC_BIT(20) #define PHB_PCIE_DLP_INBAND_PRESENCE PPC_BIT(19) - +#define PHB_PCIE_DLP_LSR 0x1A48 +#define PHB_PCIE_DLP_LANEZEROCTL 0x1A70 #define PHB_PCIE_DLP_CTL 0x1A78 #define PHB_PCIE_DLP_CTL_BYPASS_PH2 PPC_BIT(4) #define PHB_PCIE_DLP_CTL_BYPASS_PH3 PPC_BIT(5) - #define PHB_PCIE_DLP_TRWCTL 0x1A80 #define PHB_PCIE_DLP_TRWCTL_EN PPC_BIT(0) #define PHB_PCIE_DLP_TRWCTL_WREN PPC_BIT(1) +#define PHB_PCIE_DLP_TRCRDDATA 0x1A88 #define PHB_PCIE_DLP_ERRLOG1 0x1AA0 #define PHB_PCIE_DLP_ERRLOG2 0x1AA8 #define PHB_PCIE_DLP_ERR_STATUS 0x1AB0 #define PHB_PCIE_DLP_ERR_COUNTERS 0x1AB8 +#define PHB_PCIE_DLP_EIC 0x1AC8 =20 #define PHB_PCIE_LANE_EQ_CNTL0 0x1AD0 #define PHB_PCIE_LANE_EQ_CNTL1 0x1AD8 @@ -581,5 +590,4 @@ =20 #define IODA3_PEST1_FAIL_ADDR PPC_BITMASK(3, 63) =20 - #endif /* PCI_HOST_PNV_PHB4_REGS_H */ diff --git a/include/hw/pci-host/pnv_phb5.h b/include/hw/pci-host/pnv_phb5.h index d76846068a..4534083fd5 100644 --- a/include/hw/pci-host/pnv_phb5.h +++ b/include/hw/pci-host/pnv_phb5.h @@ -33,17 +33,22 @@ void pnv_phb5_cfg_core_reset(PCIDevice *d); OBJECT_CHECK(PnvPhb4PecState, (obj), TYPE_PNV_PHB5_PEC) =20 /* New registers in PHB5 from PHB4 */ -#define P16_ECAP 0x1F4 -#define P16_STAT 0x200 -#define P16_LDPM 0x204 -#define P16_FRDPM 0x208 -#define P16_SRDPM 0x20C +#define P16_ECAP_PHB5 0x1F4 +#define P16_STAT_PHB5 0x200 +#define P16_LDPM_PHB5 0x204 +#define P16_FRDPM_PHB5 0x208 +#define P16_SRDPM_PHB5 0x20C #define P32_ECAP 0x224 #define P32_CAP 0x228 #define P32_CTL 0x22C #define P32_STAT 0x230 +#define PHB_PCIE_DLP_LANE_PWR 0x1A38 +#define PHB_PCIE_DLP_RXMGN 0x1A50 +#define PHB_PCIE_DLP_LZC 0x1A70 +#define PHB_PCIE_DLP_LEC0 0x1B00 +#define PHB_PCIE_DLP_LEC1 0x1B08 +#define PHB_PCIE_PHY_EQ_CTL 0x1B38 #define PHB_PCIE_PHY_RXEQ_STAT_G3_00_03 0x1B40 #define PHB_PCIE_PHY_RXEQ_STAT_G5_12_15 0x1B98 =20 - #endif /* PCI_HOST_PNV_PHB5_H */ diff --git a/tests/qtest/pnv-phb-test.c b/tests/qtest/pnv-phb-test.c index 7e9127f81e..2f455a6b84 100644 --- a/tests/qtest/pnv-phb-test.c +++ b/tests/qtest/pnv-phb-test.c @@ -89,11 +89,10 @@ static void phb5_sticky_rst_test(QTestState *qts) g_assert_cmpuint(val, =3D=3D, (PPC_BITMASK(24, 27) | PPC_BITMASK(36, 3= 7) | PPC_BITMASK(39, 45) | PPC_BITMASK(47, 48) | PPC_BITMASK(52, 54))); - } =20 /* Check that write-only bits/regs return 0 when read */ -static void phb4_writeonly_read_test(QTestState *qts) +static void phb5_writeonly_read_test(QTestState *qts) { uint64_t val; =20 @@ -144,6 +143,12 @@ static void phb4_writeonly_read_test(QTestState *qts) g_assert_cmpuint(val, =3D=3D, 0x0); } =20 +/* Check that reading an unimplemented address 0x0 returns -1 */ +static void phb5_unimplemented_read_test(QTestState *qts) +{ + g_assert_cmpint(PHB5_XSCOM_READ(0x0), =3D=3D, -1); +} + static void phb5_tests(void) { QTestState *qts =3D NULL; @@ -157,7 +162,10 @@ static void phb5_tests(void) phb5_sticky_rst_test(qts); =20 /* Check write-only logic */ - phb4_writeonly_read_test(qts); + phb5_writeonly_read_test(qts); + + /* Check unimplemented register read */ + phb5_unimplemented_read_test(qts); =20 qtest_quit(qts); } --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094319; cv=none; d=zohomail.com; s=zohoarc; b=BA1oD0lhX5wz/lTRPsoZydTv1gogxNzNlo8tpcFRzKEGPR1dbliwvlZE71pi8KSVGpc2wSwHRPkVRW5AyYei+7jKR4j55bNtVz8B70o5W7wngugOQVNTfHhRaDhf1jXeSKa91bnBZFe685kE9hKx8Biw3Maa1w+QloAP8VwMuHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094319; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XKTckqjRmPVmtiUYUtf/v0WPcFLkwS39rEJL7oNWG7M=; b=L+rt1Wqoh2nSqW/uTdf/mUteXhOQd/AGSXZpe9zdGKwdNebRGj1VjNUfXIFh2gbkHV349uJNcM0yBbjPXsZIvf/PTcCIYBOSzlDn/VC/tGA0xO50p/UF0HuakA0bFUFHetgVNv6nbMbnpnzpAEb5CzEQhtIa2mNBaqFWUU4cyA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094319147628.0240407254707; Tue, 27 Oct 2026 02:45:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjb-0000ok-Tc; Tue, 27 Oct 2026 05:44:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjZ-0000iT-MR; Tue, 27 Oct 2026 05:44:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjX-0001Rd-97; Tue, 27 Oct 2026 05:44:45 -0400 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5j3rH1528657; Tue, 27 Oct 2026 09:44:20 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmave7re-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:19 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5ZFLU3644260; Tue, 27 Oct 2026 09:44:19 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh80jj44f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:19 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iHYF13501064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:17 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE62158052; Tue, 27 Oct 2026 09:44:17 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CF4535805E; Tue, 27 Oct 2026 09:44:16 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:16 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=XKTckqjRmPVmtiUYU tf/v0WPcFLkwS39rEJL7oNWG7M=; b=HOw1ydUjdHyqfsyx8stYCtkWhQm3wZNjq SM9yUPmiNJhiDLeeWFeSUahAj+YGscAv1gjV9ZnZXhLxPQrZFK0vhTA6s+ajxrVM zFxxu9dYJ8b2IoU6GxSG3Rzl3blpW1putYEP4gTrGQxSFPZgcikxN6q8+HGbdSjU CQYRU6/fDSFSNgOBtMhinG3RB6GIu5nNN7BAw/mMsiCpU9q7khLRYbYrs7hsQQgU XMgYk0h2DjEt0/TrVPhsJmbeyDQSmjHTT7KJEyd1Hgk9Vz+VTSadtVmXf/nEiot0 wpakwP33QDDAqbTGNcseo8/XaF+sfigLup9jhYdFnbeE0puhchBjA== From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 6/9] pnv/phb5: Set link-active status in HPSTAT and LMR registers Date: Tue, 27 Oct 2026 04:43:47 -0500 Message-ID: <20261027094350.3645085-7-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=P8SvFSAu c=1 sm=1 tr=0 ts=6ae07274 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=SX2aUA2rIF85faSKF8YA:9 X-Proofpoint-GUID: 6D0VC105kpmFruXap1jyhAx_xLg2ojXF X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfXwqC2Cw+3G6eh zOPOTDeyh5BIZnUkYRtmKVH6sbHWv9jzfrWR6vcdhYm0zFmpkxqoJJFEwl8eeTA0ZwwFCAy+UOe fA3lqz2Pp+iek7WLH08dxOS02ODhOCg= X-Proofpoint-ORIG-GUID: DFOFdWu9lOmy6mZq6lyIvL8medxIZltw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX7qcNZOB9YuNI XQgk4H+Rkhf88VmEYIft/U9OG6DWD3LqrLLIJUlGeYv8TpNTJ4EKnqlDCIV7y+4P0SOxSP/w/bu 4XMd2pRN0zI7S9+MVoxCk9czILCgsrMztxGcTIhw3RS+8HDavWfK447sjIpZxrOa18DujKMhw2j GkBqdzSFGCHyRsZyJkiuk7A9ZUQ6VHOg9/UcIdG/8n0EuqNiu/kxxkMz3F3oZcP34aC1uDfXHeB yp+e+KV8hc7colfVTPfOuIlunenFbqpwzE/PyHL1DPtVx2S5DlXJ7q3dJRJ3ww1m+6unDx9cIgO y0UA0TE3B+zyR5C3NuLE2U1ElFQgralV66DAwnMnrJKsKZiAsTLnM4nO+xowzyJLwQlDI9Lct9J BalcUkL5b0uaGLu6ag25+tC2SjY2ir+yglQ0e9UMenOvR6BRlwu+7oasRJofr0pptkqmEgMC1Vr EWmJZUQoSZYZT0DvAWg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094320102158500 Content-Type: text/plain; charset="utf-8" From: Saif Abrar Config-read the link-status register in the PCI-E macro, Depending on the link-active bit, set the link-active status in the HOTPLUG_STATUS and LINK_MANAGEMENT registers Also, clear the Presence-status active low bit in HOTPLUG_STATUS reg after config-reading the slot-status in the PCI-E macro. Signed-off-by: Saif Abrar Reviewed-by: Michael S. Tsirkin Reviewed-by: Caleb Schlossin Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 61 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 378870268a..014a0a6524 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -507,6 +507,21 @@ uint32_t get_exp_offset(PCIDevice *pdev) return rpc->exp_offset; } =20 +/* + * Config-read the link-status register in the PCI-E macro, + * convert to LE and check the link-active bit. + */ +static uint32_t is_link_active(PnvPHB4 *phb) +{ + PCIHostState *pci =3D PCI_HOST_BRIDGE(phb->phb_base); + PCIDevice *pdev =3D pci_find_device(pci->bus, 0, 0); + uint32_t exp_offset =3D get_exp_offset(pdev); + + return (be16_to_cpu(pnv_phb4_rc_config_read(phb, + exp_offset + PCI_EXP_LNKSTA, 4)) & + PCI_EXP_LNKSTA_DLLLA); +} + void pnv_phb4_cfg_core_reset(PCIDevice *d) { uint8_t *conf =3D d->config; @@ -679,6 +694,11 @@ void pnv_phb4_reg_write(void *opaque, hwaddr off, uint= 64_t val, val =3D 0; break; =20 + case PHB_PCIE_HOTPLUG_STATUS: + /* For normal operations, Simspeed diagnostic bit is always zero */ + val &=3D PHB_PCIE_HPSTAT_SIMDIAG; + break; + /* Read only registers */ case PHB_CPU_LOADSTORE_STATUS: case PHB_ETU_ERR_SUMMARY: @@ -826,6 +846,10 @@ void pnv_phb4_reg_write(void *opaque, hwaddr off, uint= 64_t val, uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, unsigned size) { PnvPHB4 *phb =3D PNV_PHB4(opaque); + /* Get the PCI-E capability offset from the root-port */ + PCIHostState *pci =3D PCI_HOST_BRIDGE(phb->phb_base); + PCIDevice *pdev =3D pci_find_device(pci->bus, 0, 0); + uint32_t exp_base =3D get_exp_offset(pdev); uint64_t val; =20 if ((off & 0xfffc) =3D=3D PHB_CONFIG_DATA) { @@ -894,8 +918,38 @@ uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, u= nsigned size) val |=3D PHB_PCIE_DLP_INBAND_PRESENCE | PHB_PCIE_DLP_TL_LINKACT; return val; =20 + /* + * Read PCI-E registers and set status for: + * - Card present (active low bit 10) + * - Link active (bit 12) + */ case PHB_PCIE_HOTPLUG_STATUS: - /* Clear write-only bit */ + /* + * Presence-status bit hpi_present_n is active-low, with reset val= ue 1. + * Start by setting this bit to 1, indicating the card is not pres= ent. + * Then check the PCI-E register and clear the bit if card is pres= ent. + */ + val |=3D PHB_PCIE_HPSTAT_PRESENCE; + + /* + * Config-read the PCI-E macro register for slot-status. + * Method for config-read converts to BE value. + * To check actual bit in the PCI-E register, + * convert the value back to host format. + * Clear the Presence-status active low bit. + */ + if (be16_to_cpu(pnv_phb4_rc_config_read(phb, exp_base + PCI_EXP_SL= TSTA, + 4)) + & PCI_EXP_SLTSTA_PDS) { + val &=3D ~PHB_PCIE_HPSTAT_PRESENCE; + } + + /* Check if link is active and set the bit */ + if (is_link_active(phb)) { + val |=3D PHB_PCIE_HPSTAT_LINKACTIVE; + } + + /* Clear write-only resample-bit */ val &=3D ~PHB_PCIE_HPSTAT_RESAMPLE; return val; =20 @@ -903,6 +957,11 @@ uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, u= nsigned size) case PHB_PCIE_LMR: /* These write-only bits always read as 0 */ val &=3D ~(PHB_PCIE_LMR_CHANGELW | PHB_PCIE_LMR_RETRAINLINK); + + /* Check if link is active and set the bit */ + if (is_link_active(phb)) { + val |=3D PHB_PCIE_LMR_LINKACTIVE; + } return val; =20 /* Silent simple reads */ --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094309; cv=none; d=zohomail.com; s=zohoarc; b=grR1eq/8WI7t76G9XY6Snot3Fvmm1szBLFRmjztztfUxE8UEqBXbjtKQ3ZK7TYde8WtFL+dvHxzGlMqYPrNNvp7T/aRVNxbnj4+C1UttICaP23jCQs97s0xXqYkKGTLPrr14cE+YGQ0PzpeD+lL+LsPyHhw10Qqh0t5kIXY332o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094309; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pKg0oj2AMdhdMFC+bfBLYHmScLWA3QDz3L730rDbk2I=; b=hrJq+8CIKaqy7ZqQYNXf0Pxy++qUVYlTv3wPLk5S9BdfEfYB5/oGgO3yVeVl1gUGKhCHZ7tJoZOm2wAi37ROXT8D4RpVp5ffH/qcJ7UP5KSTjIKYBopQXf/tP6BxwiwvltKR9tpwpVEKyUtHfq4ZA5fYqR6ug8Y0s4177qeNowY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094309176373.98223937950183; Tue, 27 Oct 2026 02:45:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjf-0000zk-LI; Tue, 27 Oct 2026 05:44:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjb-0000od-8n; Tue, 27 Oct 2026 05:44:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjY-0001Ry-CK; Tue, 27 Oct 2026 05:44:47 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5iGqT1441147; Tue, 27 Oct 2026 09:44:21 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3m6tgy-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:20 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5npSC3687787; Tue, 27 Oct 2026 09:44:20 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh7cvj8d3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:20 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9hVpS30540524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:43:31 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEE2558052; Tue, 27 Oct 2026 09:44:18 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D12C558056; Tue, 27 Oct 2026 09:44:17 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=pKg0oj 2AMdhdMFC+bfBLYHmScLWA3QDz3L730rDbk2I=; b=Fbf8hr83VAPKE+eOgayTO8 pSySPDaR60RSB4uVlN7EHYHmhrq77TpCE5oqOEZJVZRdEOxMHGZPfkf0JLxcwG5Q ZQpxtcwHmg7ccTbpFK2dBCPmy0z5MRJ0P3/9LyUCNU9w2j4pNJdp+Jq44X18acLo 6y0gieHc7kOPFFESlzE6DroO7pE6VIkJ1Wq5MjOtRF50svW0ri0o1RoeE0SAtiFu C/+TUzRToPJIq5cpMkjAXrz/lkzJfaeUIbjw7PX+Emse5MSZYK9Y1ksC3zjS2diq Owlbg9HQ1LiiJb6PwinTSCTB8xB0s+EF6h2J5qdOaCPJkdKQ/I69PXEU6MM7NPyQ == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 7/9] pnv/phb5: Set link speed and width in the DLP training control register Date: Tue, 27 Oct 2026 04:43:48 -0500 Message-ID: <20261027094350.3645085-8-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzNiBTYWx0ZWRfX7bQ+ySR49r5y 3XRgsLZuMHhktbqjK8vDm2wdkSMZ8CPhViI+4KUD+b6D+NroxF7TMocglSbxrxLwfy5Yge/EIqn R+amwUR6G2UPj/eJNsE5xYuz5Doaovk= X-Proofpoint-ORIG-GUID: Scb94iohCsdoplxP1u_oHgyn9agKTSLb X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzNiBTYWx0ZWRfX+2GOgc/9IAzM kSub3vxJTlyymHCCz6tyfWqvAICDnz5JktNpBvgdrnEf12vRYolzUbTj1VfO8Yd2rejMkm9kGMv O7BlFG+rkIJymoSIKzd6iWQR/YFg2nGMm+rJNugBc9m4nO+dcF/HoMLbLFGzua1edeFZfqHks6Q 6xv6ocWQGY3Dxqkw76FSJg0iifzm2OeY/J6Iu8y0sd0iaNKWW6c9Ji2ojuTfV0gzlOarpAMcmEv Ei51o4trpgCf8clQ0i4UKarZgTgNyZIjKUqmhjdHgiPXRqRGk8m8XwqygIulCzFt6NdMmUDSLrJ FUqizK0FjVA/sXcmjXGLVJBYNXP8KKtXFG+Mz7q4QFKAi2VA+yIeaLwCVMlm8jtZzxcOSaVHpAx q2fb8+hR4FbuLF2kvc4CLCyzM1EO5b1aIPSe5Xb41J+7jRpQdFVQijd434rvEoKleqIP+2SMAmS 8w6AbdzPqKXwRaw5XEg== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae07275 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=20KFwNOVAAAA:8 a=-b7IsxyX4n235a3dhHEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: hid7abuj4cXzZfEWQejC5V7bkZa3koi4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 clxscore=1015 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270036 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094312205158500 From: Saif Abrar Get the current link-status from PCIE macro. Extract link-speed and link-width from the link-status and set in the DLP training control (PCIE_DLP_TCR) register. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Michael S. Tsirkin Reviewed-by: Caleb Schlossin Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 014a0a6524..b0a5bdfdd6 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -517,7 +517,7 @@ static uint32_t is_link_active(PnvPHB4 *phb) PCIDevice *pdev =3D pci_find_device(pci->bus, 0, 0); uint32_t exp_offset =3D get_exp_offset(pdev); =20 - return (be16_to_cpu(pnv_phb4_rc_config_read(phb, + return (be32_to_cpu(pnv_phb4_rc_config_read(phb, exp_offset + PCI_EXP_LNKSTA, 4)) & PCI_EXP_LNKSTA_DLLLA); } @@ -851,6 +851,7 @@ uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, un= signed size) PCIDevice *pdev =3D pci_find_device(pci->bus, 0, 0); uint32_t exp_base =3D get_exp_offset(pdev); uint64_t val; + uint32_t v, lnkstatus; =20 if ((off & 0xfffc) =3D=3D PHB_CONFIG_DATA) { return pnv_phb4_config_read(phb, off & 0x3, size); @@ -912,10 +913,27 @@ uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, = unsigned size) val |=3D PHB_PCIE_SCR_PLW_X16; /* RO bit */ break; =20 - /* Link training always appears trained */ case PHB_PCIE_DLP_TRAIN_CTL: - /* TODO: Do something sensible with speed ? */ + /* Get the current link-status from PCIE */ + lnkstatus =3D be32_to_cpu(pnv_phb4_rc_config_read(phb, + exp_base + PCI_EXP_LNKSTA, 4)); + + /* Extract link-speed from the link-status */ + v =3D lnkstatus & PCI_EXP_LNKSTA_CLS; + + /* Link training always appears trained */ val |=3D PHB_PCIE_DLP_INBAND_PRESENCE | PHB_PCIE_DLP_TL_LINKACT; + + /* Set the current link-speed at the LINK_SPEED position */ + val =3D SETFIELD(PHB_PCIE_DLP_LINK_SPEED, val, v); + + /* + * Extract link-width from the link-status, + * after shifting the required bitfields. + */ + v =3D (lnkstatus & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; + /* Set the current link-width at the LINK_WIDTH position */ + val =3D SETFIELD(PHB_PCIE_DLP_LINK_WIDTH, val, v); return val; =20 /* @@ -938,7 +956,7 @@ uint64_t pnv_phb4_reg_read(void *opaque, hwaddr off, un= signed size) * convert the value back to host format. * Clear the Presence-status active low bit. */ - if (be16_to_cpu(pnv_phb4_rc_config_read(phb, exp_base + PCI_EXP_SL= TSTA, + if (be32_to_cpu(pnv_phb4_rc_config_read(phb, exp_base + PCI_EXP_SL= TSTA, 4)) & PCI_EXP_SLTSTA_PDS) { val &=3D ~PHB_PCIE_HPSTAT_PRESENCE; --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094339; cv=none; d=zohomail.com; s=zohoarc; b=iUuWc7WeoV6vpPlGzKkwv/5BRUBcvJmr2dPWvx38Ou/QkKNBN+/HhydN3RMHVNpAVzDihAjiHpc8USnuT2n2xy/fP+GeXlRFYzMAOfPr7CyzX8Z0o/GXeO2vQBNq8poWyYJ0eMytfDjw0+OVXCT9y7jXYskrg8yvmdtSon6g7uM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094339; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4THQfxyfn9AfDVLt1rjABkhsEDuGjMkkiOLip8qulqk=; b=Ch7Wb/i4Nw+IBdVwSmgzdpEDQkvMzZsgapi1XssoVj2hI3gZn4XgwIFjFmhu15AWUCgGX3yca8ukxY11T8eMMFCRmxt5gzA0RmLAtfWJF/amVV+fseeIf7xgVdk4YWcCssyAC8xr4kKTOTRnpTE88Cavk8Bj1ZkRp5XLjixNPdA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094339257414.0291798502474; Tue, 27 Oct 2026 02:45:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdjW-0000d4-6Z; Tue, 27 Oct 2026 05:44:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjU-0000b4-VL; Tue, 27 Oct 2026 05:44:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjT-0001Qr-1f; Tue, 27 Oct 2026 05:44:40 -0400 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5iZqx1441620; Tue, 27 Oct 2026 09:44:22 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3m6th5-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:21 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5npXP3687782; Tue, 27 Oct 2026 09:44:21 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hh7cvj8d5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:21 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iJBb27853542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:20 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C0E1E58062; Tue, 27 Oct 2026 09:44:19 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D232658056; Tue, 27 Oct 2026 09:44:18 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:18 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=4THQfx yfn9AfDVLt1rjABkhsEDuGjMkkiOLip8qulqk=; b=AnW49s9c5vRGY2A4/+D3Yu 637MLWk3IQR3kV4dqQ4Y2adX6O0Z4PQZI2a7iYT5oCqcTbvw7sDtpYlJjX8vwMJj 5cTvYQ++UerYNfuSOXfD2hxT50v127+05zL9Z9EPSJ5iPUWMPEm4Guv9437VlSH4 Lq2avjxP93tYqDPPzJyjl4N7OYJFEWsRYhhvaqQCcQJBnRE8pEU0wu/jh4XiKwVV RtdfjdPIj/GJDtPbYAzfp1YFO2QFtPY4+h+N9FpuABME+mXY7dJGWKX5pkBFGw2o cTHxgp3OZylFp+gkzbqeJ7xiBpgSUwRO3wbTnEqsZTBZvccd06V7KgidccbP1K2w == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 8/9] pnv/phb5: Implement IODA PCT table Date: Tue, 27 Oct 2026 04:43:49 -0500 Message-ID: <20261027094350.3645085-9-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzNiBTYWx0ZWRfX+kRYvMZCBFTC TXoafNEnXBCgA29WZCcvKpxe/HZI0zmK+/TZC1L19zFapJ2MDw06bQy29Lo/BJK2uI0ndcrnuH8 HoCfutYTXY3chwQd08uZzBAMmSofeNg= X-Proofpoint-ORIG-GUID: Hq1UDc-QJYsfq3adN0TKmaG9dMjNuZPZ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzNiBTYWx0ZWRfXz1UsD0ODej66 AfGakiHZ2kO289WVXGcL4K9VsU4traBFYH7Izyniyf2g1E+I8jbX2vPsTTUeK49pS7vOLkcfi6I Uu7/AxPbUHMrTEFjmrxMOda2JGag5If3abUPQKu9M64CWwqSYsaIgRuLiC6OoFocrKZaRWZ71T+ oCg/Fjgu7LhLvOn5KIr/Fa0bJOeGtA2IL0RzbV8UfM/sYxkk1mEtG7Mg0TkIfx48Bg69BGcHx/+ Vw4ij+B41U0RA4nqCsQv+dowBY0cGjI69O8O9QZCYmymnTHWpxuLp+aA5xsld6sMxKEg2popRcU RMHQsXKp8mctk4zzUT6mjvSIJGZoto1txep0PMt813RBjFkfOluxlC//OGZqdNYlnxYArky6rWj vpyU0UCVPK1GvKGv4Ai12voNj3oDewOIYseD2qDYZn1wB5NWPnqozI84g+9ptzs/wILMoeyP9GR 9r9BZMiDaUsyOgh00CA== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae07276 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=zgsLwUnGCMBw8fX4dgEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: MtiBSzyklooXHdpx6UUP-8K6s7JMEsBv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 impostorscore=0 suspectscore=0 clxscore=1015 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270036 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=saif.abrar@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094340130158500 From: Saif Abrar IODA PCT table is implemented without any functionality, being a debug table. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Caleb Schlossin Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 7 +++++++ include/hw/pci-host/pnv_phb4.h | 2 ++ include/hw/pci-host/pnv_phb4_regs.h | 1 + 3 files changed, 10 insertions(+) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index b0a5bdfdd6..9983781bd4 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -263,6 +263,11 @@ static uint64_t *pnv_phb4_ioda_access(PnvPHB4 *phb, mask =3D phb->big_phb ? PNV_PHB4_MAX_MIST : (PNV_PHB4_MAX_MIST >> = 1); mask -=3D 1; break; + case IODA3_TBL_PCT: + tptr =3D phb->ioda_PCT; + mask =3D phb->big_phb ? PNV_PHB4_MAX_PCT : (PNV_PHB4_MAX_PCT >> 1); + mask -=3D 1; + break; case IODA3_TBL_RCAM: mask =3D phb->big_phb ? 127 : 63; break; @@ -361,6 +366,8 @@ static void pnv_phb4_ioda_write(PnvPHB4 *phb, uint64_t = val) /* Handle side effects */ switch (table) { case IODA3_TBL_LIST: + case IODA3_TBL_PCT: + /* No action for debug tables */ break; case IODA3_TBL_MIST: { /* Special mask for MIST partial write */ diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 33e11a3fe8..8d5822f339 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -65,6 +65,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4RootBus, PNV_PHB4_ROOT_= BUS) #define PNV_PHB4_MAX_LSIs 8 #define PNV_PHB4_MAX_INTs 4096 #define PNV_PHB4_MAX_MIST (PNV_PHB4_MAX_INTs >> 2) +#define PNV_PHB4_MAX_PCT (128 * 2) #define PNV_PHB4_MAX_MMIO_WINDOWS 32 #define PNV_PHB4_MIN_MMIO_WINDOWS 16 #define PNV_PHB4_NUM_REGS (0x3000 >> 3) @@ -138,6 +139,7 @@ struct PnvPHB4 { /* On-chip IODA tables */ uint64_t ioda_LIST[PNV_PHB4_MAX_LSIs]; uint64_t ioda_MIST[PNV_PHB4_MAX_MIST]; + uint64_t ioda_PCT[PNV_PHB4_MAX_PCT]; uint64_t ioda_TVT[PNV_PHB4_MAX_TVEs]; uint64_t ioda_MBT[PNV_PHB4_MAX_MBEs]; uint64_t ioda_MDT[PNV_PHB4_MAX_PEs]; diff --git a/include/hw/pci-host/pnv_phb4_regs.h b/include/hw/pci-host/pnv_= phb4_regs.h index 9ad6713d37..897c869d20 100644 --- a/include/hw/pci-host/pnv_phb4_regs.h +++ b/include/hw/pci-host/pnv_phb4_regs.h @@ -478,6 +478,7 @@ =20 #define IODA3_TBL_LIST 1 #define IODA3_TBL_MIST 2 +#define IODA3_TBL_PCT 3 #define IODA3_TBL_RCAM 5 #define IODA3_TBL_MRT 6 #define IODA3_TBL_PESTA 7 --=20 2.52.0 From nobody Mon Nov 23 04:26:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1793094344; cv=none; d=zohomail.com; s=zohoarc; b=jKYdwX7gjVHx8YHSVszRxolzT6WpnkiWKW1IUe8x7y6hlI/pMXs0w1aLEZEnjIurB220EEuATFifioQwiZ9qXkdWrGOt9z16ES4v6g+YRMDSFTSepURH3Nv1WaN9XHL2xW4agGmNE2DIANGSqGp6EgKdMhRLGk45SEmHo5sSOI8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793094344; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xogy7iVtpXr4bxaUf/1o5XhkHLoRMoq0EZl1rIW5XHg=; b=LJjSu5ZNqxHtRam8AyBUVeoVzFRin9gznpsKJw2sO7egyXSkXKuPfqzegPGGLYbmDpQpBsKrPEZaAkYhrm/9pwlHhEjZhZ6L7AovLt74O6dq0kJg7aTdtEqSWPQ5Uv1OIOzFBXm5Lc5LAYq4HQuG4ArUDxGDNioiS+iuhFyggbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1793094344500577.1345433581462; Tue, 27 Oct 2026 02:45:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xLdje-0000ux-FM; Tue, 27 Oct 2026 05:44:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjb-0000oM-5Y; Tue, 27 Oct 2026 05:44:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xLdjY-0001Rg-1C; Tue, 27 Oct 2026 05:44:46 -0400 Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5ij3b4073420; Tue, 27 Oct 2026 09:44:24 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmbsxnjd-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:23 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69R5Z2l02510951; Tue, 27 Oct 2026 09:44:22 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hh97gsx86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 27 Oct 2026 09:44:22 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69R9iK9M23331428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 27 Oct 2026 09:44:21 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C910D5805A; Tue, 27 Oct 2026 09:44:20 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D23FD58052; Tue, 27 Oct 2026 09:44:19 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Tue, 27 Oct 2026 09:44:19 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=xogy7i VtpXr4bxaUf/1o5XhkHLoRMoq0EZl1rIW5XHg=; b=YcVbwTt6H69zRPWP5aiigC El2i6L3+/KAHX5EP+akw9x7vQFIHQLqfp3B27eQeMFjvA7jnhmaT/sjEPBoH9G+Q g9mV5eigjTL2FXRdNgzYfHhr0OSc3qPXH00CuD6MhVbabU0ciyvPM08PYcwYm1E3 AURyRcUoaInHn/KTpG/dDMIP0nTETGzG7hDtn2UBuPVjen6DH98JeLN8n4IlwNo7 X5vvC2X37WrUx/zRX3MiSIooxInH1XdZNtzaMwm0hzeKxpZ1JHXcS3pjctcBD+R9 u+wK3t+G1TQqFC8zgVBF/9ljHgW/3lksansZdrmf9zHGpwa7fkuvK0/LZmRtkKoA == From: Saif Abrar To: 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, calebs@linux.ibm.com, milesg@linux.ibm.com, jishnuvw@linux.ibm.com, adityag@linux.ibm.com, amachhiw@linux.ibm.com Subject: [PATCH v7 9/9] pnv/phb5: Mask off LSI Source-ID based on number of interrupts Date: Tue, 27 Oct 2026 04:43:50 -0500 Message-ID: <20261027094350.3645085-10-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> References: <20261027094350.3645085-1-saif.abrar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX0NFKZi+Ki6fM Smp7+3tCz/tV48nJSA/YGBXz2GcOAJd+fvLUcJfa2G277HLaJtAuAt5fVgMa6+Fwuem5ms1CDTI fhXcGJLuRCeYhYPd9OhKSBJH9/lLcPKU5esueK7MYYGxnjS0SDKMuIWmVVtjhvnxgu5z8eRrVHh XCOej8UgL/uiYlVlliLSG83l2UhgfsRuIfVHjSGo7Z6gbiqv+5r8nJtxnKDLjtf9sdtdGB80Vd0 ANatSEDopjWBHPoPXL2KcTkvAsFdWeR7dZXtmhAnehGZaCwTNMrceW1wASLQR0sCavxzuEinjTf EeDZqndtvDI4CkLLSA30eSDZjLuQ630ESFhzeOlPXOmceRcXstGranHB562ui3jWI4A1xK7Bjji S1Ui1fFsQDjlb6GUUOnwV6fPsPTcHb5EyYBu0ZkLEcg/EWM1MBu8fhaJYVbZ9VSdFsAOgEKuiFS 7MFuC5/ajWcoN1fPMLA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI3MDAzOCBTYWx0ZWRfX89dQJxq1iByx TNmbX3ftW7AIwlndo74eMI1l54+qXmeEqECGlGfbmm2IMh7SKGtk8y07ZIYkpvrjESFTaXk0lcB saZPwwDjwocEOsTxgK40rlqAQV/pKBI= X-Proofpoint-ORIG-GUID: F3W3pCQc7cOTyCDoLnyZLdTHpUU5PPSr X-Proofpoint-GUID: TU4gUAy46rNX8eX5mo9fOPCS_VoCHXTE X-Authority-Analysis: v=2.4 cv=CeKdd7rl c=1 sm=1 tr=0 ts=6ae07277 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=kUKHeS9f1dJEPYFD:21 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=-uQQ_z-csOHJncX4BtYA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-10-27_02,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610270038 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=148.163.156.1; envelope-from=saif.abrar@linux.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1793094346571158500 From: Saif Abrar Add a method to reset the value of LSI Source-ID. Mask off LSI source-id based on number of interrupts in the big/small PHB. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Caleb Schlossin Reviewed-by: Aditya Gupta Reviewed-by: Michael Kowal Reviewed-by: Michael Kowal --- hw/pci-host/pnv_phb4.c | 12 +++++++++--- hw/pci-host/pnv_phb5.c | 17 ----------------- include/hw/pci-host/pnv_phb5.h | 10 ++++------ 3 files changed, 13 insertions(+), 26 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 9983781bd4..6fa9629eb0 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -490,6 +490,7 @@ static void pnv_phb4_update_xsrc(PnvPHB4 *phb) =20 lsi_base =3D GETFIELD(PHB_LSI_SRC_ID, phb->regs[PHB_LSI_SOURCE_ID >> 3= ]); lsi_base <<=3D 3; + lsi_base &=3D (xsrc->nr_irqs - 1); =20 /* TODO: handle reset values of PHB_LSI_SRC_ID */ if (!lsi_base) { @@ -1894,6 +1895,12 @@ static void pnv_phb4_ro_mask_init(PnvPHB4Class *phb4= c) /* TODO: Add more RO-masks as regs are implemented in the model */ } =20 +static void pnv_phb4_xsrc_reset(PnvPHB4 *phb) +{ + phb->regs[PHB_LSI_SOURCE_ID >> 3] =3D PPC_BITMASK(4, 12); + pnv_phb4_update_xsrc(phb); +} + static void pnv_phb4_err_reg_reset(PnvPHB4 *phb) { STICKY_RST(PHB_ERR_STATUS, 0, PPC_BITMASK(0, 33)); @@ -1950,10 +1957,11 @@ static void pnv_phb4_reset(Object *obj, ResetType t= ype) PnvPHB4 *phb =3D PNV_PHB4(obj); =20 pnv_phb4_pbl_core_reset(phb); + + pnv_phb4_xsrc_reset(phb); pnv_phb4_err_reg_reset(phb); pnv_phb4_pcie_stack_reg_reset(phb); pnv_phb4_regb_err_reg_reset(phb); - phb->regs[PHB_PCIE_CRESET >> 3] =3D 0xE000000000000000; } =20 static void pnv_phb4_instance_init(Object *obj) @@ -2027,8 +2035,6 @@ void pnv_phb4_realize(DeviceState *dev, Error **errp) return; } =20 - pnv_phb4_update_xsrc(phb); - phb->qirqs =3D qemu_allocate_irqs(xive_source_set_irq, xsrc, xsrc->nr_= irqs); =20 pnv_phb4_xscom_realize(phb); diff --git a/hw/pci-host/pnv_phb5.c b/hw/pci-host/pnv_phb5.c index b09351f69f..ec6dfbe2b2 100644 --- a/hw/pci-host/pnv_phb5.c +++ b/hw/pci-host/pnv_phb5.c @@ -6,24 +6,7 @@ * SPDX-License-Identifier: GPL-2.0-or-later */ =20 -#include "qemu/osdep.h" -#include "qemu/log.h" -#include "qemu/bswap.h" -#include "qapi/visitor.h" -#include "qapi/error.h" -#include "target/ppc/cpu.h" -#include "hw/pci-host/pnv_phb4_regs.h" -#include "hw/pci-host/pnv_phb4.h" #include "hw/pci-host/pnv_phb5.h" -#include "hw/pci/pcie_host.h" -#include "hw/pci/pcie_port.h" -#include "hw/ppc/pnv.h" -#include "hw/ppc/pnv_xscom.h" -#include "hw/core/irq.h" -#include "hw/core/qdev-properties.h" -#include "qom/object.h" -#include "trace.h" -#include "system/reset.h" =20 void pnv_phb5_cfg_core_reset(PCIDevice *d) { diff --git a/include/hw/pci-host/pnv_phb5.h b/include/hw/pci-host/pnv_phb5.h index 4534083fd5..8f1df4892f 100644 --- a/include/hw/pci-host/pnv_phb5.h +++ b/include/hw/pci-host/pnv_phb5.h @@ -9,12 +9,10 @@ #ifndef PCI_HOST_PNV_PHB5_H #define PCI_HOST_PNV_PHB5_H =20 -#include "hw/pci-host/pnv_phb.h" -#include "hw/pci/pci_bus.h" -#include "hw/ppc/pnv.h" -#include "hw/ppc/pnv_nest_pervasive.h" -#include "hw/ppc/xive.h" -#include "qom/object.h" +#include "qemu/osdep.h" +#include "qemu/log.h" +#include "hw/pci-host/pnv_phb4_regs.h" +#include "hw/pci-host/pnv_phb4.h" =20 void pnv_phb5_cfg_core_reset(PCIDevice *d); =20 --=20 2.52.0