From patchwork Tue Oct 2 06:00:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 977642 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 42PT6P2mJtz9sCq for ; Tue, 2 Oct 2018 16:01:01 +1000 (AEST) 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 42PT6P1KmmzF38r for ; Tue, 2 Oct 2018 16:01:01 +1000 (AEST) 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=shilpa.bhat@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 42PT6H4W5JzF37B for ; Tue, 2 Oct 2018 16:00:54 +1000 (AEST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w925wfEH066680 for ; Tue, 2 Oct 2018 02:00:52 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mv0tpv0jh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 02 Oct 2018 02:00:51 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Oct 2018 07:00:50 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 2 Oct 2018 07:00:49 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w9260mgF48889916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 2 Oct 2018 06:00:48 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5501811C04C; Tue, 2 Oct 2018 09:00:26 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67CDD11C05C; Tue, 2 Oct 2018 09:00:25 +0100 (BST) Received: from oc4502181600.ibm.com (unknown [9.102.3.230]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 2 Oct 2018 09:00:25 +0100 (BST) From: Shilpasri G Bhat To: skiboot@lists.ozlabs.org Date: Tue, 2 Oct 2018 11:30:41 +0530 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 18100206-0020-0000-0000-000002CE22AE X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100206-0021-0000-0000-0000211C6233 Message-Id: <1538460041-16473-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-10-02_01:, , 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=821 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810020061 Subject: [Skiboot] [PATCH v2] powercap: occ: Fix the powercapping range allowed for user 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" OCC provides two limits for minimum powercap. One being hard powercap minimum which is guaranteed by OCC and the other one is a soft powercap minimum which may or may not be asserted due to various power-thermal reasons. This patch exports the soft-min powercap via device tree and "powercap-min" DT property will be continued to be used as hard powercap minimum. Fixes: c6aabe3f2eb5("powercap: occ: Add a generic powercap framework") Signed-off-by: Shilpasri G Bhat --- doc/device-tree/ibm,opal/power-mgt/powercap.rst | 6 +++++- hw/occ.c | 23 ++++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/doc/device-tree/ibm,opal/power-mgt/powercap.rst b/doc/device-tree/ibm,opal/power-mgt/powercap.rst index 5a8d007..89362ba 100644 --- a/doc/device-tree/ibm,opal/power-mgt/powercap.rst +++ b/doc/device-tree/ibm,opal/power-mgt/powercap.rst @@ -20,11 +20,14 @@ Each child node has below properties: Handle to indicate the current powercap `powercap-min` - Minimum possible powercap + Guaranteed hard min powercap unless there is a hardware failure `powercap-max` Maximum possible powercap +`powercap-soft-min` + Minimum possible powercap which may or may not be maintained + Powercap handle uses the following encoding: :: | Class | Reserved | Attribute | @@ -44,6 +47,7 @@ the future. powercap-current = <0x00000002>; powercap-min = <0x00000000>; powercap-max = <0x00000001>; + powercap-soft-min = <0x000000003>; }; }; }; diff --git a/hw/occ.c b/hw/occ.c index 9580bb8..56b4428 100644 --- a/hw/occ.c +++ b/hw/occ.c @@ -225,9 +225,12 @@ struct occ_response_buffer { * power to maintain a power cap. Value of 100 * means take all power from CPU. * @pwr_cap_type: Indicates type of power cap in effect - * @min_pwr_cap: Minimum allowed system power cap in Watts + * @hard_min_pwr_cap: Hard minimum system power cap in Watts. + * Guaranteed unless hardware failure * @max_pwr_cap: Maximum allowed system power cap in Watts * @cur_pwr_cap: Current system power cap + * @soft_min_pwr_cap: Soft powercap minimum. OCC may or may not be + * able to maintain this * @spare/reserved: Unused data * @cmd: Opal Command Buffer * @rsp: OCC Response Buffer @@ -243,10 +246,11 @@ struct occ_dynamic_data { u8 quick_pwr_drop; u8 pwr_shifting_ratio; u8 pwr_cap_type; - u16 min_pwr_cap; + u16 hard_min_pwr_cap; u16 max_pwr_cap; u16 cur_pwr_cap; - u8 pad[112]; + u16 soft_min_pwr_cap; + u8 pad[110]; struct opal_command_buffer cmd; struct occ_response_buffer rsp; } __packed; @@ -1327,6 +1331,7 @@ enum sensor_powercap_occ_attr { POWERCAP_OCC_MIN, POWERCAP_OCC_MAX, POWERCAP_OCC_CUR, + POWERCAP_OCC_SOFT_MIN, }; static void occ_add_powercap_sensors(struct dt_node *power_mgt) @@ -1355,6 +1360,11 @@ static void occ_add_powercap_sensors(struct dt_node *power_mgt) handle = powercap_make_handle(POWERCAP_CLASS_OCC, POWERCAP_OCC_MAX); dt_add_property_cells(node, "powercap-max", handle); + + handle = powercap_make_handle(POWERCAP_CLASS_OCC, + POWERCAP_OCC_SOFT_MIN); + dt_add_property_cells(node, "powercap-soft-min", handle); + } int occ_get_powercap(u32 handle, u32 *pcap) @@ -1372,7 +1382,7 @@ int occ_get_powercap(u32 handle, u32 *pcap) switch (powercap_get_attr(handle)) { case POWERCAP_OCC_MIN: - *pcap = ddata->min_pwr_cap; + *pcap = ddata->hard_min_pwr_cap; break; case POWERCAP_OCC_MAX: *pcap = ddata->max_pwr_cap; @@ -1380,6 +1390,9 @@ int occ_get_powercap(u32 handle, u32 *pcap) case POWERCAP_OCC_CUR: *pcap = ddata->cur_pwr_cap; break; + case POWERCAP_OCC_SOFT_MIN: + *pcap = ddata->soft_min_pwr_cap; + break; default: *pcap = 0; return OPAL_UNSUPPORTED; @@ -1420,7 +1433,7 @@ int occ_set_powercap(u32 handle, int token, u32 pcap) return OPAL_SUCCESS; if (pcap && (pcap > ddata->max_pwr_cap || - pcap < ddata->min_pwr_cap)) + pcap < ddata->soft_min_pwr_cap)) return OPAL_PARAMETER; pcap_cdata = pcap;