Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8999958ybl; Fri, 17 Jan 2020 04:47:58 -0800 (PST) X-Google-Smtp-Source: APXvYqz3M/3xWNxbHf3THBEYHh3TI1KYAcLVLarOBpFtoH4++7a8hqtvBz+OunQLX/rL1mue5V/6 X-Received: by 2002:aca:2407:: with SMTP id n7mr3305456oic.14.1579265277898; Fri, 17 Jan 2020 04:47:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579265277; cv=none; d=google.com; s=arc-20160816; b=y85QFvh83srm8kgtleheulFYQMnDzK6wNaUuhqwhQD9eiMCVLcVBXRWDfGmulksr1C pqE1ycZkOkgPzuYDBDzpNqZLL00cHsZzEF35QQzDImaBYqjiV096tKQmju84SBE6vGx6 YZdR/umzj9hqsvqEb1ZMy5QIWgHm5zYVhwFJZZzD1bqhYxW6ATk3teJqijs4pKQqo62f /JIihRG6JdHy6eOE8KmtHclv373kMZCIcQZExza25JNXGurL2HqDcjGzfDCrkohSfwsE pXXv/1G300Z5bTVWiJ+M4UCd3SKcLtXZS9/XkjsaJxZv8p9sW2cCnyruu3ocCXvuPmOU rqwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=i/gq7Wg2HuCLiFR76c1OeUooU+DcwEH6s2N9JD5GIvg=; b=J6XPoY/n953qoCJq8lRL9OgGJaTJC6ryOq8A4fVyJf5iFwyaTu2TnUOi1a57WWfhim 2twrdRG2jjHj2PhK0XYn9WXlKm7Jv2n9bYAuvE0jbFSs4T20CjdN3bkOmqZYinMNmD3n xhRZKnGnusy03cDXFLVQV0Nvbgdwq0wuuGXULGGcvPjWTnxrI2ZGNmmjPtubHaQ2FDc7 Ak66FKCRdpQm5D9+sGHxZJLRHZ4U92N6WQYmXd7GLcFAzZxjOwJSE3mlTxKA6obqLTAU uzv1xmv+OdDIaeb/soVXQCXY7MIoC/C6t6zcJoN4fhVkinDmWP5Y2ozXLWUkFprshoUI uQrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h18si15520286otj.114.2020.01.17.04.47.45; Fri, 17 Jan 2020 04:47:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbgAQMqt (ORCPT + 99 others); Fri, 17 Jan 2020 07:46:49 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:25282 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726409AbgAQMqs (ORCPT ); Fri, 17 Jan 2020 07:46:48 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 00HCbh60146155 for ; Fri, 17 Jan 2020 07:46:47 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2xk0qrkwqt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 17 Jan 2020 07:46:47 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 17 Jan 2020 12:46:45 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 17 Jan 2020 12:46:41 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 00HCkd9321758194 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 17 Jan 2020 12:46:39 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6BC9AE055; Fri, 17 Jan 2020 12:46:39 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1A7BAE05A; Fri, 17 Jan 2020 12:46:34 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.199.44.232]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 17 Jan 2020 12:46:34 +0000 (GMT) From: Kajol Jain To: acme@kernel.org, mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, anju@linux.vnet.ibm.com, maddy@linux.vnet.ibm.com, ravi.bangoria@linux.ibm.com, peterz@infradead.org, yao.jin@linux.intel.com, ak@linux.intel.com, jolsa@kernel.org, kan.liang@linux.intel.com, jmario@redhat.com, alexander.shishkin@linux.intel.com, mingo@kernel.org, paulus@ozlabs.org, namhyung@kernel.org, mpetlan@redhat.com, gregkh@linuxfoundation.org, kjain@linux.ibm.com, benh@kernel.crashing.org Subject: [RFC 1/6] powerpc/hv-24x7: Add rtas call in hv-24x7 driver to get processor details Date: Fri, 17 Jan 2020 18:16:15 +0530 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200117124620.26094-1-kjain@linux.ibm.com> References: <20200117124620.26094-1-kjain@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 20011712-0012-0000-0000-0000037E43C2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20011712-0013-0000-0000-000021BA7A9D Message-Id: <20200117124620.26094-2-kjain@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-01-17_03:2020-01-16,2020-01-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 spamscore=0 mlxscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 phishscore=0 malwarescore=0 suspectscore=0 bulkscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-2001170101 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For hv_24x7 socket/chip level events, specific chip-id to which the data requested should be added as part of pmu events. But number of chips/socket in the system details are not exposed. Patch implements read_sys_info_pseries() to get system parameter values like number of sockets and chips per socket. Rtas_call with token "PROCESSOR_MODULE_INFO" is used to get these values. Patch also make these parameters default to 1. Signed-off-by: Kajol Jain --- arch/powerpc/perf/hv-24x7.c | 68 ++++++++++++++++++++++++ arch/powerpc/platforms/pseries/pseries.h | 3 ++ 2 files changed, 71 insertions(+) diff --git a/arch/powerpc/perf/hv-24x7.c b/arch/powerpc/perf/hv-24x7.c index 573e0b309c0c..64d9fc526d68 100644 --- a/arch/powerpc/perf/hv-24x7.c +++ b/arch/powerpc/perf/hv-24x7.c @@ -19,6 +19,8 @@ #include #include #include +#include +#include <../../platforms/pseries/pseries.h> #include "hv-24x7.h" #include "hv-24x7-catalog.h" @@ -57,6 +59,68 @@ static bool is_physical_domain(unsigned domain) } } +#ifdef CONFIG_PPC_RTAS +#define PROCESSOR_MODULE_INFO 43 +#define PROCESSOR_MAX_LENGTH (8 * 1024) + +static int strbe16toh(const char *buf, int offset) +{ + return (buf[offset] << 8) + buf[offset + 1]; +} + +static u32 physsockets; /* Physical sockets */ +static u32 physchips; /* Physical chips */ + +/* Function read_sys_info_pseries() make a rtas_call which require + * data buffer of size 8K. As standard 'rtas_data_buf' is of size + * 4K, we are adding new local buffer 'rtas_local_data_buf'. + */ +char rtas_local_data_buf[PROCESSOR_MAX_LENGTH] __cacheline_aligned; + +/* + * read_sys_info_pseries() + * Retrieve the number of sockets and chips per socket details + * through the get-system-parameter rtas call. + */ +void read_sys_info_pseries(void) +{ + int call_status, len, ntypes; + + /* + * Making system parameter: chips and sockets default to 1. + */ + physsockets = 1; + physchips = 1; + memset(rtas_local_data_buf, 0, PROCESSOR_MAX_LENGTH); + spin_lock(&rtas_data_buf_lock); + + call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1, + NULL, + PROCESSOR_MODULE_INFO, + __pa(rtas_local_data_buf), + PROCESSOR_MAX_LENGTH); + + spin_unlock(&rtas_data_buf_lock); + + if (call_status != 0) { + pr_info("%s %s Error calling get-system-parameter (0x%x)\n", + __FILE__, __func__, call_status); + } else { + rtas_local_data_buf[PROCESSOR_MAX_LENGTH - 1] = '\0'; + len = strbe16toh(rtas_local_data_buf, 0); + if (len < 6) + return; + + ntypes = strbe16toh(rtas_local_data_buf, 2); + + if (!ntypes) + return; + physsockets = strbe16toh(rtas_local_data_buf, 4); + physchips = strbe16toh(rtas_local_data_buf, 6); + } +} +#endif /* CONFIG_PPC_RTAS */ + /* Domains for which more than one result element are returned for each event. */ static bool domain_needs_aggregation(unsigned int domain) { @@ -1615,6 +1679,10 @@ static int hv_24x7_init(void) if (r) return r; +#ifdef CONFIG_PPC_RTAS + read_sys_info_pseries(); +#endif + return 0; } diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h index 13fa370a87e4..1727559ce304 100644 --- a/arch/powerpc/platforms/pseries/pseries.h +++ b/arch/powerpc/platforms/pseries/pseries.h @@ -19,6 +19,9 @@ extern void request_event_sources_irqs(struct device_node *np, struct pt_regs; extern int pSeries_system_reset_exception(struct pt_regs *regs); +#ifdef CONFIG_PPC_RTAS +extern void read_sys_info_pseries(void); +#endif extern int pSeries_machine_check_exception(struct pt_regs *regs); extern long pseries_machine_check_realmode(struct pt_regs *regs); -- 2.18.1