From patchwork Mon Oct 15 09:15:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akshay Adiga X-Patchwork-Id: 983988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YXq64p0Vz9sBj for ; Mon, 15 Oct 2018 20:15:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YXq62z8YzF3CR for ; Mon, 15 Oct 2018 20:15:46 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=akshay.adiga@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42YXq33nYTzF39V for ; Mon, 15 Oct 2018 20:15:43 +1100 (AEDT) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w9F9FG1D041006 for ; Mon, 15 Oct 2018 05:15:41 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2n4nwg5qsx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 15 Oct 2018 05:15:40 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 15 Oct 2018 10:15:39 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 15 Oct 2018 10:15:36 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9F9FaBe55181414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 15 Oct 2018 09:15:36 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B086142041; Mon, 15 Oct 2018 12:15:09 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 604274204B; Mon, 15 Oct 2018 12:15:08 +0100 (BST) Received: from aks.in.ibm.com (unknown [9.124.35.29]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 15 Oct 2018 12:15:08 +0100 (BST) From: Akshay Adiga To: skiboot@lists.ozlabs.org Date: Mon, 15 Oct 2018 14:45:29 +0530 X-Mailer: git-send-email 2.17.1 X-TM-AS-GCONF: 00 x-cbid: 18101509-0016-0000-0000-0000021320BC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18101509-0017-0000-0000-0000326AAB1B Message-Id: <20181015091531.14126-1-akshay.adiga@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-15_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810150087 Subject: [Skiboot] [RFC PATCH v2 0/2] New device-tree format and Opal based idle save-restore X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stewart@linux.vnet.ibm.com, ego@linux.vnet.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 : - Deep states will have only opal-support instead of both opal and kernel - Moved "cpuidle" and "cpuoffline" as a different property called "type" - 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): opal : Support spr save-restore using new Akshay Adiga (1): SLW: Add new idle device-tree format asm/head.S | 2 - hw/chiptod.c | 2 +- hw/slw.c | 306 ++++++++++++++++++++++++++++++++++++---- include/cpu.h | 28 ++++ include/opal-api.h | 4 +- include/opal-internal.h | 1 + include/processor.h | 17 +++ 7 files changed, 329 insertions(+), 31 deletions(-)