From patchwork Mon Feb 6 18:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch via B4 Relay X-Patchwork-Id: 1738315 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sfcW7yqL; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P9b7H1tcwz23r8 for ; Tue, 7 Feb 2023 05:55:39 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4P9b7H0ysXz3f4x for ; Tue, 7 Feb 2023 05:55:39 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sfcW7yqL; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=139.178.84.217; helo=dfw.source.kernel.org; envelope-from=devnull+nathanl.linux.ibm.com@kernel.org; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sfcW7yqL; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 4P9b5x3nb6z3cHF for ; Tue, 7 Feb 2023 05:54:29 +1100 (AEDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4BEAD60FF2; Mon, 6 Feb 2023 18:54:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id D3AF4C433B4; Mon, 6 Feb 2023 18:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675709665; bh=7sHcklS3JvxNy8+b2cy0PAyfTZ+gELKlvycd7lZAN08=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=sfcW7yqLXfO50dmq5Qj9y9dMSiDuvBVU8tC6Qeg21iEaaQ6CVJPY+HUywe8/nNb4Y HKl5KHjSTR+ALxLoQy1aad+tH4kDOXWn/fhgVIm3tGdZBl4KxqIGd3L/jx9Zg069sH /26wbR/Lel/snZuggzAZSTAsIt9OrLEWmxD7p/K3EA8jSA+OdzXD2nx6oW7TtpSrp2 XgXNLgx3DgA+QPdlBE8c/NVyz1F3LIgbDhQUtpo/cJcFYRIbHH6117g5jZaoavk1mQ eTTdek0+mVBAnRBEHwV2VnnUFqyT8D1I8ok9gdvyQI8ghLAI+4P5DZO49ay7RTyO0I uNqn31WdzaD1Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2E8CC05027; Mon, 6 Feb 2023 18:54:25 +0000 (UTC) From: Nathan Lynch via B4 Submission Endpoint Date: Mon, 06 Feb 2023 12:54:32 -0600 Subject: [PATCH v2 16/19] powerpc/pseries/hv-24x7: convert to papr_sysparm API MIME-Version: 1.0 Message-Id: <20230125-b4-powerpc-rtas-queue-v2-16-9aa6bd058063@linux.ibm.com> References: <20230125-b4-powerpc-rtas-queue-v2-0-9aa6bd058063@linux.ibm.com> In-Reply-To: <20230125-b4-powerpc-rtas-queue-v2-0-9aa6bd058063@linux.ibm.com> To: Michael Ellerman , Nicholas Piggin , Christophe Leroy , Kajol Jain , Laurent Dufour , Mahesh J Salgaonkar , Andrew Donnellan , Nick Child X-Mailer: b4 0.12.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1675709663; l=2846; i=nathanl@linux.ibm.com; s=20230206; h=from:subject:message-id; bh=lmBcfoH0lj/2CvQfdz+MmavuamXOYSbQQ5ghGV+grHI=; b=Zy9zVqbkchRAMfKGtvWK2WUVrJshDR0/y3x55iNQKrPuES4pmOm0HN9jOxxLakDMsqaysUbvP fU5fNWhPDbED3A8ZZ+5yE5lp6YlVIZW1WqfgCp8iYZ6UGKE1ee5UhWE X-Developer-Key: i=nathanl@linux.ibm.com; a=ed25519; pk=6daubz/ymoaMF+8voz7UHwnhluEsmDZuqygIIMWpQQY= X-Endpoint-Received: by B4 Submission Endpoint for nathanl@linux.ibm.com/20230206 with auth_id=27 X-Original-From: Nathan Lynch X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: nathanl@linux.ibm.com Cc: Nathan Lynch , linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Nathan Lynch The new papr_sysparm API handles the details of system parameter retrieval. Use that instead of open-coding the RTAS call, work area management, and retries. Signed-off-by: Nathan Lynch --- arch/powerpc/perf/hv-24x7.c | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c index fcfebf5bd378..f388b984a336 100644 --- a/arch/powerpc/perf/hv-24x7.c +++ b/arch/powerpc/perf/hv-24x7.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -66,8 +67,6 @@ static bool is_physical_domain(unsigned int domain) * Refer PAPR+ document to get parameter token value as '43'. */ -#define PROCESSOR_MODULE_INFO 43 - static u32 phys_sockets; /* Physical sockets */ static u32 phys_chipspersocket; /* Physical chips per socket*/ static u32 phys_coresperchip; /* Physical cores per chip */ @@ -79,8 +78,7 @@ static u32 phys_coresperchip; /* Physical cores per chip */ */ void read_24x7_sys_info(void) { - const s32 token = rtas_token("ibm,get-system-parameter"); - int call_status; + struct papr_sysparm_buf *buf; /* * Making system parameter: chips and sockets and cores per chip @@ -90,27 +88,22 @@ void read_24x7_sys_info(void) phys_chipspersocket = 1; phys_coresperchip = 1; - do { - spin_lock(&rtas_data_buf_lock); - call_status = rtas_call(token, 3, 1, NULL, PROCESSOR_MODULE_INFO, - __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE); - if (call_status == 0) { - int ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]); - int len = be16_to_cpup((__be16 *)&rtas_data_buf[0]); + buf = papr_sysparm_buf_alloc(); + if (!buf) + return; - if (len >= 8 && ntypes != 0) { - phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]); - phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]); - phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]); - } + if (!papr_sysparm_get(PAPR_SYSPARM_PROC_MODULE_INFO, buf)) { + int ntypes = be16_to_cpup((__be16 *)&buf->val[0]); + int len = be16_to_cpu(buf->len); + + if (len >= 8 && ntypes != 0) { + phys_sockets = be16_to_cpup((__be16 *)&buf->val[2]); + phys_chipspersocket = be16_to_cpup((__be16 *)&buf->val[4]); + phys_coresperchip = be16_to_cpup((__be16 *)&buf->val[6]); } - spin_unlock(&rtas_data_buf_lock); - } while (rtas_busy_delay(call_status)); - - if (call_status != 0) { - pr_err("Error calling get-system-parameter %d\n", - call_status); } + + papr_sysparm_buf_free(buf); } /* Domains for which more than one result element are returned for each event. */