From patchwork Tue Jun 13 13:05:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 775155 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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 3wn9Cs440rz9s3s for ; Tue, 13 Jun 2017 23:12:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="np6srkK2"; 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 3wn9Cs2pm2zDqM3 for ; Tue, 13 Jun 2017 23:12:25 +1000 (AEST) 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="np6srkK2"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pf0-x241.google.com (mail-pf0-x241.google.com [IPv6:2607:f8b0:400e:c00::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 3wn94m4fsRzDqLQ for ; Tue, 13 Jun 2017 23:06:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="np6srkK2"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id w12so11368858pfk.0 for ; Tue, 13 Jun 2017 06:06:16 -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; bh=Ks7+OLkskXbkiKzGTs71aUO7gEhP10Zl3z79VCIRTgM=; b=np6srkK2HIlXXHRop7wDb8dWL4io7AegOnLd7ouVGjPBaaKlELkfGBwVfYPHTylVxQ r8POXrpfWTyd3pgwQ1zt8zy/teT5fSGDvaQmkIBW9Rau9wo9LmY4llC6V38Cqy8Dzchu AXlUNHqM1reU9GiheHJe8jVgeRE7bouy77/fM59Z2WjQFtQwKc2ETxcM6th2GSujh++D 1nRkyenmsHu3m4O4wZoQ5myAO8kF9669SgITXvUvD53xN2FSZagWjPgQ1zNx3rls/CGZ vbf4yYgo1wTM0oZ8ioA9sS9f+iOjf9Z+/NAV70T1DontWXEIIxKNH/RV9JJ3Nc8hN2p3 MwrA== 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=Ks7+OLkskXbkiKzGTs71aUO7gEhP10Zl3z79VCIRTgM=; b=doK7caCKsMhTn4rGUhQMhWRBmwmyNILTQ8Jjw6BRpjcyGso6VvUEdDxRLF2WRfdHky v6pe3Fge0E+elwFExv2lPjYm3aLg3DG1A2nj+dGrIQyqivgs3hTBffSIXqglxQqB2MOK WaLC6vEGZ9dTkzeMBqLr4AzXDNE1cDKB9G0ne8Ey8ioRnzcBfDCGCRoEvXorvFQh2NgY cuu9X4VWE3u47XZobh6bZ1k0v49oYdDLWkdh6xaBjZ9dPXrayjUDARJ6A4bCqmNriuS6 s9Iic1ei8m+2pTe32HrClebsGJRlNJ+i+8dLsLPSoMCFRswdnbph2C+9yb346EPesLqH owIg== X-Gm-Message-State: AKS2vOyP6enaESDqDyqBMY9wcLwTnzWtfGh+FE5bdp7kTT5LJSpYL3ZL EqX2NklZz6ncbsq+ X-Received: by 10.84.134.36 with SMTP id 33mr15708911plg.29.1497359174649; Tue, 13 Jun 2017 06:06:14 -0700 (PDT) Received: from roar.au.ibm.com ([210.185.119.63]) by smtp.gmail.com with ESMTPSA id y28sm27750667pfd.32.2017.06.13.06.06.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Jun 2017 06:06:13 -0700 (PDT) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 02/13] powerpc/64s: idle hotplug lazy-irq simplification Date: Tue, 13 Jun 2017 23:05:46 +1000 Message-Id: <20170613130557.26315-3-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170613130557.26315-1-npiggin@gmail.com> References: <20170613130557.26315-1-npiggin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Gautham R . Shenoy" , Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Rather than concern ourselves with any soft-mask logic in the CPU hotplug handler, just hard disable interrupts. This ensures there are no lazy-irqs pending, which means we can call directly to idle instruction in order to sleep. Signed-off-by: Nicholas Piggin --- arch/powerpc/platforms/powernv/idle.c | 23 +++++++++++++++-------- arch/powerpc/platforms/powernv/smp.c | 29 ++++++++++++++--------------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c index f875879ff1eb..f188d84d9c59 100644 --- a/arch/powerpc/platforms/powernv/idle.c +++ b/arch/powerpc/platforms/powernv/idle.c @@ -352,25 +352,31 @@ void power9_idle(void) /* * pnv_cpu_offline: A function that puts the CPU into the deepest * available platform idle state on a CPU-Offline. + * interrupts hard disabled and no lazy irq pending. */ unsigned long pnv_cpu_offline(unsigned int cpu) { unsigned long srr1; - u32 idle_states = pnv_get_supported_cpuidle_states(); + ppc64_runlatch_off(); + if (cpu_has_feature(CPU_FTR_ARCH_300) && deepest_stop_found) { - srr1 = __power9_idle_type(pnv_deepest_stop_psscr_val, - pnv_deepest_stop_psscr_mask); + unsigned long psscr; + + psscr = mfspr(SPRN_PSSCR); + psscr = (psscr & ~pnv_deepest_stop_psscr_mask) | + pnv_deepest_stop_psscr_val; + srr1 = power9_idle_stop(psscr); + } else if (idle_states & OPAL_PM_WINKLE_ENABLED) { - srr1 = __power7_idle_type(PNV_THREAD_WINKLE); + srr1 = power7_idle_insn(PNV_THREAD_WINKLE); } else if ((idle_states & OPAL_PM_SLEEP_ENABLED) || (idle_states & OPAL_PM_SLEEP_ENABLED_ER1)) { - srr1 = __power7_idle_type(PNV_THREAD_SLEEP); + srr1 = power7_idle_insn(PNV_THREAD_SLEEP); } else if (idle_states & OPAL_PM_NAP_ENABLED) { - srr1 = __power7_idle_type(PNV_THREAD_NAP); + srr1 = power7_idle_insn(PNV_THREAD_NAP); } else { - ppc64_runlatch_off(); /* This is the fallback method. We emulate snooze */ while (!generic_check_cpu_restart(cpu)) { HMT_low(); @@ -378,9 +384,10 @@ unsigned long pnv_cpu_offline(unsigned int cpu) } srr1 = 0; HMT_medium(); - ppc64_runlatch_on(); } + ppc64_runlatch_on(); + return srr1; } #endif diff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c index f8752795decf..c04c87adad94 100644 --- a/arch/powerpc/platforms/powernv/smp.c +++ b/arch/powerpc/platforms/powernv/smp.c @@ -144,7 +144,14 @@ static void pnv_smp_cpu_kill_self(void) unsigned long srr1, wmask; /* Standard hot unplug procedure */ - local_irq_disable(); + /* + * This hard disables local interurpts, ensuring we have no lazy + * irqs pending. + */ + WARN_ON(irqs_disabled()); + hard_irq_disable(); + WARN_ON(lazy_irq_pending()); + idle_task_exit(); current->active_mm = NULL; /* for sanity */ cpu = smp_processor_id(); @@ -162,16 +169,6 @@ static void pnv_smp_cpu_kill_self(void) */ mtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1); - /* - * Hard-disable interrupts, and then clear irq_happened flags - * that we can safely ignore while off-line, since they - * are for things for which we do no processing when off-line - * (or in the case of HMI, all the processing we need to do - * is done in lower-level real-mode code). - */ - hard_irq_disable(); - local_paca->irq_happened &= ~(PACA_IRQ_DEC | PACA_IRQ_HMI); - while (!generic_check_cpu_restart(cpu)) { /* * Clear IPI flag, since we don't handle IPIs while @@ -184,6 +181,8 @@ static void pnv_smp_cpu_kill_self(void) srr1 = pnv_cpu_offline(cpu); + WARN_ON(lazy_irq_pending()); + /* * If the SRR1 value indicates that we woke up due to * an external interrupt, then clear the interrupt. @@ -196,8 +195,7 @@ static void pnv_smp_cpu_kill_self(void) * contains 0. */ if (((srr1 & wmask) == SRR1_WAKEEE) || - ((srr1 & wmask) == SRR1_WAKEHVI) || - (local_paca->irq_happened & PACA_IRQ_EE)) { + ((srr1 & wmask) == SRR1_WAKEHVI)) { if (cpu_has_feature(CPU_FTR_ARCH_300)) { if (xive_enabled()) xive_flush_interrupt(); @@ -209,14 +207,15 @@ static void pnv_smp_cpu_kill_self(void) unsigned long msg = PPC_DBELL_TYPE(PPC_DBELL_SERVER); asm volatile(PPC_MSGCLR(%0) : : "r" (msg)); } - local_paca->irq_happened &= ~(PACA_IRQ_EE | PACA_IRQ_DBELL); smp_mb(); if (cpu_core_split_required()) continue; if (srr1 && !generic_check_cpu_restart(cpu)) - DBG("CPU%d Unexpected exit while offline !\n", cpu); + DBG("CPU%d Unexpected exit while offline srr1=%lx!\n", + cpu, srr1); + } /* Re-enable decrementer interrupts */