From patchwork Mon Jul 3 09:37:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anju T Sudhakar X-Patchwork-Id: 783380 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3x1McF10HYz9rxl for ; Mon, 3 Jul 2017 19:42:21 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3x1McF0DZ9zDrF6 for ; Mon, 3 Jul 2017 19:42:21 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org 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 3x1MWV0zwmzDr4L for ; Mon, 3 Jul 2017 19:38:13 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v639XfkP023045 for ; Mon, 3 Jul 2017 05:38:11 -0400 Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) by mx0b-001b2d01.pphosted.com with ESMTP id 2bfjk3a2r9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 03 Jul 2017 05:38:11 -0400 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 3 Jul 2017 19:38:08 +1000 Received: from d23relay09.au.ibm.com (202.81.31.228) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 3 Jul 2017 19:38:06 +1000 Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v639c5BP60162284 for ; Mon, 3 Jul 2017 19:38:05 +1000 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v639btfq027722 for ; Mon, 3 Jul 2017 19:37:56 +1000 Received: from xenial-xerus.in.ibm.com (xenial-xerus.in.ibm.com [9.124.35.20] (may be forged)) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v639bkFP027271; Mon, 3 Jul 2017 19:37:53 +1000 From: Anju T Sudhakar To: mpe@ellerman.id.au Subject: [PATCH v12 02/10] powerpc/powernv: Autoload IMC device driver module Date: Mon, 3 Jul 2017 15:07:48 +0530 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499074673-30576-1-git-send-email-anju@linux.vnet.ibm.com> References: <1499074673-30576-1-git-send-email-anju@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17070309-1617-0000-0000-000001F0CF0C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17070309-1618-0000-0000-000048381596 Message-Id: <1499074673-30576-3-git-send-email-anju@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-07-03_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1707030160 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stewart@linux.vnet.ibm.com, ego@linux.vnet.ibm.com, mikey@neuling.org, maddy@linux.vnet.ibm.com, hemant@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, eranian@google.com, anju@linux.vnet.ibm.com, anton@samba.org, sukadev@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, dja@axtens.net Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Code to create platform device for the IMC counters. Paltform devices are created based on the IMC compatibility string. New Config flag "CONFIG_HV_PERF_IMC_CTRS" add to contain the IMC counter changes. Signed-off-by: Anju T Sudhakar Signed-off-by: Hemant Kumar Signed-off-by: Madhavan Srinivasan --- arch/powerpc/platforms/powernv/Kconfig | 10 +++++ arch/powerpc/platforms/powernv/Makefile | 1 + arch/powerpc/platforms/powernv/opal-imc.c | 73 +++++++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal.c | 18 ++++++++ 4 files changed, 102 insertions(+) create mode 100644 arch/powerpc/platforms/powernv/opal-imc.c diff --git a/arch/powerpc/platforms/powernv/Kconfig b/arch/powerpc/platforms/powernv/Kconfig index 6a6f4ef46b9e..543c6cd5e8d3 100644 --- a/arch/powerpc/platforms/powernv/Kconfig +++ b/arch/powerpc/platforms/powernv/Kconfig @@ -30,3 +30,13 @@ config OPAL_PRD help This enables the opal-prd driver, a facility to run processor recovery diagnostics on OpenPower machines + +config HV_PERF_IMC_CTRS + bool "Hypervisor supplied In Memory Collection PMU events (Nest & Core)" + default y + depends on PERF_EVENTS && PPC_POWERNV + help + Enable access to hypervisor supplied in-memory collection counters + in perf. IMC counters are available from Power9 systems. + + If unsure, select Y. diff --git a/arch/powerpc/platforms/powernv/Makefile b/arch/powerpc/platforms/powernv/Makefile index b5d98cb3f482..715e531f6711 100644 --- a/arch/powerpc/platforms/powernv/Makefile +++ b/arch/powerpc/platforms/powernv/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_PPC_SCOM) += opal-xscom.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_TRACEPOINTS) += opal-tracepoints.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o +obj-$(CONFIG_HV_PERF_IMC_CTRS) += opal-imc.o diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c new file mode 100644 index 000000000000..5b1045c81af4 --- /dev/null +++ b/arch/powerpc/platforms/powernv/opal-imc.c @@ -0,0 +1,73 @@ +/* + * OPAL IMC interface detection driver + * Supported on POWERNV platform + * + * Copyright (C) 2017 Madhavan Srinivasan, IBM Corporation. + * (C) 2017 Anju T Sudhakar, IBM Corporation. + * (C) 2017 Hemant K Shaw, IBM Corporation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int opal_imc_counters_probe(struct platform_device *pdev) +{ + struct device_node *imc_dev = NULL; + + if (!pdev || !pdev->dev.of_node) + return -ENODEV; + + /* + * Check whether this is kdump kernel. If yes, just return. + */ + if (is_kdump_kernel()) + return -ENODEV; + + imc_dev = pdev->dev.of_node; + if (!imc_dev) + return -ENODEV; + + return 0; +} + +static const struct of_device_id opal_imc_match[] = { + { .compatible = IMC_DTB_COMPAT }, + {}, +}; + +static struct platform_driver opal_imc_driver = { + .driver = { + .name = "opal-imc-counters", + .of_match_table = opal_imc_match, + }, + .probe = opal_imc_counters_probe, +}; + +MODULE_DEVICE_TABLE(of, opal_imc_match); +module_platform_driver(opal_imc_driver); +MODULE_DESCRIPTION("PowerNV OPAL IMC driver"); +MODULE_LICENSE("GPL"); diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 59684b4af4d1..fbdca259ea76 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include #include #include +#include #include "powernv.h" @@ -705,6 +707,17 @@ static void opal_pdev_init(const char *compatible) of_platform_device_create(np, NULL, NULL); } +#ifdef CONFIG_HV_PERF_IMC_CTRS +static void __init opal_imc_init_dev(void) +{ + struct device_node *np; + + np = of_find_compatible_node(NULL, NULL, IMC_DTB_COMPAT); + if (np) + of_platform_device_create(np, NULL, NULL); +} +#endif + static int kopald(void *unused) { unsigned long timeout = msecs_to_jiffies(opal_heartbeat) + 1; @@ -778,6 +791,11 @@ static int __init opal_init(void) /* Setup a heatbeat thread if requested by OPAL */ opal_init_heartbeat(); +#ifdef CONFIG_HV_PERF_IMC_CTRS + /* Detect IMC pmu counters support and create PMUs */ + opal_imc_init_dev(); +#endif + /* Create leds platform devices */ leds = of_find_node_by_path("/ibm,opal/leds"); if (leds) {