From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751267AbdE3K2R (ORCPT ); Tue, 30 May 2017 06:28:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35130 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751004AbdE3K2Q (ORCPT ); Tue, 30 May 2017 06:28:16 -0400 Date: Tue, 30 May 2017 15:58:05 +0530 From: Gautham R Shenoy To: Nicholas Piggin Cc: "Gautham R. Shenoy" , Michael Ellerman , Michael Neuling , Vaidyanathan Srinivasan , Shilpasri G Bhat , Akshay Adiga , Benjamin Herrenschmidt , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/6] powernv:idle: Decouple Timebase restore & Per-core SPRs restore Reply-To: ego@linux.vnet.ibm.com References: <20170530161238.08a8abe3@roar.ozlabs.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170530161238.08a8abe3@roar.ozlabs.ibm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-TM-AS-GCONF: 00 x-cbid: 17053010-0024-0000-0000-0000027F46C8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007143; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000212; SDB=6.00867670; UDB=6.00431120; IPR=6.00647549; BA=6.00005384; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015642; XFM=3.00000015; UTC=2017-05-30 10:28:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17053010-0025-0000-0000-0000442F5F1E Message-Id: <20170530102805.GB8563@in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-05-30_07:,, 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-1703280000 definitions=main-1705300198 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 30, 2017 at 04:12:38PM +1000, Nicholas Piggin wrote: > On Tue, 16 May 2017 14:19:44 +0530 > "Gautham R. Shenoy" wrote: > > > From: "Gautham R. Shenoy" > > > > On POWER8, in case of > > - nap: both timebase and hypervisor state is retained. > > - fast-sleep: timebase is lost. But the hypervisor state is retained. > > - winkle: timebase and hypervisor state is lost. > > > > Hence, the current code for handling exit from a idle state assumes > > that if the timebase value is retained, then so is the hypervisor > > state. Thus, the current code doesn't restore per-core hypervisor > > state in such cases. > > > > But that is no longer the case on POWER9 where we do have stop states > > in which timebase value is retained, but the hypervisor state is > > lost. So we have to ensure that the per-core hypervisor state gets > > restored in such cases. > > > > Fix this by ensuring that even in the case when timebase is retained, > > we explicitly check if we are waking up from a deep stop that loses > > per-core hypervisor state (indicated by cr4 being eq or gt), and if > > this is the case, we restore the per-core hypervisor state. > > > > Signed-off-by: Gautham R. Shenoy > > --- > > arch/powerpc/kernel/idle_book3s.S | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S > > index 4898d67..afd029f 100644 > > --- a/arch/powerpc/kernel/idle_book3s.S > > +++ b/arch/powerpc/kernel/idle_book3s.S > > @@ -731,13 +731,14 @@ timebase_resync: > > * Use cr3 which indicates that we are waking up with atleast partial > > * hypervisor state loss to determine if TIMEBASE RESYNC is needed. > > */ > > - ble cr3,clear_lock > > + ble cr3,.Ltb_resynced > > /* Time base re-sync */ > > bl opal_resync_timebase; > > /* > > - * If waking up from sleep, per core state is not lost, skip to > > - * clear_lock. > > + * If waking up from sleep (POWER8), per core state > > + * is not lost, skip to clear_lock. > > */ > > +.Ltb_resynced: > > blt cr4,clear_lock > > > > /* > > It's more that timebase was not lost, rather than resynced. > Can we just do a 'bgtl cr3,opal_resync_timebase'? Yes, that's looks much better. I hadn't thought of bgtl. Will update this. > > I guess cr4 branch will never be true on POWER9... I think Yes. Inside pnv_wakeup_tb_loss, cr4 will either have gt or eq set. This branch applies only to POWER8 where cr4 would be eq only on winkle, and not on fastsleep (a state that loses timebase but not hypervisor state). > pnv_wakeup_tb_loss is going to end up clearer being split > into two between isa 207 and 300. But that can wait until > after POWER9 is working properly. Sure. > > Reviewed-by: Nicholas Piggin > -- Thanks and Regards gautham.