From patchwork Fri Mar 8 02:25:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053340 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.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 44Frw51Pf3z9s9T for ; Fri, 8 Mar 2019 13:26:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QytrsmbT"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44Frw46FbxzDqGN for ; Fri, 8 Mar 2019 13:26:12 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QytrsmbT"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frvp70NRzDqGN for ; Fri, 8 Mar 2019 13:25:56 +1100 (AEDT) Received: by mail-pg1-x544.google.com with SMTP id u9so12838409pgo.7 for ; Thu, 07 Mar 2019 18:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LZWYeTnDncNVV25mr8BkXgySDXt001roqWLBk5iA7dU=; b=QytrsmbTdOTFuPD+SEBrodaSIgSezfW9+s30bqObjWf5koSU4d9x6QaTHhBoeS8KzC aHpMxuZzHMrf+SD3HKbuqpxv0OPlRafDefs+p3rkrw8GOEc4ZQ0bZBYA6tARcn4SBYhw mAVZf5E7qCrQjH9hIjH6cGsoMwt4aItDCs7Lzg8Jd9TucWiEvprwKwka7wVVHLiKiU2B IYODe1t+nyyKdGggc5VAsoSqsGbEMKnL4DC+zMHlsX+swZRg8l3eE+u16T1rYIf2LtJ3 sNIuvcdVP1fc4ocb04w3Gbd/O7Gzh+AtwehDGuXHu4IlYH+7OH9K+bjgH4RwxUlL5u60 HJ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LZWYeTnDncNVV25mr8BkXgySDXt001roqWLBk5iA7dU=; b=CYLDVZflhIyIlZY+sa5pS7rFQ6KOmq9cxifeVuZ6CRlYk3UDRp904iyDZ1xqQsIhzB Y9pPT0MRChGjB5vA1cJ5gDn6NJr7h6HhN2Cu/Pi7ysAAw2hiCRxlG95im8gTtn0mGebK GkGH5fJs/jDGc7oBf1HF0ZkClYNqkJFGp/KesDImq3BADdYKY83jVIsPn6NZ3X/WEBat ApRKqCOPMCgTPgWeSAASnnon1t+Q0uu0baJnA1mv8htWh6+bHovXHmAa/O3ysEHPDjbu 191dCqekYsFFS66C5Z8mizlKwkOVqb/SrBPrERwoxEITkhFrLxIEJtk+IBl3HH19LETg jAUQ== X-Gm-Message-State: APjAAAXqoibpYzHTSsgM5hp7ZZrYobU1MHb2chbh/2hcleS+gvUEFflT /gWFQKVf1YcPV2vrmzIBJ38yE8YE X-Google-Smtp-Source: APXvYqwdfAZpQpXU5Wq34Va347nl7hfoXiE4OfLbuj6QIHlfKI1//tnYotEmjVVqPrgx27tPQVx1Hg== X-Received: by 2002:a17:902:ea8c:: with SMTP id cv12mr15930148plb.123.1552011954061; Thu, 07 Mar 2019 18:25:54 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.25.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:25:53 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:33 +1000 Message-Id: <20190308022539.9313-2-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 1/7] libpdbg: Fix CHECK_ERR macro to evaluate once in error case 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Nicholas Piggin --- libpdbg/operations.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libpdbg/operations.h b/libpdbg/operations.h index dc5042a..85fc117 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -22,9 +22,10 @@ #define PRINT_ERR PR_DEBUG("failed\n"); #define CHECK_ERR(x) do { \ - if (x) { \ + typeof(x) __x = (x); \ + if (__x) { \ PRINT_ERR; \ - return x; \ + return __x; \ } \ } while(0) From patchwork Fri Mar 8 02:25:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053341 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.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 44Frw80WMkz9sBF for ; Fri, 8 Mar 2019 13:26:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="G23eZUsH"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44Frw75cCczDqGb for ; Fri, 8 Mar 2019 13:26:15 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::531; helo=mail-pg1-x531.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="G23eZUsH"; dkim-atps=neutral Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frvq23QqzDqGb for ; Fri, 8 Mar 2019 13:25:59 +1100 (AEDT) Received: by mail-pg1-x531.google.com with SMTP id m2so12838171pgl.5 for ; Thu, 07 Mar 2019 18:25:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=blnZgjxSkBQa5+dOWuYKcIzHCyLrqYkuqje8h1nQLHs=; b=G23eZUsHSJwCGa3GwNbJbVKVzTRBHHfspy5IGXsppjBktY3obg4a7k9eoBVHXpAM3N btKBIl3ICf5KAZ8yAJktvi2KvCdT3Qmctl7rupZip3z9uMRs/2kG6o39FXWhOVTP+nDM axC1C3KAuP/wVhgUR7yQkN5VcqqrTZR7z/iu3vthtbRCYVPDnrnmk7lQ3QPqbO5MLHD8 GwQr6gkDw4qx5qwHyKd9dqUlxAMBt4ufC6j3OPmNApcvh42mPJAQMovLjFv5xYPh7hL+ 5WSkuuizH+l8qRVCPxgx2wVFqqtfxAu16sHEEwfye//0qNEP2z2KCmiPEcTQCHSnq8TC 6hKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=blnZgjxSkBQa5+dOWuYKcIzHCyLrqYkuqje8h1nQLHs=; b=DP8m0LpYwYu4NwPXysWNZdiw9ewH6csZrUbEJp/qcWdKo/yfqZUtuID6j1cFaHeU8T qzDS9mF4WBuT1nEZiEtItl7xVhNnZcoKPutrQJK4Q8FhsTWhJLllxFHzHesFrVwZ4l4P WEdj65PjtQv5y3a0N46CzuvH/6ngKHFBuX7vtdXLWN6yfm4HXWrKb/dfmScS96vKgyar +DsP/cr5DuqibxkOC/s/SfWgrjZnT1EuNEjW+CHq4lGA1dh+lBqhfoogNFYirXd04tng A8oqla+79kz6ovjWm0aWwKONUdyZS3coMjSmj/ZpB5L+zRXZb9lFqmMd8l7ys9JLiEie K4tQ== X-Gm-Message-State: APjAAAXmJDbig2uN8t3bmZlKP71llUjWXiRLPlXAbM2ghe13XiJp0nfp F4wFSku2gWidQRrbwkaMUaSjrTF7 X-Google-Smtp-Source: APXvYqwTpbtUT2LuS4w4aTkbpUDrqXKRivbEvU9oUWpptWDo7lgmLTd9YeM3Ynu4Bz7zPbmRjRIlSA== X-Received: by 2002:a17:902:248:: with SMTP id 66mr12043855plc.286.1552011956455; Thu, 07 Mar 2019 18:25:56 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.25.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:25:56 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:34 +1000 Message-Id: <20190308022539.9313-3-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/7] libpdbg/p8chip.c: read status from correct target 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" --- libpdbg/p8chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 914c335..61b1e25 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -291,7 +291,7 @@ static int p8_thread_stop(struct thread *thread) CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_STOP)); /* Wait for thread to quiese */ - CHECK_ERR(pib_read(&chip->target, RAS_STATUS_REG, &val)); + CHECK_ERR(pib_read(&thread->target, RAS_STATUS_REG, &val)); if (i++ > RAS_STATUS_TIMEOUT) { PR_ERROR("Unable to quiesce thread %d (0x%016" PRIx64 ").\n", thread->id, val); From patchwork Fri Mar 8 02:25:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053342 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 44FrwD1D8Fz9sBb for ; Fri, 8 Mar 2019 13:26:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eb5KwB/F"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44FrwC2Dp0zDqHF for ; Fri, 8 Mar 2019 13:26:19 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::544; helo=mail-pg1-x544.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eb5KwB/F"; dkim-atps=neutral Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frvr5JgzzDqGC for ; Fri, 8 Mar 2019 13:26:00 +1100 (AEDT) Received: by mail-pg1-x544.google.com with SMTP id 125so12600534pgc.12 for ; Thu, 07 Mar 2019 18:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t9NAwmQtPFdpPdimU2KeCJEBIuO4FOr3j/DWbs6ozqE=; b=eb5KwB/F4Z6uUGaYv6sLnpjrrwTMV0Yom+E9I5eA2hKE1aZAZsp8vHcYSnpIQtoJks P+ajCoX+QBXfjomAfbfUxzxgtqKH0plOpaGRJ4zPJ/wFN36WzDaB3itQY9RWafhtu/aT tqZ4vjSUA+f0CnyiuPOyk2ZDWE4DC1L907HaF7xcJino2ZzkdarFCIvZCIHc3qYjBOn6 v/Meu6L+hUHUUK0E6JhbeiGFTNi+mUBJgEwCgPJd2vCeQWmvHwo5VWqu3jAmhu6NPwDe 0RzfPgivPKgbRltfZaElYC5AiU3og735fnV86E5NGlLvTHRQBgtmF+BRhCqP4N8I3Ovq 3ULg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t9NAwmQtPFdpPdimU2KeCJEBIuO4FOr3j/DWbs6ozqE=; b=GPl6P6pMBvF5QCb+q2uxEi6kn8w5slTpraefotZGwGhTyCIKcrz4DwUZfpTAgMU2zC EbB+ZoJXz3K1O0fZTze6sFMMV+cPNGA57Fq+fvzndlwRHXYSoJsFC6S2pc7EOp3hL/zJ VaeImW9Xo15dCfoPxoboA4TCuEYXMhFQBQN9SLWFVjOHBsM69ezTsghdMqddqdZ8fEGG pt63nqVxFZAG/k8b5S5nqlN1TSzo8clcQIebCSNgQhf/eewmBIj4gf5GbOnfwn7WJvik /myxb8cBKdDNrmgHcoJLdyhkpV6kioEdhgkWmEyjuNxuQzf5FRVA2feGe/fa0sw1K0Wb jrIA== X-Gm-Message-State: APjAAAXOV8X6wQ3bT4SNtsvmxHmjqxWWNQydlx5zCOFOLiZQadGo/yHT 1C2bWp1pdDbrdCwwke1LilfaR4eH X-Google-Smtp-Source: APXvYqy1V6Z43MKbEzMQ/X3iNXqHHstrjwmV9qqqsFFh1/gPfgD9Y4phTP6p+fTVTXbW7FHh6nTySQ== X-Received: by 2002:aa7:9102:: with SMTP id 2mr15802529pfh.179.1552011958766; Thu, 07 Mar 2019 18:25:58 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.25.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:25:58 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:35 +1000 Message-Id: <20190308022539.9313-4-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 3/7] libpdbg/p8chip.c: Only write the SP_STOP bit once 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The workbook recipe is to write SP_STOP once, then poll for status. Also add a small delay between polling to give a reasonable timeout and avoid hitting the scom bus hard for no good reason. Signed-off-by: Nicholas Piggin --- libpdbg/p8chip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index 61b1e25..b93e953 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -286,9 +286,11 @@ static int p8_thread_stop(struct thread *thread) struct core *chip = target_to_core( pdbg_target_require_parent("core", &thread->target)); + /* Quiese active thread */ + CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_STOP)); + do { - /* Quiese active thread */ - CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_STOP)); + usleep(1); /* Wait for thread to quiese */ CHECK_ERR(pib_read(&thread->target, RAS_STATUS_REG, &val)); From patchwork Fri Mar 8 02:25:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053343 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 44FrwH0Mh5z9s9T for ; Fri, 8 Mar 2019 13:26:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="g06sCKSY"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44FrwG6PTvzDqHg for ; Fri, 8 Mar 2019 13:26:22 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::541; helo=mail-pg1-x541.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="g06sCKSY"; dkim-atps=neutral Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frvv4znYzDqGC for ; Fri, 8 Mar 2019 13:26:03 +1100 (AEDT) Received: by mail-pg1-x541.google.com with SMTP id b2so12829811pgl.9 for ; Thu, 07 Mar 2019 18:26:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tT8lMGStIWuWqtONu6EVL/ptiWNj3dD8+k51A4gVfow=; b=g06sCKSYoBNJKG5jrP0WuKutPiTo0/hiB1yCvNIPZYOqKG/VRjcgkSw7fL019XTQNA FqEF3htjvTF1/ZBmXLTSzpzQDHGfbU2WrYTzl9bK3d/9TLRE2+ARYxzrnu0ajSAIax1p pvPZeHK9cGB/pDXv+p1uaGFtk60VSSj3WgiWXXkB+PSAJhJQttwGdc/3k+4eZWrmpPGu CtQx+j8OkeT13ZAiPnqUfvemY6578gMvOikf33PoVN3jvOKg6tJU3TJEbCnUuO2AGXnF m/cSQ/PhY+ohmGQqaDSfn4pCNBf4ULKPylRFkEuCV5lW8dNrdaJKGQYezXv/41adFKeh iCTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tT8lMGStIWuWqtONu6EVL/ptiWNj3dD8+k51A4gVfow=; b=tEJ5T18xE3izkiQxAfDn+Ds02nwm/Z84LCWGNST1xmggvDdLHI8pAWflqp9Fei0WoF n8BKki1DU9BnCWEgm5GVQFh3pgt4JsQgx6wiF5kamxzyJD4Ipi0VCJJpaATqfVj1gnXT aYz3P6xtwHhZuig7Nt+vUDQ/pazcwLSrdXnkgKdEwOFv1LahKmaivd05IBx+zimpft7C lIw2SOGiQSxufDYSh01xR0+S+B3Eac4QajQ5Nj5Z04esnmkG33azbgTQh6FXTDrdb9aM Ce/1ehlR1Mz30SplW3teM/qlYaJhY2rkPAY2cORu7yx4RoDQgQlqw7Nw2M3aBEKou5c5 HbOQ== X-Gm-Message-State: APjAAAUz9fyWoInOin9AQUnlZENja82sVUQx8fQbZlIx724TvQzdXcIs XAklIjK2kyLGj5BnIvIDzkWHcuWYzl0= X-Google-Smtp-Source: APXvYqxtLOMK+77LQrrNo6yAmC3ygggImTCoeRfnfI7fR8PgMM+zsEucXroPDWa7EGMsT1eOXOLOHw== X-Received: by 2002:a62:d281:: with SMTP id c123mr15880718pfg.210.1552011961189; Thu, 07 Mar 2019 18:26:01 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.25.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:26:00 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:36 +1000 Message-Id: <20190308022539.9313-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 4/7] libpdbg/p8chip.c: release special wakeups for P8 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This copies the special wakeup release logic from p9chip.c Signed-off-by: Nicholas Piggin --- libpdbg/p8chip.c | 61 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index b93e953..b9fa26d 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -163,16 +163,11 @@ static int assert_special_wakeup(struct core *chip) return 0; } -#if 0 -/* TODO: Work out when to do this. */ -static int deassert_special_wakeup(struct core *chip) +static void deassert_special_wakeup(struct core *chip) { /* Assert special wakeup to prevent low power states */ - CHECK_ERR(pib_write(&chip->target, PMSPCWKUPFSP_REG, 0)); - - return 0; + pib_write(&chip->target, PMSPCWKUPFSP_REG, 0); } -#endif static struct thread_state get_thread_status(struct thread *thread) { @@ -487,6 +482,16 @@ static int p8_thread_probe(struct pdbg_target *target) return 0; } +static void p8_thread_release(struct pdbg_target *target) +{ + struct core *core = target_to_core(pdbg_target_require_parent("core", target)); + struct thread *thread = target_to_thread(target); + + if (thread->status.quiesced) + /* this thread is still quiesced so don't release spwkup */ + core->release_spwkup = false; +} + static int p8_get_hid0(struct pdbg_target *chip, uint64_t *value) { CHECK_ERR(pib_read(chip, HID0_REG, value)); @@ -534,6 +539,7 @@ static struct thread p8_thread = { .compatible = "ibm,power8-thread", .class = "thread", .probe = p8_thread_probe, + .release = p8_thread_release, }, .step = p8_thread_step, .start = p8_thread_start, @@ -562,16 +568,55 @@ static int p8_core_probe(struct pdbg_target *target) if (!GETFIELD(PPC_BIT(0), value)) return -1; - assert_special_wakeup(core); + if (assert_special_wakeup(core)) + return -1; + + /* Child threads will set this to false if they are released while quiesced */ + core->release_spwkup = true; + return 0; } +static void p8_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; + + deassert_special_wakeup(core); + usleep(10000); +} + static struct core p8_core = { .target = { .name = "POWER8 Core", .compatible = "ibm,power8-core", .class = "core", .probe = p8_core_probe, + .release = p8_core_release, }, }; DECLARE_HW_UNIT(p8_core); From patchwork Fri Mar 8 02:25:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053344 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.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 44FrwK70Ngz9s9h for ; Fri, 8 Mar 2019 13:26:25 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EOaicUIG"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44FrwK5TpbzDqHF for ; Fri, 8 Mar 2019 13:26:25 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::42c; helo=mail-pf1-x42c.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EOaicUIG"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frvy2mmGzDqGC for ; Fri, 8 Mar 2019 13:26:06 +1100 (AEDT) Received: by mail-pf1-x42c.google.com with SMTP id n22so12958595pfa.3 for ; Thu, 07 Mar 2019 18:26:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w5EhDAlHSLrwKv38xkpVt8SeTqxXUTjZy63YX6A6KJo=; b=EOaicUIGAcb8gSglU4rUjUOZdvOqCp9RFGV8AN+ppm8FCQ6zoHdG3ofaZQyVdAjxjX AZrBd3Aso2FK6POl4kV7TbZfkPE+KWtPKjtNaUUInHEVUYMUdrdMzJ4ePGPCFbYBvBOw lC7+CXl4R7zz14ZsH89FxDQwMN/GwXQ/2rJC+sEIh3/2U91mK1JCe8kI1tIbdk3BEsME Cx5N+byEFFAHmwEBj+ps1TfWkYAta89GfJpnIVUleh7Ejk3/1iW6vQT8WhD6joYR5XeH V8oEp50reddr7XIf3S8kffipqeitdlfDw9hFZzX45XqVq9AVQXmRtzk7rEui+SgTm0y2 E61g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=w5EhDAlHSLrwKv38xkpVt8SeTqxXUTjZy63YX6A6KJo=; b=XGIw8twInRXnr0Mta2lEJGm9td3vbevU+m0GcUodmEU1EAxAHWiO0UsXKJL0TpdY4C b+jkl3ZCix8JRzWF33CUYTq+mgqAf2yn+nVpoFeaBobQUVeyuJOD0OPTZmQTOYZyNJ9G dYJ8JksjF6wXfIjr7TjWF0HuYU2H72ZDz9V/YwWDBf1veZfOpJNtCGsgjOmlhYZte8Ti NgblEb+AgqzRXjC0RPYBr1JoGOw9PlBGB8eNfOVPke2fj+dVBnGv850RWeTjDaMAN/aK y/xD774ZgOryne528wnuEf7qU+nxcI8FgeQ0aifnLjM/IGiRqi9ipJtXkLaREVEkH4FM IBzA== X-Gm-Message-State: APjAAAUDmcJsqsTtewkjROkT/bwTm6R2+gURuRAgBkX+Mhilt7+tfytk SJ9p34OV2YMgc/xcyXpzKCADVhLAbkc= X-Google-Smtp-Source: APXvYqxx7Q/+ru90CwmS5SISUlxbaZ2beBBDUmecvFb8bA3jMS0Ayklw9fAnMvIIx+eLL6cB0jcc5A== X-Received: by 2002:a17:902:8bc2:: with SMTP id r2mr16401795plo.55.1552011963921; Thu, 07 Mar 2019 18:26:03 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.26.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:26:03 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:37 +1000 Message-Id: <20190308022539.9313-6-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 5/7] libpdbg: use MTMSRD opcode rather than MTMSR 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" XXX: have to ensure this still does the right thing on P9 --- libpdbg/operations.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libpdbg/operations.h b/libpdbg/operations.h index 85fc117..867f997 100644 --- a/libpdbg/operations.h +++ b/libpdbg/operations.h @@ -59,7 +59,7 @@ #define MTNIA_OPCODE 0x00000002UL #define MFNIA_OPCODE 0x00000004UL #define MFMSR_OPCODE 0x7c0000a6UL -#define MTMSR_OPCODE 0x7c000124UL +#define MTMSR_OPCODE 0x7c000164UL #define MFSPR_OPCODE 0x7c0002a6UL #define MTSPR_OPCODE 0x7c0003a6UL #define MFOCRF_OPCODE 0x7c100026UL From patchwork Fri Mar 8 02:25:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053345 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.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 44FrwN4KGHz9s9T for ; Fri, 8 Mar 2019 13:26:28 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IDLdl41d"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44FrwN2TbxzDqGC for ; Fri, 8 Mar 2019 13:26:28 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::432; helo=mail-pf1-x432.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IDLdl41d"; dkim-atps=neutral Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frw05ffpzDqHk for ; Fri, 8 Mar 2019 13:26:08 +1100 (AEDT) Received: by mail-pf1-x432.google.com with SMTP id u9so12957440pfn.1 for ; Thu, 07 Mar 2019 18:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Cn3xyXs8RstLyXSOo/C/PocIBs50/aSBAanbKN0YK4U=; b=IDLdl41d92CaZpnM0Vl/yosl5R+tiMex/pXxKRcmQpLOHVUamLzOUmzOPq9Amk1BDv 1Q5s5QDX7oLyBG+9ML4jxNz5j6ax0HIkIuTaIXUXc4d+udj5FSTUfZApG8zFbD6g9CxE UAERGe5sk17ykAv/IJ9OIYg1LGQz4+dBu55JITdVO5ipyA3m+tqD9HWb4sAIJdiC8503 twXgShSm5k4dKRei9ncv24bcLZsQkLrlRn1XdZ9PVclSSfo89QeDbMx4e2596hN/fJzX 1QopIFK8YqE5QPAu/8S2OBccbQlIJDrRwdjhKbHGct4XGHL0RYUnx/IESz6xAT2kJAVR qRPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Cn3xyXs8RstLyXSOo/C/PocIBs50/aSBAanbKN0YK4U=; b=hdHORkPzlDXpOCQ6Zxbtze3KZt3+5wrvQRgAWLH5XT99yXjJneGRcR3YYiJXk45Qog 290HPuEJRbjrUIJPQmIkyQFoWuWmhyk6Amt10BKK6tC+awavujDPwGEqQlJaHPr84Xo9 2lcGiualMR1xSF9bAQ0vfRK+VpVcSK4zQoCcyVBFnD0b6Murx8spM52Z1OOct3qIX6vV 6aY2wdKLHH0XXa+AqSZwXsZj2kqbg93Y/gQX2Jl31/lQ/nr5mbO9Sz3MIf0hIom+CJLb 2ULy9HJPi2K4IGhgI7i99S/LIHF0d8ICx92111fXF51tXIjiFJfGUGTw7O9BtdyRwO/3 IFHQ== X-Gm-Message-State: APjAAAUvTLAWdIToFOFkDKnobqwFM9qtAuQB0zA6kjQcpw8BPHTRYcvx XOj5P/sbaFYRPT1ckOXjDn8OeoEt2p0= X-Google-Smtp-Source: APXvYqwllkkEM651puCDxTLq7PSkts5gxrbHZwndPKzN+CeJeHA9axVkP0RAlgiMr1CyG6E//LAojg== X-Received: by 2002:a17:902:1025:: with SMTP id b34mr16537696pla.306.1552011966228; Thu, 07 Mar 2019 18:26:06 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.26.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:26:05 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:38 +1000 Message-Id: <20190308022539.9313-7-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 6/7] libpdbg/p8chip.c: ram state setup sequence match workbook 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This makes a few changes to stop and ram procedure. First of all, the existing thread_stop procedure is also setting up some of the ram state. Change that to just do the stop sequence from the workbook, and move the ram stuff into ram setup and destroy. The workbook calls for inactive threads being rammed to set a thread active state before ram mode is exited, in order for GPRs modified by ramming to avoid getting lost. Currently the code does that in the stop sequence before ram mode is activated. The code also currently deasserts the thread active bit after exiting ram mode, which is not part of the workbook, so this is no longer done. Signed-off-by: Nicholas Piggin --- libpdbg/p8chip.c | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index b9fa26d..a12c2fe 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -278,8 +278,6 @@ static int p8_thread_stop(struct thread *thread) { int i = 0; uint64_t val; - struct core *chip = target_to_core( - pdbg_target_require_parent("core", &thread->target)); /* Quiese active thread */ CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_STOP)); @@ -298,39 +296,17 @@ static int p8_thread_stop(struct thread *thread) } break; } - - /* We can continue ramming if either the - * thread is not active or the SRQ/LSU/TS bits - * are set. */ - } while ((val & RAS_STATUS_THREAD_ACTIVE) && - !((val & RAS_STATUS_SRQ_EMPTY) - && (val & RAS_STATUS_LSU_QUIESCED) - && (val & RAS_STATUS_TS_QUIESCE))); - - - /* Make the threads RAM thread active */ - CHECK_ERR(pib_read(&chip->target, THREAD_ACTIVE_REG, &val)); - val |= PPC_BIT(8) >> thread->id; - CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); + } while (!(val & RAS_STATUS_INST_COMPLETE) && + !(val & RAS_STATUS_TS_QUIESCE)); return 0; } static int p8_thread_start(struct thread *thread) { - uint64_t val; - struct core *chip = target_to_core( - pdbg_target_require_parent("core", &thread->target)); - /* Activate thread */ CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_START)); - /* Restore thread active */ - CHECK_ERR(pib_read(&chip->target, THREAD_ACTIVE_REG, &val)); - val &= ~(PPC_BIT(8) >> thread->id); - val |= PPC_BIT(thread->id); - CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); - return 0; } @@ -365,8 +341,10 @@ static int p8_ram_setup(struct thread *thread) return 1; } - if (!(thread->status.active)) + if (!(thread->status.active)) { + PR_WARNING("Thread is in power save state, can not RAM\n"); return 2; + } /* Activate RAM mode */ CHECK_ERR(pib_read(&chip->target, RAM_MODE_REG, &ram_mode)); @@ -425,7 +403,14 @@ static int p8_ram_destroy(struct thread *thread) { struct core *chip = target_to_core( pdbg_target_require_parent("core", &thread->target)); - uint64_t ram_mode; + uint64_t val, ram_mode; + + if (!(get_thread_status(thread).active)) { + /* Mark the RAM thread active so GPRs stick */ + CHECK_ERR(pib_read(&chip->target, THREAD_ACTIVE_REG, &val)); + val |= PPC_BIT(8) >> thread->id; + CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); + } /* Disable RAM mode */ CHECK_ERR(pib_read(&chip->target, RAM_MODE_REG, &ram_mode)); From patchwork Fri Mar 8 02:25:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1053346 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 44FrwR4SnMz9sBF for ; Fri, 8 Mar 2019 13:26:31 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VxUtyD1S"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44FrwR3GGxzDqHp for ; Fri, 8 Mar 2019 13:26:31 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::533; helo=mail-pg1-x533.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="VxUtyD1S"; dkim-atps=neutral Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44Frw35w7jzDqHL for ; Fri, 8 Mar 2019 13:26:11 +1100 (AEDT) Received: by mail-pg1-x533.google.com with SMTP id i130so12849292pgd.1 for ; Thu, 07 Mar 2019 18:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FC6j/XnGSqwB9oVTo98BARKpks/+iU9RtgG1NlbUPsk=; b=VxUtyD1S+3VN+uUMAKr6qW7IC5kVwP/6Q5kIXO+FTByGYTeoMnwcsQf0D+waovIxBE jctE8KdUGvlPLef8k1FaI9RoM03fmtORFAO8jPf2keZvTi17ryZNYkW1dmzKdk0Cg2Fc /2iLDPCyMgcVTsr0G5q2sclyPx4m0OycljH9cLd+KUrsgrlJc5FTgx9rgCGnhAmbftSb dQ9Y0YabWr2BwvxmMaJL057F+8I+xD9K7rWzUgwmLfdCa/yo/3IvKCPrCvlf7v4ZQVGL TSYkzSWpmThh1VG9DspFhKY1u9FjR4KZuo12Ktoy7MQtYUoGd+BbNWA7ls5Zi9K8FDOQ louQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FC6j/XnGSqwB9oVTo98BARKpks/+iU9RtgG1NlbUPsk=; b=dlWLrF/fs2YpjEW8CTjSIFTrIQVXsZDAuvWxUPU34Da/IHTG3TjTSvDTvIIeVzZnSQ z/7+bKZq7D3Pxb2XZQXo3vgLRNSVGwjY0DJ4uSXiWpuavfWe9F7jGrfPXTxhbUCroGdR 5cntWCeR4T5M0J/y/AG+lnLQxONBU/u05uRtpysisep8NW+4hP9pj1z0Js0RCkizHRQ4 yPfdNwXWEQ4CHYZ0V3pK8M4lLFTzJAdLvgEeVauuXvL0pw6w6ahQmsHdqB2B56UrZq2t qnqG0r0HfHzLLscf/krRgKbbVu3DoRo461yv8jkIOulrTq38w4hHkRuxevH3naPpncjk mQCg== X-Gm-Message-State: APjAAAXG/mLj7AdwY1KwBUOL8lmehs2Fq4SD7XRwdS6WyTOevBn788JL 2qxkUXBh1DccTH7XoS5asMJMuupkZRM= X-Google-Smtp-Source: APXvYqwu/wXydNK0cVvTVa3YBv2b6Vd7qptPBgfDmGofBHuDKSghmsBdu8Zy5/ztYZBDl2TwkzmY2w== X-Received: by 2002:a63:c64c:: with SMTP id x12mr14482187pgg.285.1552011969279; Thu, 07 Mar 2019 18:26:09 -0800 (PST) Received: from bobo.local0.net ([193.114.104.11]) by smtp.gmail.com with ESMTPSA id j68sm16295524pfc.64.2019.03.07.18.26.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 18:26:08 -0800 (PST) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Fri, 8 Mar 2019 12:25:39 +1000 Message-Id: <20190308022539.9313-8-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190308022539.9313-1-npiggin@gmail.com> References: <20190308022539.9313-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 7/7] libpdbg/p8chip.c: Emulate sreset using ramming for active threads 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: Nicholas Piggin Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Based on patch from Alistair, some fixes and changes: - account HILE bit, set/clear MSR_LE - clear MSR_PR - don't use raw ramming (clearer this way, not perf critical) At the moment, must manually stop all threads in the core, and manually restart them. Can change behaviour depending on what exactly we want (e.g., sreset all threads may be good for debugging). --- libpdbg/p8chip.c | 82 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index a12c2fe..062da39 100644 --- a/libpdbg/p8chip.c +++ b/libpdbg/p8chip.c @@ -29,6 +29,7 @@ #define RAS_STATUS_TIMEOUT 100 #define DIRECT_CONTROLS_REG 0x0 +#define DIRECT_CONTROL_SP_SRESET PPC_BIT(60) #define DIRECT_CONTROL_SP_STEP PPC_BIT(61) #define DIRECT_CONTROL_SP_START PPC_BIT(62) #define DIRECT_CONTROL_SP_STOP PPC_BIT(63) @@ -310,12 +311,6 @@ static int p8_thread_start(struct thread *thread) return 0; } -static int p8_thread_sreset(struct thread *thread) -{ - /* Broken on p8 */ - return 1; -} - static int p8_ram_setup(struct thread *thread) { struct pdbg_target *target; @@ -339,6 +334,13 @@ static int p8_ram_setup(struct thread *thread) tmp = target_to_thread(target); if (!(get_thread_status(tmp).quiesced)) return 1; + +#if 1 + /* Mark all threads in the core active so GPRs stick */ + CHECK_ERR(pib_read(&chip->target, THREAD_ACTIVE_REG, &val)); + val |= PPC_BIT(8) >> thread->id; + CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); +#endif } if (!(thread->status.active)) { @@ -454,6 +456,74 @@ static int p8_ram_putxer(struct pdbg_target *thread, uint64_t value) return 0; } +#define SPR_SRR0 0x01a +#define SPR_SRR1 0x01b + +#define HID0_HILE PPC_BIT(19) + +#define MSR_HV PPC_BIT(3) /* Hypervisor mode */ +#define MSR_EE PPC_BIT(48) /* External Int. Enable */ +#define MSR_PR PPC_BIT(49) /* Problem State */ +#define MSR_FE0 PPC_BIT(52) /* FP Exception 0 */ +#define MSR_FE1 PPC_BIT(55) /* FP Exception 1 */ +#define MSR_IR PPC_BIT(58) /* Instructions reloc */ +#define MSR_DR PPC_BIT(59) /* Data reloc */ +#define MSR_RI PPC_BIT(62) /* Recoverable Interrupt */ +#define MSR_LE PPC_BIT(63) /* Little Endian */ + +static int p8_get_hid0(struct pdbg_target *chip, uint64_t *value); +static int emulate_sreset(struct thread *thread) +{ + struct pdbg_target *chip = pdbg_target_parent("core", &thread->target); + uint64_t hid0; + uint64_t old_nia, old_msr; + uint64_t new_nia, new_msr; + + printf("emulate sreset begin\n"); + CHECK_ERR(p8_get_hid0(chip, &hid0)); + printf("emulate sreset HILE=%d\n", !!(hid0 & HID0_HILE)); + CHECK_ERR(ram_getnia(&thread->target, &old_nia)); + CHECK_ERR(ram_getmsr(&thread->target, &old_msr)); + new_nia = 0x100; + new_msr = (old_msr & ~(MSR_PR | MSR_IR | MSR_DR | MSR_FE0 | MSR_FE1 | MSR_EE | MSR_RI)) | MSR_HV; + if (hid0 & HID0_HILE) + new_msr |= MSR_LE; + else + new_msr &= ~MSR_LE; + printf("emulate sreset old NIA:%llx MSR:%llx\n", old_nia, old_msr); + printf("emulate sreset new NIA:%llx MSR:%llx\n", new_nia, new_msr); + CHECK_ERR(ram_putspr(&thread->target, SPR_SRR0, old_nia)); + CHECK_ERR(ram_putspr(&thread->target, SPR_SRR1, old_msr)); + CHECK_ERR(ram_putnia(&thread->target, new_nia)); + CHECK_ERR(ram_putmsr(&thread->target, new_msr)); + printf("emulate sreset done\n"); + + return 0; +} + +static int p8_thread_sreset(struct thread *thread) +{ + int rc; + + if (!(thread->status.active)) { + CHECK_ERR(pib_write(&thread->target, DIRECT_CONTROLS_REG, DIRECT_CONTROL_SP_SRESET)); + return 0; + } + + /* Thread was active, emulate the sreset */ + rc = p8_ram_setup(thread); + if (rc) + return rc; + rc = emulate_sreset(thread); + if (rc) { + p8_ram_destroy(thread); + return rc; + } + + return 0; +// return p8_thread_start(thread); +} + /* * Initialise all viable threads for ramming on the given core. */