From patchwork Thu Feb 16 18:39:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 728874 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 3vPQBc4gFHz9s0g for ; Fri, 17 Feb 2017 05:47:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dIF8/zVI"; 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 3vPQBc3d8QzDqJ0 for ; Fri, 17 Feb 2017 05:47:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dIF8/zVI"; 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 3vPQ193ykNzDqGW for ; Fri, 17 Feb 2017 05:39:25 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="dIF8/zVI"; dkim-atps=neutral Received: by mail-pf0-x241.google.com with SMTP id 19so2163888pfo.3 for ; Thu, 16 Feb 2017 10:39:25 -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=AXsTBBOrGIJNFGW2tDll96JaAMrLHPVqrmdZB+JBBDA=; b=dIF8/zVIjyC07ehiYiG5jQeCZMGkvTJHwGueW5Z2H/fnHpPAyLkAF0ruXWEaI5lhxi CZLXGRBpFBIRMw9DBM553ZITrmnBbBS6ZUIzEy4XtP87J+N6GUaAO1doNy5FTw/jHLRb yXbLmv5e3G/M4DCic2VPC39dzC3RA7QQiVdO577Ozldkf8hxj7Q/u+c+kvLNJUrw8d3P aubsZ1uf9ZocJo8mgp+MypO1jeSV9B47EwZiCMtwgRY4kimeF4jnVOA1/T2sqxjU7vIJ fzkGQv1LA55KYTCt0TtHqRDQQ478JFqcFCcr9kUOJrJRySHDbD5tYPBQJV7ibsy75Wvg Z9Sw== 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=AXsTBBOrGIJNFGW2tDll96JaAMrLHPVqrmdZB+JBBDA=; b=JJfQBmBI8URf+N/c45dRGgn/nleVoncLjXEd7qBQp8vJGcpjxN9lBt2v8Wxhi3dOcK 2PQm2oDzS/ViRt8Z4wilKqEC2vdXyUPUxdWqTQqOQqVHIshcki+qJymdnd2R4hFPox5I dlgXDbB1Mi7B8QbkbSSTKJv96lgB6lwo8vD74g4t/fiLiSgwS5kou+Br3ZS1/48F31zc 9RH34xQzEiC+SsYx6mbNYpyZoLU9M2bSRgGqshn78W2wrsuo80N9OMUC7u8ZC+DpbI85 pz6hIBdMzF8g72Yb4IjW+a5fAhS6q5XtJxl3IrBtHlKOTYsAAUk8GVUqZIF/4QMlhPLx 8xoA== X-Gm-Message-State: AMke39kUD0x/Xpo3Gk7w0W6WNfhl9Vc+H7b3fstUgHfYMqhbNvWIU76Vske1FhKXqCKzNA== X-Received: by 10.84.241.203 with SMTP id t11mr5268377plm.18.1487270363542; Thu, 16 Feb 2017 10:39:23 -0800 (PST) Received: from roar.local0.net ([61.68.126.103]) by smtp.gmail.com with ESMTPSA id 67sm14933494pfd.120.2017.02.16.10.39.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 10:39:22 -0800 (PST) From: Nicholas Piggin To: linuxppc-dev@lists.ozlabs.org Subject: [PATCH 4/5] powerpc/64s: consolidate pnv_restore_hyp_resource into pnv_powersave_wakeup Date: Fri, 17 Feb 2017 04:39:00 +1000 Message-Id: <20170216183901.28611-5-npiggin@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170216183901.28611-1-npiggin@gmail.com> References: <20170216183901.28611-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: Nicholas Piggin Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" There is only one caller, so this reduces spaghetti of subsequent callees returning into the caller. Signed-off-by: Nicholas Piggin Reviewed-by: Gautham R. Shenoy --- arch/powerpc/kernel/idle_book3s.S | 66 +++++++++++++++------------------------ 1 file changed, 26 insertions(+), 40 deletions(-) diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index ab15dee371c9..58364a834f87 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -372,33 +372,6 @@ _GLOBAL(power9_idle_stop) */ .global pnv_powersave_wakeup pnv_powersave_wakeup: - bl pnv_restore_hyp_resource - - li r0,PNV_THREAD_RUNNING - stb r0,PACA_THREAD_IDLE_STATE(r13) /* Clear thread state */ - -#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE - li r0,KVM_HWTHREAD_IN_KERNEL - stb r0,HSTATE_HWTHREAD_STATE(r13) - /* Order setting hwthread_state vs. testing hwthread_req */ - sync - lbz r0,HSTATE_HWTHREAD_REQ(r13) - cmpwi r0,0 - beq 1f - b kvm_start_guest -1: -#endif - - /* Return SRR1 from power7_nap() */ - mfspr r3,SPRN_SRR1 - blt cr3,pnv_wakeup_noloss - b pnv_wakeup_loss - -/* - * Check whether we have woken up with hypervisor state loss. If yes, - * restore hypervisor state and return back to reset vector. - */ -pnv_restore_hyp_resource: ld r2,PACATOC(r13); BEGIN_FTR_SECTION @@ -416,7 +389,7 @@ BEGIN_FTR_SECTION */ rldicl r5,r5,4,60 cmpd cr4,r5,r4 - bge cr4,pnv_wakeup_tb_loss + bgel cr4,pnv_wakeup_tb_loss FTR_SECTION_ELSE @@ -425,23 +398,36 @@ FTR_SECTION_ELSE * Check if we slept with winkle. */ lbz r0,PACA_THREAD_IDLE_STATE(r13) - cmpwi cr2,r0,PNV_THREAD_NAP - cmpwi cr4,r0,PNV_THREAD_WINKLE - bgt cr2,pnv_wakeup_tb_loss /* Either sleep or Winkle */ + cmpwi cr2,r0,PNV_THREAD_NAP + cmpwi cr4,r0,PNV_THREAD_WINKLE + bgtl cr2,pnv_wakeup_tb_loss /* Either sleep or Winkle */ - /* - * We fall through here if PACA_THREAD_IDLE_STATE shows we are waking - * up from nap. At this stage CR3 shouldn't contains 'gt' since that - * indicates we are waking with hypervisor state loss from nap. - */ - bgt cr3,. ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300) /* - * Waking up without hypervisor state loss. Return to - * reset vector + * Waking up without hypervisor state loss, or continuing after + * hypervisor state has been restored. */ - blr + + li r0,PNV_THREAD_RUNNING + stb r0,PACA_THREAD_IDLE_STATE(r13) /* Clear thread state */ + +#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE + li r0,KVM_HWTHREAD_IN_KERNEL + stb r0,HSTATE_HWTHREAD_STATE(r13) + /* Order setting hwthread_state vs. testing hwthread_req */ + sync + lbz r0,HSTATE_HWTHREAD_REQ(r13) + cmpwi r0,0 + beq 1f + b kvm_start_guest +1: +#endif + + /* Return SRR1 from power7_nap() */ + mfspr r3,SPRN_SRR1 + blt cr3,pnv_wakeup_noloss + b pnv_wakeup_loss /* * Called if waking up from idle state which can cause either partial or