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; }