Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2599652imm; Thu, 11 Oct 2018 12:57:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV63CY7G73LmR7l53ivpMg64V/AkrQs2G3RhbcpgF3vevsvAsFeYg/xjpBEckBUHoZnEGIvbo X-Received: by 2002:a63:88c1:: with SMTP id l184-v6mr2580796pgd.431.1539287833281; Thu, 11 Oct 2018 12:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539287833; cv=none; d=google.com; s=arc-20160816; b=GRtScPjfy5ZguR0A/U8v9iWQ+leSwChtifd4yZmVF6YtUCcHJo1u/OzQ0mnsxKtSBM T0dGGaRHV0ogExgzzQKdGWpwK/rOnk26PK5P6QNuu7bKg3I0U6Z+lCQDHV2+giNDBtf2 Gkj1SMH8k8e6TFcEjsd4pbDnvPj4IXYxhfeZ4k2STxTaUzB95hNC4rG9EvpQoBS9Pf+A 7uvqqTSkJIOu2tuf3FbcWsq7YLo7Zq0+ChFcAneBtWlDe349ofCwQis7gwnAaMEFQh31 28SgphaPLs+bNX9FoB+qDVI13I4X9E/w6Oer4hYX220O4pyM+h60IcDqOye0/pkNEpq8 TA7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=MksRJ+C2rJrllRc3ReKK6Yfk7dgXChe1JArvN/CPh3I=; b=FqX11yMoqh+0mdFVzPDPjzBmWLu1cidyTWc3/Fp2s3vIiK1NzGAkMokiRgYSRv7pPR aYdRQ92DZRqTE9oQyjexacL3lRrCG0uMADg6xa7WZ11d75ROljenUFt8d8sNLUr1EMy5 wVcOMn6WikmeeRJK4Xawh7NO3tKqXKiX7mGP02aLBbs+PLbzCJRtRah5FY3iyRaSI1/E H2QLVj1AOi+aRS22QiMwbfC+iE2WlHXg867QNsERvgTBA0uLtYFeVHE3z1sSJ3zf9nLJ 97poSqKvP6Mxs5hN0f7tvsIji1Pm0lqM1lKUO9gFYMdClGaxPu26LiQEUb7Gqej2Zf5l xxMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iiPtGSK+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16-v6si27925643pfi.34.2018.10.11.12.56.57; Thu, 11 Oct 2018 12:57:13 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iiPtGSK+; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727278AbeJLDYi (ORCPT + 99 others); Thu, 11 Oct 2018 23:24:38 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34260 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbeJLDYi (ORCPT ); Thu, 11 Oct 2018 23:24:38 -0400 Received: by mail-pf1-f194.google.com with SMTP id k19-v6so4949344pfi.1; Thu, 11 Oct 2018 12:55:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MksRJ+C2rJrllRc3ReKK6Yfk7dgXChe1JArvN/CPh3I=; b=iiPtGSK+nhwXd4auAjQKgRCtQb/NKh7L6j+TjTalEiEGz/GvBZxuxcuAX9uOPmokoR 7Ii3TJLQVYLZpa+xA5Rr1Vsr9/FfO7Ez9uo/uwaa+y//AjOpB+ZowcLu1N5H4TXnsy7G sQB3AEnCD0zFK7Dzs/SLpM4d/v4xpHg4+fc2HSWS7Lj/xiWY0IfVYg0ANxpMUpKpNN+2 d3UbIQlKyK45PM30Jn1sXySveoYg+UbuMrh6mpuiSASMMpDsT0GIhm8jQjKSBvZLBH11 sdi4+DYzZ8SpG2dOmg76k2vXo/ad7nu5T0DJe89UzOQDmczkx1TDpfEr/DAwJ6JrfxwM /gZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MksRJ+C2rJrllRc3ReKK6Yfk7dgXChe1JArvN/CPh3I=; b=AyL6xKcoXTJCjpeal1XNxNdGUr5igpDTgphccEHN/27k+zRYNaZoc90wo3UkPenis2 KEnwjB9LJcsKJo3Mp/mKwe5nzctMxV3atjePpYt5cFe0mCDh8ErsSRq6Yvw3WyW1PcLA xJYybA3T4lq32ZVQynQUlanF2uv60QmIUKuEohMh/23I+VDdFoigUPRhyDeORUGEApDZ 49SybYITDidQXOJSitLOoL4Ylxhaa70Uustez8YCjeszwqoSYh/rgSufcRSVaWh7XcvL c4E3T0qibos2s6NbzJfh4NXIUUUkl2qQIxv5R2cccIeeax60WEMJeWEzR1XHMNx5eaUR 799g== X-Gm-Message-State: ABuFfoid/9kA/uyyLDH630vcOOqinY25TMc4U4p8vpgTxaBOMJNZVSeX 4de23jn4tQTs2UoVG5Ia2LtTAKBD X-Received: by 2002:a62:6dc3:: with SMTP id i186-v6mr2959194pfc.218.1539287751395; Thu, 11 Oct 2018 12:55:51 -0700 (PDT) Received: from [192.168.1.70] (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id u1-v6sm27113907pgr.61.2018.10.11.12.55.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Oct 2018 12:55:50 -0700 (PDT) Subject: Re: [RFC PATCH v2 0/3] New device-tree format and Opal based idle save-restore To: Akshay Adiga , linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "devicetree@vger.kernel.org" Cc: huntbag@linux.vnet.ibm.com, npiggin@gmail.com, benh@kernel.crashing.org, mpe@ellerman.id.au, ego@linux.vnet.ibm.com References: <20181011132237.14604-1-akshay.adiga@linux.vnet.ibm.com> From: Frank Rowand Message-ID: <1b6bcd31-1dc8-abf7-304a-4de95b8f998b@gmail.com> Date: Thu, 11 Oct 2018 12:55:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181011132237.14604-1-akshay.adiga@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org + devicetree mail list On 10/11/18 06:22, Akshay Adiga wrote: > Previously if a older kernel runs on a newer firmware, it may enable > all available states irrespective of its capability of handling it. > New device tree format adds a compatible flag, so that only kernel > which has the capability to handle the version of stop state will enable > it. > > Older kernel will still see stop0 and stop0_lite in older format and we > will depricate it after some time. > > 1) Idea is to bump up the version string in firmware if we find a bug or > regression in stop states. A fix will be provided in linux which would > now know about the bumped up version of stop states, where as kernel > without fixes would ignore the states. > > 2) Slowly deprecate cpuidle/cpuhotplug threshold which is hard-coded > into cpuidle-powernv driver. Instead use compatible strings to indicate > if idle state is suitable for cpuidle and hotplug. > > New idle state device tree format : > power-mgt { > ... > ibm,enabled-stop-levels = <0xec000000>; > ibm,cpu-idle-state-psscr-mask = <0x0 0x3003ff 0x0 0x3003ff>; > ibm,cpu-idle-state-latencies-ns = <0x3e8 0x7d0>; > ibm,cpu-idle-state-psscr = <0x0 0x330 0x0 0x300330>; > ibm,cpu-idle-state-flags = <0x100000 0x101000>; > ibm,cpu-idle-state-residency-ns = <0x2710 0x4e20>; > ibm,idle-states { > stop4 { > flags = <0x207000>; > compatible = "ibm,state-v1", > "opal-support"; > type = "cpuidle"; > psscr-mask = <0x0 0x3003ff>; > handle = <0x102>; > latency-ns = <0x186a0>; > residency-ns = <0x989680>; > psscr = <0x0 0x300374>; > }; > ... > stop11 { > ... > compatible = "ibm,state-v1", > "opal-support"; > type = "cpuoffline"; > ... > }; > }; > > High-level parsing algorithm : > > Say Known version string = "ibm,state-v1" > > for each stop state node in device tree: > if (compatible has known version string) > kernel takes care of stop-transitions > else if (compatible has "opal-support") > OPAL takes care of stop-transitions > else > Skip All deeper states > > When a state does not have both version support and opal support, > Its possible to exit from a shallower state. Hence skipping all > deeper states. > > OPAL support for idle states > ---------------------------- > > With this patch series, all the states that loose hypervisor state > will be handled through opal_call. > > Patch 3 adds support for Saving/restoring of SPRs and resync-timebase > in OPAL. Also all the decision making such as identifying first thread > in the core and taking locks before restoring, etc are implemented in > OPAL. > > How does it work ? > ------------------- > > Consider a case that stop4 has a bug. We take the following steps to > mitigate the problem. > > 1) Change compatible string for stop4 in OPAL to "ibm-state-v2" and > remove "opal-supported". ship the new firmware. > The kernel ignores stop4 and all deeper states. But we will still have > shallower states. Prevents from completely disabling stop states. > > 2) Implement workaround in OPAL and add "opal-supported". Ship new firmware > The kernel uses opal for stop-transtion , which has workaround implemented. > We get stop4 and deeper states working without kernel changes and backports. > (and considerably less time) > > 3) Implement workaround in kernel and add "ibm-state-v2" as known versions > The kernel will now be able to handle stop4 and deeper states. > > Changes from v1 : > - Code is rebased on Nick Piggin's v4 patch "powerpc/64s: reimplement book3s > idle code in C" > http://patchwork.ozlabs.org/patch/969596/ > - All the states that loses hypervisor states will be handled by OPAL > - All the decision making such as identifying first thread in > the core and taking locks before restoring in such cases have also been > moved to OPAL > > > Abhishek Goel (1): > cpuidle/powernv: save-restore sprs in opal > > Akshay Adiga (2): > cpuidle/powernv: Add support for states with ibm,cpuidle-state-v1 > powernv/cpuidle: Pass pointers instead of values to stop loop > > arch/powerpc/include/asm/cpuidle.h | 9 + > arch/powerpc/include/asm/opal-api.h | 4 +- > arch/powerpc/include/asm/opal.h | 3 + > arch/powerpc/include/asm/processor.h | 8 +- > arch/powerpc/kernel/idle_book3s.S | 6 +- > arch/powerpc/platforms/powernv/idle.c | 247 ++++++++++++++---- > .../powerpc/platforms/powernv/opal-wrappers.S | 2 + > drivers/cpuidle/cpuidle-powernv.c | 46 ++-- > 8 files changed, 251 insertions(+), 74 deletions(-) >