From nobody Sun Jun 28 02:48:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0F38C433F5 for ; Tue, 15 Feb 2022 15:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239685AbiBOPL3 (ORCPT ); Tue, 15 Feb 2022 10:11:29 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239655AbiBOPL1 (ORCPT ); Tue, 15 Feb 2022 10:11:27 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F276D4F0; Tue, 15 Feb 2022 07:11:17 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FF3v2a020784; Tue, 15 Feb 2022 15:11:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=+S524gr2yY/a9UThKXni+iuVvgWEC/xxBSmrBKnELqY=; b=m6xVLZ1s/ukrpwYj3zU6C36aRzXwrXgzJeKfdGTpK/QFBhjur1OGEssg8EhnK5HDuSTD H5PUSZq9zciuZ24Sga6rfnc1Tx2TmzS2bYs/22V9oQ+KbHY/9KYVr4XKqrxWMb/f3b2Z jiVSoShOXHyfLaHAb2qgah2uJumL8OMvwP+AXBfobJ/rzBsxFimSAgQ1KpIaKwgfw459 G4cAKbRMIkVIPP7mf105XZqDbLRh4wRpQWM+c2zlEDJeKR26kDc5IjWebOpCTET/IlFF LHXwIOmGNWd8HZZJMI4dVzDHiH/gkKXZOq64yZ1f2GzzNHiJtowtHEMzmqT4w16/6TkY pA== Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8e8c0qeq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:02 +0000 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21FF8Ggu026258; Tue, 15 Feb 2022 15:11:01 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma03wdc.us.ibm.com with ESMTP id 3e64hatv8f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:00 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21FFAx5p37814718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 15:10:59 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6029A124080; Tue, 15 Feb 2022 15:10:59 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3DCA124062; Tue, 15 Feb 2022 15:10:57 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.156.4]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 15 Feb 2022 15:10:57 +0000 (GMT) From: Eddie James To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jdelvare@suse.com, linux@roeck-us.net, joel@jms.id.au, eajames@linux.ibm.com Subject: [PATCH 1/4] hwmon: (occ) Add sysfs entry for IPS (Idle Power Saver) status Date: Tue, 15 Feb 2022 09:10:19 -0600 Message-Id: <20220215151022.7498-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220215151022.7498-1-eajames@linux.ibm.com> References: <20220215151022.7498-1-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ywrTUjtHauSJeTSWLpiGYN5Qix9lVt91 X-Proofpoint-GUID: ywrTUjtHauSJeTSWLpiGYN5Qix9lVt91 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-15_04,2022-02-14_04,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 mlxscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150088 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" BMC control applications need to check the Idle Power Saver status byte returned by the OCC poll response, so export it in sysfs with the other OCC-specific data. Signed-off-by: Eddie James Reviewed-by: Joel Stanley --- drivers/hwmon/occ/common.h | 1 + drivers/hwmon/occ/sysfs.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index 5020117be740..a88c66d36e38 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -119,6 +119,7 @@ struct occ { u8 prev_stat; u8 prev_ext_stat; u8 prev_occs_present; + u8 prev_ips_status; }; =20 int occ_setup(struct occ *occ, const char *name); diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c index 03b16abef67f..6dc69c9aa4c2 100644 --- a/drivers/hwmon/occ/sysfs.c +++ b/drivers/hwmon/occ/sysfs.c @@ -63,6 +63,9 @@ static ssize_t occ_sysfs_show(struct device *dev, else val =3D 1; break; + case 8: + val =3D header->ips_status; + break; default: return -EINVAL; } @@ -88,6 +91,7 @@ static SENSOR_DEVICE_ATTR(occ_mem_throttle, 0444, occ_sys= fs_show, NULL, 4); static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_sysfs_show, NULL, = 5); static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6); static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7); +static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8); static DEVICE_ATTR_RO(occ_error); =20 static struct attribute *occ_attributes[] =3D { @@ -99,6 +103,7 @@ static struct attribute *occ_attributes[] =3D { &sensor_dev_attr_occ_quick_pwr_drop.dev_attr.attr, &sensor_dev_attr_occ_state.dev_attr.attr, &sensor_dev_attr_occs_present.dev_attr.attr, + &sensor_dev_attr_occ_ips_status.dev_attr.attr, &dev_attr_occ_error.attr, NULL }; @@ -162,6 +167,11 @@ void occ_sysfs_poll_done(struct occ *occ) sysfs_notify(&occ->bus_dev->kobj, NULL, name); } =20 + if (header->ips_status !=3D occ->prev_ips_status) { + name =3D sensor_dev_attr_occ_ips_status.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + if (occ->error && occ->error !=3D occ->prev_error) { name =3D dev_attr_occ_error.attr.name; sysfs_notify(&occ->bus_dev->kobj, NULL, name); @@ -174,6 +184,7 @@ void occ_sysfs_poll_done(struct occ *occ) occ->prev_stat =3D header->status; occ->prev_ext_stat =3D header->ext_status; occ->prev_occs_present =3D header->occs_present; + occ->prev_ips_status =3D header->ips_status; } =20 int occ_setup_sysfs(struct occ *occ) --=20 2.27.0 From nobody Sun Jun 28 02:48:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3572C433EF for ; Tue, 15 Feb 2022 15:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239689AbiBOPLj (ORCPT ); Tue, 15 Feb 2022 10:11:39 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239684AbiBOPL3 (ORCPT ); Tue, 15 Feb 2022 10:11:29 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CB4108572; Tue, 15 Feb 2022 07:11:19 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FF9WIK002341; Tue, 15 Feb 2022 15:11:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=a+iuWb53O1yR35Q/SiXyv/UA3c60dTEY9xh/KCry72g=; b=Iaz4v0XMPuB3N3KQ+6mUYgvtK+j/k95UqHerBly5xD2N27y6nQyCaD237aEM5+JuJBch hQNCq+02IVoychnt8e0Dflsg8moBC8zA9W+y+kkmZaz/VElEOh+WM6n5gh1wbVF3bUli ci69v/rWgrihV8izv6hRr1+VYuEol6VGz/8oOqpKrjRzIe1x013jNoOSP+vELkRPlYuW Wz8xR/MUcA38woBoORa+p971sEjg1z8PzKIY7m9e0ICW8MPaX34e6SWYfWAao/x+v1vG LrfeuCpHhpHMKa0G8w6/qWZ6UKzg4Ct93HxmRfVX3bIBe7rUPPVv9M8BGU/ji2Xayt5j 7Q== Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8atse3xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:03 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21FF8PEO029351; Tue, 15 Feb 2022 15:11:02 GMT Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by ppma05wdc.us.ibm.com with ESMTP id 3e64hajvvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:02 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21FFB15A20971938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 15:11:01 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4647812407F; Tue, 15 Feb 2022 15:11:01 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF0FA124066; Tue, 15 Feb 2022 15:10:59 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.156.4]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 15 Feb 2022 15:10:59 +0000 (GMT) From: Eddie James To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jdelvare@suse.com, linux@roeck-us.net, joel@jms.id.au, eajames@linux.ibm.com Subject: [PATCH 2/4] hwmon: (occ) Add sysfs entry for OCC mode Date: Tue, 15 Feb 2022 09:10:20 -0600 Message-Id: <20220215151022.7498-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220215151022.7498-1-eajames@linux.ibm.com> References: <20220215151022.7498-1-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: W6rH2zBTLXAMblnhqE1HGru988coMkUd X-Proofpoint-GUID: W6rH2zBTLXAMblnhqE1HGru988coMkUd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-15_04,2022-02-14_04,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 suspectscore=0 mlxlogscore=936 adultscore=0 mlxscore=0 phishscore=0 spamscore=0 clxscore=1015 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150088 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" BMC control applications need to check the OCC mode returned by the OCC poll response, so export it in sysfs with the other OCC-specific data. Signed-off-by: Eddie James Reviewed-by: Joel Stanley --- drivers/hwmon/occ/common.h | 1 + drivers/hwmon/occ/sysfs.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index a88c66d36e38..2dd4a4d240c0 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -120,6 +120,7 @@ struct occ { u8 prev_ext_stat; u8 prev_occs_present; u8 prev_ips_status; + u8 prev_mode; }; =20 int occ_setup(struct occ *occ, const char *name); diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c index 6dc69c9aa4c2..88f655887c95 100644 --- a/drivers/hwmon/occ/sysfs.c +++ b/drivers/hwmon/occ/sysfs.c @@ -66,6 +66,9 @@ static ssize_t occ_sysfs_show(struct device *dev, case 8: val =3D header->ips_status; break; + case 9: + val =3D header->mode; + break; default: return -EINVAL; } @@ -92,6 +95,7 @@ static SENSOR_DEVICE_ATTR(occ_quick_pwr_drop, 0444, occ_s= ysfs_show, NULL, 5); static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_show, NULL, 6); static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7); static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8); +static SENSOR_DEVICE_ATTR(occ_mode, 0444, occ_sysfs_show, NULL, 9); static DEVICE_ATTR_RO(occ_error); =20 static struct attribute *occ_attributes[] =3D { @@ -104,6 +108,7 @@ static struct attribute *occ_attributes[] =3D { &sensor_dev_attr_occ_state.dev_attr.attr, &sensor_dev_attr_occs_present.dev_attr.attr, &sensor_dev_attr_occ_ips_status.dev_attr.attr, + &sensor_dev_attr_occ_mode.dev_attr.attr, &dev_attr_occ_error.attr, NULL }; @@ -172,6 +177,11 @@ void occ_sysfs_poll_done(struct occ *occ) sysfs_notify(&occ->bus_dev->kobj, NULL, name); } =20 + if (header->mode !=3D occ->prev_mode) { + name =3D sensor_dev_attr_occ_mode.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + if (occ->error && occ->error !=3D occ->prev_error) { name =3D dev_attr_occ_error.attr.name; sysfs_notify(&occ->bus_dev->kobj, NULL, name); @@ -185,6 +195,7 @@ void occ_sysfs_poll_done(struct occ *occ) occ->prev_ext_stat =3D header->ext_status; occ->prev_occs_present =3D header->occs_present; occ->prev_ips_status =3D header->ips_status; + occ->prev_mode =3D header->mode; } =20 int occ_setup_sysfs(struct occ *occ) --=20 2.27.0 From nobody Sun Jun 28 02:48:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47A3DC433EF for ; Tue, 15 Feb 2022 15:11:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238899AbiBOPLq (ORCPT ); Tue, 15 Feb 2022 10:11:46 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239694AbiBOPLg (ORCPT ); Tue, 15 Feb 2022 10:11:36 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4713108772; Tue, 15 Feb 2022 07:11:21 -0800 (PST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FF3rTL007750; Tue, 15 Feb 2022 15:11:06 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=CwnMi/2c4QJHMS+MQeJ3zcFvrjSZ/vSRpTXDKgZxgFs=; b=UZZHMEE1df4MoG+DscfuZMMefHUr/3K1ekPE7nvIZXi8WCxuX6wlFRu3F6B81EKr/I2O bE4/gY3i6zd8PlO9ZGGq2jzF7Q3SQ2GCN4+zXthDcJCKy8g06Bnnyr4nHip8lF4AvVcU OEZymq7Lij/8yB3AsZlhqwbvz4HPQSZ3kGg6p1vkwXem55/8vv7LGGTur59ncl2zKPTA wgic2P+UcIZPNbWjTUwMt+SXtogGT6ZMP0dANBn+0GLelGcOJp5T/O90s5xFk/ruzbPs vY20oSgnIrdfzkD4g/fdM1BtX66Y3Led77EIYDfrIHxd3SW8WKR4DZtlTilHKMf+8ypy Vw== Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8edn8d0x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:06 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21FF8MIl007887; Tue, 15 Feb 2022 15:11:05 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 3e64hb94gg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:05 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21FFB3uh31785408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 15:11:03 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 44C49124052; Tue, 15 Feb 2022 15:11:03 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A9CDB124085; Tue, 15 Feb 2022 15:11:01 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.156.4]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 15 Feb 2022 15:11:01 +0000 (GMT) From: Eddie James To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jdelvare@suse.com, linux@roeck-us.net, joel@jms.id.au, eajames@linux.ibm.com Subject: [PATCH 3/4] hwmon: (occ) Add sysfs entries for additional extended status bits Date: Tue, 15 Feb 2022 09:10:21 -0600 Message-Id: <20220215151022.7498-4-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220215151022.7498-1-eajames@linux.ibm.com> References: <20220215151022.7498-1-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ydSGys_Sws354-17k1wr3k__DS5gQ9RE X-Proofpoint-ORIG-GUID: ydSGys_Sws354-17k1wr3k__DS5gQ9RE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-15_04,2022-02-14_04,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=767 lowpriorityscore=0 priorityscore=1501 suspectscore=0 adultscore=0 impostorscore=0 bulkscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150088 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add sysfs entries for DVFS due to a VRM Vdd over-temperature condition, and add the GPU throttling condition bits (such that if bit 1 is set, GPU1 is throttling). Signed-off-by: Eddie James Reviewed-by: Joel Stanley --- drivers/hwmon/occ/sysfs.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/hwmon/occ/sysfs.c b/drivers/hwmon/occ/sysfs.c index 88f655887c95..b2f788a77746 100644 --- a/drivers/hwmon/occ/sysfs.c +++ b/drivers/hwmon/occ/sysfs.c @@ -19,6 +19,8 @@ #define OCC_EXT_STAT_DVFS_POWER BIT(6) #define OCC_EXT_STAT_MEM_THROTTLE BIT(5) #define OCC_EXT_STAT_QUICK_DROP BIT(4) +#define OCC_EXT_STAT_DVFS_VDD BIT(3) +#define OCC_EXT_STAT_GPU_THROTTLE GENMASK(2, 0) =20 static ssize_t occ_sysfs_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -69,6 +71,12 @@ static ssize_t occ_sysfs_show(struct device *dev, case 9: val =3D header->mode; break; + case 10: + val =3D !!(header->ext_status & OCC_EXT_STAT_DVFS_VDD); + break; + case 11: + val =3D header->ext_status & OCC_EXT_STAT_GPU_THROTTLE; + break; default: return -EINVAL; } @@ -96,6 +104,8 @@ static SENSOR_DEVICE_ATTR(occ_state, 0444, occ_sysfs_sho= w, NULL, 6); static SENSOR_DEVICE_ATTR(occs_present, 0444, occ_sysfs_show, NULL, 7); static SENSOR_DEVICE_ATTR(occ_ips_status, 0444, occ_sysfs_show, NULL, 8); static SENSOR_DEVICE_ATTR(occ_mode, 0444, occ_sysfs_show, NULL, 9); +static SENSOR_DEVICE_ATTR(occ_dvfs_vdd, 0444, occ_sysfs_show, NULL, 10); +static SENSOR_DEVICE_ATTR(occ_gpu_throttle, 0444, occ_sysfs_show, NULL, 11= ); static DEVICE_ATTR_RO(occ_error); =20 static struct attribute *occ_attributes[] =3D { @@ -109,6 +119,8 @@ static struct attribute *occ_attributes[] =3D { &sensor_dev_attr_occs_present.dev_attr.attr, &sensor_dev_attr_occ_ips_status.dev_attr.attr, &sensor_dev_attr_occ_mode.dev_attr.attr, + &sensor_dev_attr_occ_dvfs_vdd.dev_attr.attr, + &sensor_dev_attr_occ_gpu_throttle.dev_attr.attr, &dev_attr_occ_error.attr, NULL }; @@ -166,6 +178,18 @@ void occ_sysfs_poll_done(struct occ *occ) sysfs_notify(&occ->bus_dev->kobj, NULL, name); } =20 + if ((header->ext_status & OCC_EXT_STAT_DVFS_VDD) !=3D + (occ->prev_ext_stat & OCC_EXT_STAT_DVFS_VDD)) { + name =3D sensor_dev_attr_occ_dvfs_vdd.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_GPU_THROTTLE) !=3D + (occ->prev_ext_stat & OCC_EXT_STAT_GPU_THROTTLE)) { + name =3D sensor_dev_attr_occ_gpu_throttle.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + if ((header->status & OCC_STAT_MASTER) && header->occs_present !=3D occ->prev_occs_present) { name =3D sensor_dev_attr_occs_present.dev_attr.attr.name; --=20 2.27.0 From nobody Sun Jun 28 02:48:27 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B43D6C433F5 for ; Tue, 15 Feb 2022 15:11:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239731AbiBOPLx (ORCPT ); Tue, 15 Feb 2022 10:11:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239696AbiBOPLg (ORCPT ); Tue, 15 Feb 2022 10:11:36 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DD6B10BC; Tue, 15 Feb 2022 07:11:23 -0800 (PST) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 21FF3sNR007859; Tue, 15 Feb 2022 15:11:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=Kd1FD4NJgY4bDYP6yHxyjz7rGjiUViUnTQ1l/FQqWVQ=; b=TXi2D9R92xTUSwVEXodwRPFO2Hk7KFA++mciV7GLyPjXrMlw+w1S63QX85WY/dPu2RG8 A66xQqnhydLpjci5K3sFPQVbGqYiv3h6+IxkQrXzuYLhTEgyPhbZO/0S+/wk1iUSLbzj HXEimJmzmMipmyGG4rnjDBMbxYJ0qadKUUP8f6BEwUC8aUdRq8fCH/8SSxWMoDfDgWtY 5AyQk0uiKTDZzmEO/IP87Jj6IUyOb7HlivpDYSYHlIbd0Ead3c6TB9U4W5ZHQMJadaCi RIyqTjOUtNctgZ+RFi8FHg1ppHTHB/olc4+B4qPpW5MdBXitvw15v9G6LT/y50wTLSjl oA== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com with ESMTP id 3e8edn8d1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:07 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 21FF9nHA026176; Tue, 15 Feb 2022 15:11:06 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma02dal.us.ibm.com with ESMTP id 3e64hbh47q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 15 Feb 2022 15:11:06 +0000 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 21FFB5Xw31064544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Feb 2022 15:11:05 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41D14124066; Tue, 15 Feb 2022 15:11:05 +0000 (GMT) Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4313124071; Tue, 15 Feb 2022 15:11:03 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.156.4]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 15 Feb 2022 15:11:03 +0000 (GMT) From: Eddie James To: linux-hwmon@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jdelvare@suse.com, linux@roeck-us.net, joel@jms.id.au, eajames@linux.ibm.com Subject: [PATCH 4/4] hwmon: (occ) Add soft minimum power cap attribute Date: Tue, 15 Feb 2022 09:10:22 -0600 Message-Id: <20220215151022.7498-5-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220215151022.7498-1-eajames@linux.ibm.com> References: <20220215151022.7498-1-eajames@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: jzDnhRFcB_nxWz-yQJwHFsTK31JU-xMA X-Proofpoint-ORIG-GUID: jzDnhRFcB_nxWz-yQJwHFsTK31JU-xMA X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-15_04,2022-02-14_04,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=941 lowpriorityscore=0 priorityscore=1501 suspectscore=0 adultscore=0 impostorscore=0 bulkscore=0 clxscore=1015 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2201110000 definitions=main-2202150088 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Export the power caps data for the soft minimum power cap through hwmon. Signed-off-by: Eddie James Reviewed-by: Joel Stanley --- drivers/hwmon/occ/common.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index 0cb4a0a6cbc1..f00cd59f1d19 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -674,6 +674,9 @@ static ssize_t occ_show_caps_3(struct device *dev, case 7: val =3D caps->user_source; break; + case 8: + val =3D get_unaligned_be16(&caps->soft_min) * 1000000ULL; + break; default: return -EINVAL; } @@ -835,12 +838,13 @@ static int occ_setup_sensor_attrs(struct occ *occ) case 1: num_attrs +=3D (sensors->caps.num_sensors * 7); break; - case 3: - show_caps =3D occ_show_caps_3; - fallthrough; case 2: num_attrs +=3D (sensors->caps.num_sensors * 8); break; + case 3: + show_caps =3D occ_show_caps_3; + num_attrs +=3D (sensors->caps.num_sensors * 9); + break; default: sensors->caps.num_sensors =3D 0; } @@ -1047,6 +1051,15 @@ static int occ_setup_sensor_attrs(struct occ *occ) attr->sensor =3D OCC_INIT_ATTR(attr->name, 0444, show_caps, NULL, 7, 0); attr++; + + if (sensors->caps.version > 2) { + snprintf(attr->name, sizeof(attr->name), + "power%d_cap_min_soft", s); + attr->sensor =3D OCC_INIT_ATTR(attr->name, 0444, + show_caps, NULL, + 8, 0); + attr++; + } } } =20 --=20 2.27.0