Received: by 10.223.185.116 with SMTP id b49csp4757499wrg; Tue, 6 Mar 2018 23:58:20 -0800 (PST) X-Google-Smtp-Source: AG47ELv1W51Ntjl6ZAefVNF1TQKL0znYLxXI8PImFmqCQvokw8dKVZOlA3Z9wfs5I9lpQUKPkT/r X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr9608528plp.319.1520409500421; Tue, 06 Mar 2018 23:58:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520409500; cv=none; d=google.com; s=arc-20160816; b=asbxAZg5EDyG/imMr7EsvrpXx+OjZTG/9inTNLfula1CLpWWC/9e7/ygLHaBlbuqdf cLSBRs4yarcoXJJjZNOh3rj7rXm4alHKrE04Vrk+tHwAerpHRWBZtPQnW3KcYk+iBJ7X b8XSn5jYC9c5jO4++ujWj4MoBg29T4QA+gip+nLTC/B3BH2X6VcDxeNTwf/qDCx/4xWG /KTYUxg1TOPhqkhW470VP7ySpESGwEJIND9I14K+2PR3vofHVjRCdPT/4wuHt3vtMGu0 DOkRp/I3Vcr0UuLeX+rKtT8MrEZqEGOinQ7vqR0H793T7ZTsDcQMpKu38Lp5KMfxHDHx v1Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=YqTGh1DjesvaEP3uo3Cgdaz2m/Ro5OSgzDNyKH3+z5s=; b=JBZUJcdo4bKlc5BAm1+HwjDodLxN/hMd04Kp1vvW1oH41lYN4SUmPQPjuypnZAaA9e vCce6QiqcvX3klmEf4I2gMiirfhgm9xY2Lx33EehiN5DwP0HBKVw2w/HhKKpIobs5Wnr 7/wWdjL7xjAUC46fsgBLy/ji/Ym7kcI0auv7RQC1zbCHH1daARMlUbeCctLXGDQFWY5J lVAoxVlqsXUCckDXJBZmJjCZJ3iAND6THQp1ksZ40P8T+Dypo5W1lFqwj6UaCWJ8TuK4 PvH8BPk3uaXdSaOz7dSyS68Snl5j3UiZevECL3Z01XeqkOxWXjSjSmh+mHXJjzIJ4zpY krwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z13si12267923pfh.217.2018.03.06.23.58.06; Tue, 06 Mar 2018 23:58:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751193AbeCGH5E (ORCPT + 99 others); Wed, 7 Mar 2018 02:57:04 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:32930 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbeCGH5C (ORCPT ); Wed, 7 Mar 2018 02:57:02 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w277tkfA137740 for ; Wed, 7 Mar 2018 02:57:02 -0500 Received: from e06smtp14.uk.ibm.com (e06smtp14.uk.ibm.com [195.75.94.110]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gjac2utmn-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 07 Mar 2018 02:57:01 -0500 Received: from localhost by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Mar 2018 07:56:59 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Mar 2018 07:56:58 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w277uvvl62128164; Wed, 7 Mar 2018 07:56:57 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72CCF42049; Wed, 7 Mar 2018 07:49:20 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F279D42041; Wed, 7 Mar 2018 07:49:18 +0000 (GMT) Received: from drishya.in.ibm.com (unknown [9.109.212.233]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 7 Mar 2018 07:49:18 +0000 (GMT) Date: Wed, 7 Mar 2018 13:26:53 +0530 From: Vaidyanathan Srinivasan To: Benjamin Herrenschmidt Cc: Akshay Adiga , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com, stable@vger.kernel.org Subject: Re: [RESEND][PATCH] cpuidle/powernv : Restore different PSSCR for idle and hotplug Reply-To: svaidy@linux.vnet.ibm.com References: <1519846389-29414-1-git-send-email-akshay.adiga@linux.vnet.ibm.com> <1519854022.2520.12.camel@au1.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1519854022.2520.12.camel@au1.ibm.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-TM-AS-GCONF: 00 x-cbid: 18030707-0016-0000-0000-0000052DCB6E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030707-0017-0000-0000-0000286AE50A Message-Id: <20180307075653.GB26738@drishya.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-07_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803070093 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Benjamin Herrenschmidt [2018-03-01 08:40:22]: > On Thu, 2018-03-01 at 01:03 +0530, Akshay Adiga wrote: > > commit 1e1601b38e6e ("powerpc/powernv/idle: Restore SPRs for deep idle > > states via stop API.") uses stop-api provided by the firmware to restore > > PSSCR. PSSCR restore is required for handling special wakeup. When special > > wakeup is completed, the core enters stop state based on restored PSSCR. > > > > Currently PSSCR is restored to deepest available stop state, causing > > a idle cpu to enter deeper stop state on a special wakeup, which causes > > the cpu to hang on wakeup. > > > > A "sensors" command which reads temperature (through DTS sensors) on idle > > cpu can trigger special wakeup. > > > > Failed Scenario : > > Request restore of PSSCR with RL = 11 > > cpu enters idle state (stop5) > > user triggers "sensors" command > > Assert special wakeup on cpu > > Restores PSSCR with RL = 11 <---- Done by firmware > > Read DTS sensor > > Deassert special wakeup > > cpu enters idle state (stop11) <-- Instead of stop5 > > > > Cpu hang is caused because cpu ended up in a deeper state than it requested > > > > This patch fixes instability caused by special wakeup when stop11 is > > enabled. Requests restore of PSSCR to deepest stop state used by cpuidle. > > Only when offlining cpu, request restore of PSSCR to deepest stop state. > > On onlining cpu, request restore of PSSCR to deepest stop state used by > > cpuidle. > > So if we chose a stop state, but somebody else does a special wakeup, > we'll end up going back into a *deeper* one than the one we came from ? Unfortunately yes. This is the current limitation. If we are in stop4 and above and we had not set a PSSCR to be restored, then the hardware will default to all bits set (stop15) leading to entry into stop11 after the special wakeup is removed. The requirement is such that we need to have a correct PSSCR restore value set using stop-api. We need to set a restore PSSCR value that represents one in a group like stop4,5,6,7 will have identical state loss, hence we can either set a PSSCR of 7 or 4 or 5 for any of this stop state entry and not have to use stop-api to set exact value of stop4 or 5 at every entry. > I still think this is broken by design. The chip should automatically > go back to the state it went to after special wakeup, thus the PPE > controlling the state should override the PSSCR value accordingly > rather than relying on those SW hoops. Special wakeup de-assertion and re-entry hits this limitation where we have lost the original content of PSSCR SPR and hence CME does not know what was requested. Additional stop-api calls from software could have been avoided, but practically we have only cpu hotplug case that uses stop11 and needs this stop-api. We can default the system to stop4 or stop5 and then make stop-api call to explicitly set stop11 and then hotplug out the cpu. We have to restore the deepest cpuidle state (stop4/5) back during online. As such this is not much of software overhead. But we need an elegant method to control these calls from OPAL flags so that kernel behaviour can be more closely controlled. If we want to use stop11 in cpuidle (despite being very slow) for evaluation reasons, then we will need to make more stop-api call to choose between stop4/5 vs stop11 since they belong to different group. Even in this case, since stop11 is the slow path, we would want to set stop11 before entry and restore to stop4/5 after wakeup. This way we still completely avoid stop-api call in fast-path stop4/5 entry/exit. --Vaidy