From patchwork Mon Jul 19 13:19:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1507033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=g+0/FuJD; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GT2ZL6vZ4z9sWl for ; Mon, 19 Jul 2021 23:22:18 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GT2ZL3XG7z3bhG for ; Mon, 19 Jul 2021 23:22:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=g+0/FuJD; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=g+0/FuJD; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GT2Y75JY8z30MK for ; Mon, 19 Jul 2021 23:21:15 +1000 (AEST) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 16JD3jtc010088 for ; Mon, 19 Jul 2021 09:21:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CDx1kTsK95PwscEDbWXa5U9/3RYKIDvB1BIgbsLqzzI=; b=g+0/FuJDEIwTomPzIWEtbAQ4sfe0T/G+z4rCGtl1p+NMYPLmhVZCdSpQPi9zQJQm7XAg /X4exXNHU/0qpMMLDxVzbOw8h6IqDbsZrIO9F1nQ6pGurQ25E2de1XyMqdI8sIvgVVCl oUj92tpehYEnUH2UBUYh+q+Br/LlZN9kZkr8RCHRFap3a7w2MSTGCTwIQv96vb0K2Txf wmCfKqO0LlxgoGQKVJf5FxmmZllQ44iCZJfW9OTYbJopwwxHYbigmxwgnpm1RZtvn1qk AKDJMN3uFpDl/7RcRFseaVN+3xuSvYrwwi6Va12RrhF6glXrVYm0OyWiuTnH4p12RcRN OA== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 39w8w8jtn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Jul 2021 09:21:13 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 16JDCZA3022827 for ; Mon, 19 Jul 2021 13:21:11 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04fra.de.ibm.com with ESMTP id 39upu88ck1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 19 Jul 2021 13:21:10 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 16JDL77718874850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 19 Jul 2021 13:21:07 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F704A405D; Mon, 19 Jul 2021 13:21:07 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 371C3A405E; Mon, 19 Jul 2021 13:21:06 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.85.86.230]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 19 Jul 2021 13:21:05 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Mon, 19 Jul 2021 18:49:29 +0530 Message-Id: <20210719132012.150948-19-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210719132012.150948-1-hegdevasant@linux.vnet.ibm.com> References: <20210719132012.150948-1-hegdevasant@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: z5DL4vusbEQxWQjlE68v9D6XzmgvY7kx X-Proofpoint-GUID: z5DL4vusbEQxWQjlE68v9D6XzmgvY7kx X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-07-19_05:2021-07-19, 2021-07-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 lowpriorityscore=0 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 impostorscore=0 spamscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107190076 Subject: [Skiboot] [PATCH 18/61] phys/P10: Use topology index to get phys mapping X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ryan Grimm Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This fixes multipchip rainier boot issue. for Rainer: chip0: ibm,primary-topology-index = < 0x0>; chip1: ibm,primary-topology-index = < 0x4>; chip2: ibm,primary-topology-index = < 0x8>; chip3: ibm,primary-topology-index = < 0xc>; for Denali: node0: chip0: ibm,primary-topology-index = < 0x0>; chip1: ibm,primary-topology-index = < 0x1>; chip2: ibm,primary-topology-index = < 0x2>; chip3: ibm,primary-topology-index = < 0x3>; node1: chip0: ibm,primary-topology-index = < 0x4>; chip1: ibm,primary-topology-index = < 0x5>; chip2: ibm,primary-topology-index = < 0x6>; chip3: ibm,primary-topology-index = < 0x7>; Note that bmc_create_node() gets called very early in the boot process. Hence we have to traverse through HDAT ntuple to get right topology index. May be we can optimize pcid_to_topology_idx() function as its pretty much duplicate of pcid_to_chip_id(). But for now lets keep it as separate function. Signed-off-by: Vasant Hegde Signed-off-by: Ryan Grimm Signed-off-by: Vasant Hegde --- hdata/fsp.c | 4 +++- hdata/hdata.h | 1 + hdata/spira.c | 28 ++++++++++++++++++++++++++++ hw/phys-map.c | 18 ++++++++++++++++-- hw/test/phys-map-test.c | 7 ++++++- include/phys-map.h | 3 +++ 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/hdata/fsp.c b/hdata/fsp.c index 42f1121ab..30cda53f6 100644 --- a/hdata/fsp.c +++ b/hdata/fsp.c @@ -361,6 +361,7 @@ static void bmc_create_node(const struct HDIF_common_hdr *sp) struct dt_node *lpcm, *lpc, *n; u64 lpcm_base, lpcm_end; uint32_t chip_id; + uint32_t topology_idx; int size; bmc_node = dt_new(dt_root, "bmc"); @@ -399,8 +400,9 @@ static void bmc_create_node(const struct HDIF_common_hdr *sp) * phys map offset */ chip_id = pcid_to_chip_id(be32_to_cpu(iopath->lpc.chip_id)); + topology_idx = pcid_to_topology_idx(be32_to_cpu(iopath->lpc.chip_id)); - phys_map_get(chip_id, LPC_BUS, 0, &lpcm_base, NULL); + __phys_map_get(topology_idx, chip_id, LPC_BUS, 0, &lpcm_base, NULL); lpcm = dt_new_addr(dt_root, "lpcm-opb", lpcm_base); assert(lpcm); diff --git a/hdata/hdata.h b/hdata/hdata.h index bae4eaa58..6aad82932 100644 --- a/hdata/hdata.h +++ b/hdata/hdata.h @@ -24,6 +24,7 @@ extern void vpd_data_parse(struct dt_node *node, extern struct dt_node *find_xscom_for_chip(uint32_t chip_id); extern uint32_t pcid_to_chip_id(uint32_t proc_chip_id); +extern uint32_t pcid_to_topology_idx(uint32_t proc_chip_id); extern uint32_t get_xscom_id(const struct sppcrd_chip_info *cinfo); extern struct dt_node *add_core_common(struct dt_node *cpus, diff --git a/hdata/spira.c b/hdata/spira.c index 7d56f3f29..baa23751d 100644 --- a/hdata/spira.c +++ b/hdata/spira.c @@ -1418,6 +1418,34 @@ uint32_t pcid_to_chip_id(uint32_t proc_chip_id) return (uint32_t)-1; } +uint32_t pcid_to_topology_idx(uint32_t proc_chip_id) +{ + unsigned int i; + const void *hdif; + + /* First, try the proc_chip ntuples for chip data */ + for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i, + SPPCRD_HDIF_SIG) { + const struct sppcrd_chip_info *cinfo; + + cinfo = HDIF_get_idata(hdif, SPPCRD_IDATA_CHIP_INFO, NULL); + if (!CHECK_SPPTR(cinfo)) { + prerror("XSCOM: Bad ChipID data %d\n", i); + continue; + } + if (proc_chip_id == be32_to_cpu(cinfo->proc_chip_id)) { + if (proc_gen <= proc_gen_p9) + return get_xscom_id(cinfo); + else + return ((u32)cinfo->topology_id_table[cinfo->primary_topology_loc]); + } + } + + /* Not found, what to do ? Assert ? For now return a number + * guaranteed to not exist + */ + return (uint32_t)-1; +} /* Create '/ibm,opal/led' node */ static void dt_init_led_node(void) { diff --git a/hw/phys-map.c b/hw/phys-map.c index 2c4d8e45f..194e4953d 100644 --- a/hw/phys-map.c +++ b/hw/phys-map.c @@ -277,7 +277,7 @@ static inline bool phys_map_entry_null(const struct phys_map_entry *e) /* This crashes skiboot on error as any bad calls here are almost * certainly a developer error */ -void phys_map_get(uint64_t gcid, enum phys_map_type type, +void __phys_map_get(uint64_t topology_idx, uint64_t gcid, enum phys_map_type type, int index, uint64_t *addr, uint64_t *size) { const struct phys_map_entry *e; uint64_t a; @@ -302,7 +302,7 @@ void phys_map_get(uint64_t gcid, enum phys_map_type type, break; } a = e->addr; - a += gcid << phys_map->chip_select_shift; + a += topology_idx << (phys_map->chip_select_shift); if (addr) *addr = a; @@ -322,6 +322,20 @@ error: assert(0); } +void phys_map_get(uint64_t gcid, enum phys_map_type type, + int index, uint64_t *addr, uint64_t *size) +{ + struct proc_chip *chip; + uint64_t topology_idx = gcid; + + if (proc_gen >= proc_gen_p10) { + chip = get_chip(gcid); + topology_idx = chip->primary_topology; + } + + return __phys_map_get(topology_idx, gcid, type, index, addr, size); +} + void phys_map_init(unsigned long pvr) { const char *name = "unused"; diff --git a/hw/test/phys-map-test.c b/hw/test/phys-map-test.c index 2aabdb826..aa5b7339a 100644 --- a/hw/test/phys-map-test.c +++ b/hw/test/phys-map-test.c @@ -79,6 +79,11 @@ static inline bool map_call_entry_null(const struct map_call_entry *t) /* Pick a chip ID, any ID. */ #define FAKE_CHIP_ID 8 +struct proc_chip *get_chip(uint32_t chip_id __unused) +{ + return NULL; +} + static void check_map_call(void) { uint64_t start, size, end; @@ -98,7 +103,7 @@ static void check_map_call(void) /* Loop over table entries ... */ for (e = phys_map->table; !phys_map_entry_null(e); e++) { - phys_map_get(FAKE_CHIP_ID, e->type, e->index, &start, &size); + __phys_map_get(FAKE_CHIP_ID, FAKE_CHIP_ID, e->type, e->index, &start, &size); /* Check for alignment */ if ((e->type != SYSTEM_MEM) && (e->type != RESV)) { diff --git a/include/phys-map.h b/include/phys-map.h index ae7a4aa55..97351a720 100644 --- a/include/phys-map.h +++ b/include/phys-map.h @@ -48,6 +48,9 @@ enum phys_map_type { extern void phys_map_get(uint64_t gcid, enum phys_map_type type, int index, uint64_t *addr, uint64_t *size); +extern void __phys_map_get(uint64_t topology_idx, uint64_t gcid, + enum phys_map_type type, int index, uint64_t *addr, uint64_t *size); + extern void phys_map_init(unsigned long pvr); #endif /* __PHYS_MAP_H */