From patchwork Tue Jun 19 05:25:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJD0Tgqz9s4w for ; Tue, 19 Jun 2018 15:25:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJC5b5rzF0jD for ; Tue, 19 Jun 2018 15:25:47 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ45yBrzDrcd for ; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ42lCNz9s37; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 4F1F2EE78BC; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:18 +1000 Message-Id: <20180619052535.24043-1-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 Subject: [Pdbg] [PATCH 01/18] Make -a the default for probe X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- src/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main.c b/src/main.c index cf9a3b212e..d104404049 100644 --- a/src/main.c +++ b/src/main.c @@ -618,10 +618,6 @@ void print_target(struct pdbg_target *target, int level) struct pdbg_target *next; enum pdbg_target_status status; - /* Did we want to probe this target? */ - if (!target_selected(target)) - return; - pdbg_target_probe(target); /* Does this target actually exist? */ From patchwork Tue Jun 19 05:25:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931378 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJZ3lycz9s37 for ; Tue, 19 Jun 2018 15:26:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJZ0VJFzF0WP for ; Tue, 19 Jun 2018 15:26:05 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ50gcjzF0dW for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ42wX0z9s3C; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 53F99EE78BD; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:19 +1000 Message-Id: <20180619052535.24043-2-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 02/18] p8chip: Restore RAS_MODE_REG to original value X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This correctly restores the MR_THREAD_IN_DEBUG bit rather than always clearing it after. Signed-off-by: Michael Neuling --- libpdbg/p8chip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 6640bb46a8..3e90c8dd16 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -127,8 +127,7 @@ static struct thread_state get_thread_status(struct thread *thread) /* Need to activete debug mode to get complete status */ pib_read(&thread->target, RAS_MODE_REG, &mode_reg); - mode_reg |= MR_THREAD_IN_DEBUG; - pib_write(&thread->target, RAS_MODE_REG, mode_reg); + pib_write(&thread->target, RAS_MODE_REG, mode_reg | MR_THREAD_IN_DEBUG); /* Read status */ pib_read(&thread->target, RAS_STATUS_REG, &val); @@ -194,7 +193,6 @@ static struct thread_state get_thread_status(struct thread *thread) } /* Clear debug mode */ - mode_reg &= ~MR_THREAD_IN_DEBUG; pib_write(&thread->target, RAS_MODE_REG, mode_reg); return thread_status; From patchwork Tue Jun 19 05:25:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931374 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJH6bbcz9s37 for ; Tue, 19 Jun 2018 15:25:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJH4S0DzF0l6 for ; Tue, 19 Jun 2018 15:25:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ46nLNzF0WP for ; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ42yVsz9s47; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 5944EEE78BE; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:20 +1000 Message-Id: <20180619052535.24043-3-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 03/18] htm: Remove unused index in dts X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- p8-pib.dts.m4 | 1 - 1 file changed, 1 deletion(-) diff --git a/p8-pib.dts.m4 b/p8-pib.dts.m4 index e5c34041ad..82d11d8cee 100644 --- a/p8-pib.dts.m4 +++ b/p8-pib.dts.m4 @@ -10,7 +10,6 @@ define(`CORE', `core@CORE_BASE($1) { chtm@11000 { compatible = "ibm,power8-chtm"; reg = <0x0 0x11000 0xB>; - index = <0x0>; }; THREAD(0); From patchwork Tue Jun 19 05:25:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJQ0BQpz9s4w for ; Tue, 19 Jun 2018 15:25:58 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJP3T6hzDrcd for ; Tue, 19 Jun 2018 15:25:57 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ50tfPzF0dd for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ43536z9s4n; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 5E29AEE78BF; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:21 +1000 Message-Id: <20180619052535.24043-4-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 04/18] htm: Fix potential issue with HTM_ERR macro X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Braces are fun. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index a1975448c2..0e5890182e 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -30,7 +30,7 @@ #include "target.h" #include "debug.h" -#define HTM_ERR(x) ({int rc = x; if (rc) {PR_ERROR("HTM Error %d %s:%d\n", \ +#define HTM_ERR(x) ({int rc = (x); if (rc) {PR_ERROR("HTM Error %d %s:%d\n", \ rc, __FILE__, __LINE__);} \ rc;}) From patchwork Tue Jun 19 05:25:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931375 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJL1X6tz9s3C for ; Tue, 19 Jun 2018 15:25:54 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJK6W8CzF0fX for ; Tue, 19 Jun 2018 15:25:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ514w5zF0dj for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ43XKCz9s4v; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 65181EE78C0; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:22 +1000 Message-Id: <20180619052535.24043-5-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 05/18] htm: Remove old comments and prints X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- src/htm.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/htm.c b/src/htm.c index e28c75ece3..8e99ef2ebb 100644 --- a/src/htm.c +++ b/src/htm.c @@ -323,8 +323,6 @@ int run_htm(int optind, int argc, char *argv[]) } if (type == HTM_CORE) { - fprintf(stderr, "Warning: Core HTM is currently experimental\n"); - pdbg_for_each_class_target("core", target) { if (target_selected(target)) { if (!core_target) { @@ -343,15 +341,7 @@ int run_htm(int optind, int argc, char *argv[]) return 0; } - /* - * Check that powersave is off. - * - * This is as easy as checking that every single - * thread is "ACTIVE" and hasn't gone into any sleep - * state. - * - * On P9 it requires checking for THREAD_STATUS_STOP - */ + /* Check that powersave is off */ pdbg_for_each_class_target("thread", target) { pdbg_target_probe(target); @@ -360,7 +350,6 @@ int run_htm(int optind, int argc, char *argv[]) if (!is_smt1(target)) return 0; - } /* Select the correct chtm target */ From patchwork Tue Jun 19 05:25:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931377 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 418xJW1Dysz9s4v for ; Tue, 19 Jun 2018 15:26:03 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJV55qLzDrcd for ; Tue, 19 Jun 2018 15:26:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ52nCQzF0fX for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ44MSkz9s4w; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 6BFB4EE78C1; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:23 +1000 Message-Id: <20180619052535.24043-6-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 06/18] htm: Remove trace and analyse X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" These don't really make and sense. We are going to make things simpler with start, stop, dump and also add a record commands that does it all. Signed-off-by: Michael Neuling --- src/htm.c | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/htm.c b/src/htm.c index 8e99ef2ebb..1103b9c8c9 100644 --- a/src/htm.c +++ b/src/htm.c @@ -211,40 +211,6 @@ static int run_dump(enum htm_type type) return rc; } -static int run_trace(enum htm_type type) -{ - int rc; - - rc = run_reset(type); - if (rc == 0) { - printf("No HTM units were reset.\n"); - printf("It is unlikely anything will start... trying anyway\n"); - } - - rc = run_start(type); - if (rc == 0) - printf("No HTM units were started\n"); - - return rc; -} - -static int run_analyse(enum htm_type type) -{ - int rc; - - rc = run_stop(type); - if (rc == 0) { - printf("No HTM units were stopped.\n"); - printf("It is unlikely anything will dump... trying anyway\n"); - } - - rc = run_dump(type); - if (rc == 0) - printf("No HTM buffers were dumped to file\n"); - - return rc; -} - static struct { const char *name; const char *args; @@ -256,8 +222,6 @@ static struct { { "status", "", "Get %s HTM status", &run_status }, { "reset", "", "Reset %s HTM", &run_reset }, { "dump", "", "Dump %s HTM buffer to file", &run_dump }, - { "trace", "", "Configure and start %s HTM", &run_trace }, - { "analyse","", "Stop and dump %s HTM", &run_analyse}, }; static void print_usage(enum htm_type type) From patchwork Tue Jun 19 05:25:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931385 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJs4rg7z9s3C for ; Tue, 19 Jun 2018 15:26:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJs2x7kzF0dd for ; Tue, 19 Jun 2018 15:26:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ569cczF0l6 for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ44Mmyz9s52; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 72B02EE78C2; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:24 +1000 Message-Id: <20180619052535.24043-7-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 07/18] htm: Move start() and stop() lower X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" So they can use some helper functions later. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 100 +++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 0e5890182e..b4bdd3f5e5 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -315,27 +315,6 @@ static int get_status(struct htm *htm, struct htm_status *status) return 0; } -static int do_htm_stop(struct htm *htm) -{ - struct htm_status status; - get_status(htm, &status); - if (HTM_ERR(get_status(htm, &status))) - return -1; - - if (status.state == UNINITIALIZED) { - PR_INFO("* Skipping STOP trigger, HTM appears uninitialized\n"); - return -1; - } - if (status.state == TRACING) { - PR_INFO("* Sending STOP trigger to HTM\n"); - if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_STOP))) - return -1; - } else { - PR_INFO("* Skipping STOP trigger, HTM is not running\n"); - } - return 1; -} - /* * This sequence will trigger all HTM to start at "roughly" the same * time. @@ -538,35 +517,6 @@ static int is_startable(struct htm_status *status) return (status->state == READY || status->state == PAUSED); } -static int do_htm_start(struct htm *htm) -{ - struct htm_status status; - - if (HTM_ERR(get_status(htm, &status))) - return -1; - - if (!is_startable(&status)) { - PR_ERROR("HTM not in a startable state!\n"); - return -1; - } - - PR_INFO("* Sending START trigger to HTM\n"); - if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_MARK_VALID))) - return -1; - - if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_START))) - return -1; - - /* - * Instead of the HTM_TRIG_START, this is where you might want - * to call do_adu_magic() - * for_each_child_target("adu", &htm->target.parent, do_adu_magic, NULL, NULL); - * see what I mean? - */ - - return 1; -} - static char *get_debugfs_file(struct htm *htm, const char *file) { uint32_t chip_id; @@ -756,6 +706,56 @@ static int do_htm_reset(struct htm *htm, uint64_t *r_base, uint64_t *r_size) return 1; } +static int do_htm_start(struct htm *htm) +{ + struct htm_status status; + + if (HTM_ERR(get_status(htm, &status))) + return -1; + + if (!is_startable(&status)) { + PR_ERROR("HTM not in a startable state!\n"); + return -1; + } + + PR_INFO("* Sending START trigger to HTM\n"); + if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_MARK_VALID))) + return -1; + + if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_START))) + return -1; + + /* + * Instead of the HTM_TRIG_START, this is where you might want + * to call do_adu_magic() + * for_each_child_target("adu", &htm->target.parent, do_adu_magic, NULL, NULL); + * see what I mean? + */ + + return 1; +} + +static int do_htm_stop(struct htm *htm) +{ + struct htm_status status; + get_status(htm, &status); + if (HTM_ERR(get_status(htm, &status))) + return -1; + + if (status.state == UNINITIALIZED) { + PR_INFO("* Skipping STOP trigger, HTM appears uninitialized\n"); + return -1; + } + if (status.state == TRACING) { + PR_INFO("* Sending STOP trigger to HTM\n"); + if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_STOP))) + return -1; + } else { + PR_INFO("* Skipping STOP trigger, HTM is not running\n"); + } + return 1; +} + static int do_htm_status(struct htm *htm) { struct htm_status status; From patchwork Tue Jun 19 05:25:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJc4xlhz9s3C for ; Tue, 19 Jun 2018 15:26:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJc3pTPzF0mR for ; Tue, 19 Jun 2018 15:26:08 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ52t7JzF0jD for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ44Mqcz9s5c; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 74FEAEE78C3; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:25 +1000 Message-Id: <20180619052535.24043-8-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 08/18] htm: Remove base/size from reset X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Base/size aren't needed so remove them. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 15 +++++---------- libpdbg/libpdbg.h | 2 +- libpdbg/target.h | 2 +- src/htm.c | 11 +---------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index b4bdd3f5e5..48ad001f15 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -207,11 +207,11 @@ int htm_stop(struct pdbg_target *target) return htm ? htm->stop(htm) : -1; } -int htm_reset(struct pdbg_target *target, uint64_t *base, uint64_t *size) +int htm_reset(struct pdbg_target *target) { struct htm *htm = check_and_convert(target); - return htm ? htm->reset(htm, base, size) : -1; + return htm ? htm->reset(htm) : -1; } int htm_status(struct pdbg_target *target) @@ -615,7 +615,7 @@ static bool is_configured(struct htm *htm) return true; } -static int configure_memory(struct htm *htm, uint64_t *r_base, uint64_t *r_size) +static int configure_memory(struct htm *htm) { uint64_t i, size, base, val; uint16_t mem_size; @@ -667,15 +667,10 @@ static int configure_memory(struct htm *htm, uint64_t *r_base, uint64_t *r_size) if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_RESET))) return -1; - if (r_size) - *r_size = size; - if (r_base) - *r_base = base; - return 0; } -static int do_htm_reset(struct htm *htm, uint64_t *r_base, uint64_t *r_size) +static int do_htm_reset(struct htm *htm) { struct htm_status status; @@ -700,7 +695,7 @@ static int do_htm_reset(struct htm *htm, uint64_t *r_base, uint64_t *r_size) } - if (HTM_ERR(configure_memory(htm, r_base, r_size))) + if (HTM_ERR(configure_memory(htm))) return -1; return 1; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index c0990d928c..1f5c31167f 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -165,7 +165,7 @@ struct thread_state { int htm_start(struct pdbg_target *target); int htm_stop(struct pdbg_target *target); int htm_status(struct pdbg_target *target); -int htm_reset(struct pdbg_target *target, uint64_t *base, uint64_t *size); +int htm_reset(struct pdbg_target *target); int htm_dump(struct pdbg_target *target, uint64_t size, char *filename); int adu_getmem(struct pdbg_target *target, uint64_t addr, uint8_t *ouput, uint64_t size); diff --git a/libpdbg/target.h b/libpdbg/target.h index e4a3ed41f0..ac00b56e86 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -93,7 +93,7 @@ struct htm { struct pdbg_target target; int (*start)(struct htm *); int (*stop)(struct htm *); - int (*reset)(struct htm *, uint64_t *, uint64_t *); + int (*reset)(struct htm *); int (*status)(struct htm *); int (*dump)(struct htm *, uint64_t, char *); }; diff --git a/src/htm.c b/src/htm.c index 1103b9c8c9..a41b2e52bb 100644 --- a/src/htm.c +++ b/src/htm.c @@ -148,7 +148,6 @@ static int run_status(enum htm_type type) static int run_reset(enum htm_type type) { - uint64_t old_base = 0, base, size; struct pdbg_target *target; int rc = 0; @@ -161,18 +160,10 @@ static int run_reset(enum htm_type type) printf("Resetting HTM@"); print_htm_address(type, target); - if (htm_reset(target, &base, &size) != 1) { + if (htm_reset(target) != 1) { printf("Couldn't reset HTM@"); print_htm_address(type, target); } - if (old_base != base) { - printf("The kernel has initialised HTM memory at:\n"); - printf("base: 0x%016" PRIx64 " for 0x%016" PRIx64 " size\n", - base, size); - printf("In case of system crash/xstop use the following to dump the trace on the BMC:\n"); - printf("./pdbg getmem 0x%016" PRIx64 " 0x%016" PRIx64 " > htm.dump\n", - base, size); - } rc++; } From patchwork Tue Jun 19 05:25:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931386 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJw4wNTz9s3C for ; Tue, 19 Jun 2018 15:26:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJw3D0HzF0mQ for ; Tue, 19 Jun 2018 15:26:24 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ569ZQzF0kx for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ44YXwz9s70; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 7F443EE78C4; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:26 +1000 Message-Id: <20180619052535.24043-9-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 09/18] htm: Remove reset by adding it to start X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- libpdbg/htm.c | 12 +++--------- libpdbg/libpdbg.h | 1 - libpdbg/target.h | 1 - src/htm.c | 25 ------------------------- 4 files changed, 3 insertions(+), 36 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 48ad001f15..d7ffbccd54 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -207,13 +207,6 @@ int htm_stop(struct pdbg_target *target) return htm ? htm->stop(htm) : -1; } -int htm_reset(struct pdbg_target *target) -{ - struct htm *htm = check_and_convert(target); - - return htm ? htm->reset(htm) : -1; -} - int htm_status(struct pdbg_target *target) { struct htm *htm = check_and_convert(target); @@ -705,6 +698,9 @@ static int do_htm_start(struct htm *htm) { struct htm_status status; + if (do_htm_reset(htm) < 0) + return -1; + if (HTM_ERR(get_status(htm, &status))) return -1; @@ -950,7 +946,6 @@ static struct htm nhtm = { }, .start = do_htm_start, .stop = do_htm_stop, - .reset = do_htm_reset, .status = do_htm_status, .dump = do_htm_dump, }; @@ -965,7 +960,6 @@ static struct htm chtm = { }, .start = do_htm_start, .stop = do_htm_stop, - .reset = do_htm_reset, .status = do_htm_status, .dump = do_htm_dump, }; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 1f5c31167f..21e10c61b1 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -165,7 +165,6 @@ struct thread_state { int htm_start(struct pdbg_target *target); int htm_stop(struct pdbg_target *target); int htm_status(struct pdbg_target *target); -int htm_reset(struct pdbg_target *target); int htm_dump(struct pdbg_target *target, uint64_t size, char *filename); int adu_getmem(struct pdbg_target *target, uint64_t addr, uint8_t *ouput, uint64_t size); diff --git a/libpdbg/target.h b/libpdbg/target.h index ac00b56e86..6f8d4b8b08 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -93,7 +93,6 @@ struct htm { struct pdbg_target target; int (*start)(struct htm *); int (*stop)(struct htm *); - int (*reset)(struct htm *); int (*status)(struct htm *); int (*dump)(struct htm *, uint64_t, char *); }; diff --git a/src/htm.c b/src/htm.c index a41b2e52bb..a58a968c08 100644 --- a/src/htm.c +++ b/src/htm.c @@ -146,30 +146,6 @@ static int run_status(enum htm_type type) return rc; } -static int run_reset(enum htm_type type) -{ - struct pdbg_target *target; - int rc = 0; - - pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { - if (!target_selected(target)) - continue; - pdbg_target_probe(target); - if (target_is_disabled(target)) - continue; - - printf("Resetting HTM@"); - print_htm_address(type, target); - if (htm_reset(target) != 1) { - printf("Couldn't reset HTM@"); - print_htm_address(type, target); - } - rc++; - } - - return rc; -} - static int run_dump(enum htm_type type) { struct pdbg_target *target; @@ -211,7 +187,6 @@ static struct { { "start", "", "Start %s HTM", &run_start }, { "stop", "", "Stop %s HTM", &run_stop }, { "status", "", "Get %s HTM status", &run_status }, - { "reset", "", "Reset %s HTM", &run_reset }, { "dump", "", "Dump %s HTM buffer to file", &run_dump }, }; From patchwork Tue Jun 19 05:25:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931381 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 418xJk0tPcz9s47 for ; Tue, 19 Jun 2018 15:26:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJj5VLHzF0l6 for ; Tue, 19 Jun 2018 15:26:13 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ569fczF0lh for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ44MtMz9s5f; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 84354EE78C5; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:27 +1000 Message-Id: <20180619052535.24043-10-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 10/18] htm: Cleanup configure_chtm() X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- libpdbg/htm.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index d7ffbccd54..7cf93f8fae 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -51,6 +51,9 @@ #define HID0_SINGLE_DECODE PPC_BIT(4) #define HID0_EN_INST_TRACE PPC_BIT(17) #define HID0_TRACE_EN PPC_BIT(23) +#define HID0_TRACE_BITS (HID0_ONE_PER_GROUP | HID0_DO_SINGLE |\ + HID0_SINGLE_DECODE | HID0_EN_INST_TRACE |\ + HID0_TRACE_EN) /* * This is a CORE register not a HTM register, don't pass the HTM @@ -431,26 +434,18 @@ static int configure_chtm(struct htm *htm) return -1; if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE, - HTM_MODE_ENABLE | HTM_MODE_WRAP))) + HTM_MODE_ENABLE))) return -1; - /* Not great to assume the core is the parent of the htm. */ + if (HTM_ERR(pib_read(htm->target.parent, HID0_REGISTER, &hid0))) return -1; - - hid0 |= (HID0_DO_SINGLE | HID0_SINGLE_DECODE | HID0_EN_INST_TRACE | - HID0_TRACE_EN | HID0_ONE_PER_GROUP); - - /* Not great to assume the core is the parent of the htm. */ + hid0 |= HID0_TRACE_BITS; if (HTM_ERR(pib_write(htm->target.parent, HID0_REGISTER, hid0))) return -1; - /* Not great to assume the core is the parent of the htm. */ if (HTM_ERR(pib_read(htm->target.parent, NCU_MODE_REGISTER, &ncu))) return -1; - ncu |= NCU_MODE_HTM_ENABLE; - - /* Not great to assume the core is the parent of the htm. */ if (HTM_ERR(pib_write(htm->target.parent, NCU_MODE_REGISTER, ncu))) return -1; From patchwork Tue Jun 19 05:25:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931382 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 418xJm2fcNz9s3C for ; Tue, 19 Jun 2018 15:26:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJl4dQZzF0fX for ; Tue, 19 Jun 2018 15:26:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ56MBzzF0mQ for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ4639cz9s78; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 8ADF9EE78C6; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:28 +1000 Message-Id: <20180619052535.24043-11-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 11/18] htm: Add deconfigure_*htm() and add it to stop() X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Cleanup the core from running in single issue mode when we stop the trace. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 7cf93f8fae..dedf0e1938 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -452,6 +452,34 @@ static int configure_chtm(struct htm *htm) return 0; } +static int deconfigure_chtm(struct htm *htm) +{ + uint64_t hid0, ncu; + + if (!pdbg_target_is_class(&htm->target, "chtm")) + return 0; + + if (HTM_ERR(pib_read(htm->target.parent, NCU_MODE_REGISTER, &ncu))) + return -1; + ncu &= ~NCU_MODE_HTM_ENABLE; + if (HTM_ERR(pib_write(htm->target.parent, NCU_MODE_REGISTER, ncu))) + return -1; + + if (HTM_ERR(pib_read(htm->target.parent, HID0_REGISTER, &hid0))) + return -1; + hid0 &= ~(HID0_TRACE_BITS); + if (HTM_ERR(pib_write(htm->target.parent, HID0_REGISTER, hid0))) + return -1; + + if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,0))) + return -1; + +// FIXME this needs kernel work to happen +// if (HTM_ERR(deconfigure_debugfs_memtrace(htm))) +// return -1; + return 0; +} + static int configure_nhtm(struct htm *htm) { uint64_t val; @@ -500,6 +528,14 @@ static int configure_nhtm(struct htm *htm) return 0; } +static int deconfigure_nhtm(struct htm *htm) +{ + if (!pdbg_target_is_class(&htm->target, "nhtm")) + return 0; + // FIXME: write and test this + return 0; +} + static int is_startable(struct htm_status *status) { return (status->state == READY || status->state == PAUSED); @@ -739,6 +775,12 @@ static int do_htm_stop(struct htm *htm) } else { PR_INFO("* Skipping STOP trigger, HTM is not running\n"); } + + if (deconfigure_chtm(htm) < 0) + return -1; + if (deconfigure_nhtm(htm) < 0) + return -1; + return 1; } From patchwork Tue Jun 19 05:25:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJp4X4tz9s3C for ; Tue, 19 Jun 2018 15:26:18 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJp3Ms3zF0kx for ; Tue, 19 Jun 2018 15:26:18 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ569GRzF0WP for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ467jxz9s7T; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 8D69CEE78C7; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:29 +1000 Message-Id: <20180619052535.24043-12-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 12/18] htm: Cleanup reset X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Simplify the code. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index dedf0e1938..790ca4feef 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -430,6 +430,9 @@ static int configure_chtm(struct htm *htm) { uint64_t hid0, ncu; + if (!pdbg_target_is_class(&htm->target, "chtm")) + return 0; + if (HTM_ERR(configure_debugfs_memtrace(htm))) return -1; @@ -484,6 +487,9 @@ static int configure_nhtm(struct htm *htm) { uint64_t val; + if (!pdbg_target_is_class(&htm->target, "nhtm")) + return 0; + if (HTM_ERR(configure_debugfs_memtrace(htm))) return -1; @@ -702,21 +708,10 @@ static int do_htm_reset(struct htm *htm) return -1; if (!is_resetable(&status) || !is_configured(htm)) { - if (pdbg_target_is_class(&htm->target, "nhtm")) { - if (HTM_ERR(configure_nhtm(htm))) { - PR_ERROR("Couldn't setup Nest HTM during reset\n"); - return -1; - } - } else if (pdbg_target_is_class(&htm->target, "chtm")) { - if (HTM_ERR(configure_chtm(htm))) { - PR_ERROR("Couldn't setup Core HTM during reset\n"); - return -1; - } - } else { /* Well... */ - PR_ERROR("Unknown HTM class! %s\n", - pdbg_target_class_name(&htm->target)); - } - + if (configure_nhtm(htm) < 0) + return -1; + if (configure_chtm(htm) < 0) + return -1; } if (HTM_ERR(configure_memory(htm))) From patchwork Tue Jun 19 05:25:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931388 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJz69Pmz9s3C for ; Tue, 19 Jun 2018 15:26:27 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJz50JTzF0fX for ; Tue, 19 Jun 2018 15:26:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ61QDPzF0dd for ; Tue, 19 Jun 2018 15:25:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ50vTsz9s8r; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 97A54EE78BC; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:30 +1000 Message-Id: <20180619052535.24043-13-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 13/18] htm: Toggle debug bit so trace actually starts X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Without this the trace doesn't actually run. In the past, it was only running once the user did another htm command which toggled this bit during the probe. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 790ca4feef..4003ac3b35 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -720,6 +720,31 @@ static int do_htm_reset(struct htm *htm) return 1; } +/* Stolen from p8chip.c */ +#define RAS_MODE_REG 0x1 +#define MR_THREAD_IN_DEBUG PPC_BIT(43) +static int htm_toggle_debug_bit(struct htm *htm) +{ + struct pdbg_target *target; + uint64_t reg; + + /* FIXME: this is a hack for P8 */ + if (!dt_node_is_compatible(htm->target.parent, "ibm,power8-core")) { + PR_ERROR("HTM is POWER8 only currently\n"); + return -1; + } + + pdbg_for_each_target("thread", htm->target.parent, target) { + if (pdbg_target_index(target) == 0) { + /* Need to set this bit to ensure HTM starts */ + pib_read (target, RAS_MODE_REG, ®); + pib_write(target, RAS_MODE_REG, reg | MR_THREAD_IN_DEBUG); + pib_write(target, RAS_MODE_REG, reg); + } + } + return 0; +} + static int do_htm_start(struct htm *htm) { struct htm_status status; @@ -742,6 +767,9 @@ static int do_htm_start(struct htm *htm) if (HTM_ERR(pib_write(&htm->target, HTM_SCOM_TRIGGER, HTM_TRIG_START))) return -1; + if (htm_toggle_debug_bit(htm)) + return -1; + /* * Instead of the HTM_TRIG_START, this is where you might want * to call do_adu_magic() From patchwork Tue Jun 19 05:25:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xK30L4Gz9s3C for ; Tue, 19 Jun 2018 15:26:31 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xK26FdDzF0dj for ; Tue, 19 Jun 2018 15:26:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ63166zF0dj for ; Tue, 19 Jun 2018 15:25:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ50wHkz9s9F; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id 9DE1EEE78BD; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:31 +1000 Message-Id: <20180619052535.24043-14-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 14/18] htm: Cleanup status X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Make total the actual trace size. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 4003ac3b35..b037997245 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -807,6 +807,24 @@ static int do_htm_stop(struct htm *htm) return 1; } +static uint64_t htm_trace_size(struct htm_status *status) +{ + uint64_t size; + uint64_t mem_size = status->mem_size; + + if (status->mem_size_select) + size = 16; + else + size = 512; + + while (mem_size) { + size <<= 1; + mem_size >>= 1; + } + + return size << 20; +} + static int do_htm_status(struct htm *htm) { struct htm_status status; @@ -829,15 +847,7 @@ static int do_htm_status(struct htm *htm) if (HTM_ERR(get_status(htm, &status))) return -1; - if (status.mem_size_select) - total = 16; - else - total = 512; - - while (status.mem_size) { - total <<= 1; - status.mem_size >>= 1; - } + total = htm_trace_size(&status); PR_DEBUG("HTM status : 0x%016" PRIx64 "\n", status.raw); printf("State: "); @@ -875,13 +885,14 @@ static int do_htm_status(struct htm *htm) printf("\n"); printf("addr:0x%016" PRIx64 "\n", status.mem_base); - printf("size:0x%016" PRIx64 " ", total << 20); - if (total > 512) - printf("[ %" PRIu64 "GB ]", total >> 10); + printf("size:0x%016" PRIx64 " ", total); + if (total >= 0x20000000) + printf("[ %" PRIu64 "GB ]", total >> 30); else - printf("[ %" PRIu64 "MB ]", total); + printf("[ %" PRIu64 "MB ]", total >> 20); printf("\n"); printf("curr:0x%016" PRIx64 "\n", status.mem_last); + return 1; } From patchwork Tue Jun 19 05:25:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931384 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJr1f7cz9s3C for ; Tue, 19 Jun 2018 15:26:20 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJr0L0nzDrcd for ; Tue, 19 Jun 2018 15:26:20 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ570NNzF0n5 for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ50yP7z9s9J; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id A454EEE78BE; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:32 +1000 Message-Id: <20180619052535.24043-15-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 15/18] htm: Print dump file from library X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- libpdbg/htm.c | 1 + src/htm.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index b037997245..9c229dc99f 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -924,6 +924,7 @@ static int do_htm_dump(struct htm *htm, uint64_t size, char *filename) if (size == 0) size = status.mem_last - status.mem_base; + printf("Dumping %li MB to %s\n", size >> 20, filename); if (status.mem_last - status.mem_base > size) { PR_INFO("Requested size is larger than trace 0x%" PRIx64" vs 0x%" PRIx64 "\n", size, status.mem_last - status.mem_base); diff --git a/src/htm.c b/src/htm.c index a58a968c08..ae7e1ea1e2 100644 --- a/src/htm.c +++ b/src/htm.c @@ -166,7 +166,6 @@ static int run_dump(enum htm_type type) /* size = 0 will dump everything */ printf("Dumping HTM@"); print_htm_address(type, target); - printf("File: %s\n", filename); if (htm_dump(target, 0, filename) != 1) { printf("Couldn't dump HTM@"); print_htm_address(type, target); From patchwork Tue Jun 19 05:25:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931387 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJy163nz9s3C for ; Tue, 19 Jun 2018 15:26:26 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJx6flCzF0dW for ; Tue, 19 Jun 2018 15:26:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ56PYpzF0mR for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ46RCCz9s7c; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id AA742EE78BF; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:33 +1000 Message-Id: <20180619052535.24043-16-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 16/18] htm: Add record command X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This starts the trace, waits for it to complete (ie fill the buffer), then stops the trace and dumps out the file. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ libpdbg/libpdbg.h | 1 + libpdbg/target.h | 1 + src/htm.c | 32 ++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index 9c229dc99f..a6445c2420 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -227,6 +227,16 @@ int htm_dump(struct pdbg_target *target, uint64_t size, char *filename) return htm->dump(htm, 0, filename); } +int htm_record(struct pdbg_target *target, char *filename) +{ + struct htm *htm = check_and_convert(target); + + if (!htm || !filename) + return -1; + + return htm->record(htm, filename); +} + static int get_status(struct htm *htm, struct htm_status *status) { uint64_t val; @@ -825,6 +835,26 @@ static uint64_t htm_trace_size(struct htm_status *status) return size << 20; } +static bool htm_complete(struct htm_status *status) +{ + return (status->state == COMPLETE); +} + +static int htm_wait_complete(struct htm *htm) +{ + struct htm_status status; + + while (1) { + if (HTM_ERR(get_status(htm, &status))) + return -1; + PR_DEBUG("loop curr:0x%016" PRIx64 "\n", status.mem_last); + if (htm_complete(&status)) + break; + usleep(100000); + } + return 0; +} + static int do_htm_status(struct htm *htm) { struct htm_status status; @@ -976,6 +1006,24 @@ static int do_htm_dump(struct htm *htm, uint64_t size, char *filename) return 1; } +static int do_htm_record(struct htm *htm, char *filename) +{ + if (do_htm_start(htm) < 0) + return -1; + + if (htm_wait_complete(htm)) + return -1; + + if (do_htm_stop(htm) < 0) + return -1; + + if (do_htm_dump(htm, 0, filename) < 0) + return -1; + + + return 1; +} + static bool is_debugfs_memtrace_ok(void) { return access(DEBUGFS_MEMTRACE, F_OK) == 0; @@ -1018,6 +1066,7 @@ static struct htm nhtm = { }, .start = do_htm_start, .stop = do_htm_stop, + .record = do_htm_record, .status = do_htm_status, .dump = do_htm_dump, }; @@ -1032,6 +1081,7 @@ static struct htm chtm = { }, .start = do_htm_start, .stop = do_htm_stop, + .record = do_htm_record, .status = do_htm_status, .dump = do_htm_dump, }; diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 21e10c61b1..6b635a9b78 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -166,6 +166,7 @@ int htm_start(struct pdbg_target *target); int htm_stop(struct pdbg_target *target); int htm_status(struct pdbg_target *target); int htm_dump(struct pdbg_target *target, uint64_t size, char *filename); +int htm_record(struct pdbg_target *target, char *filename); int adu_getmem(struct pdbg_target *target, uint64_t addr, uint8_t *ouput, uint64_t size); int adu_putmem(struct pdbg_target *target, uint64_t addr, uint8_t *input, uint64_t size); diff --git a/libpdbg/target.h b/libpdbg/target.h index 6f8d4b8b08..9d2ad90bcf 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -95,6 +95,7 @@ struct htm { int (*stop)(struct htm *); int (*status)(struct htm *); int (*dump)(struct htm *, uint64_t, char *); + int (*record)(struct htm *, char *); }; #define target_to_htm(x) container_of(x, struct htm, target) diff --git a/src/htm.c b/src/htm.c index ae7e1ea1e2..eff46a6c93 100644 --- a/src/htm.c +++ b/src/htm.c @@ -177,6 +177,37 @@ static int run_dump(enum htm_type type) return rc; } +static int run_record(enum htm_type type) +{ + struct pdbg_target *target; + char *filename; + int rc = 0; + + pdbg_for_each_class_target(HTM_ENUM_TO_STRING(type), target) { + if (!target_selected(target)) + continue; + pdbg_target_probe(target); + if (target_is_disabled(target)) + continue; + + filename = get_htm_dump_filename(target); + if (!filename) + return 0; + + /* size = 0 will dump everything */ + printf("Recording HTM@"); + print_htm_address(type, target); + if (htm_record(target, filename) != 1) { + printf("Couldn't record HTM@"); + print_htm_address(type, target); + } + rc++; + free(filename); + } + + return rc; +} + static struct { const char *name; const char *args; @@ -187,6 +218,7 @@ static struct { { "stop", "", "Stop %s HTM", &run_stop }, { "status", "", "Get %s HTM status", &run_status }, { "dump", "", "Dump %s HTM buffer to file", &run_dump }, + { "record", "", "Start, wait & dump %s HTM", &run_record }, }; static void print_usage(enum htm_type type) From patchwork Tue Jun 19 05:25:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931389 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.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 418xK14fz0z9s3C for ; Tue, 19 Jun 2018 15:26:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xK13F3yzF0nB for ; Tue, 19 Jun 2018 15:26:29 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ6316vzF0nB for ; Tue, 19 Jun 2018 15:25:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ50wS2z9s9G; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id AFCC6EE78C0; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:34 +1000 Message-Id: <20180619052535.24043-17-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 17/18] htm: Change buffer wrappings semantics X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" "htm record" is set to non-wrapping mode "htm start" is in wrapping mode since it's assumed "htm stop" will stop it. Signed-off-by: Michael Neuling --- libpdbg/htm.c | 33 ++++++++++++++++++++++----------- src/htm.c | 4 ++-- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/libpdbg/htm.c b/libpdbg/htm.c index a6445c2420..c4eeabbb59 100644 --- a/libpdbg/htm.c +++ b/libpdbg/htm.c @@ -436,9 +436,9 @@ static int configure_debugfs_memtrace(struct htm *htm) return 0; } -static int configure_chtm(struct htm *htm) +static int configure_chtm(struct htm *htm, bool wrap) { - uint64_t hid0, ncu; + uint64_t hid0, ncu, val; if (!pdbg_target_is_class(&htm->target, "chtm")) return 0; @@ -446,8 +446,9 @@ static int configure_chtm(struct htm *htm) if (HTM_ERR(configure_debugfs_memtrace(htm))) return -1; + val = wrap ? HTM_MODE_WRAP : 0; if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE, - HTM_MODE_ENABLE))) + HTM_MODE_ENABLE | val))) return -1; if (HTM_ERR(pib_read(htm->target.parent, HID0_REGISTER, &hid0))) @@ -493,7 +494,7 @@ static int deconfigure_chtm(struct htm *htm) return 0; } -static int configure_nhtm(struct htm *htm) +static int configure_nhtm(struct htm *htm, bool wrap) { uint64_t val; @@ -507,10 +508,11 @@ static int configure_nhtm(struct htm *htm) * The constant is the VGTARGET field, taken from a cronus * booted system which presumably set it up correctly */ + val = wrap ? HTM_MODE_WRAP : 0; if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE, HTM_MODE_ENABLE | NHTM_MODE_CRESP_PRECISE | - HTM_MODE_WRAP | + val | 0xFFFF000000))) return -1; @@ -710,7 +712,7 @@ static int configure_memory(struct htm *htm) return 0; } -static int do_htm_reset(struct htm *htm) +static int do_htm_reset(struct htm *htm, bool wrap) { struct htm_status status; @@ -718,9 +720,9 @@ static int do_htm_reset(struct htm *htm) return -1; if (!is_resetable(&status) || !is_configured(htm)) { - if (configure_nhtm(htm) < 0) + if (configure_nhtm(htm, wrap) < 0) return -1; - if (configure_chtm(htm) < 0) + if (configure_chtm(htm, wrap) < 0) return -1; } @@ -755,11 +757,11 @@ static int htm_toggle_debug_bit(struct htm *htm) return 0; } -static int do_htm_start(struct htm *htm) +static int __do_htm_start(struct htm *htm, bool wrap) { struct htm_status status; - if (do_htm_reset(htm) < 0) + if (do_htm_reset(htm, wrap) < 0) return -1; if (HTM_ERR(get_status(htm, &status))) @@ -790,6 +792,11 @@ static int do_htm_start(struct htm *htm) return 1; } +static int do_htm_start(struct htm *htm) +{ + return __do_htm_start(htm, true); +} + static int do_htm_stop(struct htm *htm) { struct htm_status status; @@ -926,6 +933,10 @@ static int do_htm_status(struct htm *htm) return 1; } +/* + * FIXME: + * Look for eyecatcher 0xacef_f000 at start, otherwise assume wrapping + */ static int do_htm_dump(struct htm *htm, uint64_t size, char *filename) { char *trace_file; @@ -1008,7 +1019,7 @@ static int do_htm_dump(struct htm *htm, uint64_t size, char *filename) static int do_htm_record(struct htm *htm, char *filename) { - if (do_htm_start(htm) < 0) + if (__do_htm_start(htm, false) < 0) return -1; if (htm_wait_complete(htm)) diff --git a/src/htm.c b/src/htm.c index eff46a6c93..02e55c1833 100644 --- a/src/htm.c +++ b/src/htm.c @@ -86,7 +86,7 @@ static int run_start(enum htm_type type) if (target_is_disabled(target)) continue; - printf("Starting HTM@"); + printf("Starting with buffer wrapping HTM@"); print_htm_address(type, target); if (htm_start(target) != 1) { printf("Couldn't start HTM@"); @@ -195,7 +195,7 @@ static int run_record(enum htm_type type) return 0; /* size = 0 will dump everything */ - printf("Recording HTM@"); + printf("Recording till buffer wraps HTM@"); print_htm_address(type, target); if (htm_record(target, filename) != 1) { printf("Couldn't record HTM@"); From patchwork Tue Jun 19 05:25:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 931380 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418xJf5GVTz9s47 for ; Tue, 19 Jun 2018 15:26:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 418xJf3W7dzF0l6 for ; Tue, 19 Jun 2018 15:26:10 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 418xJ55wFJzDrcd for ; Tue, 19 Jun 2018 15:25:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 418xJ46Rgsz9s8f; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) Received: by localhost.localdomain (Postfix, from userid 1000) id B2237EE78C8; Tue, 19 Jun 2018 15:25:40 +1000 (AEST) From: Michael Neuling To: alistair@popple.id.au Date: Tue, 19 Jun 2018 15:25:35 +1000 Message-Id: <20180619052535.24043-18-mikey@neuling.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619052535.24043-1-mikey@neuling.org> References: <20180619052535.24043-1-mikey@neuling.org> Subject: [Pdbg] [PATCH 18/18] htm: Documentation update X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, pdbg@lists.ozlabs.org MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Michael Neuling --- README.md | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index f462df0240..a698703709 100644 --- a/README.md +++ b/README.md @@ -330,27 +330,25 @@ $ sudo ./pdbg -p 0 getmem -ci 0x0003ffff40000000 4 |hexdump -C ``` ### Hardware Trace Macro -Expoitation of HTM is limited to POWER9 NestHTM from the powerpc host. -POWER8 (core and nest( is currently experimental. The dump files -should be correct but have not been confirmed to be. - -Using HTM requires a kernel built with both `CONFIG_PPC_MEMTRACE=y` -(v4.14) and `CONFIG_SCOM_DEBUGFS=y`. debugfs should be mounted at -`/sys/kernel/debug`. -pdbg provides a `htm` command with a variety of subcommands: - - `trace` will configure the hardware and start tracing - - `analyse` which still stop the trace and dump the result to a file +Expoitation of HTM is limited to POWER9 NestHTM from the powerpc host. +POWER8 (core and nest). +pdbg provides a `htm` command with a variety of subcommands the most +useful command is `record` which will start the trace, wait for buffer +to fill (~1 sec), stop and then dump (~5 sec). eg. ``` -./pdbg -b host -d p9 -a htm trace -[allow test to run] -./pdbg -b host -d p9 -a htm analyse +pdbg -p0 -c4 core htm record ``` -If you are running into a checkstop issue, `htm trace` will print the +There are also low level commands which can also be used: + - `start` will configure the hardware and start tracing in wrapping mode. + - `stop` will still stop the trace and deconfigure the hardware + - `dump` will dump the trace to a file + +If you are running into a checkstop issue, `htm status` will print the physical address of the buffer it is tracing into and the BMC can be used to recover this memory after checkstop see `getmem`. -pdbg also provides some of the basic functionality to use HTM, such as -`htm reset`, `htm start` and `htm stop` to perform each step manually -if required. +Using HTM requires a kernel built with both `CONFIG_PPC_MEMTRACE=y` +(v4.14) and `CONFIG_SCOM_DEBUGFS=y`. debugfs should be mounted at +`/sys/kernel/debug`. Ubuntu 18.04 has this by default.