From patchwork Sun Nov 19 09:14:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 839284 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yfmS21pnWz9ryk for ; Sun, 19 Nov 2017 20:16:18 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="URzQxPzZ"; 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 3yfmS20YfFzDrSl for ; Sun, 19 Nov 2017 20:16:18 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="URzQxPzZ"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::241; helo=mail-pg0-x241.google.com; envelope-from=npiggin@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="URzQxPzZ"; dkim-atps=neutral Received: from mail-pg0-x241.google.com (mail-pg0-x241.google.com [IPv6:2607:f8b0:400e:c05::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yfmR44JjbzDrSb for ; Sun, 19 Nov 2017 20:15:28 +1100 (AEDT) Received: by mail-pg0-x241.google.com with SMTP id z184so5088641pgd.13 for ; Sun, 19 Nov 2017 01:15:28 -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; bh=9++tpQHx0sz3mS6fKvFdzZhgZBCMVd9g2XZIvI3ZyeQ=; b=URzQxPzZEamS0bkotjSym+g3e6F29qYVQ0MLHYbAEWoiuNaT2TfVv70vf3UCPSaYG0 FvglGL/Tn9mEWLFDyZRN8kjtB8ySos0RD0f2lLxixFJhAtKXc7o2kbZ979v3ejllrh+q iECiJOqmXItmnLx2LqjxIkHzk+JoF+qXRi/S7bqlK67ZlK0bkuXD2R1zOWtu3WwbrMy6 /gCBkLnnBpdY16J8fXUDWWzT9kXTwUU0q9StJqD4WxeP5PtkvcCbs4as8OBkkvxFfwLW VWDOlOMkVninbbhbXLeWeornPXxK7Xb6Sc1DyiybUN2SKaQEh+qxZqx3ReJ7Ztf7MIcp HOVQ== 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; bh=9++tpQHx0sz3mS6fKvFdzZhgZBCMVd9g2XZIvI3ZyeQ=; b=Iu81ad6iN57snWnpC16KyG0Tj1gqjqVrVWLNbFXyc/6NZqto4dFXdHZsq6ex/L/Tbm 5PzhNW95RcFIp69wPmoNUuGbeK7FAcac40eXtNHlZmSpO8v8BnyL+xZbYXJIdaTOIOYB F/wKDozotDVnp/83XlH9uQujOVo/rR1Wf9rjDZsaWUhMGJbaXeREULtZMGkXHwOQBaJb T2N1YjHpBxB5ClnEv8FWYVQ6IzIXPvYwkNVynC2urlaAyS2CZCYxY56OyovJ4WTf/iW1 cAtcfIKKyi4vhCc6lakwJhbRcMLd86TmAjqJhTFwJ/xdq3Yb+9SJC5DcbxwCVf9NwlLN 2/GA== X-Gm-Message-State: AJaThX4iPjFl6AqpzIQLV4TSAvSqdUNm9fU5dIw9QHAy1HILNzfroeY4 dgnNAAzQB86iFYAEvERZVOsFKA== X-Google-Smtp-Source: AGs4zMY+58afYVHNHvNlZwyL1eFouqNfsGEKQyhY2FihfyTtkizbRG5NR8CfbFJsTbHbaXiUr9kHHw== X-Received: by 10.159.244.12 with SMTP id x12mr10684755plr.312.1511082926205; Sun, 19 Nov 2017 01:15:26 -0800 (PST) Received: from roar.au.ibm.com (27-33-241-2.tpgi.com.au. [27.33.241.2]) by smtp.gmail.com with ESMTPSA id k12sm12709621pgo.5.2017.11.19.01.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Nov 2017 01:15:25 -0800 (PST) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Sun, 19 Nov 2017 19:14:52 +1000 Message-Id: <20171119091508.28372-3-npiggin@gmail.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171119091508.28372-1-npiggin@gmail.com> References: <20171119091508.28372-1-npiggin@gmail.com> Subject: [Skiboot] [PATCH 02/18] fast-reboot: factor out direct control loops for sreset X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This provides a reasonable contained API that can is possible to move moved into the direct-controls subsystem in a future patch. Signed-off-by: Nicholas Piggin --- core/fast-reboot.c | 79 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 58 insertions(+), 21 deletions(-) diff --git a/core/fast-reboot.c b/core/fast-reboot.c index f63a6454..62c7216b 100644 --- a/core/fast-reboot.c +++ b/core/fast-reboot.c @@ -226,13 +226,10 @@ static void set_direct_ctl(struct cpu_thread *cpu, uint64_t bits) xscom_write(chip_id, xscom_addr, bits); } -static bool fast_reset_p8(void) +static int sreset_all_prepare(void) { struct cpu_thread *cpu; - /* Mark ourselves as last man standing in need of a reset */ - last_man_standing = this_cpu(); - prlog(PR_DEBUG, "RESET: Resetting from cpu: 0x%x (core 0x%x)\n", this_cpu()->pir, pir_to_core_id(this_cpu()->pir)); @@ -257,16 +254,28 @@ static bool fast_reset_p8(void) if (cpu != this_cpu()) set_direct_ctl(cpu, P8_DIRECT_CTL_STOP); + } - /* Also make sure that saved_r1 is 0 ! That's what will - * make our reset vector jump to fast_reboot_entry - */ - cpu->save_r1 = 0; + return true; +} + +static void sreset_all_finish(void) +{ + struct cpu_thread *cpu; + + for_each_cpu(cpu) { + /* GARDed CPUs are marked unavailable. Skip them. */ + if (cpu->state == cpu_state_unavailable) + continue; + + if (cpu->primary == cpu) + clr_special_wakeup(cpu); } +} - /* Restore skiboot vectors */ - copy_exception_vectors(); - setup_reset_vector(); +static void sreset_all_others(void) +{ + struct cpu_thread *cpu; prlog(PR_DEBUG, "RESET: Pre-napping all threads but one...\n"); @@ -291,6 +300,42 @@ static bool fast_reset_p8(void) if (cpu != this_cpu()) set_direct_ctl(cpu, P8_DIRECT_CTL_SRESET); } +} + +static void sreset_cpu(struct cpu_thread *cpu) +{ + set_direct_ctl(cpu, P8_DIRECT_CTL_PRENAP); + set_direct_ctl(cpu, P8_DIRECT_CTL_SRESET); +} + +static bool fast_reset_p8(void) +{ + struct cpu_thread *cpu; + + /* Mark ourselves as last man standing in need of a reset */ + last_man_standing = this_cpu(); + + if (!sreset_all_prepare()) + return false; + + /* Put everybody in stop except myself */ + for_each_cpu(cpu) { + /* GARDed CPUs are marked unavailable. Skip them. */ + if (cpu->state == cpu_state_unavailable) + continue; + + /* Also make sure that saved_r1 is 0 ! That's what will + * make our reset vector jump to fast_reboot_entry + */ + cpu->save_r1 = 0; + } + + /* Restore skiboot vectors */ + copy_exception_vectors(); + setup_reset_vector(); + + /* Send everyone else to 0x100 */ + sreset_all_others(); return true; } @@ -463,8 +508,7 @@ void __noreturn fast_reboot_entry(void) lock(&reset_lock); if (last_man_standing && next_cpu(first_cpu())) { prlog(PR_DEBUG, "RESET: last man standing fixup...\n"); - set_direct_ctl(last_man_standing, P8_DIRECT_CTL_PRENAP); - set_direct_ctl(last_man_standing, P8_DIRECT_CTL_SRESET); + sreset_cpu(last_man_standing); } last_man_standing = NULL; unlock(&reset_lock); @@ -540,14 +584,7 @@ void __noreturn fast_reboot_entry(void) prlog(PR_DEBUG, "RESET: Releasing special wakeups...\n"); - for_each_cpu(cpu) { - /* GARDed CPUs are marked unavailable. Skip them. */ - if (cpu->state == cpu_state_unavailable) - continue; - - if (cpu->primary == cpu) - clr_special_wakeup(cpu); - } + sreset_all_finish(); prlog(PR_INFO, "RESET: All done, cleaning up...\n");