From nobody Wed Feb 11 02:33:17 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.vnet.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1770731026; cv=none; d=zohomail.com; s=zohoarc; b=PyzMoq6qAA8JLH/meWabYretnkEMwY4L3sFXYDGWxLSg90YhOlHA1W/kcuMHKWJ1ba6TBzH9TypiCUVG0IZi84hTRKJDaNaFgoZPOgy5Oz1/URM3Cg5SV4FrF6pLk5HQ6NiIV+O6N/q5ZkKc0X5H2mgiwAJat0W5v1Zo6smJu1c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770731026; 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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=S4shNQN9fwoS+DqjKLjVhjAhPZKpz3Pq55hbYoR/o00=; b=B26P1Enr2sj881hFvOvoEWzqoYO+br6ifUdsoUR69susN/zp1EYec3PB1XdB8E8EXOQkc4OE1nR+MA1b/n285AQ+9cbbe3Dz/xctyARftC/lwfzXwbPJE3xqMuOsElrsd3EvZtYdc35MMNLO+d6wM0P8fsvSbambbfn5ZPdJd20= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1770731026803689.2507257583625; Tue, 10 Feb 2026 05:43:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vpo0R-0001NJ-0A; Tue, 10 Feb 2026 08:42:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vpo0O-0001M2-OZ; Tue, 10 Feb 2026 08:42:16 -0500 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 1vpo0M-0003Dp-Ew; Tue, 10 Feb 2026 08:42:16 -0500 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 61A8irWU111923; Tue, 10 Feb 2026 13:42:05 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 4c696ucea5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Feb 2026 13:42:04 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 61AA6KB5001499; Tue, 10 Feb 2026 13:42:03 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4c6gqn1gcq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Feb 2026 13:42:03 +0000 Received: from smtpav03.wdc07v.mail.ibm.com (smtpav03.wdc07v.mail.ibm.com [10.39.53.230]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 61ADg1Zi53805388 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Feb 2026 13:42:02 GMT Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E32E358054; Tue, 10 Feb 2026 13:42:01 +0000 (GMT) Received: from smtpav03.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B55C35805C; Tue, 10 Feb 2026 13:42:00 +0000 (GMT) Received: from gfwr526.rchland.ibm.com (unknown [9.10.239.119]) by smtpav03.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 10 Feb 2026 13:42:00 +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=S4shNQ N9fwoS+DqjKLjVhjAhPZKpz3Pq55hbYoR/o00=; b=Qh+PKKBjiPqBGwg1SuL7Kz HWXWWJy5Co1YO59By0JlSiEz/1JYgJBgpL1uS8i13WhO05U/dRWIp73jcEGFn3HG /l4QxH+85qyzKy1+5It0k7FYfd3xMBwJ/YFR/UN8RLkbaZefZq1cV/vTrQ4HclAO WmMwAy+OesRh2NtRBWOnEAXrvjSeQO83tU7A0v/diOS/4q04E0NVp16sAuo5e/Xz KuMRMt9IGtg7gy6ngPqwdobN4TI0TKtwNrH4J3Do7g04uUpLBnGZeLu8InJGDoN2 1pIzUNhe09RoPSHaDm4/fzCCSj2eLDLG5sIJH/Ci5+iTKwj4JQfIKKTD9CCn/grw == From: Saif Abrar To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Cc: 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, saif.abrar@linux.vnet.ibm.com Subject: [PATCH v3 4/9] pnv/phb4: Implement read-only and write-only bits of registers Date: Tue, 10 Feb 2026 07:40:54 -0600 Message-ID: <20260210134110.1515322-5-saif.abrar@linux.vnet.ibm.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260210134110.1515322-1-saif.abrar@linux.vnet.ibm.com> References: <20251230102156.886288-1-saif.abrar@linux.vnet.ibm.com> <20260210134110.1515322-1-saif.abrar@linux.vnet.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=YZiwJgRf c=1 sm=1 tr=0 ts=698b35ac cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=IkcTkHD0fZMA:10 a=HzLeVaNsDn8A:10 a=VkNPw1HP01LnGYTKEx00:22 a=Mpw57Om8IfrbqaoTuvik:22 a=GgsMoib0sEa3-_RKJdDe:22 a=VnNF1IyMAAAA:8 a=aow-egSQAAAA:8 a=20KFwNOVAAAA:8 a=mfz1QdnSRwmfuQrPUawA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=gFNbaldVC-z-bsjSTzMo:22 X-Proofpoint-ORIG-GUID: fV-kleKN3AKfDlzc7FvPbjdIbz8N_Nfc X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjEwMDExMiBTYWx0ZWRfX2mny80u27hoc qRxjiOj1v+S5p7xStG3n7CITkAW1MjEUX+nCGCTk5Cir5PESsd7fRmG5zaHS+wg/dA6u+uanrEz cpyPXGgmeNF9UTgDEG1Wbe47Axu9Oy05H5HrujLknbvWsnWXJ7Ez+vnSVl3UXWuqkvFJySYV0vk EJagGwNTTcZrl1Ijvfgl6Gg3yTePmDENBVHleDrb7mdjV/03lAzqocQll6Kf758wcstBquhc7hu NxGB6FXqRFVGw07sWRVGLkRcv8gdRKe9w9qFnelpbbxnsJMOQNI93f2Jq/w5jxWXyhzde7H8usQ cA/Dfq9ampy7HgG1EdtIxGpw0DU/ncpuROaia0z9wTjzN9UVlIh3lQhd+BZcdjyP7k1xeIMFM6k vTCDWST01qx8yYrbx92yyyWuL2v4tm3veDoh62Q+wA5QVz9+S4c1R5yRKGUVBpKMMQ8IOgZZJsK cEAWAO4UHJ8JxuPWFSA== X-Proofpoint-GUID: rYvPEaYe9_4y4z-ldt70eD54nIpFcxrA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-10_01,2026-02-10_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 adultscore=0 clxscore=1015 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2602100112 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=lists.gnu.org; Received-SPF: none client-ip=148.163.156.1; envelope-from=saif.abrar@linux.vnet.ibm.com; helo=mx0a-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_NONE=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: 1770731027642154100 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. Added .class_size in pnv_phb4_type_info for PnvPHB4Class. Signed-off-by: Saif Abrar Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: "Michael S. Tsirkin" --- v3: - Updates for coding guidelines. - Added class size for PnvPHB4Class. v2: New PnvPHB4Class to hold each register's RO mask. hw/pci-host/pnv_phb4.c | 80 ++++++++++++++++++++++++++--- include/hw/pci-host/pnv_phb4.h | 13 ++++- include/hw/pci-host/pnv_phb4_regs.h | 20 ++++++-- tests/qtest/pnv-phb4-test.c | 60 +++++++++++++++++++++- 4 files changed, 159 insertions(+), 14 deletions(-) diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c index 961888e952..07479346c2 100644 --- a/hw/pci-host/pnv_phb4.c +++ b/hw/pci-host/pnv_phb4.c @@ -706,6 +706,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 @@ -781,7 +787,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 */ @@ -819,7 +825,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: @@ -829,18 +835,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; =20 - /* DMA read sync: make it look like it's complete */ - case PHB_DMARD_SYNC: - return PHB_DMARD_SYNC_COMPLETE; + case PHB_PCIE_HOTPLUG_STATUS: + /* Clear write-only bit */ + val &=3D ~PHB_PCIE_HPSTAT_RESAMPLE; + return val; + + /* 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: @@ -1685,6 +1722,32 @@ static PCIIOMMUOps pnv_phb4_iommu_ops =3D { .get_address_space =3D pnv_phb4_dma_iommu, }; =20 +static void pnv_phb4_ro_mask_init(PnvPHB4 *phb) +{ + PnvPHB4Class *phb4c =3D PNV_PHB4_GET_CLASS(phb); + + /* + * 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)); @@ -1744,6 +1807,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) @@ -1754,6 +1818,9 @@ static void pnv_phb4_instance_init(Object *obj) =20 /* XIVE interrupt source object */ object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE); + + /* Initialize RO-mask of registers */ + pnv_phb4_ro_mask_init(phb); } =20 void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb) @@ -1933,6 +2000,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 47a5c3edf5..bea0684724 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 df5e86d29a..dfd0e01d1e 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) @@ -370,6 +372,7 @@ #define P32_CAP 0x228 #define P32_CTL 0x22C #define P32_STAT 0x230 + /* PHB4 REGB registers */ =20 /* PBL core */ @@ -395,8 +398,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) @@ -405,7 +408,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) @@ -433,7 +443,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-phb4-test.c b/tests/qtest/pnv-phb4-test.c index 419f34987a..2078fab9a9 100644 --- a/tests/qtest/pnv-phb4-test.c +++ b/tests/qtest/pnv-phb4-test.c @@ -73,7 +73,8 @@ static void phb4_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. @@ -81,7 +82,59 @@ static void phb4_sticky_rst_test(QTestState *qts) PHB4_XSCOM_WRITE(PHB_PBL_ERR_INJECT, PPC_BITMASK(0, 63)); PHB4_XSCOM_WRITE(PHB_PCIE_CRESET, PHB_PCIE_CRESET_PBL); /*Reset*/ val =3D PHB4_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, 0xF00DFD8E00); +} + +/* 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. + */ + PHB4_XSCOM_WRITE(PHB_DMA_SYNC, PPC_BITMASK(0, 63)); + val =3D PHB4_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. + */ + PHB4_XSCOM_WRITE(PHB_PCIE_HOTPLUG_STATUS, PPC_BITMASK(0, 63)); + val =3D PHB4_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. + */ + PHB4_XSCOM_WRITE(PHB_PCIE_LMR, PPC_BITMASK(0, 63)); + val =3D PHB4_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. + */ + PHB4_XSCOM_WRITE(PHB_PCIE_DLP_TRWCTL, PPC_BITMASK(0, 63)); + val =3D PHB4_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. + */ + PHB4_XSCOM_WRITE(PHB_LEM_ERROR_AND_MASK, PPC_BITMASK(0, 63)); + val =3D PHB4_XSCOM_READ(PHB_LEM_ERROR_AND_MASK); + g_assert_cmpuint(val, =3D=3D, 0x0); + + PHB4_XSCOM_WRITE(PHB_LEM_ERROR_OR_MASK, PPC_BITMASK(0, 63)); + val =3D PHB4_XSCOM_READ(PHB_LEM_ERROR_OR_MASK); + g_assert_cmpuint(val, =3D=3D, 0x0); } =20 static void phb4_tests(void) @@ -96,6 +149,9 @@ static void phb4_tests(void) /* Check sticky reset of a register */ phb4_sticky_rst_test(qts); =20 + /* Check write-only logic */ + phb4_writeonly_read_test(qts); + qtest_quit(qts); } =20 --=20 2.47.3