From patchwork Mon Aug 13 05:02:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 956812 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41pkB16c1mz9s7X for ; Mon, 13 Aug 2018 15:02:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41pkB13spVzF0bZ for ; Mon, 13 Aug 2018 15:02:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41pk9y5Sf9zDr5t for ; Mon, 13 Aug 2018 15:02:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41pk9y38xhz9ryt; Mon, 13 Aug 2018 15:02:30 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Mon, 13 Aug 2018 15:02:19 +1000 Message-Id: <20180813050219.30067-1-alistair@popple.id.au> X-Mailer: git-send-email 2.11.0 Subject: [Pdbg] [PATCH] libpdbg: Don't release special wakeup when threads are quiesced X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Alistair Popple --- libpdbg/p9chip.c | 40 ++++++++++++++++++++++++++++++++++++++++ libpdbg/target.h | 1 + 2 files changed, 41 insertions(+) diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c index 2585f11..189d80a 100644 --- a/libpdbg/p9chip.c +++ b/libpdbg/p9chip.c @@ -125,6 +125,15 @@ static int p9_thread_probe(struct pdbg_target *target) return 0; } +static void p9_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 p9_thread_start(struct thread *thread) { if (!(thread->status.quiesced)) @@ -392,6 +401,7 @@ static struct thread p9_thread = { .compatible = "ibm,power9-thread", .class = "thread", .probe = p9_thread_probe, + .release = p9_thread_release, }, .start = p9_thread_start, .stop = p9_thread_stop, @@ -472,6 +482,7 @@ static int p9_chiplet_getring(struct chiplet *chiplet, uint64_t ring_addr, int64 static int p9_core_probe(struct pdbg_target *target) { + struct core *core = target_to_core(target); int i = 0; uint64_t value; @@ -493,12 +504,41 @@ static int p9_core_probe(struct pdbg_target *target) } } while (!(value & SPECIAL_WKUP_DONE)); + /* Child threads will set this to false if they are released while quiesced */ + core->release_spwkup = true; + return 0; } static void p9_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, PPM_SPWKUP_FSP, 0); usleep(10000); } diff --git a/libpdbg/target.h b/libpdbg/target.h index 6c2fa17..9f055ac 100644 --- a/libpdbg/target.h +++ b/libpdbg/target.h @@ -131,6 +131,7 @@ struct fsi { struct core { struct pdbg_target target; + bool release_spwkup; }; #define target_to_core(x) container_of(x, struct core, target)