From nobody Mon Nov 23 04:26:36 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=1793293926; cv=none; d=zohomail.com; s=zohoarc; b=ATlTIXGoaOyHOc0XXjuTZVgnJcDiiXCnSMBu6wMjsHdqvRKpUVlBAh1Ia/wJs5fD6K72r/Df0JRZCoASOXUPNPFJMRUEpX0/KDBTRRXnu8ybtAR71K/HUthzm7BNshUuCwJQN86qxzcrHyUPILxPBtmTtVqCtZpb+g5xW9ORON4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293926; 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=5kfKI09+2kO3jT68VAcnAvCW4rNcsJxWq24lH1L0P3Q=; b=QRegcBBKgf2M4r/f6gO4TvynFB6HiRG43dkMeac2Uc3U2ENX865Jm5gQPQ0y8t2t72MO27J72tGWQ+2dP4rpbS0njafjqTstELP/BcCZa4kFrHKPjoeObdLnPXB1xWvd5vGXp9L84YOEwkPPkCrYUd/uO+HOhNvqMgvb4Qw5GXE= 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 1793293926140400.6662545645305; Thu, 29 Oct 2026 10:12:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTek-00066O-53; Thu, 29 Oct 2026 13:11:14 -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 1xMTeg-000656-7l; Thu, 29 Oct 2026 13:11:10 -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 1xMTed-0007y1-S1; Thu, 29 Oct 2026 13:11:09 -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 69TGEYZX410652; Thu, 29 Oct 2026 17:10:59 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3mkt69-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:10:58 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69TGJntJ3392668; Thu, 29 Oct 2026 17:10:58 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hm69e166k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:10:58 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THAuUi4588508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:10:56 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87FF558045; Thu, 29 Oct 2026 17:10:56 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 018BF58050; Thu, 29 Oct 2026 17:10:55 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:10:54 +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=5kfKI0 9+2kO3jT68VAcnAvCW4rNcsJxWq24lH1L0P3Q=; b=KvBvO+NK639dvbVeNgLl5k AUvZZPC5iYSmMWq14DAdOWpxhsw+jExcaneQGu4z5Fje1XQe4xzg8+/3y9te2oze FdjLTR0qoxFfQk1YiXPbEKFStni9c6sEi+p25iHN+z4y2Y+XIt6Q+IgFgKjJ6rNd 43kZYd3b+6oXaCvEBuhSaWaQmDxHcVx08BGBKiwlj1uGQNKF8gwkIdwjy6VgGpmk 5UOZKSs7/LakqG2YK/7i2LUeCkA1v5hkvc2DCRj7A3E6dhQZepBI9DVGQldxcEfN JAFun9B15u0hw8juVJa8VOWmUJ1lcgnQSFmGEbPZvfYeLDZQW+70zhg6kgB1LWAw == 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 RESEND 1/9] qtest/phb5: Add testbench for PHB Date: Thu, 29 Oct 2026 12:10:39 -0500 Message-ID: <20261029171047.3862430-2-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX5BVobwtr8jUA 97v6aQTsvtgCovNPkcHtAT6HEAfAv4Ug2oUAtG0avg6sJno99QDpUCM9FL8HijMfj4Xui033624 quvUzEt4H1CfYQKSw4UsDW1hHCfDsvY= X-Proofpoint-ORIG-GUID: _RizoBGEDKreyWcy0V-fi36JEd1aNNZf X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX0cDzRY45pyrT +Tbi2F1ns1jNdP/udCEj6r9TQp8XgHUThXfCO5WSRSrZoBdGJ+ezS8/tRYvxA6yZQ/BbJb7dDci dqlRD9CP3KRC9LqL/FgoGqAuVlBFbyDjAarl9ZV/18ET7mXwfK19uQN8I8I8xgkfV8s2JDBpFp4 1Z+dkt+zER2B/EyFFYvuP4TaMtHxFTZxVycLobA+f7LEz0t+KUDfQbY0lhQH0rUsJ2oo2GqTOIZ 6VfovYTHEnywPhkhXoCt3m864DtZKWvGOzjKP4wUDlwyTch8JMtCQu4l+Y9nVwwvUFFzvkb3BhI P4huTE0NGIhsm1fGb3o+Sw9nsqDN6qb4Z6iIfmzNTaecAIsALTSuGxRiYPH9+08u0zJq4IqPpUW W3kDckJJ6HlBxiHWIfbyw25kpUK1Lw== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae37e23 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==: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=zHMdCkDpksyigQT-iYMA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: ihvrS9_X-vgvAYrvYJIRyFE3oLno6FRZ 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-29_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293927112158500 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 46d4fc1d2b..5dc1ee1b35 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:36 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=1793293902; cv=none; d=zohomail.com; s=zohoarc; b=dfvV21kbTblSIoPwWLAgejt6YQjH8wOikDyx38ktiaq9wpHcb8FoM+OnkApGhZLSYdTyvZ1jyZrJhLKaHMNnFBRbx+L/JkdCaIhGIF0zLDJIEBSd22/fJWYPktVJEk/EiIYOX+89BRr/9kilKRlGoBKbbUD+/odL3oI6/rrT5vI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293902; 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=gWMKEo2j8omAivPwsvvwaPly6OVa8jzwCSS2mvByMlM=; b=ie6apHYHuWlBDBo/JwiOprOOL0FGKhqisDPyUVzGcU0OFTKTL9rwe9Vg42XTUTEMwT3sOX3r0aaolveDUvxLxcgGAoI6GKhdQiGlaxlPbiM2gBMTcmINYJlEhNPEcFQsIdhIhn+V6o1kjnpEzQ1myVqjsWmazaGgFmVn61gfHns= 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 1793293902220921.3442546429292; Thu, 29 Oct 2026 10:11:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTeg-00065R-UU; Thu, 29 Oct 2026 13:11:10 -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 1xMTee-00064W-Fg; Thu, 29 Oct 2026 13:11:08 -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 1xMTea-0007xS-La; Thu, 29 Oct 2026 13:11:08 -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 69TGEAsU461170; Thu, 29 Oct 2026 17:11:01 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 4hgmd7bnea-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:00 +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 69TGJv193329847; Thu, 29 Oct 2026 17:10:59 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hm8qp8ep5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:10:59 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THAAUZ24904414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:10:10 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41E7A58045; Thu, 29 Oct 2026 17:10:58 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A785E58050; Thu, 29 Oct 2026 17:10:56 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:10:56 +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=gWMKEo 2j8omAivPwsvvwaPly6OVa8jzwCSS2mvByMlM=; b=rdLYMNpw2fP2WKb913onY0 E5+fcV69tUrEtzT+BB/Gps/9kHIi8ICp5NCLKCc6+ZdUSTFhCJsRgMzhvDsFkb// SY4miYGTNC76RmGER/RN4pcIVYTMKSkmgc78uKVMmp2SyKLmeg3bfOCNX4VuntVN nsXMJ4UXAvZkSXd4KWF5+Y8TvgahapjaxgS6J3J8k497j2bo3kiV8HJ5Vsjd02b7 QiLHBs8vO5nkfZ2o5IG1vxIXkCSjZu+x61dQ7My4vI7U5RqfBHWbEKuNZ8+m8Dbu slaM4HUViBR1wLbU+b0u/Dx1XLL9kotcrVY8NY0Xh0xhh7CdM2IO59xZc+n9hRHA == 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 RESEND 2/9] pnv/phb5: Add reset logic to PHB5 Date: Thu, 29 Oct 2026 12:10:40 -0500 Message-ID: <20261029171047.3862430-3-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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=6ae37e24 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=U7nrCbtTmkRpXpFmAIza: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-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX0g8VXvkAhbE9 zCT3edF/G5WstlMPl5eG/FiBCnHXSXdEgh40ruMWWvsCJOWWvxEIu/R1gDqHefuyDD8xYbl2jGI ErMarorD1BJj1cd9Z0miC1aq6/0VDu+0del1FRlGoHe9AzLwNlDvl/42erFaGnb9+ei1mKlIkDA 5o54B4OxxSqHwlTRCpGw9rPeveCVRoUklZywaYDyarXIGJzhNORJbwTr5NxoNHjm4oaAbJJ1ZaM NNQmnRr2ZSd4JInOxYD53Gz6CYpQOsdomE/9Ut1kqVm4k9PU1ibWmnkcZV5Vmj3wtQjyZeiRU9C +is5JVSvY/Lol3L7pe3aVxDKJ4SC+I2mbb0al4PMvuVGD7sLf9nh9fLL2HRKSypDBLWxnJ0cNMk tLVJRJ3KA/Lf7//kpx8ILmGK/a6wiLmO+ogjNjm+WTPa601/mW9h2pWluGJCwUKJa6pwwA/48RA RMJVqxB9CD0DZEUdFGQ== X-Proofpoint-GUID: ZxzNVLBFZ0oFN5g6x7qN48igAOzKCzrJ X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfXzKIJtUtz+5I+ pbxUvM5io7exnwZCdyTft7vMGNjIT2dWuaM0Yx6ELFbp6Rj3UXDAsyUGIoHJ+ZIE8ozVDDY4/kx 0tAHVvptzAaasjoOjeyqnnMKXT/OGH4= X-Proofpoint-ORIG-GUID: 1hRo9SXHKl2XwxbwFThf7_tuSpHFMUZj 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-29_05,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-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293902817158500 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 ac09a0b034..12a5834f61 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", \ @@ -503,6 +504,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) { @@ -621,6 +653,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: @@ -1546,6 +1590,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); @@ -1622,6 +1673,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 /* @@ -1715,12 +1768,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:36 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=1793293898; cv=none; d=zohomail.com; s=zohoarc; b=AGAeKgBninMzr7uw8IVG+unmVU02vtOow1Sa2vJPcsBglBBWIp1NhcWCyoWyNqrDxnnwhTXEejyoviDzEa1ckZPXyTLBY8UfQiplBrIlsLekPEqHUCDDOr63NtbB2dYnjpL1riC9661C+3LTX7/ES8SIqm2zd+km1vYZfIuG6Dw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293898; 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=WmbANlbXIPv3cmqyJnMkVPE81OBygJ2+kdu5qHzrr3w=; b=f9qBx96ZTGpiGyZNsslz4rMzqxVdStyXgOOeaMIbry/nmSBgf4RhwtzMafOrLfFqZltZo8UssoBypk9JvpH7u1kaJfEG1PFRK7Z4J9p9jwZaJAMWOghBd9hVVo5Rf5G1rMO9XbnfNkqI/qJ4GI18s3cXNpyzousks0vkpzFh6Xk= 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 1793293898655729.6337791008644; Thu, 29 Oct 2026 10:11:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTet-0006AC-K9; Thu, 29 Oct 2026 13:11:24 -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 1xMTeq-00069M-ND; Thu, 29 Oct 2026 13:11:20 -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 1xMTei-0007ym-H7; Thu, 29 Oct 2026 13:11:15 -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 69TGE7Ag3038808; Thu, 29 Oct 2026 17:11:02 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 4hgmbtbqa8-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:02 +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 69TGJuok2213642; Thu, 29 Oct 2026 17:11:01 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hk010s8w5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:01 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB0Fa32637478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:00 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E6DF358045; Thu, 29 Oct 2026 17:10:59 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 611D058050; Thu, 29 Oct 2026 17:10:58 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:10:58 +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=WmbANlbXIPv3cmqyJ nMkVPE81OBygJ2+kdu5qHzrr3w=; b=cQPmwf+l61WNCp9L3yCILPtY+AcXDl9Q7 YKFs9VesAJTOysW7205aDFnRgKFQ2XbNXVmFyS+YnWmd6q8zl8SHh5fQZSpW8QOy NCGbg1EpYOet5EaUn9wyjfUXuUP6QRjKFmjauKAp4vy67uOnYslaaXr0rVOA6gk0 WtV+6g04UiDRhQI/fGrXXUWeOiT4AxoC/u4z4gdKJxICLjtnaWH2IjbQDaa9nuXr sc6gDCBe/rnBMF1EcsgVewxCEOd8hcvSLPKdnUSViUPToGb4V6FP8gjsjaHiAiYQ Qiz8POVsX9G2IhXukofnWJSNTqXstgfgeLjJbW4wyXzGuElszPcoQ== 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 RESEND 3/9] pnv/phb5: Implement sticky reset logic in PHB5 Date: Thu, 29 Oct 2026 12:10:41 -0500 Message-ID: <20261029171047.3862430-4-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX6K+3CoycZkjX fMp8kZfkHvBnVd12VgfUvzgTno74m3HkfhEN/By6Mz3tyxfd7R3O0fR0uWsaUwm0XYz1C2t8fxx Cw4pkVYNG+KeWC56kNwwqZk8woML9N4KdVRSHdjio/VMrcE3owLnFOUbxOsbzxZfNFgCYA5kh8t D+v65yqkDxRnpeA0MBFyZB/Wfe1StN0DMKEC7KExGG+NcQuE+PvU0yqDCOJbOI030OMIxxF/xGY QaXw7ooUB5aKignWUbqba9AFPtlHuyNozcRFWXQSCF9juY2g3HvYYqu4qa3QSKjWR4Yid8s9P2Z XBg16AGZFJS/9qA9W+v70fqAJQYS5nlcD4EWSC7SAu5kk0cWaWPq7r8KuhwARXGeDF7oktn7cie 8BTZca3aFejgXtIwYdcus6ng3cDgMSDfgo1zvv1XM6XFKODDKUlgH2ZFfM8GQ+0ZmulGkfqu/RK HGQ1+qR9+d+dx2s26pQ== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX964lO2X5GUGO ehzdrJq/jGt1uhHa0P/kTR9lyPZMiRV/80QVQMIWB2iWk8590UB/XjHS8m9mxhU8TdBQ2rglCTH ABOrwImXOdAyq7U95m5p4NrB1sjUHm4= X-Proofpoint-ORIG-GUID: uRCQTSocRHir-T6ytnY2TLbzDMS-lEEm X-Proofpoint-GUID: Kx9pWRzrXXt4adE82IBkXZaT1i7zNkKR X-Authority-Analysis: v=2.4 cv=CeKdd7rl c=1 sm=1 tr=0 ts=6ae37e26 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=_OqsxZwj8_jexw0pSn4A:9 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-29_05,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-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293899664154100 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 12a5834f61..f2edbf9212 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -504,9 +504,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); @@ -519,14 +527,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; @@ -665,6 +710,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: @@ -1590,11 +1646,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:36 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=1793293967; cv=none; d=zohomail.com; s=zohoarc; b=WueoS/+WvckyRIW2Pa53yPUeGDNsdC6AYbWAZPpQEV0XYEA8/alcdqFfUSwlMpJsCSqjsKacHEcplIDXma1QMQf9Lqj6yiYhUrSEsHH1/yQRPDV2BrSzOD8ecw8ObuePmwgtw1KH50Dbv5Nt2NRcQZH2XWMBlv6qudQzARteeyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293967; 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=dQ7PO9hIUBSf/AZjhYFrBgOXux2B6HU1uDfZXhHGMnE=; b=j5HCvhzOlHYLGTczNvkEajaHK5X6A8XLLYR4Ml49LkD2G9wmJ3+jwZoEor58lPCNYlG4NpuWMyzoKEvvojELitKyMOgUoZBrd+p43feqi7Dx/gTdoaHQ6T6UkkQbptbLl620pfWSDH6ndPqHEEkIW+xqqAaVLk+jYZkxRMai5aE= 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 1793293967597314.48240969540643; Thu, 29 Oct 2026 10:12:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTfB-0006Oe-9n; Thu, 29 Oct 2026 13:11:41 -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 1xMTf4-0006G0-1Y; Thu, 29 Oct 2026 13:11:34 -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 1xMTf1-00080Y-ES; Thu, 29 Oct 2026 13:11:33 -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 69TGE5OU3038777; Thu, 29 Oct 2026 17:11:05 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 4hgmbtbqad-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:03 +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 69TGJuol2213642; Thu, 29 Oct 2026 17:11:03 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hk010s8wa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:03 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB1vw32572000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:01 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EBDC58045; Thu, 29 Oct 2026 17:11:01 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1277958050; Thu, 29 Oct 2026 17:11:00 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:10:59 +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=dQ7PO9 hIUBSf/AZjhYFrBgOXux2B6HU1uDfZXhHGMnE=; b=WoeaWoKOTolNhoWJnc7iLO KLMALE7SRARVeYrwS60P43kgFzuS+ejGQHpq7jgIfwTcj2pErY18hX0DU5Kwaby2 vn+j8YwbdckseP7AW545AcluAsoB0j/WqVuffklPf7kZxosiAM75qnfoPWO9CDPY Rs2RBhIJaoNq5MT0sSG2AySiQRppn6/wAV13o0RjVJOied6sJOnQ4faR+bjPKSWk Qe6YbDTFGokjpHHdRTatDonFt5sR0bxobCVfH12/0PqSFMKgdyKMJZrbzm0nsmCb g0SWTkbZ7+tcMaTNp2g/WEUGjtn+dU9T8qb9DfgQ3rrsWrrpSmWyzqP9RUjjDDTQ == 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 RESEND 4/9] pnv/phb5: Implement read-only and write-only bits of registers Date: Thu, 29 Oct 2026 12:10:42 -0500 Message-ID: <20261029171047.3862430-5-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX1zd0UpCzcnXe JQ8QFgEBv4HV6bmtskcvfXfoVoUxmcA7rZyOA6mBQ0W/3jpQGnT6xaKyjQN1hRCsFMJ/fMf3B53 br6MRhV+dpHlwkX3ayZ5+pihinFiEStjdV/02Ys+yqAGyYTzs0tAp5zlTOrlULQeFxOpIGz1aiS DV+Ze2sYgn14kYTr6Jz2x6aioxNWNl6M+wDRyDauQ3t7or2Jkt32fU9X+0mv5WbydTXyN8WXtRi T8fBcg0y1YI+O6JsrLcxjrE7xWFbQNA/+AxbLfnezjaM3OvEPcJTLwmkguysDp1HGvxn37jSfW9 AXhd0VIHTsC/Us8Bvn8Achj+j1n8K6/U5Z7l0le4imbNMpw6TsMfrPVB3jTmInitXWXzerCZGiR vCzqV6pRoL4Z+czTPKyCyz2DfRH2rOhhfM9KZHRykKUmomvyevn6sdlKBOJh074MPz8O0BcsW9o JPUQBu2wn+IsdnKSWrw== X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX1gPc7QRVBhjt ZnyQ58jpxduhiIyJhup2fzCDxS2f1TAgkkJcvhHWqSDON1VF7gv5zUEL/4f8vnvg/HdSfTqHfG0 Udr8W+go61pbVFLmroanBanIWcY7/pk= X-Proofpoint-ORIG-GUID: orpdQwPgwLu5zCOfSqQDL5j0qCo6TZhI X-Proofpoint-GUID: ICuqDbxBwyPE8zC8VipjXc6WJ0zzyomL X-Authority-Analysis: v=2.4 cv=CeKdd7rl c=1 sm=1 tr=0 ts=6ae37e28 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 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=20KFwNOVAAAA:8 a=djULNIhFhI7Ibwp2e0QA: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-29_05,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-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293968584154100 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 f2edbf9212..918842abfa 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -662,6 +662,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 @@ -737,7 +743,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 */ @@ -780,7 +786,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: @@ -790,18 +796,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: @@ -1646,6 +1683,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)); @@ -1705,6 +1766,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) @@ -1879,6 +1941,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); @@ -1887,6 +1950,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 { @@ -1894,6 +1960,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:36 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=1793293914; cv=none; d=zohomail.com; s=zohoarc; b=j5yoRYtQj2kcdiS9dixySj/maJBpNhJ8CPNfNMyOQSkRmvSYanWjiaAuSMn1PC8u4ZG7OwjL8v1g0HOjvbziuamLyBbcfcUj/JrPcJvL26ONBQFjMzvP5cA0YZEDRRMp9oDTwmnfF/+wjCK1gRTtq7fzvD2Yyd4sPVmfo06gb7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293914; 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=3uOULYwrxB7QIHTJKSmZv1L/KiXx7qwnlQSv+vdCtDA=; b=FTGQ/kMNvr3xlyy3403bvuUgeGIFctB3vB2p8CzD8mfKw8Kg08CZmdf+wM6QRIPtw96UQJRtU44U9eaG5o0YcnN0PVwpTIHk+JhffDvBN/HG9XMvt2sJHCkmJXr2gJSxlEpsnMR/5wW5vsFaJkrWqDsWFxJoZcpF8AsfACEzNQA= 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 1793293914437339.0600066713822; Thu, 29 Oct 2026 10:11:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTex-0006Bi-Lt; Thu, 29 Oct 2026 13:11:27 -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 1xMTet-0006AD-6k; Thu, 29 Oct 2026 13:11:23 -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 1xMTej-0007yv-Ka; Thu, 29 Oct 2026 13:11:22 -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 69TGECR4409668; Thu, 29 Oct 2026 17:11:05 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3mkt6t-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:05 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69TGK4C33393195; Thu, 29 Oct 2026 17:11:04 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hm69e1677-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:04 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB3pk27591196 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:03 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45C7358045; Thu, 29 Oct 2026 17:11:03 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AE0AD58052; Thu, 29 Oct 2026 17:11:01 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:11:01 +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=3uOULY wrxB7QIHTJKSmZv1L/KiXx7qwnlQSv+vdCtDA=; b=QUc+7IHh1BNhPV8J2hgjFy zp93s3ZJ+GRoqbbCokigQ6PI+UgKXYwtmBrNhkozlsfIteazM31GgL8+bo/vlNv+ VZu0bkT1YLrSya1PzK1mZGN+eOgR8Zc/yzlWpEz+QjNgnKrlrUckimDubYxBXsia fUOrBJiIOz31Jdb+FNXxqbj2LzQdLhCABTndDQtIQ9J4cxdc4ceuKcE81hgaZbgO qW4j0UVDZQb7Pqjjdd4NJ2mXNcoK7hd3DMfXI4InNNPwmkwQ49BOmnVY68UbME82 kt15u7uU5MwaAmzZFc8S7vGjCCX5zN2uyRh7EnYJUYs6eOJCIPMb023fhLPLAa0Q == 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 RESEND 5/9] pnv/phb5: Implement write-clear and return 1's on unimplemented reg read Date: Thu, 29 Oct 2026 12:10:43 -0500 Message-ID: <20261029171047.3862430-6-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX3kGXn4GOdRvP LU9+xvyTYF5W+IwvDLBmbBDeAu4EN6G9AX0PaC8VhTxzOK6Orb8ul81uQqA/3uQ2C4kfUJJalmr qRmDgE7IFezXQ7EkRa2nmDp7qhuSfp8= X-Proofpoint-ORIG-GUID: Y-NctQjMynob3nEa8qTfI4FTld0NWuYj X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX7tzJSISSBWXL V0LCqNPxILGRdHNk0rhGma/VB2ClYAsccQ8DMqU+eFV6CyXd+9F2MWcrG1w+nMyipHjyAILAsxw cLPGVk+wK7Alouyr+Dh6vytW58l1tnuehnbri72Rea9bG9qTOpfYvD3BfFfkUPqpCK9MhGSF+dM rrscr+bsolMOfwbSB8B9jEqYwiPSP/YUQN5t7tN6m0raxf+dwJfELNTIZKHAPNxvcGe8Y1e7dz/ C5+OJHs8EXVodSpKGKRZknRkzRTAwB9eFxWhkQctDcOqGxvvG0WBQAbftDpJlQmNOOZ/OIq+4eA iLWVJvDXU+nc6KG3sjoZIKh5eTbzAuMNrqmAfvHbog79EW+xmrgzHVcluPciwnpLmXPL1M5yx5R XecIvsRg6fx2ZQwaXMCGVTUzOcAnEQ== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae37e29 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==: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=5RaDrMxcQoNUQC0trd8A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-GUID: jmh2cNwxFPeXObvedT59-TXurabHATQh 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-29_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293915814154100 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 918842abfa..5aa63f00fa 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. @@ -543,6 +543,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 */ @@ -580,7 +584,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); @@ -610,8 +614,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; @@ -650,7 +687,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: @@ -659,6 +695,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 @@ -681,6 +722,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) { @@ -728,32 +770,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; @@ -841,36 +920,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; } @@ -1812,7 +1929,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:36 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=1793293957; cv=none; d=zohomail.com; s=zohoarc; b=jwrQTLPJPCLtcLj8q6eTFjpFIy1a3muk3Flkrzy33bVawa/wy5jpS1njnu0sVIDCiCO6dZRrrsCZxZIHkpG3/xbvBBkdKcfUJ7tGH/QZaqSfDNf0L5tN3UfraX5vMMTbJZdIdEAseWDcMBK9W98QCHhVqRtWG1YzSfYRXgb5biM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293957; 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=0TxIHfRNTHuv/VtNu6ElNIAWPxT7TqMs+GLSUMDItZE=; b=VY8uBW1iizJRAMU+g+cGStbrqCqCRZ7gBUw6a8/lPjf7mPe5nuhZe3aFmLFWD0EKKZN7c3Bzwsha966bGcW5w1cFdAo7HPpmtWssXtZXElsHHw/cayG4Jt55so1IlKzoc0eSWsKdoYbyGz7bif0RHyVFVe7TciY18aC6jhb3C8A= 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 17932939577641014.4212417209905; Thu, 29 Oct 2026 10:12:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTf9-0006MA-Pd; Thu, 29 Oct 2026 13:11:39 -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 1xMTf1-0006Fm-R8; Thu, 29 Oct 2026 13:11:33 -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 1xMTez-00080L-Cr; Thu, 29 Oct 2026 13:11:31 -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 69TGEBYZ409643; Thu, 29 Oct 2026 17:11:07 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3mkt74-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:06 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69TGK5B63450011; Thu, 29 Oct 2026 17:11:06 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4hm6pb92c2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:06 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB5SA65929668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:05 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E0B9358054; Thu, 29 Oct 2026 17:11:04 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6504F58052; Thu, 29 Oct 2026 17:11:03 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:11:03 +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=0TxIHfRNTHuv/VtNu 6ElNIAWPxT7TqMs+GLSUMDItZE=; b=KF82iVVcEPpQL5x2hj/Oh4b9t815JjQ+/ XnetxDJXH7zF84OcJU++c2J5HJritprOJG3ZL8IHiAUL28z5IQhYc324JQcZKL7t nhAHteUm/u6ALWr0WKQk2wjFaHR0z0LZWlmQnYER4waMs72tcLKq7gE8V0GDgxgQ cstE/Ix3myBy3AB/Mf+D8QyF/ntGzoOKxz9+XJvSIxwP9Wh9bD/VnQyKhovzrNnt uk+st/sGpZhT2Z+X4Fff77DcSTOlUmkHm/01cXooXV32QxEvuQwBbmF2nhvAcXXN Y3JewkkOQENf4A5h4TZI+URAuGZYwCE38WB9FYhIENaligwgfrftg== 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 RESEND 6/9] pnv/phb5: Set link-active status in HPSTAT and LMR registers Date: Thu, 29 Oct 2026 12:10:44 -0500 Message-ID: <20261029171047.3862430-7-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX1Y420w9nziz8 EKRAyS8eRTFlXydo7BonntQgpqUF3BkVvER0L3RKAxJTP1wwRFxWoxXcDcHl2lCirFaBE2LS2n1 K9qkUO+yvLnbjKaSQ28Gs7Yu1aPucjM= X-Proofpoint-ORIG-GUID: ksNcIXkrPYwmRQNdyv9rr0GQCBel5oT3 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX9mIkZqxk7hGa bVCskubhqo+D7cE7OGKJ4VBRPQfKo0XoB/PYQFP1uT0GpV/B+8O+oO4LhM2EDxHMdbi6y/KM7mF FGyLGKhugsc+rdmMlRI0VtdOZxh7wnZxDhVbl1OtcmwLBJnO+x1poHq3KSNf5J10anXad57KI9E N92l8sPuiWe9cgUFdVaEdW//1/pZ7Fpw0tKq7H6eHGTloX2nkUfhlA4z//x7EXhctWWMNgkKgB1 RBf+66BgrU3YnFh86WcKCj6A2f51vQDMVeb2aZwKMxa7aoKGWSDvAB5FTjSYCUb2mFbBDAQvt59 KumlMjYBZdBN7Sy4xUQFmcYe6tD9RghKyOGJXFfr81L+ROMiNEBYCLH39skqiOk1Jf1kn14eKN6 ltyaBFNrrL682emR2/8Z4CXoIfKUIg== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae37e2b cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=660iZSQnnn4A:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=20KFwNOVAAAA:8 a=SX2aUA2rIF85faSKF8YA:9 X-Proofpoint-GUID: DBSbypPbvzv7e_afc1v8ElJLDTBnGwv0 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-29_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293960349154100 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 5aa63f00fa..8658b0e5b6 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -511,6 +511,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; @@ -688,6 +703,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: @@ -835,6 +855,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) { @@ -908,8 +932,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 @@ -917,6 +971,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:36 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=1793293976; cv=none; d=zohomail.com; s=zohoarc; b=EO0ycKK2zIIU04f8bFyk5MXYPHfkLr9593tLSCZZkjz68Ly3JYAb3QI2SsqVIQaqYPYHg00Ct94eDV5S2IcLJw6gp9H8Gp3Bo/I1LrNfOUcZfkqgZxSWPibMyyBM+8hpoMv3iUxiibrSeL/BGcU17j8lX5weyg5u8z9VHjYM6mE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293976; 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=GdDbDJOlqMU7cfw55LUH8uYjfsx38RR7txjDsJxEhJ4=; b=lNSq//pvuJTQ7nTmkaNmGkkl6nyEeHEJkgjMCVo9vJ/duIW9DXGN+n8YPeqRAeWf76x5ecB5qyxDpWxiZSGSP8dBD2fB49VJNpPvZBnE4Glm24E64SFwWLCj6miOgCeGOPeIVONPQCSvOl2Wpvf1yUOa4LRd0nj/N/IwupEVuFk= 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 1793293976631823.8015103671261; Thu, 29 Oct 2026 10:12:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTfB-0006QE-TG; Thu, 29 Oct 2026 13:11:41 -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 1xMTf3-0006Fv-DT; Thu, 29 Oct 2026 13:11:34 -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 1xMTf1-00080o-L2; Thu, 29 Oct 2026 13:11:33 -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 69TGEJam409744; Thu, 29 Oct 2026 17:11:08 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgj3mkt79-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:08 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69TGJnLT3392662; Thu, 29 Oct 2026 17:11:07 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hm69e167j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:07 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB6cE30016194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:06 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87A8058052; Thu, 29 Oct 2026 17:11:06 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0BF3858050; Thu, 29 Oct 2026 17:11:05 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:11:04 +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=GdDbDJ OlqMU7cfw55LUH8uYjfsx38RR7txjDsJxEhJ4=; b=LtiR/WX3AuD7jNlQjridQM uF9Xhv2fbA+shIhMuA948Trk1mEl1ggaShd/V9DKsnz/XGd3RnydeLrD6ywhqp4k sicNGDJhnNRyyrSTgTTTszNX8vIvDkH26wpxspnEoc8gf7db+t+6jjTrlvipx44j KFBHdQx2btyL7T84i5ihvGG4uC8bXo60VdhTKAkDdT6VJo8jobabZpBGGCmhrh/T qBpa5VK0cFCjgDAuK8Mqayek3UxgqNWYrG/zIHs2c6PHZcfDFdBBib4MVxKvS6bz 59HaBF2w76raPAsE1kfgXAdoH2V9e66sP34YNxO71VB7Tuq7NOolqp/WvNz9I85A == 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 RESEND 7/9] pnv/phb5: Set link speed and width in the DLP training control register Date: Thu, 29 Oct 2026 12:10:45 -0500 Message-ID: <20261029171047.3862430-8-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfXxbVEUTja0AuJ cOuOdExoIqRn+p9DgAuOEABbwLICJLJTo7GGZg2pMu3t6hKZfBv6Wk6UVoVAOkmUvFiAXlgy+vy 5iZn+nvHGgBAJVBzUyNvhFihWEC1B9g= X-Proofpoint-ORIG-GUID: nyHq7zUoUZ9bG3fTdBYSbo4Wgk9SMXak X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX4dzWC2+PXQPL 3mHldgleJVT8D08Vr6QpmdlVnQS5Nl++9o0v/4MNyC7ys39uKMk8zsTjkcGlemsX2KeiV3uEmiM FCHu5/ZIL4M0oNlvyd2v/lUqrccEgM+5AiAWIm3wd4x3uu771ixIitJU+yhqVOTSLasfl3EEAeU joop/vVGcLV0k+d9awy+rq0sqPYZFgF/VxRJ3Ss5plPpivF2oN+NaOfCu/B0QBtxAOY+JkhBgUL P6YcAiB/9hBPfcX/bbPyaYr0zW0zDtC9KSHJ5t5ACJjWhm2U2BekXnDfPqVU+2iwuANx16cNi4h I2bqDUSG2UhdSzN6AO8korqyRUYeLvuddxlUX75/sggNq+ZJYpr2t4NqmUS2MQgcpjt6Zi89aCn ER8tzVFIkhIyZOABleG472Sxz/9iwA== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae37e2c cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==: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: TAHnAFp7FU1upeUPKYIqGXS6-hNCfqQb 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-29_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293978626154100 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 8658b0e5b6..4a49461f4e 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -521,7 +521,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); } @@ -860,6 +860,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) { if (size > 4) { @@ -926,10 +927,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 /* @@ -952,7 +970,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:36 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=1793293942; cv=none; d=zohomail.com; s=zohoarc; b=mCGUs8X9GDTvD8OE7pAXArNcdlDmo3S9R+d8y/TMeXBjrB4cBC0nCepjJT5E2o2VJZsWpUi71rzGGpZ3AUd+KVJux1aj3ss7I9pVLvykpA+4TkPJKw/yhVUWulOMsJpfEk8010/74ZjkP/lR0q+yqnvDLvxHn3hgWtlV8da8W9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293942; 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=9gpBmCFxKMjUaIet0V0EIZpGa8+b36EAztvkTEoizXk=; b=TuhX2UK6MbnwmdCafiVliQEWBA2oDMiYvTRw25AH948FOzZs+exJTFHTwFaLeV7uIFVldF43aywgf8BBvRr/+3aQ3SnBraXZNKtRb910z/w30ZS+OM6HmJFKE7gN0Z89cwSqhjjL7cDj7SWEocE9JqlZolLDEGXPee+jFk3fOwI= 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 1793293942559398.5454209884157; Thu, 29 Oct 2026 10:12:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTfB-0006Oh-DD; Thu, 29 Oct 2026 13:11:41 -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 1xMTf3-0006Fx-Nn; Thu, 29 Oct 2026 13:11:34 -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 1xMTf0-00080T-SG; Thu, 29 Oct 2026 13:11:33 -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 69TGE3mQ460979; Thu, 29 Oct 2026 17:11:10 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4hgmd7bnf8-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:10 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 69TGJxiT3393108; Thu, 29 Oct 2026 17:11:09 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hm69e167q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:09 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB8Fk27787842 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:08 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E79658045; Thu, 29 Oct 2026 17:11:08 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6E4D58050; Thu, 29 Oct 2026 17:11:06 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:11:06 +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=9gpBmC FxKMjUaIet0V0EIZpGa8+b36EAztvkTEoizXk=; b=kdjS3PM1VCQruWLM7Rebn+ gcyqeWKFw7HmLaFYOMS6qJZ+B7n9bWDOSgrTQGd/yIb03ReWVtVlKT2VZEBXjsad mvuTQ0130YoTpejit3F3WgPXbEfqEeMF39oCSnShSS7qSYm4JkUD7COPK0htd7j2 xbaBrTqJysYOnYsHL+c51wh5MKWAmiOfaHxb6Da4riBxg/UBYjw6hc4bAOL8kDUU gSI+wNmJ0hS17jg668DIUcRzI842IxT088eUgoWEsJ7YKZF8FAzwqQ5ldanGDgpb vUbi5Jdl69XHW8aO2RPWlPEeIIpwxOV+vKNLmQqPbaFXF/CKLrXiAgybs3tUuKcg == 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 RESEND 8/9] pnv/phb5: Implement IODA PCT table Date: Thu, 29 Oct 2026 12:10:46 -0500 Message-ID: <20261029171047.3862430-9-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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=6ae37e2e cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==: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=zgsLwUnGCMBw8fX4dgEA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX1w0F/V1k7ZhU +foVDQp3UgsBUL3C4KO3ooPqVHTuI0zxONzs+YuPj8VwGsAPIagngjIna5XvvwzMkFdw2y3FCwT DQ/XelsxRHshbFj187ZN3C1etcrnAX8v72koft8tzdsjCOIprN5BBD4Yf1a23rZ5vUw3cUgiV+4 FjSXCFoG48t2hBYRjVPvBVEu0PI81mbEbXU5r5IjYJOQy0zr0Tcx5+ZfY8fdINi7bSN5rp5+j7K 1Y7Hhedtsrbwn254mTKLCHAbkHOVGxh/0BMXzdPK+hk82xy/LMo9SRF5TmPPh6g0OIxt1fJqe2t XlGVrlzY0eVmUi51Cc4xRQU1a1Kv/scpUdQTlq9zQMj/aj8z5Pb9l8IPJfXoK/6scS0uDhC4KX0 25apCC/39uNC+NiV8Rb/ATchOXivRx3q7JuZMCwMPYY61vjBbiTC1BYG03KAps8Gj7hNPRFvKPF yddzjI64iRJSdeJudUw== X-Proofpoint-GUID: GhgqTKMzv9ZPMwOrJOKzvMzHt1YZsIDW X-Proofpoint-Spam-Info: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfXz8ufsHBr/Z+T fJobYB6xYE2dFf5DRkvdjuscCSKiGAewAKJ+9c0UUHk+ht6KZXHEhw9JweA+iHqEBJmNi9ozT1K U1uMssxz6lNDtdAZ4whfvw0JsSfbKrc= X-Proofpoint-ORIG-GUID: 8r9Gm-Hp1_RP8xgxziDvyPAkJTOGePLS 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-29_05,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-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293944178154100 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 4a49461f4e..956d82f551 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -267,6 +267,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; @@ -365,6 +370,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:36 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=1793293957; cv=none; d=zohomail.com; s=zohoarc; b=FXrBwzUdQWAHwpvcdUH1GddXAPM5F5B7ftPvaONbHjsyKaMVkyOzlWr0eBuQjbup2Hv2s6DO0z7RAd3y18qgjjf73aiUY+WTxqvCPnvrDpTk7rgMW69poP/RFwrA1K8Bj16JuQq5XoAi7btqn1ykKowvkLI3ifPiF1JwsBr9sbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793293957; 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=kN2z2zpwvqfKKyJGFFfzfkGYWKMPBLyflh6HYbvBJc0=; b=Q1an9I+ANG+XdgFIOkBVodu4KJIqw/D08s83pGWl4Xb8I6btELfvssnLRL7ci+B36y6eYP1L0DKlYHx5sOZVMNDxcNHrXwCooHJJlSOSLQdofY+ax2CyMbH9i8FwBsLH70/LsvDTSrgml0oSRM2Oyelm1yMtn8nzMUJtcX1ToFM= 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 1793293957128568.6481649998228; Thu, 29 Oct 2026 10:12:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xMTf8-0006LE-So; Thu, 29 Oct 2026 13:11:38 -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 1xMTf2-0006Fn-A0; Thu, 29 Oct 2026 13:11:33 -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 1xMTf0-00080V-JQ; Thu, 29 Oct 2026 13:11:32 -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 69TGEIbP409737; Thu, 29 Oct 2026 17:11:12 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 4hgj3mkt7p-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:12 +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 69TGJxX12213874; Thu, 29 Oct 2026 17:11:11 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4hk010s8wx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Oct 2026 17:11:11 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 69THB9DI49414576 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Oct 2026 17:11:09 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB93D58045; Thu, 29 Oct 2026 17:11:09 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4DC2758050; Thu, 29 Oct 2026 17:11:08 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 29 Oct 2026 17:11:08 +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=kN2z2z pwvqfKKyJGFFfzfkGYWKMPBLyflh6HYbvBJc0=; b=pp2a8+x2WXf5ZGiS0vQcqC oAn2PKazZGRvJuVTAJH+WZoFuejSSQY4OVJh5hNLttyOwRW6hmTjEPwq5yVV9QtI E4PPlWjmrFPWlaWRYE6D8kBd0QV5VZmjT7Bvx/ir71EUFO5xyVcnrOiI1U/7avc6 qVIv0q3g0Z0UCQkyhYplg3WgEOwEnF7wE/lOzIj1wfSTgJkgDOhrxMEfqlP+pMrQ vR66qr/Wd0oz/xkkEETdn9jO/f+xASxHDi0z5WfjAE3JB4wkhgA4Upt1LpdB/cgR UV79B6oY6U6sXDFevPIyprq+IPA8WgvhdrWViVA4OVWzgSW1JbhW7pKWLgAKb6OA == 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 RESEND 9/9] pnv/phb5: Mask off LSI Source-ID based on number of interrupts Date: Thu, 29 Oct 2026 12:10:47 -0500 Message-ID: <20261029171047.3862430-10-saif.abrar@linux.ibm.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20261029171047.3862430-1-saif.abrar@linux.ibm.com> References: <20261029171047.3862430-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: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX7BoGpZTtvJGI /BlWD+vIabHgM3olnIg4B+j4bZqUgHGBDBruyI+yK5A6sbW0YFZJh07Xx2vt2NL+ctxyq3eAXC7 5xn8N/qm4/nsh+jo47Gf7eS+FIJNDIw= X-Proofpoint-ORIG-GUID: BQx7yECr8GI3dNQmWM9-vZvqCtNuehlA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDI5MDA2NSBTYWx0ZWRfX0rfFpimI1ESw FRoh5AcPeUi8FSLdaePb31AN+jMJnUv1zdhOqcaWLdoa6yBj8JFHEfp/qw1RBnX8qLGDhnHvI6r ff3xBEjqoiLPAPf1+atDfiz9bG5lqo2lH8FWPm1o2ngQ/vbunpauHPmNmIYju3yGraf5Ewf0jB2 NSCEX/JR3vd5tNo1e5L3EMt/xkneX37ApIv8NiiebmO/3GDGS2buf6nQvUAP7GqV920D8DMRp30 he+Id+M38+98wx8axKs7sMcVr9Qt6Pm36uPx1W0VqeWO+NME47npwmZ+s6+p7tImir8Txyny6fR q2kqt+4+uTz7W6T1R+pIlWdk0QlvawB5KngLh8tNlrhBohf+2ZT1Kf5q8VJojQ1PintK5vkTJIb 34rHUr7UWkibWnMlnssHuVCUtr0/vA== X-Authority-Analysis: v=2.4 cv=G7uJgNk5 c=1 sm=1 tr=0 ts=6ae37e30 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=Y2IxJ9c9Rs8Kov3niI8_: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-GUID: g6saIVi7Gn3a7WrZtTq_4y0xgCgj-5T6 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-29_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 malwarescore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610290065 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, KHOP_DYNAMIC=0.001, 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: 1793293958428154100 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 956d82f551..95318c9d74 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -494,6 +494,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) { @@ -1908,6 +1909,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)); @@ -1964,10 +1971,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) @@ -2041,8 +2049,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