From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752305AbcIGFR6 (ORCPT ); Wed, 7 Sep 2016 01:17:58 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35968 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751080AbcIGFR4 (ORCPT ); Wed, 7 Sep 2016 01:17:56 -0400 X-IBM-Helo: d01dlp01.pok.ibm.com X-IBM-MailFrom: ego@linux.vnet.ibm.com From: "Gautham R. Shenoy" To: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: "Gautham R. Shenoy" , Vaidyanathan Srinivasan , Michael Neuling , Michael Ellerman , "Shreyas B. Prabhu" Subject: [PATCH] powernv: Restore SPRs correctly upon wake up from hypervisor state loss Date: Wed, 7 Sep 2016 10:46:30 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16090705-0040-0000-0000-000001415808 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00005721; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000185; SDB=6.00754782; UDB=6.00357238; IPR=6.00527634; BA=6.00004698; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00012604; XFM=3.00000011; UTC=2016-09-07 05:17:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16090705-0041-0000-0000-0000051C70B1 Message-Id: <1473225390-4281-1-git-send-email-ego@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-09-07_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1609070081 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gautham R. Shenoy" pnv_wakeup_tb_loss function currently expects the cr4 to be "eq" if the CPU is waking up from a complete hypervisor state loss. Hence, it currently restores the SPR contents only if cr4 is "eq". However, after the commit bcef83a00dc4 ("powerpc/powernv: Add platform support for stop instruction"), on ISA_V300 CPUs, the function pnv_restore_hyp_resource sets cr4 to contain the result of the comparison between state the CPU has woken up and the first deepest stop state before calling pnv_wakeup_tb_loss. Thus if the CPU woke up from a state that is deeper than the first deepest stop state, cr4 have "gt" set and hence, pnv_wakeup_tb_loss will fail to restore the SPRs on waking up from such a state. Fix the code in pnv_wakeup_tb_loss to restore the SPR states when cr4 is "eq" or "gt". Fixes: Commit bcef83a00dc4 ("powerpc/powernv: Add platform support for stop instruction") Cc: Vaidyanathan Srinivasan Cc: Michael Neuling Cc: Michael Ellerman Cc: Shreyas B. Prabhu Signed-off-by: Gautham R. Shenoy --- arch/powerpc/kernel/idle_book3s.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index 2265c63..bd739fe 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S @@ -411,7 +411,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) * * r13 - PACA * cr3 - gt if waking up with partial/complete hypervisor state loss - * cr4 - eq if waking up from complete hypervisor state loss. + * cr4 - gt or eq if waking up from complete hypervisor state loss. */ _GLOBAL(pnv_wakeup_tb_loss) ld r1,PACAR1(r13) @@ -453,7 +453,7 @@ lwarx_loop2: * At this stage * cr2 - eq if first thread to wakeup in core * cr3- gt if waking up with partial/complete hypervisor state loss - * cr4 - eq if waking up from complete hypervisor state loss. + * cr4 - gt or eq if waking up from complete hypervisor state loss. */ ori r15,r15,PNV_CORE_IDLE_LOCK_BIT @@ -481,7 +481,7 @@ first_thread_in_subcore: * If waking up from sleep, subcore state is not lost. Hence * skip subcore state restore */ - bne cr4,subcore_state_restored + blt cr4,subcore_state_restored /* Restore per-subcore state */ ld r4,_SDR1(r1) @@ -526,7 +526,7 @@ timebase_resync: * If waking up from sleep, per core state is not lost, skip to * clear_lock. */ - bne cr4,clear_lock + blt cr4,clear_lock /* * First thread in the core to wake up and its waking up with @@ -557,7 +557,7 @@ common_exit: * If waking up from sleep, hypervisor state is not lost. Hence * skip hypervisor state restore. */ - bne cr4,hypervisor_state_restored + blt cr4,hypervisor_state_restored /* Waking up from winkle */ -- 1.9.4