From patchwork Fri Dec 15 07:21:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shilpasri G Bhat X-Patchwork-Id: 849003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yyhhS6FQ6z9ryQ for ; Fri, 15 Dec 2017 18:22:16 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3yyhhS57CyzDrnS for ; Fri, 15 Dec 2017 18:22:16 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: 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=) 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 3yyhgW3KYkzDrnb for ; Fri, 15 Dec 2017 18:21:27 +1100 (AEDT) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vBF7KHIZ046342 for ; Fri, 15 Dec 2017 02:21:24 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ev8w2j91b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 15 Dec 2017 02:21:24 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Dec 2017 07:21:22 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 15 Dec 2017 07:21:19 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vBF7LJxl32440478; Fri, 15 Dec 2017 07:21:19 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2278A4051; Fri, 15 Dec 2017 07:15:36 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC957A4040; Fri, 15 Dec 2017 07:15:35 +0000 (GMT) Received: from oc4502181600.ibm.com (unknown [9.79.203.247]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 15 Dec 2017 07:15:35 +0000 (GMT) From: Shilpasri G Bhat To: skiboot@lists.ozlabs.org Date: Fri, 15 Dec 2017 12:51:03 +0530 X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1513322463-24801-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> References: <1513322463-24801-1-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17121507-0012-0000-0000-000005996418 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17121507-0013-0000-0000-000019148296 Message-Id: <1513322463-24801-5-git-send-email-shilpa.bhat@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-12-15_03:, , 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-1712150105 Subject: [Skiboot] [PATCH V2 4/4] sensors: occ: Filter out de-configured sensors X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 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 copies APSS, GPU sensors on platforms that dont have them. The de-configured sensors are copied with 0 sensor values. So filter out the zero'ed environment sensors as they are not present on the system. Signed-off-by: Shilpasri G Bhat --- hw/occ-sensor.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c index bc5085a..e41c850 100644 --- a/hw/occ-sensor.c +++ b/hw/occ-sensor.c @@ -706,6 +706,17 @@ static void add_sensor_node(const char *loc, const char *type, int i, int attr, *phandle = node->phandle; } +static bool check_sensor_sample(struct occ_sensor_data_header *hb, u32 offset) +{ + struct occ_sensor_record *ping, *pong; + + ping = (struct occ_sensor_record *)((u64)hb + hb->reading_ping_offset + + offset); + pong = (struct occ_sensor_record *)((u64)hb + hb->reading_pong_offset + + offset); + return ping->sample || pong->sample; +} + void occ_sensors_init(void) { struct proc_chip *chip; @@ -759,6 +770,9 @@ void occ_sensors_init(void) if (!(md[i].type & HWMON_SENSORS_MASK)) continue; + if (!check_sensor_sample(hb, md[i].reading_offset)) + continue; + if (md[i].location == OCC_SENSOR_LOC_CORE) { int num = parse_entity(md[i].name, NULL);