From nobody Mon May 6 10:43:46 2024 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=1677775108; cv=none; d=zohomail.com; s=zohoarc; b=EFz8lFaGPdX8ToCQNMCOdwrjxtucwOqwW5E/LXPTptg6PTK66Cq2qV52W0r30XcsEpw3DiAbgr9IU8I8mC3f195tR871gXPQaBEVGfys4/vXnXGyvlGABrejYyvNnFt3zQtPvmD+TX5FoUHpqB3uDs8hpCIA48anLMyPNrFtT60= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677775108; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5vXVQpn2ZNQBDx6+PBciSEsq3nlJCTyGz5H/F5fwG8g=; b=nXyJp4TDbqtUcW6C/kZXX2mRBTitEKZIf4nLECT88Vl+ow0OV1YQPBIbe2BMvpVZqHCEc0251TtBngmfo4sYSz1+5OIDijdP1Bx7Rto8YuxZCWtAKA+5kBpF/WFIvaRUPN4ZFCy/8Kwa7WE8usjLP1OHYub7LijHI7r3sol7xQE= 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 1677775108381829.1571234246222; Thu, 2 Mar 2023 08:38:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXlvy-00070M-CX; Thu, 02 Mar 2023 11:37:34 -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 1pXlvx-0006t1-El; Thu, 02 Mar 2023 11:37:33 -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 1pXlvv-0000h7-Ji; Thu, 02 Mar 2023 11:37:33 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322GVKed001031; Thu, 2 Mar 2023 16:37:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2y6rrn2d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:22 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 322GWL8j010978; Thu, 2 Mar 2023 16:37:21 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2y6rrn0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:21 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 322GU8iG022378; Thu, 2 Mar 2023 16:37:19 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3nybdbmfq1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:19 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 322GbGS31704664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 16:37:16 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 800D52004B; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 26D1920040; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) Received: from borneo.ibmuc.com (unknown [9.171.65.81]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=5vXVQpn2ZNQBDx6+PBciSEsq3nlJCTyGz5H/F5fwG8g=; b=aI349W3DD5PyOReHNWMKwBPOEu3fI+eZQfAfVLGuS7YOQwJxXiGnEm109G6uYCceslp9 TG54rJyzJUW8+rUnLDZZfwlyv6uuo6mdJ+GKkc8VbuHfaGvHh9xwSJM/KbG0EseySpdK dErYQln4hdOLbB496CvY1hrPz0032C5qIuf1UBLt8055z6RyQHPJuyexi1Ym0OODd+Hn aqgbUX6a+Hy7bzAShJf4uKnXtJddQF2b1M+XEklRbMyPEtihHDTvGpcwmKKD4qHTNLn6 XUQpKCrOinAuIHd8188NG1ntH7LGRoqrYV+LXPD0V7UoGT2eJAb9/+jRChLoK8nynDmq CA== From: Frederic Barrat To: clg@kaod.org, danielhb413@gmail.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/4] pnv_phb4_pec: Keep track of instantiated PHBs Date: Thu, 2 Mar 2023 17:37:12 +0100 Message-Id: <20230302163715.129635-2-fbarrat@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302163715.129635-1-fbarrat@linux.ibm.com> References: <20230302163715.129635-1-fbarrat@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: cZJ0VhviZOZgw4VrOQofEqJIy2PiB5kW X-Proofpoint-ORIG-GUID: EbSj8lwpoZiMcWw1Tf3YT5Z4th5jXV-5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_09,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 malwarescore=0 mlxlogscore=675 impostorscore=0 clxscore=1015 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020144 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: pass client-ip=148.163.156.1; envelope-from=fbarrat@linux.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, 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: 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: 1677775110235100003 Content-Type: text/plain; charset="utf-8" Add an array on the PEC object to keep track of the PHBs which are instantiated. The array can be sparsely populated when using user-created PHBs. It will be useful for the next patch to only export instantiated PHBs in the device tree. Signed-off-by: Frederic Barrat Reviewed-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4_pec.c | 12 +++++++----- hw/ppc/pnv.c | 1 + include/hw/pci-host/pnv_phb4.h | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 43267a428f..97c06bb0a0 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -112,9 +112,9 @@ static const MemoryRegionOps pnv_pec_pci_xscom_ops =3D { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 -static void pnv_pec_default_phb_realize(PnvPhb4PecState *pec, - int stack_no, - Error **errp) +static PnvPHB *pnv_pec_default_phb_realize(PnvPhb4PecState *pec, + int stack_no, + Error **errp) { PnvPHB *phb =3D PNV_PHB(qdev_new(TYPE_PNV_PHB)); int phb_id =3D pnv_phb4_pec_get_phb_id(pec, stack_no); @@ -128,8 +128,9 @@ static void pnv_pec_default_phb_realize(PnvPhb4PecState= *pec, &error_fatal); =20 if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) { - return; + return NULL; } + return phb; } =20 static void pnv_pec_realize(DeviceState *dev, Error **errp) @@ -148,8 +149,9 @@ static void pnv_pec_realize(DeviceState *dev, Error **e= rrp) =20 /* Create PHBs if running with defaults */ if (defaults_enabled()) { + g_assert(pec->num_phbs <=3D MAX_PHBS_PER_PEC); for (i =3D 0; i < pec->num_phbs; i++) { - pnv_pec_default_phb_realize(pec, i, errp); + pec->phbs[i] =3D pnv_pec_default_phb_realize(pec, i, errp); } } =20 diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 44b1fbbc93..24bf8461d6 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -314,6 +314,7 @@ static PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip,= PnvPHB4 *phb, =20 for (j =3D 0; j < pec->num_phbs; j++) { if (index =3D=3D pnv_phb4_pec_get_phb_id(pec, j)) { + pec->phbs[j] =3D phb->phb_base; return pec; } } diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 28d61b96c7..0b72ef1471 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -185,6 +185,8 @@ struct PnvPhb4PecState { =20 /* PHBs */ uint32_t num_phbs; +#define MAX_PHBS_PER_PEC 3 + PnvPHB *phbs[MAX_PHBS_PER_PEC]; =20 PnvChip *chip; }; --=20 2.39.2 From nobody Mon May 6 10:43:46 2024 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=1677775140; cv=none; d=zohomail.com; s=zohoarc; b=WcEd4lxnBvcHs+VWpznF60VefCwEXWVjy3eBdvx3YAC3IwPvBRMdwPcuv1yeVcD2dSXCnRBGMkcAtS+iUqrCRme0kxjmvR7rkj61pcWW9B9ItJfIXVL+e6I8xaqVIfI3jDaq2pTdbO0bmWsnWmnpGBvh0mjik6zN67NOl2BTL8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677775140; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CdYuQ8h4T6zIhbp5VPhp7GcSaH32zpaUltZ7wXoX93k=; b=RgdrhG4bVuM2akSHlhGABXrbWRZYt3jdNnDQk59JrWWNVFKxSwW/GCMJLeumiWIJ7l7VweI2zeKMd4njtNgdvSB0j9x/7/c1PsttNS6kBWFM8V7BTULdrjitozjUJmKokkuj6AUqaEGEKc2cwgnF0jRIlqX7Dtb1L1JA6m8IyKw= 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 167777514043411.576589007527787; Thu, 2 Mar 2023 08:39:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXlvw-0006eh-AQ; Thu, 02 Mar 2023 11:37:32 -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 1pXlvs-0006MA-Oq; Thu, 02 Mar 2023 11:37:28 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5] helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pXlvq-0000g1-Rx; Thu, 02 Mar 2023 11:37:28 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322GVWjm018024; Thu, 2 Mar 2023 16:37:22 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2xw1sdym-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:22 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 322GWsjE032043; Thu, 2 Mar 2023 16:37:21 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2xw1sdxb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:21 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 321NG5CQ015479; Thu, 2 Mar 2023 16:37:19 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3nybdbmfq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:19 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 322GbHVG63701456 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 16:37:17 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F396820043; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9AABC20040; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) Received: from borneo.ibmuc.com (unknown [9.171.65.81]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 2 Mar 2023 16:37:16 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CdYuQ8h4T6zIhbp5VPhp7GcSaH32zpaUltZ7wXoX93k=; b=O3Kd68rVJrDFbgZlvcZ08IcSxozPTLAWr3Aa+FH0RQsaAnnenx1lfND30wPALZ7V6uxE 7/fL7edOwZgaxMStnL1eN1DM6RRbQrN6OXoUojiltMd2eSObMJ5EB0bjkwo1MM94QID8 TEzQ4FDrIC+dCzJphYbTXGVOg5l1eSkvCgv9MwY5rnpe+rxFNEyOzSbXTPZDoCV7CXFn y3jNHsYqwxBVGh9sbWHdbo84tGNOpGPS3EvqUdItF5F4yM43QSO2plk0f1u8ZPxm3hyr 73b1Ko4l4CLwinmAz0ANppN0ZSiMrQDyvBb0wiL2JMXHOu1s/p8WUThZObTTSRRS83gK tw== From: Frederic Barrat To: clg@kaod.org, danielhb413@gmail.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/4] pnv_phb4_pec: Only export existing PHBs to the device tree Date: Thu, 2 Mar 2023 17:37:13 +0100 Message-Id: <20230302163715.129635-3-fbarrat@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302163715.129635-1-fbarrat@linux.ibm.com> References: <20230302163715.129635-1-fbarrat@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: fuZ-0Q6r-8tqPn1DYeuFa0dlJOs_3d3x X-Proofpoint-ORIG-GUID: 1Z2kjGYw6RtbfoDlBy1WnIXMsoQLg0C7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_09,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 phishscore=0 clxscore=1015 adultscore=0 priorityscore=1501 lowpriorityscore=0 mlxscore=0 impostorscore=0 spamscore=0 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020139 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: pass client-ip=148.163.158.5; envelope-from=fbarrat@linux.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_MSPIKE_H2=-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: 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: 1677775142632100007 Content-Type: text/plain; charset="utf-8" So far, we were always exporting all possible PHBs to the device tree. It works well when using the default config but it potentially adds non-existing devices when using '-nodefaults' and user-created PHBs, causing the firmware (skiboot) to report errors when probing those PHBs. This patch only exports PHBs which have been realized to the device tree. Fixes: d786be3fe746 ("ppc/pnv: enable user created pnv-phb for powernv9") Signed-off-by: Frederic Barrat Reviewed-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4_pec.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 97c06bb0a0..6c9b386069 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -199,9 +199,12 @@ static int pnv_pec_dt_xscom(PnvXScomInterface *dev, vo= id *fdt, pecc->compat_size))); =20 for (i =3D 0; i < pec->num_phbs; i++) { - int phb_id =3D pnv_phb4_pec_get_phb_id(pec, i); int stk_offset; =20 + if (!pec->phbs[i]) { + continue; + } + name =3D g_strdup_printf("stack@%x", i); stk_offset =3D fdt_add_subnode(fdt, offset, name); _FDT(stk_offset); @@ -209,7 +212,8 @@ static int pnv_pec_dt_xscom(PnvXScomInterface *dev, voi= d *fdt, _FDT((fdt_setprop(fdt, stk_offset, "compatible", pecc->stk_compat, pecc->stk_compat_size))); _FDT((fdt_setprop_cell(fdt, stk_offset, "reg", i))); - _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", phb_id))); + _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", + pec->phbs[i]->phb_id))); } =20 return 0; --=20 2.39.2 From nobody Mon May 6 10:43:46 2024 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=1677775303; cv=none; d=zohomail.com; s=zohoarc; b=SQy8kmZTwcwL+pqxsUx8NY08hGmCYbk+ahB20M3Gt5rJP667JGyPXWr8DlrIDlJcEuMaWAEB0jYjYZmF49N6GsyyoOMrRoWNm4rWASaq2c/Ja1grjqDPoEzi+sSWdvUCoSQYSFelduzEukJ3hAvQF8Pp5GLxVqHn0rHvf0ID7mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677775303; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D3DJzkr2hqjPLsNV8hTHumtnbD9BcU6eKp+m/ihlnMQ=; b=S1tVrDUI8Kbj2HaK6Q1jvdmL1QLvcHG0a4XuzkhP8hGSLsm962Qs3pwxvO9kgcIVhqqDjoaPy27ItubqrQQ6o5o0xnqsWKyeR5t3Qt1fzHK1eQxEuVldnBSt6XkbvZ9ZA4tTWL7hWQDBVXRBp6PSVmtIx2zcnzq4z5M3tHzRNXo= 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 1677775303412967.0650969439607; Thu, 2 Mar 2023 08:41:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXlw0-0007Hp-7x; Thu, 02 Mar 2023 11:37:36 -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 1pXlvy-00077A-Sk; Thu, 02 Mar 2023 11:37:34 -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 1pXlvw-0000hH-9C; Thu, 02 Mar 2023 11:37:34 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322GVRpV017417; Thu, 2 Mar 2023 16:37:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2wdwvk65-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:22 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 322GVitv019754; Thu, 2 Mar 2023 16:37:22 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2wdwvk4r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:22 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3222LNpX028691; Thu, 2 Mar 2023 16:37:20 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3nybab4gem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:19 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 322GbHZ150266582 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 16:37:17 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 723232004F; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 192EF20040; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) Received: from borneo.ibmuc.com (unknown [9.171.65.81]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=D3DJzkr2hqjPLsNV8hTHumtnbD9BcU6eKp+m/ihlnMQ=; b=X7dlQfKrwP/WWvg1sfVZnpO33xgu5JaVVvxhSvIxHxkbqZFuxO3IxnivrfeMD05o4Wv+ g+Ay6uzfGGDlHZzSDlq8htni37Ump713B3XVIl7sg6y+PKG6/G4zirUlK+4BH1J1tQif cFE9Eo4Y1jopdrkGSgclunU/EkB+n1gXZqLzAV1dQSbVTpfHXqZPB5B0wGg35fDDQKuZ vAvBB5c5GxN4cvaJeqJpkwsHr5T/SXYoQ6Gnt9V+5dLD+6o5GW+mo8KAY5udgLw4uqr3 MncS3c3SFT1caPL00xBC2lQ2RINeJbkwhJwAs/L5LqktZNIzHqRNN5tFMnvH+wgNvQfM 2A== From: Frederic Barrat To: clg@kaod.org, danielhb413@gmail.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 3/4] pnv_phb4_pec: Move pnv_phb4_get_pec() to rightful file Date: Thu, 2 Mar 2023 17:37:14 +0100 Message-Id: <20230302163715.129635-4-fbarrat@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302163715.129635-1-fbarrat@linux.ibm.com> References: <20230302163715.129635-1-fbarrat@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: i9RTDb8f3QKlV6vnzg0SFjJQ8BYWpHs7 X-Proofpoint-GUID: 3H-b2RfkNkyTBViNtOfu5b_g-e6EmnT0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_09,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020144 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: pass client-ip=148.163.156.1; envelope-from=fbarrat@linux.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, 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: 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: 1677775304037100001 Content-Type: text/plain; charset="utf-8" The function pnv_phb4_get_pec() exposes some internals of the PEC and PHB logic, yet it was in the higher level hw/ppc/pnv.c file for historical reasons: P8 implements the PHBs from pnv.c directly, but on P9/P10, it's done through the CEC model, which has its own file. So move pnv_phb4_get_pec() to hw/pci-host/pnv_phb4_pec.c, where it fits naturally. While at it, replace the PnvPHB4 parameter by the PnvPHB front-end, since it has all the information needed and simplify it a bit. No functional changes. Signed-off-by: Frederic Barrat Reviewed-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb4_pec.c | 40 +++++++++++++++++++++++++++++++ hw/ppc/pnv.c | 44 +--------------------------------- include/hw/pci-host/pnv_phb4.h | 1 + 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 6c9b386069..6e2e5ae186 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -112,6 +112,46 @@ static const MemoryRegionOps pnv_pec_pci_xscom_ops =3D= { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 +PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB *phb, Error **errp) +{ + PnvPhb4PecState *pecs =3D NULL; + int chip_id =3D phb->chip_id; + int index =3D phb->phb_id; + int i, j; + + if (phb->version =3D=3D 4) { + Pnv9Chip *chip9 =3D PNV9_CHIP(chip); + + pecs =3D chip9->pecs; + } else if (phb->version =3D=3D 5) { + Pnv10Chip *chip10 =3D PNV10_CHIP(chip); + + pecs =3D chip10->pecs; + } else { + g_assert_not_reached(); + } + + for (i =3D 0; i < chip->num_pecs; i++) { + /* + * For each PEC, check the amount of phbs it supports + * and see if the given phb4 index matches an index. + */ + PnvPhb4PecState *pec =3D &pecs[i]; + + for (j =3D 0; j < pec->num_phbs; j++) { + if (index =3D=3D pnv_phb4_pec_get_phb_id(pec, j)) { + pec->phbs[j] =3D phb; + return pec; + } + } + } + error_setg(errp, + "pnv-phb4 chip-id %d index %d didn't match any existing PEC= ", + chip_id, index); + + return NULL; +} + static PnvPHB *pnv_pec_default_phb_realize(PnvPhb4PecState *pec, int stack_no, Error **errp) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 24bf8461d6..46010b30ad 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -284,48 +284,6 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint3= 2_t pir, g_free(reg); } =20 -static PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB4 *phb, - Error **errp) -{ - PnvPHB *phb_base =3D phb->phb_base; - PnvPhb4PecState *pecs =3D NULL; - int chip_id =3D phb->chip_id; - int index =3D phb->phb_id; - int i, j; - - if (phb_base->version =3D=3D 4) { - Pnv9Chip *chip9 =3D PNV9_CHIP(chip); - - pecs =3D chip9->pecs; - } else if (phb_base->version =3D=3D 5) { - Pnv10Chip *chip10 =3D PNV10_CHIP(chip); - - pecs =3D chip10->pecs; - } else { - g_assert_not_reached(); - } - - for (i =3D 0; i < chip->num_pecs; i++) { - /* - * For each PEC, check the amount of phbs it supports - * and see if the given phb4 index matches an index. - */ - PnvPhb4PecState *pec =3D &pecs[i]; - - for (j =3D 0; j < pec->num_phbs; j++) { - if (index =3D=3D pnv_phb4_pec_get_phb_id(pec, j)) { - pec->phbs[j] =3D phb->phb_base; - return pec; - } - } - } - error_setg(errp, - "pnv-phb4 chip-id %d index %d didn't match any existing PEC= ", - chip_id, index); - - return NULL; -} - /* * Adds a PnvPHB to the chip. Returns the parent obj of the * PHB which varies with each version (phb version 3 is parented @@ -349,7 +307,7 @@ Object *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb, Er= ror **errp) return OBJECT(chip); } =20 - phb->pec =3D pnv_phb4_get_pec(chip, PNV_PHB4(phb->backend), errp); + phb->pec =3D pnv_phb4_get_pec(chip, phb, errp); =20 return OBJECT(phb->pec); } diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 0b72ef1471..5c5edb2941 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -157,6 +157,7 @@ struct PnvPHB4 { =20 void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon); int pnv_phb4_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); +PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB *phb, Error **errp= ); void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb); extern const MemoryRegionOps pnv_phb4_xscom_ops; =20 --=20 2.39.2 From nobody Mon May 6 10:43:46 2024 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=1677775185; cv=none; d=zohomail.com; s=zohoarc; b=E1LlongDHFZMVeAHznapBbLvzeFVpyWMhNRfIA0v1+KPHrBFgvp3Zh5Rp/S1sMQlY7wi1SYcAE+43c3BZx2+reixHjxblsbWq3r6tHm6Rj72KGHmSDjOy2uxjfvUl5rdI5YcjrsqQgulIUDW2FYlPmp0hBA+X9b3bfJswPBIP+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677775185; h=Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VKif39YbzKsYxZkK6ufmcAbnXHwi9WvJw+hl+9M37tc=; b=YfxeMkGphQ/dMJZoBNglDlmFWOuY5KiQZePfc+MnguJXEVlia9BiVwM4aAtekiVy8SANwdx1p1qTMuRcbJps5NSv6gwlyD3xVNoA2jCw7wLggrNouTNmEFZqbS0SdAR9spZnIZMD4NshFQO9smA1K05C6Xb9NV0jsGV1WRnpKEo= 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 1677775185572322.6150867075685; Thu, 2 Mar 2023 08:39:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pXlw2-0007c8-Dl; Thu, 02 Mar 2023 11:37:38 -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 1pXlvz-0007Cy-Ld; Thu, 02 Mar 2023 11:37:35 -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 1pXlvx-0000hT-KB; Thu, 02 Mar 2023 11:37:35 -0500 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 322GUbtj006993; Thu, 2 Mar 2023 16:37:23 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2y7d0kna-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:23 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 322GUbNL007078; Thu, 2 Mar 2023 16:37:23 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3p2y7d0km7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:22 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3227OPXf008599; Thu, 2 Mar 2023 16:37:20 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma02fra.de.ibm.com (PPS) with ESMTPS id 3nybe2mf9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 02 Mar 2023 16:37:20 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 322GbIaX63308252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 2 Mar 2023 16:37:18 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E473520040; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8C8F02004B; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) Received: from borneo.ibmuc.com (unknown [9.171.65.81]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 2 Mar 2023 16:37:17 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=VKif39YbzKsYxZkK6ufmcAbnXHwi9WvJw+hl+9M37tc=; b=gmJh7ugSt/u7dvIFLR6n3rQyMa4Xv28SPAzjNN3RpbUx+dZDTmEgD2AC5SUVgmxAOzNf mxoYWD6x4/Yuv/RCS+BI6UU+hLqXN78umLhYQgMADh9GgGWwkTHEnUxxAQ9s1+kRTbOG ShU6sZSUNLjlVTMma/w7VMbbGmXd8wkIsiAFvBGAWl0BOTc+mgj9mOrgfNXjgLOipk4L FkeGAFkL8y5QOnKoAC86/dFD/Nvk18IIx8qp/lRpmpTbV2cm+y7iJewLFDdJbZe7pXwL b15aZz0uyBQJ/FE9eSbABc48yxaT2gCrD6zU6SzSynj3iK63fNa8PA3UbgIGSpucENkB ng== From: Frederic Barrat To: clg@kaod.org, danielhb413@gmail.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 4/4] pnv_phb4_pec: Simplify/align code to parent user-created PHBs Date: Thu, 2 Mar 2023 17:37:15 +0100 Message-Id: <20230302163715.129635-5-fbarrat@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230302163715.129635-1-fbarrat@linux.ibm.com> References: <20230302163715.129635-1-fbarrat@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: _xMhN4JlzHarmRNhQXYMX6uHNeyI1vFf X-Proofpoint-ORIG-GUID: D2VFGRWguWHoiBPNyYbF309A9BJ1v0rl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-02_09,2023-03-02_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 spamscore=0 priorityscore=1501 mlxscore=0 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303020144 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: pass client-ip=148.163.156.1; envelope-from=fbarrat@linux.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, 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: 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: 1677775186870100003 Content-Type: text/plain; charset="utf-8" When instantiating a user-created PHB on P9/P10, we don't really have a reason any more to go through an indirection in pnv_chip_add_phb() in pnv.c, we can go straight to the right function in pnv_phb4_pec.c. That way, default PHBs and user-created PHBs are all handled in the same file. This patch also renames pnv_phb4_get_pec() to pnv_pec_add_phb() to better reflect that it "hooks" a PHB to a PEC. For P8, the PHBs are parented to the chip directly, so it makes sense to keep calling pnv_chip_add_phb() in pnv.c, to also be consistent with where default PHBs are handled. The only change here is that, since that function is now only used for P8, we can refine the return type. So overall, the PnvPHB front-end now has a pnv_phb_user_get_parent() function which handles the parenting of the user-created PHBs by calling the right function in the right file based on the processor version. It's also easily extensible if we ever need to support a different parent object. Signed-off-by: Frederic Barrat Reviewed-by: Daniel Henrique Barboza --- hw/pci-host/pnv_phb.c | 11 ++++++++++- hw/pci-host/pnv_phb4_pec.c | 3 ++- hw/ppc/pnv.c | 29 ++++++++--------------------- include/hw/pci-host/pnv_phb4.h | 2 +- include/hw/ppc/pnv.h | 2 +- 5 files changed, 22 insertions(+), 25 deletions(-) diff --git a/hw/pci-host/pnv_phb.c b/hw/pci-host/pnv_phb.c index c62b08538a..82332d7a05 100644 --- a/hw/pci-host/pnv_phb.c +++ b/hw/pci-host/pnv_phb.c @@ -62,6 +62,15 @@ static bool pnv_parent_fixup(Object *parent, BusState *p= arent_bus, return true; } =20 +static Object *pnv_phb_user_get_parent(PnvChip *chip, PnvPHB *phb, Error *= *errp) +{ + if (phb->version =3D=3D 3) { + return OBJECT(pnv_chip_add_phb(chip, phb)); + } else { + return OBJECT(pnv_pec_add_phb(chip, phb, errp)); + } +} + /* * User created devices won't have the initial setup that default * devices have. This setup consists of assigning a parent device @@ -79,7 +88,7 @@ static bool pnv_phb_user_device_init(PnvPHB *phb, Error *= *errp) return false; } =20 - parent =3D pnv_chip_add_phb(chip, phb, errp); + parent =3D pnv_phb_user_get_parent(chip, phb, errp); if (!parent) { return false; } diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c index 6e2e5ae186..3b2850f7a3 100644 --- a/hw/pci-host/pnv_phb4_pec.c +++ b/hw/pci-host/pnv_phb4_pec.c @@ -112,7 +112,7 @@ static const MemoryRegionOps pnv_pec_pci_xscom_ops =3D { .endianness =3D DEVICE_BIG_ENDIAN, }; =20 -PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB *phb, Error **errp) +PnvPhb4PecState *pnv_pec_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp) { PnvPhb4PecState *pecs =3D NULL; int chip_id =3D phb->chip_id; @@ -141,6 +141,7 @@ PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB= *phb, Error **errp) for (j =3D 0; j < pec->num_phbs; j++) { if (index =3D=3D pnv_phb4_pec_get_phb_id(pec, j)) { pec->phbs[j] =3D phb; + phb->pec =3D pec; return pec; } } diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 46010b30ad..11cb48af2f 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -285,31 +285,18 @@ static void pnv_dt_icp(PnvChip *chip, void *fdt, uint= 32_t pir, } =20 /* - * Adds a PnvPHB to the chip. Returns the parent obj of the - * PHB which varies with each version (phb version 3 is parented - * by the chip, version 4 and 5 are parented by the PEC - * device). - * - * TODO: for version 3 we're still parenting the PHB with the - * chip. We should parent with a (so far not implemented) - * PHB3 PEC device. + * Adds a PnvPHB to the chip on P8. + * Implemented here, like for defaults PHBs */ -Object *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp) +PnvChip *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb) { - if (phb->version =3D=3D 3) { - Pnv8Chip *chip8 =3D PNV8_CHIP(chip); - - phb->chip =3D chip; - - chip8->phbs[chip8->num_phbs] =3D phb; - chip8->num_phbs++; - - return OBJECT(chip); - } + Pnv8Chip *chip8 =3D PNV8_CHIP(chip); =20 - phb->pec =3D pnv_phb4_get_pec(chip, phb, errp); + phb->chip =3D chip; =20 - return OBJECT(phb->pec); + chip8->phbs[chip8->num_phbs] =3D phb; + chip8->num_phbs++; + return chip; } =20 static void pnv_chip_power8_dt_populate(PnvChip *chip, void *fdt) diff --git a/include/hw/pci-host/pnv_phb4.h b/include/hw/pci-host/pnv_phb4.h index 5c5edb2941..2d026db9a3 100644 --- a/include/hw/pci-host/pnv_phb4.h +++ b/include/hw/pci-host/pnv_phb4.h @@ -157,7 +157,7 @@ struct PnvPHB4 { =20 void pnv_phb4_pic_print_info(PnvPHB4 *phb, Monitor *mon); int pnv_phb4_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index); -PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB *phb, Error **errp= ); +PnvPhb4PecState *pnv_pec_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp); void pnv_phb4_bus_init(DeviceState *dev, PnvPHB4 *phb); extern const MemoryRegionOps pnv_phb4_xscom_ops; =20 diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index 96fb850419..409f3bf763 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -100,7 +100,7 @@ struct PnvMachineState { }; =20 PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id); -Object *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb, Error **errp); +PnvChip *pnv_chip_add_phb(PnvChip *chip, PnvPHB *phb); =20 #define PNV_FDT_ADDR 0x01000000 #define PNV_TIMEBASE_FREQ 512000000ULL --=20 2.39.2