From patchwork Tue Nov 10 04:52:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1397293 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 4CVb8X0Zkwz9sPB for ; Tue, 10 Nov 2020 15:53:00 +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=J54NGOaq; 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 4CVb8W5J6wzDqcy for ; Tue, 10 Nov 2020 15:52:59 +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) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CVb7x67SgzDqYY for ; Tue, 10 Nov 2020 15:52:29 +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=J54NGOaq; 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 4CVb7w6C1Qz9sTK; Tue, 10 Nov 2020 15:52:28 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1604983949; bh=+LK9/U7edkgyT5k/Nv4nFWWW8A/AwzwIDuYZnsHWV60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J54NGOaqmR2TRc6koI+aACmakqM4X+cyR7giOXqnmS/w0HS82UViffne/Swej2zaG BfPMJ5Up40hMfVNVTDIk0WNkSobJ774VArTXAh00CySM0HR28MniaxfEmHXtN5NtHG 6i5OAbmvVkQCJqWsNTpw51NvXhFZlqHVtli6xWavNwpYUrqC77vWVBckRQQU4oD9tU fbCVbtw4BpFvF3Q1f4g0XPcNaCLf0FPifWNsTUPAySPzRsIenyOrwkYwCt7X2xE22/ pkWPwwI4xc4zWBt/76oMpP4yzU6YG9ycSHnvA51ERCK1t8EAsEAoxAVye8n+264Pph 6EEnlwRIwE2ZQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 10 Nov 2020 15:52:14 +1100 Message-Id: <20201110045217.137133-2-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 1/4] libpdbg: Separate p10 core driver 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 --- Makefile.am | 1 + libpdbg/p10_fapi_targets.c | 38 -------------------- libpdbg/p10chip.c | 71 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 38 deletions(-) create mode 100644 libpdbg/p10chip.c diff --git a/Makefile.am b/Makefile.am index cf505fd..fc7e2f6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -184,6 +184,7 @@ libpdbg_la_SOURCES = \ libpdbg/p9chip.c \ libpdbg/p9_fapi_targets.c \ libpdbg/p9_scom_addr.h \ + libpdbg/p10chip.c \ libpdbg/p10_fapi_targets.c \ libpdbg/p10_scom_addr.h \ libpdbg/sbefifo.c \ diff --git a/libpdbg/p10_fapi_targets.c b/libpdbg/p10_fapi_targets.c index 0779f50..6023389 100644 --- a/libpdbg/p10_fapi_targets.c +++ b/libpdbg/p10_fapi_targets.c @@ -43,43 +43,6 @@ static struct eq p10_eq = { }; DECLARE_HW_UNIT(p10_eq); -#define NUM_CORES_PER_EQ 4 -static uint64_t p10_core_translate(struct core *c, uint64_t addr) -{ - int region = 0; - int chip_unitnum = pdbg_target_index(t(c)); - - switch(chip_unitnum % NUM_CORES_PER_EQ) { - case 0: - region = 8; - break; - case 1: - region = 4; - break; - case 2: - region = 2; - break; - case 3: - region = 1; - break; - } - addr = set_chiplet_id(addr, EQ0_CHIPLET_ID + pdbg_target_index(t(c)) / 4); - addr &= 0xFFFFFFFFFFFF0FFFULL; - addr |= ((region & 0xF) << 12); - - return addr; -} - -static struct core p10_core = { - .target = { - .name = "POWER10 core", - .compatible = "ibm,power10-core", - .class = "core", - .translate = translate_cast(p10_core_translate), - }, -}; -DECLARE_HW_UNIT(p10_core); - static uint64_t p10_pec_translate(struct pec *pec, uint64_t addr) { int chip_unitnum = pdbg_target_index(t(pec)); @@ -564,7 +527,6 @@ __attribute__((constructor)) static void register_p10_fapi_targets(void) { pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_eq_hw_unit); - pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_core_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_pec_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_phb_hw_unit); pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_nmmu_hw_unit); diff --git a/libpdbg/p10chip.c b/libpdbg/p10chip.c new file mode 100644 index 0000000..7a3976a --- /dev/null +++ b/libpdbg/p10chip.c @@ -0,0 +1,71 @@ +/* Copyright 2020 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. + */ +#include +#include + +#include "hwunit.h" +#include "bitutils.h" +#include "operations.h" +#include "chip.h" +#include "debug.h" + +#define NUM_CORES_PER_EQ 4 +#define EQ0_CHIPLET_ID 0x20 + +static uint64_t p10_core_translate(struct core *c, uint64_t addr) +{ + int region = 0; + int chip_unitnum = pdbg_target_index(&c->target); + int chiplet_id = EQ0_CHIPLET_ID + chip_unitnum / NUM_CORES_PER_EQ; + + switch(chip_unitnum % NUM_CORES_PER_EQ) { + case 0: + region = 8; + break; + case 1: + region = 4; + break; + case 2: + region = 2; + break; + case 3: + region = 1; + break; + } + addr &= 0xFFFFFFFFC0FFFFFFULL; + addr |= ((chiplet_id & 0x3F) << 24); + + addr &= 0xFFFFFFFFFFFF0FFFULL; + addr |= ((region & 0xF) << 12); + + return addr; +} + +static struct core p10_core = { + .target = { + .name = "POWER10 Core", + .compatible = "ibm,power10-core", + .class = "core", + .translate = translate_cast(p10_core_translate), + }, +}; +DECLARE_HW_UNIT(p10_core); + +__attribute__((constructor)) +static void register_p10chip(void) +{ + pdbg_hwunit_register(PDBG_DEFAULT_BACKEND, &p10_core_hw_unit); +} From patchwork Tue Nov 10 04:52:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1397289 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CVb8912nPz9sSn for ; Tue, 10 Nov 2020 15:52:41 +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=BMkQY9Hj; 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 4CVb883D9NzDqcn for ; Tue, 10 Nov 2020 15:52:40 +1100 (AEDT) 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4CVb7y1Jw5zDqYb 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=BMkQY9Hj; 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 4CVb7x2y0nz9sTL; 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=MZuJw2ttBbSiJcQ+rqmab9ZhvQq4Ucidgg+StNBdfYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BMkQY9Hj1IsXwtvAiDcNBTDFtxXwOpmcnhDCFGKJ/Mz4CKO2/gG3p7dtl8PC+J1tF mzejZzZ0ZCUEaPp0WRC0v5fGX5Bs7Ktu2HK6UNVe8JJtZhbZXYM847z6nkNDdlxN4g 8SwHD3MAjUmMmUenmBlh/z4u9AmSaUgUoGqzkYRBwri+Sjzqn2aXi1DEwCZJGS6UQ4 V6yflRx9N3su2WZVCLnMNSVsbfSVL3M5Z3Ag/RFupTCVCvIyn4iAefo/u+e+os1Grv hWebt7udfslD2BW77JFzNgJ3YY1QJSpU7aV8MZUeuQXyklPGsNw/ANaw+xC1VzsFaO pNuKsxM4bYNpw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 10 Nov 2020 15:52:15 +1100 Message-Id: <20201110045217.137133-3-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 2/4] libpdbg: Add p10 core probe/release functions 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/p10chip.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/libpdbg/p10chip.c b/libpdbg/p10chip.c index 7a3976a..b1eb4a6 100644 --- a/libpdbg/p10chip.c +++ b/libpdbg/p10chip.c @@ -22,6 +22,70 @@ #include "chip.h" #include "debug.h" +/* PCB Slave registers */ +#define QME_SSH_FSP 0xE8824 +#define SPECIAL_WKUP_DONE PPC_BIT(1) +#define QME_SPWU_FSP 0xE8834 + +#define SPECIAL_WKUP_TIMEOUT 100 /* 100ms */ + +static int p10_core_probe(struct pdbg_target *target) +{ + struct core *core = target_to_core(target); + uint64_t value; + int i = 0; + + CHECK_ERR(pib_write(target, QME_SPWU_FSP, PPC_BIT(0))); + do { + usleep(1000); + CHECK_ERR(pib_read(target, QME_SSH_FSP, &value)); + + if (i++ > SPECIAL_WKUP_TIMEOUT) { + PR_ERROR("Timeout waiting for special wakeup on %s@0x%08" PRIx64 "\n", + target->name, + pdbg_target_address(target, NULL)); + break; + } + } while (!(value & SPECIAL_WKUP_DONE)); + + core->release_spwkup = true; + + return 0; +} + +static void p10_core_release(struct pdbg_target *target) +{ + struct pdbg_target *child; + struct core *core = target_to_core(target); + enum pdbg_target_status status; + + usleep(1); /* enforce small delay before and after it is cleared */ + + /* Probe and release all threads to ensure release_spwkup is up to + * date */ + pdbg_for_each_target("thread", target, child) { + status = pdbg_target_status(child); + + /* This thread has already been release so should have set + * release_spwkup to false if it was quiesced, */ + if (status == PDBG_TARGET_RELEASED) + continue; + + status = pdbg_target_probe(child); + if (status != PDBG_TARGET_ENABLED) + continue; + + /* Release the thread to ensure release_spwkup is updated. */ + pdbg_target_release(child); + } + + if (!core->release_spwkup) + return; + + pib_write(target, QME_SPWU_FSP, 0); + usleep(10000); +} + #define NUM_CORES_PER_EQ 4 #define EQ0_CHIPLET_ID 0x20 @@ -59,6 +123,8 @@ static struct core p10_core = { .name = "POWER10 Core", .compatible = "ibm,power10-core", .class = "core", + .probe = p10_core_probe, + .release = p10_core_release, .translate = translate_cast(p10_core_translate), }, }; 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); From patchwork Tue Nov 10 04:52:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1397291 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 4CVb8L3cbrz9sPB for ; Tue, 10 Nov 2020 15:52:50 +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=lWDblCpU; 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 4CVb8K4HzSzDqZ2 for ; Tue, 10 Nov 2020 15:52:49 +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 4CVb7y3zZVzDqYq 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=lWDblCpU; 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 4CVb7y1mctz9sTR; Tue, 10 Nov 2020 15:52:30 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1604983950; bh=P20fYRst1Xc9n43PtRHNZv2X0Vms60uiKVf5bTE+VSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWDblCpUpZ2KJL8JQQ0WuoE9P99INSodZcFhEG3svH0eLwo1Mt1d2Ha7d13mB92j0 sDZj8bTbp85Jlc2LugglzogD1DnotE3rlCxy2a8ButFBxQW0CZrN5pS15ZWtEsj71K 6j+DmEpfRF8Ui/B6xKPOe72ZKtVa4L/Nd+/vlYgzqWULBGZL1ehl/uvKL4yleqGkIY dTdp9LxV2/g4k4HsxR4OTKAimzDBOvwJOCN3e0yF9fKpLynVUdqTuekBc3wOo4Dyav P+QF0fiuzGOX1yIlNAaYbrbNwqMGJHOIeD1vyHbULVVULFuwRVYo/KQWgc6N6s+r0O 4+8QD+r3Idw0g== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 10 Nov 2020 15:52:17 +1100 Message-Id: <20201110045217.137133-5-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 4/4] libdbg: Use the correct thread state function 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/sbefifo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index bfe25cf..cfc8488 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -370,7 +370,16 @@ static int sbefifo_thread_op(struct thread *thread, uint32_t oper) static struct thread_state sbefifo_thread_state(struct thread *thread) { - return p9_thread_state(thread); + struct pdbg_target *pib = pdbg_target_require_parent("pib", &thread->target); + struct sbefifo *sbefifo = pib_to_sbefifo(pib); + struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); + + if (sbefifo_proc(sctx) == SBEFIFO_PROC_P9) + return p9_thread_state(thread); + else if (sbefifo_proc(sctx) == SBEFIFO_PROC_P10) + return p10_thread_state(thread); + else + abort(); } static int sbefifo_thread_start(struct thread *thread)