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