From patchwork Mon Feb 24 11:35:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pratik R. Sampat" X-Patchwork-Id: 1243008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48R0Q91ycMz9sP7 for ; Mon, 24 Feb 2020 22:36:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48R0Q90rMLzDqNW for ; Mon, 24 Feb 2020 22:36:33 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=psampat@linux.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.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 48R0Nw1WT5zDqM0 for ; Mon, 24 Feb 2020 22:35:27 +1100 (AEDT) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 01OBYXtw145117 for ; Mon, 24 Feb 2020 06:35:25 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 2yb1arc9t6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 24 Feb 2020 06:35:24 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 24 Feb 2020 11:35:22 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 24 Feb 2020 11:35:21 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 01OBZItw49610956 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 24 Feb 2020 11:35:18 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1D9E811C054; Mon, 24 Feb 2020 11:35:18 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9627A11C058; Mon, 24 Feb 2020 11:35:16 +0000 (GMT) Received: from pratiks-thinkpad.in.ibm.com (unknown [9.124.31.88]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 24 Feb 2020 11:35:16 +0000 (GMT) From: Pratik Rajesh Sampat To: skiboot@lists.ozlabs.org, oohall@gmail.com, ego@linux.vnet.ibm.com, svaidy@linux.ibm.com, premjha2@in.ibm.com, akshay.adiga@linux.vnet.ibm.com, pratik.sampat@in.ibm.com, psampat@linux.ibm.com Date: Mon, 24 Feb 2020 17:05:08 +0530 X-Mailer: git-send-email 2.24.1 In-Reply-To: References: MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 20022411-0012-0000-0000-00000389C20C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20022411-0013-0000-0000-000021C66105 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572 definitions=2020-02-24_02:2020-02-21, 2020-02-24 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 phishscore=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 suspectscore=2 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002240098 Subject: [Skiboot] [PATCH v5 4/4] Advertise the self-save and self-restore attributes in the device tree 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Support for self save and self restore interface is advertised in the device tree, along with the list of SPRs it supports for each. The Special Purpose Register identification is encoded in a 2048 bitmask structure, where each bit signifies the identification key of that SPR which is consistent with that of the POWER architecture set for that register. Signed-off-by: Pratik Rajesh Sampat --- .../ibm,opal/power-mgt/self-restore.rst | 25 ++++ .../ibm,opal/power-mgt/self-save.rst | 25 ++++ hw/slw.c | 112 ++++++++++++++++++ include/skiboot.h | 1 + 4 files changed, 163 insertions(+) create mode 100644 doc/device-tree/ibm,opal/power-mgt/self-restore.rst create mode 100644 doc/device-tree/ibm,opal/power-mgt/self-save.rst diff --git a/doc/device-tree/ibm,opal/power-mgt/self-restore.rst b/doc/device-tree/ibm,opal/power-mgt/self-restore.rst new file mode 100644 index 00000000..2b2e62fe --- /dev/null +++ b/doc/device-tree/ibm,opal/power-mgt/self-restore.rst @@ -0,0 +1,25 @@ +ibm,opal/power-mgt/self-restore device tree entries +=================================================== + +This node exports the bitmask representing the special purpose registers that +the self-restore API currently supports. + +Example: + +.. code-block:: dts + + self-restore { + sprn-bitmask = <0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x42010000 0x0 0x0 + 0x20000 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x0 0x100000 0x900000 0x0 0x0 0x530000 0x0 0x0 0x0 + 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x10000>; + phandle = <0x1c7>; + }; + +sprn-bitmask +------------ + +This property is a bitmask of of all the existing SPRs and if the SPR is +supported, the corresponding bit of the SPR number is set to 1. diff --git a/doc/device-tree/ibm,opal/power-mgt/self-save.rst b/doc/device-tree/ibm,opal/power-mgt/self-save.rst new file mode 100644 index 00000000..450c56dd --- /dev/null +++ b/doc/device-tree/ibm,opal/power-mgt/self-save.rst @@ -0,0 +1,25 @@ +ibm,opal/power-mgt/self-save device tree entries +=================================================== + +This node exports the bitmask representing the special purpose registers that +the self-save API currently supports. + +Example: + +.. code-block:: dts + + self-save { + sprn-bitmask = <0x0 0x0 0x0 0x0 0x100000 0x0 0x0 0x0 0x42010000 0x0 0x0 + 0x20000 0x0 0x0 0x0 0x10000 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x0 0x0 0x100000 0x840000 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 + 0x0 0x10000>; + phandle = <0x1c8>; + }; + +sprn-bitmask +------------ + +This property is a bitmask of of all the existing SPRs and if the SPR is +supported, the corresponding bit of the SPR number is set to 1. diff --git a/hw/slw.c b/hw/slw.c index 0e92adaa..333f15f2 100644 --- a/hw/slw.c +++ b/hw/slw.c @@ -29,6 +29,7 @@ #include static uint32_t slw_saved_reset[0x100]; +#define SPR_BITMAP_LENGTH 2048 static bool slw_current_le = false; @@ -750,6 +751,115 @@ static void slw_late_init_p9(struct proc_chip *chip) } } +/* Add device tree properties to determine self-save | restore */ +void add_cpu_self_save_properties(void) +{ + struct dt_node *self_restore, *self_save, *power_mgt; + uint64_t *self_save_mask, *self_restore_mask; + bool self_save_supported = true; + uint64_t compVector = -1; + struct proc_chip *chip; + int i, rc; + + const uint64_t self_restore_regs[] = { + P8_SPR_HRMOR, + P8_SPR_HMEER, + P8_SPR_PMICR, + P8_SPR_PMCR, + P8_SPR_HID0, + P8_SPR_HID1, + P8_SPR_HID4, + P8_SPR_HID5, + P8_SPR_HSPRG0, + P8_SPR_LPCR, + P9_STOP_SPR_PSSCR, + P8_MSR_MSR + }; + + const uint64_t self_save_regs[] = { + P9_STOP_SPR_DAWR, + P9_STOP_SPR_HSPRG0, + P9_STOP_SPR_LDBAR, + P9_STOP_SPR_LPCR, + P9_STOP_SPR_PSSCR, + P9_STOP_SPR_MSR, + P9_STOP_SPR_HRMOR, + P9_STOP_SPR_HMEER, + P9_STOP_SPR_PMCR, + P9_STOP_SPR_PTCR + }; + + chip = next_chip(NULL); + assert(chip); + rc = proc_stop_api_discover_capability((void *) chip->homer_base, + &compVector); + if (rc == STOP_SAVE_ARG_INVALID_IMG) { + prlog(PR_DEBUG, "HOMER BASE INVALID\n"); + return; + } else if (rc == STOP_SAVE_API_IMG_INCOMPATIBLE) { + prlog(PR_DEBUG, "STOP API running incompatible versions\n"); + if ((compVector & SELF_RESTORE_VER_MISMATCH) == 0) { + prlog(PR_DEBUG, "Self-save API unsupported\n"); + self_save_supported = false; + } + } + + power_mgt = dt_find_by_path(dt_root, "/ibm,opal/power-mgt"); + if (!power_mgt) { + prerror("OCC: dt node /ibm,opal/power-mgt not found\n"); + return; + } + + self_restore = dt_new(power_mgt, "self-restore"); + if (!self_restore) { + prerror("OCC: Failed to create self restore node"); + return; + } + + self_restore_mask = zalloc(SPR_BITMAP_LENGTH / 8); + if (!self_restore_mask) + return; + + for (i = 0; i < ARRAY_SIZE(self_restore_regs); i++) { + int bitmask_idx = self_restore_regs[i] / 64; + uint64_t bitmask_pos = self_restore_regs[i] % 64; + self_restore_mask[bitmask_idx] |= 1ul << bitmask_pos; + } + for (i = 0; i < (SPR_BITMAP_LENGTH / 64); i++) { + self_restore_mask[i] = be64_to_cpu(self_restore_mask[i]); + } + + dt_add_property(self_restore, "sprn-bitmask", self_restore_mask, + SPR_BITMAP_LENGTH / 8); + free(self_restore_mask); + + if (proc_gen != proc_gen_p9 || !self_save_supported) + return; + + self_save = dt_new(power_mgt, "self-save"); + if (!self_save) { + prerror("OCC: Failed to create self save node"); + return; + } + + self_save_mask = zalloc(SPR_BITMAP_LENGTH / 8); + if (!self_save_mask) + return; + + for (i = 0; i < ARRAY_SIZE(self_save_regs); i++) { + int bitmask_idx = self_save_regs[i] / 64; + uint64_t bitmask_pos = self_save_regs[i] % 64; + self_save_mask[bitmask_idx] |= 1ul << bitmask_pos; + } + for (i = 0; i < (SPR_BITMAP_LENGTH / 64); i++) { + self_save_mask[i] = be64_to_cpu(self_save_mask[i]); + } + + dt_add_property(self_save, "sprn-bitmask", self_save_mask, + SPR_BITMAP_LENGTH / 8); + free(self_save_mask); +} + /* Add device tree properties to describe idle states */ void add_cpu_idle_state_properties(void) { @@ -1563,4 +1673,6 @@ void slw_init(void) } } add_cpu_idle_state_properties(); + if (has_deep_states) + add_cpu_self_save_properties(); } diff --git a/include/skiboot.h b/include/skiboot.h index 072ce589..676211ad 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -209,6 +209,7 @@ extern void early_uart_init(void); extern void homer_init(void); extern void slw_init(void); extern void add_cpu_idle_state_properties(void); +extern void add_cpu_self_save_properties(void); extern void lpc_rtc_init(void); /* flash support */