Received: by 10.223.164.202 with SMTP id h10csp4445069wrb; Mon, 20 Nov 2017 15:55:10 -0800 (PST) X-Google-Smtp-Source: AGs4zMYi6YTt+vhuwEpeklnASSjOzjwicqwtWLQ1yuc9Gp+O8p702SIB17Mio5ArcSckb8okAa7k X-Received: by 10.84.234.198 with SMTP id i6mr15657621plt.260.1511222110211; Mon, 20 Nov 2017 15:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511222110; cv=none; d=google.com; s=arc-20160816; b=YoOpKeUCCRLwu6udaZLW/tYkkBC+s9YSwQaHKAWM7ovT3FBvZ8PupktbuG/o2No7Ly g2UOmOnICb8tsPyxnaZnzhh2C0RpQEZuwj4Zwy27AuQyDmnBDuixlztrIA9gRgWJQBrD tJovrY5JXWxjzHwPOu94QAdpk3dfsCEhfTu6F7ozTWqznWac+dIeVBtRTDobnxXAMEOf TIF57siH6KAdu0cobeqmiiKVGrHTmdt7N/YCJ2kgBpWM+v9ju8TKNpyJxym8ReliJQhv oEP+XWAMz8qw4BfFf9ynjVeKoZDenFSKHutFX3QSZjioIlIbRViMoO27h70M+Ll70Ly7 cEVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=uy896TKlXmROwsLWzRBnr2rXgfjdMxTwyISksFDaow4=; b=b2WzDknJBWSFnre0KJWPdDsdgYyT9r55QCyUqoJ2DxwtXw94jd/0UkpS2E9Y61xlap pL1KxAVlHrPvNGtb8g5p3n7ZqTcgvd7fKFCa6tyPYMeECbstHS5urAQdoRDoLNaLL2PH H1kT8s/vw7N6GuL7kWagUNuK2QR6OodT88k5EuxXQUtPbqBwH/f3smH4J2dLWmTSeqmw 5gQnARxOyLQELpsorQMwkoQGNeELvoCpw5ePP78PF31G4EKRznz4+Sin8HIBsjqSM9gu hKk2YTS6Kw+bQBg14B5U8FDrhMOmiKPnfEy38vVh5QO17WKksfYERN+6hbFeDX1lr2vH Za0w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s24si7142559plr.750.2017.11.20.15.55.00; Mon, 20 Nov 2017 15:55:10 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752401AbdKTXyP (ORCPT + 69 others); Mon, 20 Nov 2017 18:54:15 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60230 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbdKTXyK (ORCPT ); Mon, 20 Nov 2017 18:54:10 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAKNrP8B076780 for ; Mon, 20 Nov 2017 18:54:08 -0500 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ec65mywk1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 20 Nov 2017 18:54:08 -0500 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Nov 2017 16:54:07 -0700 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Nov 2017 16:54:05 -0700 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAKNs49q6226256; Mon, 20 Nov 2017 16:54:04 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D856BE040; Mon, 20 Nov 2017 16:54:04 -0700 (MST) Received: from oc3016140333.ibm.com (unknown [9.41.174.252]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id ECA9FBE03E; Mon, 20 Nov 2017 16:54:03 -0700 (MST) From: Eddie James To: linux-kernel@vger.kernel.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux@roeck-us.net, jdelvare@suse.com, corbet@lwn.net, mark.rutland@arm.com, robh+dt@kernel.org, joel@jms.id.au, eajames@linux.vnet.ibm.com, "Edward A. James" Subject: [PATCH v3 12/12] hwmon (occ): Add sysfs notification for errors and throttling Date: Mon, 20 Nov 2017 17:53:41 -0600 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1511222021-562-1-git-send-email-eajames@linux.vnet.ibm.com> References: <1511222021-562-1-git-send-email-eajames@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17112023-0028-0000-0000-000008B04090 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008101; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000240; SDB=6.00948827; UDB=6.00479139; IPR=6.00729107; BA=6.00005702; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018113; XFM=3.00000015; UTC=2017-11-20 23:54:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17112023-0029-0000-0000-0000386A88F3 Message-Id: <1511222021-562-13-git-send-email-eajames@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-20_12:,, 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711200318 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Edward A. James" In order to aid application usage of the error, throttling, and presence count properties, use sysfs_notify to notify users of change on these attributes. Signed-off-by: Edward A. James --- drivers/hwmon/occ/common.c | 53 ++++++++++++++++++++++++++++++++++++++++++++-- drivers/hwmon/occ/common.h | 5 +++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c index 7a0606d..7c97a4c 100644 --- a/drivers/hwmon/occ/common.c +++ b/drivers/hwmon/occ/common.c @@ -146,6 +146,8 @@ static ssize_t occ_show_error(struct device *dev, static DEVICE_ATTR(occ_error, 0444, occ_show_error, NULL); +static void occ_sysfs_notify(struct occ *occ); + static int occ_poll(struct occ *occ) { struct occ_poll_response_header *header; @@ -169,7 +171,7 @@ static int occ_poll(struct occ *occ) if (occ->error_count++ > OCC_ERROR_COUNT_THRESHOLD) occ->error = rc; - return rc; + goto done; } /* clear error since communication was successful */ @@ -190,7 +192,9 @@ static int occ_poll(struct occ *occ) occ->last_safe = 0; } - return 0; +done: + occ_sysfs_notify(occ); + return rc; } static int occ_set_user_power_cap(struct occ *occ, u16 user_power_cap) @@ -1244,6 +1248,51 @@ static ssize_t occ_show_status(struct device *dev, .attrs = occ_attributes, }; +static void occ_sysfs_notify(struct occ *occ) +{ + const char *name; + struct occ_poll_response_header *header = + (struct occ_poll_response_header *)occ->resp.data; + + /* sysfs attributes aren't loaded yet; don't proceed */ + if (!occ->hwmon) + goto done; + + if (header->occs_present != occ->previous_occs_present && + (header->status & OCC_STAT_MASTER)) { + name = sensor_dev_attr_occs_present.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_DVFS_OT) != + (occ->previous_ext_status & OCC_EXT_STAT_DVFS_OT)) { + name = sensor_dev_attr_occ_dvfs_ot.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_DVFS_POWER) != + (occ->previous_ext_status & OCC_EXT_STAT_DVFS_POWER)) { + name = sensor_dev_attr_occ_dvfs_power.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if ((header->ext_status & OCC_EXT_STAT_MEM_THROTTLE) != + (occ->previous_ext_status & OCC_EXT_STAT_MEM_THROTTLE)) { + name = sensor_dev_attr_occ_mem_throttle.dev_attr.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + + if (occ->error && occ->error != occ->previous_error) { + name = dev_attr_occ_error.attr.name; + sysfs_notify(&occ->bus_dev->kobj, NULL, name); + } + +done: + occ->previous_error = occ->error; + occ->previous_ext_status = header->ext_status; + occ->previous_occs_present = header->occs_present; +} + /* only need to do this once at startup, as OCC won't change sensors on us */ static void occ_parse_poll_response(struct occ *occ) { diff --git a/drivers/hwmon/occ/common.h b/drivers/hwmon/occ/common.h index cef2174..ffc809f 100644 --- a/drivers/hwmon/occ/common.h +++ b/drivers/hwmon/occ/common.h @@ -111,6 +111,11 @@ struct occ { int error; unsigned int error_count; /* number of errors observed */ unsigned long last_safe; /* time OCC entered safe state */ + + /* store previous poll state to compare; notify sysfs on change */ + int previous_error; + u8 previous_ext_status; + u8 previous_occs_present; }; int occ_setup(struct occ *occ, const char *name); -- 1.8.3.1 From 1584157802944265030@xxx Wed Nov 15 18:30:09 +0000 2017 X-GM-THRID: 1584157802944265030 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread