From patchwork Fri Jun 25 06:19:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1496943 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=tXtqMq9i; 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 4GB6Nc5PTpz9sX5 for ; Fri, 25 Jun 2021 16:22:08 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GB6Nd3XHkz3c0J for ; Fri, 25 Jun 2021 16:22:09 +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=tXtqMq9i; 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.156.1; 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=tXtqMq9i; dkim-atps=neutral Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 4GB6MG5kKzz3bs1 for ; Fri, 25 Jun 2021 16:20:58 +1000 (AEST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 15P6FLS3035303 for ; Fri, 25 Jun 2021 02:20:56 -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 : content-transfer-encoding : mime-version; s=pp1; bh=eF3kslbMrl2cAfkDLV0Jk2fWoK3aqrpw7/gK/NwF9uQ=; b=tXtqMq9iFiGzJRw9jLv1L3SdGOeltli2W2xnTOubQI00c9az1y2gynm9yWXYznpLQN7E UAVGf3LzPGvPa5sVTa/9ubZFvhap3TmrwKQcxzXmSOdJ3MNFVjuaUpzcXNq49aaOAOIJ QpTmqm15Eh/YRViuWZ0MMInBtE+0CSnSwn3++vwXuTyG91WJF+bSi7zB/YAfQsqXVdHo ia1swbSiQYj9NRDRBZQgi3kf/zHP/Zn0rMyvsMP5WUnmP8btHW9wqVC7LbAu5tY3ltsL z2lmMhGYaZlOd8Pk2IE2s9DuSgFW0yLB59udPX9TundId1PQyRS6fQvWx0HJa6QhLZQa 8Q== Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 39d9q1g5pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 Jun 2021 02:20:55 -0400 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 15P686JR029695 for ; Fri, 25 Jun 2021 06:20:53 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma06fra.de.ibm.com with ESMTP id 3997uhhkkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 25 Jun 2021 06:20:53 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 15P6KolF28311932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Jun 2021 06:20:50 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C4CB042042; Fri, 25 Jun 2021 06:20:50 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DED042049; Fri, 25 Jun 2021 06:20:49 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.199.46.25]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 25 Jun 2021 06:20:49 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Fri, 25 Jun 2021 11:49:37 +0530 Message-Id: <20210625061937.47314-23-hegdevasant@linux.vnet.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210625061937.47314-1-hegdevasant@linux.vnet.ibm.com> References: <20210625061937.47314-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: cr1nPQVcFUNKoVGqb3Hkc0xYl2D9AUlw X-Proofpoint-GUID: cr1nPQVcFUNKoVGqb3Hkc0xYl2D9AUlw X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391, 18.0.790 definitions=2021-06-25_02:2021-06-24, 2021-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 spamscore=0 adultscore=0 impostorscore=0 priorityscore=1501 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2106250034 Subject: [Skiboot] [PATCH 22/22] hw/imc: Do scoms on the secondary core in fused core mode for core-imc counters 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" From: Anju T Sudhakar Core IMC hardware mandates initiating of three scoms to enable or disable of the Core IMC engine. This has to be done for each core, and is done in the opal_imc_counters_init(). In fused core mode, the scom has to be done explicitly for the secondary core to enable or disable core IMC engine in that core. Do the scom for the secondary core, by calculating the core id from the incoming cpu id. This patch is based on the series, Initial fused-core support for POWER9 [v5]: https://lists.ozlabs.org/pipermail/skiboot/2020-April/016778.html Signed-off-by: Anju T Sudhakar --- hw/imc.c | 153 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 90 insertions(+), 63 deletions(-) diff --git a/hw/imc.c b/hw/imc.c index e7893b50e..dab668fe6 100644 --- a/hw/imc.c +++ b/hw/imc.c @@ -727,6 +727,82 @@ static uint32_t get_imc_scom_addr_for_quad(int core, uint64_t addr) return 0; } } + +static int64_t core_imc_counters_init(uint64_t addr, int port_id, + int phys_core_id, struct cpu_thread *c) +{ + uint32_t pdbar_addr, event_mask_addr, htm_addr; + int ret; + + /* Get the scom address for this core, based on the platform */ + pdbar_addr = get_imc_scom_addr_for_quad(phys_core_id, + pdbar_scom_index[port_id]); + event_mask_addr = get_imc_scom_addr_for_core(phys_core_id, + CORE_IMC_EVENT_MASK_ADDR); + + /* + * Core IMC hardware mandate initing of three scoms + * to enbale or disable of the Core IMC engine. + * + * PDBAR: Scom contains the real address to store per-core + * counter data in memory along with other bits. + * + * EventMask: Scom contain bits to denote event to multiplex + * at different MSR[HV PR] values, along with bits for + * sampling duration. + * + * HTM Scom: scom to enable counter data movement to memory. + */ + + + if (xscom_write(c->chip_id, pdbar_addr, + (u64)(CORE_IMC_PDBAR_MASK & addr))) { + prerror("error in xscom_write for pdbar\n"); + return OPAL_HARDWARE; + } + + if (has_deep_states) { + if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT) { + struct proc_chip *chip = get_chip(c->chip_id); + + ret = stop_api_init(chip, phys_core_id, pdbar_addr, + (u64)(CORE_IMC_PDBAR_MASK & addr), + P9_STOP_SCOM_REPLACE, + P9_STOP_SECTION_EQ_SCOM, + "pdbar"); + if (ret) + return ret; + ret = stop_api_init(chip, phys_core_id, + event_mask_addr, + (u64)CORE_IMC_EVENT_MASK, + P9_STOP_SCOM_REPLACE, + P9_STOP_SECTION_CORE_SCOM, + "event_mask"); + if (ret) + return ret; + } else { + prerror("IMC: Wakeup engine not present!"); + return OPAL_HARDWARE; + } + } + + if (xscom_write(c->chip_id, event_mask_addr, + (u64)CORE_IMC_EVENT_MASK)) { + prerror("error in xscom_write for event mask\n"); + return OPAL_HARDWARE; + } + + /* Get the scom address for htm_mode scom based on the platform */ + htm_addr = get_imc_scom_addr_for_quad(phys_core_id, + htm_scom_index[port_id]); + if (xscom_write(c->chip_id, htm_addr, + (u64)CORE_IMC_HTM_MODE_DISABLE)) { + prerror("error in xscom_write for htm mode\n"); + return OPAL_HARDWARE; + } + return OPAL_SUCCESS; +} + /* * opal_imc_counters_init : This call initialize the IMC engine. * @@ -739,7 +815,7 @@ static int64_t opal_imc_counters_init(uint32_t type, uint64_t addr, uint64_t cpu struct cpu_thread *c = find_cpu_by_pir(cpu_pir); int port_id, phys_core_id; int ret; - uint32_t pdbar_addr, event_mask_addr, htm_addr, trace_addr; + uint32_t htm_addr, trace_addr; uint64_t trace_scom_val = TRACE_IMC_SCOM(IMC_TRACE_SAMPLESEL_VAL, IMC_TRACE_CPMCLOAD_VAL, 0, IMC_TRACE_CPMC2SEL_VAL, @@ -762,73 +838,24 @@ static int64_t opal_imc_counters_init(uint32_t type, uint64_t addr, uint64_t cpu if (proc_chip_quirks & QUIRK_MAMBO_CALLOUTS) return OPAL_SUCCESS; - /* Get the scom address for this core, based on the platform */ - pdbar_addr = get_imc_scom_addr_for_quad(phys_core_id, - pdbar_scom_index[port_id]); - event_mask_addr = get_imc_scom_addr_for_core(phys_core_id, - CORE_IMC_EVENT_MASK_ADDR); - + ret = core_imc_counters_init(addr, port_id, phys_core_id, c); + if (ret < 0) + return ret; /* - * Core IMC hardware mandate initing of three scoms - * to enbale or disable of the Core IMC engine. - * - * PDBAR: Scom contains the real address to store per-core - * counter data in memory along with other bits. - * - * EventMask: Scom contain bits to denote event to multiplex - * at different MSR[HV PR] values, along with bits for - * sampling duration. - * - * HTM Scom: scom to enable counter data movement to memory. + * If fused core is supported, do the scoms for the + * secondary core also. */ + if (this_cpu()->is_fused_core) { + struct cpu_thread *c1 = find_cpu_by_pir(cpu_pir ^ 1); + phys_core_id = pir_to_core_id(c1->pir); + port_id = phys_core_id % 4; - if (xscom_write(c->chip_id, pdbar_addr, - (u64)(CORE_IMC_PDBAR_MASK & addr))) { - prerror("error in xscom_write for pdbar\n"); - return OPAL_HARDWARE; - } - - if (has_deep_states) { - if (wakeup_engine_state == WAKEUP_ENGINE_PRESENT) { - struct proc_chip *chip = get_chip(c->chip_id); - - ret = stop_api_init(chip, phys_core_id, pdbar_addr, - (u64)(CORE_IMC_PDBAR_MASK & addr), - P9_STOP_SCOM_REPLACE, - P9_STOP_SECTION_EQ_SCOM, - "pdbar"); - if (ret) - return ret; - ret = stop_api_init(chip, phys_core_id, - event_mask_addr, - (u64)CORE_IMC_EVENT_MASK, - P9_STOP_SCOM_REPLACE, - P9_STOP_SECTION_CORE_SCOM, - "event_mask"); - if (ret) - return ret; - } else { - prerror("IMC: Wakeup engine not present!"); - return OPAL_HARDWARE; - } - } - - if (xscom_write(c->chip_id, event_mask_addr, - (u64)CORE_IMC_EVENT_MASK)) { - prerror("error in xscom_write for event mask\n"); - return OPAL_HARDWARE; - } - - /* Get the scom address for htm_mode scom based on the platform */ - htm_addr = get_imc_scom_addr_for_quad(phys_core_id, - htm_scom_index[port_id]); - if (xscom_write(c->chip_id, htm_addr, - (u64)CORE_IMC_HTM_MODE_DISABLE)) { - prerror("error in xscom_write for htm mode\n"); - return OPAL_HARDWARE; + ret = core_imc_counters_init(addr, port_id, phys_core_id, c1); + if (ret < 0) + return ret; } - return OPAL_SUCCESS; + return ret; case OPAL_IMC_COUNTERS_TRACE: if (!c) return OPAL_PARAMETER;