From patchwork Tue Nov 10 04:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1397290 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CVb8D3dqvz9sTK for ; Tue, 10 Nov 2020 15:52:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=yDzSkW5s; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CVb8D10PBzDqd9 for ; Tue, 10 Nov 2020 15:52:44 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CVb7y2hN8zDqYp for ; Tue, 10 Nov 2020 15:52:30 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=yDzSkW5s; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4CVb7x5yVSz9sPB; Tue, 10 Nov 2020 15:52:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1604983949; bh=GJG0Pb4ITgHFy6kh2TZpJm36fMm57G3IPsNksvaUFng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yDzSkW5she58OOzSLvBhN0NoHfXMdW08Rp1yD3LTwiFbzh+BQfcDS7xfP56V5pJH5 N1+J6mv3+Z3PV2teHdH/zpRmsJoHD2EuaVWR4dhPxeUDptsOUPNJDXvuv0ZK9jT6c5 GJa5zL4nnOGoWyIHyeZC5TXvhgSsNinEOlwpvrJrcqGw4veLap2xjbHmCy3mZCWhAj xSVjC4eFv0ihNXX00Gs5UyVt73EUMidO7SanrKXBkIJrzjgOF0/yBxMks+YYMMuZbv C+valj0v15U/l799MgslNiYEUs/ejiM1MYL3lqbnYZJiVpBIZnbycvV91y9DNHknba puqa4e26bgfEQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 10 Nov 2020 15:52:16 +1100 Message-Id: <20201110045217.137133-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201110045217.137133-1-amitay@ozlabs.org> References: <20201110045217.137133-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 3/4] libpdbg: Add p10 thread state X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 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: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- libpdbg/chip.h | 1 + libpdbg/p10chip.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/libpdbg/chip.h b/libpdbg/chip.h index 11e8e8b..2231053 100644 --- a/libpdbg/chip.h +++ b/libpdbg/chip.h @@ -44,5 +44,6 @@ int ram_getcr(struct thread *thread, uint32_t *value); int ram_putcr(struct thread *thread, uint32_t value); struct thread_state p9_thread_state(struct thread *thread); +struct thread_state p10_thread_state(struct thread *thread); #endif diff --git a/libpdbg/p10chip.c b/libpdbg/p10chip.c index b1eb4a6..12395f5 100644 --- a/libpdbg/p10chip.c +++ b/libpdbg/p10chip.c @@ -22,6 +22,10 @@ #include "chip.h" #include "debug.h" +#define P10_CORE_THREAD_STATE 0x28412 +#define P10_THREAD_INFO 0x28413 +#define P10_RAS_STATUS 0x28454 + /* PCB Slave registers */ #define QME_SSH_FSP 0xE8824 #define SPECIAL_WKUP_DONE PPC_BIT(1) @@ -29,6 +33,54 @@ #define SPECIAL_WKUP_TIMEOUT 100 /* 100ms */ +static int thread_read(struct thread *thread, uint64_t addr, uint64_t *data) +{ + struct pdbg_target *core = pdbg_target_require_parent("core", &thread->target); + + return pib_read(core, addr, data); +} + +struct thread_state p10_thread_state(struct thread *thread) +{ + struct thread_state thread_state; + uint64_t value; + uint8_t smt_mode; + + thread_read(thread, P10_RAS_STATUS, &value); + + thread_state.quiesced = (GETFIELD(PPC_BITMASK(1 + 8*thread->id, 3 + 8*thread->id), value) == 0x7); + + thread_read(thread, P10_THREAD_INFO, &value); + thread_state.active = !!(value & PPC_BIT(thread->id)); + + smt_mode = GETFIELD(PPC_BITMASK(8,9), value); + switch (smt_mode) { + case 0: + thread_state.smt_state = PDBG_SMT_1; + break; + + case 2: + thread_state.smt_state = PDBG_SMT_2; + break; + + case 3: + thread_state.smt_state = PDBG_SMT_4; + break; + + default: + thread_state.smt_state = PDBG_SMT_UNKNOWN; + break; + } + + thread_read(thread, P10_CORE_THREAD_STATE, &value); + if (value & PPC_BIT(56 + thread->id)) + thread_state.sleep_state = PDBG_THREAD_STATE_STOP; + else + thread_state.sleep_state = PDBG_THREAD_STATE_RUN; + + return thread_state; +} + static int p10_core_probe(struct pdbg_target *target) { struct core *core = target_to_core(target);