From patchwork Thu Sep 3 09:22:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: maddy X-Patchwork-Id: 513878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A2C8114016A for ; Thu, 3 Sep 2015 19:23:53 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 654E51A2758 for ; Thu, 3 Sep 2015 19:23:53 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D0ED41A2357 for ; Thu, 3 Sep 2015 19:23:41 +1000 (AEST) Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 3 Sep 2015 19:23:41 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 3 Sep 2015 19:23:41 +1000 X-Helo: d23dlp03.au.ibm.com X-MailFrom: maddy@linux.vnet.ibm.com X-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id B2D463578053 for ; Thu, 3 Sep 2015 19:23:40 +1000 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t839NXNG2949432 for ; Thu, 3 Sep 2015 19:23:42 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t839N7j5011273 for ; Thu, 3 Sep 2015 19:23:08 +1000 Received: from SrihariMadhavan.ibm.com ([9.124.94.151]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t839MvjU010720; Thu, 3 Sep 2015 19:23:05 +1000 From: Madhavan Srinivasan To: stewart@linux.vnet.ibm.com, jk@ozlabs.org Date: Thu, 3 Sep 2015 14:52:29 +0530 Message-Id: <1441272156-23548-3-git-send-email-maddy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441272156-23548-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1441272156-23548-1-git-send-email-maddy@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15090309-0033-0000-0000-0000020F3056 Subject: [Skiboot] [PATCH v5 2/9] OPAL nest feature detection X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: skiboot@lists.ozlabs.org MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Initialize the nest pmu and load the nest meta-data. The nest events supported by HW are available as a lid (meta-data), called "Catalog". The catalog lid loaded in two parts. First, it is queued for loading in the preload function and in the second, loaded catalog is verified and used to detect chip nest instrumentation support. New file called "nest.c" added to "hw/" directory to contain nest support code. Code added to include the file in Makefile. Signed-off-by: Madhavan Srinivasan --- core/init.c | 9 ++++ hw/Makefile.inc | 2 +- hw/fsp/fsp.c | 2 + hw/nest.c | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/platform.h | 1 + 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 hw/nest.c diff --git a/core/init.c b/core/init.c index e5952535806a..79f70e28e7dd 100644 --- a/core/init.c +++ b/core/init.c @@ -44,6 +44,7 @@ #include #include #include +#include /* * Boot semaphore, incremented by each CPU calling in @@ -555,6 +556,8 @@ static void do_ctors(void) void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu) { + int loaded; + /* * WARNING: At this point. the timebases have * *not* been synchronized yet. Do not use any timebase @@ -714,6 +717,9 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu) if (platform.init) platform.init(); + /* Start Nest pmu catalog lid loading */ + loaded = preload_catalog_lid(); + /* Setup dummy console nodes if it's enabled */ if (dummy_console_enabled()) dummy_console_add_nodes(); @@ -721,6 +727,9 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu) /* Init SLW related stuff, including fastsleep */ slw_init(); + /* Init Nest PMU unit */ + nest_pmu_init(loaded); + op_display(OP_LOG, OP_MOD_INIT, 0x0002); /* Read in NVRAM and set it up */ diff --git a/hw/Makefile.inc b/hw/Makefile.inc index 034947c0f86f..80978867eb33 100644 --- a/hw/Makefile.inc +++ b/hw/Makefile.inc @@ -2,7 +2,7 @@ SUBDIRS += hw HW_OBJS = xscom.o chiptod.o gx.o cec.o lpc.o lpc-uart.o psi.o -HW_OBJS += homer.o slw.o occ.o fsi-master.o centaur.o +HW_OBJS += homer.o slw.o occ.o fsi-master.o centaur.o nest.o HW_OBJS += nx.o nx-rng.o nx-crypto.o nx-842.o HW_OBJS += p7ioc.o p7ioc-inits.o p7ioc-phb.o p5ioc2.o p5ioc2-phb.o HW_OBJS += phb3.o sfc-ctrl.o fake-rtc.o bt.o p8-i2c.o prd.o diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c index c80fff721700..922dd911ad0d 100644 --- a/hw/fsp/fsp.c +++ b/hw/fsp/fsp.c @@ -106,6 +106,7 @@ static u64 fsp_hir_timeout; #define KERNEL_LID_PHYP 0x80a00701 #define KERNEL_LID_OPAL 0x80f00101 #define INITRAMFS_LID_OPAL 0x80f00102 +#define NEST_CATALOG_LID 0x81e00610 /* * We keep track on last logged values for some things to print only on @@ -2224,6 +2225,7 @@ static struct { { RESOURCE_ID_CAPP, CAPP_IDX_MURANO_DD21, 0x80a02001 }, { RESOURCE_ID_CAPP, CAPP_IDX_VENICE_DD10, 0x80a02003 }, { RESOURCE_ID_CAPP, CAPP_IDX_VENICE_DD20, 0x80a02004 }, + { RESOURCE_ID_CATALOG, RESOURCE_SUBID_NONE, NEST_CATALOG_LID}, }; static void fsp_start_fetching_next_lid(void); diff --git a/hw/nest.c b/hw/nest.c new file mode 100644 index 000000000000..3c08eb58ad57 --- /dev/null +++ b/hw/nest.c @@ -0,0 +1,124 @@ +/* Copyright 2015 IBM Corp. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * Locking notes: + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Pointer holding the Catalog file in memory + */ +struct nest_catalog_desc *catalog_desc; + +/* + * Catalog Page-0 (each page is 4K bytes long) contains + * information about event, group, formula structure offsets + * in the catalog. Cache these offsets in struct nest_catalog_page_0 + * to help the search later. + */ +struct nest_catalog_page_0 *page0_desc; + +int preload_catalog_lid() +{ + size_t size = NEST_CATALOG_SIZE; + int loaded; + + catalog_desc = malloc(sizeof(struct nest_catalog_desc)); + if (!catalog_desc) { + prerror("nest-counters: No mem for nest_catalog_desc structure\n"); + return OPAL_NO_MEM; + } + + catalog_desc->catalog = malloc(NEST_CATALOG_SIZE); + if (!catalog_desc->catalog) { + prerror("nest-counters: No mem for catalog lid \n"); + free(catalog_desc); + return OPAL_NO_MEM; + } + + loaded = start_preload_resource(RESOURCE_ID_CATALOG, + RESOURCE_SUBID_NONE, + catalog_desc->catalog, &size); + + return loaded; +} + +int load_catalog_lid(int loaded) +{ + if (loaded == OPAL_SUCCESS) + loaded = wait_for_resource_loaded(RESOURCE_ID_CATALOG, + RESOURCE_SUBID_NONE); + + if (loaded != OPAL_SUCCESS) { + prerror("nest-counters: Error loading catalog lid\n"); + return OPAL_RESOURCE; + } + + /* + * Now that we have loaded the catalog, check for the + * catalog magic. + */ + page0_desc = (struct nest_catalog_page_0 *)CATALOG(catalog_desc); + if (page0_desc->magic != CATALOG_MAGIC) { + prerror("nest-counters: Error catalog magic number mismatch\n"); + return OPAL_RESOURCE; + } + + /* + * Check for Chip event support in this catalog. + */ + if (page0_desc->chip_group_offset == 0) { + prerror("nest-counters: Not Supported \n"); + return OPAL_UNSUPPORTED; + } + + /* + * Lets save some entry points to help out search + */ + GROUP_ENTRY(catalog_desc) = CATALOG(catalog_desc) + + (page0_desc->group_data_offs * 4096); + EVENT_ENTRY(catalog_desc) = CATALOG(catalog_desc) + + (page0_desc->event_data_offs * 4096); + CHIP_EVENT_ENTRY(catalog_desc) = EVENT_ENTRY(catalog_desc) + + (page0_desc->chip_event_offset); + CHIP_GROUP_ENTRY(catalog_desc) = GROUP_ENTRY(catalog_desc) + + (page0_desc->chip_group_offset); + CORE_EVENT_ENTRY(catalog_desc) = EVENT_ENTRY(catalog_desc) + + (page0_desc->core_event_offset); + CORE_GROUP_ENTRY(catalog_desc) = GROUP_ENTRY(catalog_desc) + + (page0_desc->core_group_offset); + + return OPAL_SUCCESS; +} + +void nest_pmu_init(int loaded) +{ + + if (load_catalog_lid(loaded) != OPAL_SUCCESS) { + prerror("nest-counters: Catalog failed to load\n"); + return; + } + +} diff --git a/include/platform.h b/include/platform.h index 80aa8babbe43..355ab3f1c03d 100644 --- a/include/platform.h +++ b/include/platform.h @@ -26,6 +26,7 @@ enum resource_id { RESOURCE_ID_KERNEL, RESOURCE_ID_INITRAMFS, RESOURCE_ID_CAPP, + RESOURCE_ID_CATALOG, }; #define RESOURCE_SUBID_NONE 0 #define RESOURCE_SUBID_SUPPORTED 1