From patchwork Tue Mar 12 01:49:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1055022 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 44JHwQ2Cl2z9s4V for ; Tue, 12 Mar 2019 12:49:58 +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="XLJvl0vU"; 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 44JHwQ0cfczDqFD for ; Tue, 12 Mar 2019 12:49:58 +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::441; helo=mail-pf1-x441.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="XLJvl0vU"; dkim-atps=neutral Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 44JHw70xdHzDqDV for ; Tue, 12 Mar 2019 12:49:42 +1100 (AEDT) Received: by mail-pf1-x441.google.com with SMTP id i19so625977pfd.0 for ; Mon, 11 Mar 2019 18:49:42 -0700 (PDT) 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=QBHKcdmi17qm8pC+7XLvlDvWRpgWsEYjBH9VVOHtit0=; b=XLJvl0vUkUeNE2tt02/41iNMp8tYsvk/NYk6K1xW3PaoB2z+oPKI/Qk9NQLJqFhpEM Y3zLzUGnXfOKZseEtjdb2A/lEndq3OF/bcoct+QaBPqNk2pNl4VSLMYZq/ceqBFARsmP u6VAdi7RF6G5j+1PMyCez8PgLY7tBHUQ/28qisDzIjoogWo4lxIahEkEJSRpS92DuLmp 2a8f1x20kvnxWluETJY092fHZtFKuUE2ovroYqY9Kb9+kBFGo/0z0wnEEI0LxJZ4Yywj 86LtK1Qf6t/i2TOa2mxx4WSG3tMbmaegFAnxaG26Tq7DKE4mRU+dyK4Apln5bYEJi65s VZhQ== 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=QBHKcdmi17qm8pC+7XLvlDvWRpgWsEYjBH9VVOHtit0=; b=r73oKVaIS5bLf110ygrHtDqEzF+WVmlmoLg2A+h/8tfxK5icDQISOIhZGG1uLGOzsx bT7ozAw0cs5LYHtfH2fcQTM1839VEtI0pzePoNDL9hjvlBnGnfm7cf/y0QIbbn9dSwDk FADAPA4FWCMxNEfZ3cslXEipDo9Kf6KnBSm3wYdOaiXjcR4eIYX3+4kNRD8Dy0h/QlGY jPwSM81yMBb21imDrSId3HOFm11+Z81YbVWChMQgDzTEsvgZMyVRQx11bMOUzg3i1OBn 4yvBa+M++ItcZ4wlvZjygK1ELs5vRQmZSOVjLQ2q8pXMnsI+vu0Viw7x+O1AVscoTPMl +Xaw== X-Gm-Message-State: APjAAAXKBwXIE2aybdcZt5i4KVdLMlfEOpBWSYJMr7Ks+a6LZW+hgwFT 0KPJtRyQb/P0/Mnxu7ahNvDjFOvcTEU= X-Google-Smtp-Source: APXvYqztIw0xaE0OShguDYM/cHPeX5FqV+vUbaioQS5WHaij1YHmNALzp9n1Z4Ru3DHyVM6WJVpSoQ== X-Received: by 2002:a17:902:bd82:: with SMTP id q2mr37272947pls.65.1552355381108; Mon, 11 Mar 2019 18:49:41 -0700 (PDT) Received: from bobo.ibm.com ([1.132.158.219]) by smtp.gmail.com with ESMTPSA id m9sm10592891pfi.31.2019.03.11.18.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Mar 2019 18:49:40 -0700 (PDT) From: Nicholas Piggin To: pdbg@lists.ozlabs.org Date: Tue, 12 Mar 2019 11:49:17 +1000 Message-Id: <20190312014920.25368-5-npiggin@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190312014920.25368-1-npiggin@gmail.com> References: <20190312014920.25368-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 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 | 67 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/libpdbg/p8chip.c b/libpdbg/p8chip.c index b93e953..71e6569 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) { @@ -318,6 +313,8 @@ static int p8_thread_stop(struct thread *thread) val |= PPC_BIT(8) >> thread->id; CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); + thread->status = get_thread_status(thread); + return 0; } @@ -336,6 +333,8 @@ static int p8_thread_start(struct thread *thread) val |= PPC_BIT(thread->id); CHECK_ERR(pib_write(&chip->target, THREAD_ACTIVE_REG, val)); + thread->status = get_thread_status(thread); + return 0; } @@ -366,7 +365,7 @@ static int p8_ram_setup(struct thread *thread) return 1; tmp = target_to_thread(target); - if (!(get_thread_status(tmp).quiesced)) + if (!tmp->status.quiesced) return 1; } @@ -487,6 +486,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 +543,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 +572,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);