From patchwork Tue Apr 7 14:45:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 458694 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3C9C014021A for ; Wed, 8 Apr 2015 00:47:33 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id CC0F31A0BF5 for ; Wed, 8 Apr 2015 00:47:32 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 835811A057D for ; Wed, 8 Apr 2015 00:46:14 +1000 (AEST) Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Apr 2015 15:46:10 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Apr 2015 15:46:07 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3CC7E17D8042; Tue, 7 Apr 2015 15:46:40 +0100 (BST) Received: from d06av08.portsmouth.uk.ibm.com (d06av08.portsmouth.uk.ibm.com [9.149.37.249]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t37Ek7q953805292; Tue, 7 Apr 2015 14:46:07 GMT Received: from d06av08.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t37Ek64h020098; Tue, 7 Apr 2015 08:46:07 -0600 Received: from hermes.kaod.org (sig-9-79-57-245.de.ibm.com [9.79.57.245]) by d06av08.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t37Ek5KK020083; Tue, 7 Apr 2015 08:46:05 -0600 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: lm-sensors@lm-sensors.org Date: Tue, 7 Apr 2015 16:45:56 +0200 Message-Id: <1428417956-28617-1-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <5523ECC4.9010609@fr.ibm.com> References: <5523ECC4.9010609@fr.ibm.com> MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15040714-0021-0000-0000-0000037D640B Cc: Jean Delvare , skiboot@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org, Guenter Roeck Subject: [Skiboot] [PATCH 4/4] hwmon: (ibmpowernv) pretty print labels X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 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" The new OPAL device tree adds a few properties which can be used to add extra information on the sensor label. In the case of a cpu core sensor, the firmware exposes the physical identifier of the core in the "ibm,pir" property. The driver translates this identifier in a linux cpu number and prints out a range corresponding to the hardware threads of the core (as they share the same sensor). The numbering gives a hint on the localization of the core in the system (which socket, which chip). Signed-off-by: Cédric Le Goater --- Changes since v1: - check cpu validity before printing out the attribute label. if invalid, use a "phy" prefix to distinguish a linux cpu number from a physical cpu number. drivers/hwmon/ibmpowernv.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) Index: linux.git/drivers/hwmon/ibmpowernv.c =================================================================== --- linux.git.orig/drivers/hwmon/ibmpowernv.c +++ linux.git/drivers/hwmon/ibmpowernv.c @@ -113,9 +113,43 @@ static ssize_t show_label(struct device static void __init make_sensor_label(struct device_node *np, struct sensor_data *sdata, const char *label) { + u32 id; size_t n; n = snprintf(sdata->label, sizeof(sdata->label), "%s", label); + + /* + * Core temp pretty print + */ + if (!of_property_read_u32(np, "ibm,pir", &id)) { + int i = -1; + + for_each_possible_cpu(i) + if (paca[i].hw_cpu_id == id) + break; + + if (i != -1) + /* + * The digital thermal sensors are associated + * with a core. Let's print out the range of + * cpu ids corresponding to the hardware + * threads of the core. + */ + n += snprintf(sdata->label + n, + sizeof(sdata->label) - n, + " %d-%d", i, i+7); + else + n += snprintf(sdata->label + n, + sizeof(sdata->label) - n, + " phy%d", id); + } + + /* + * Membuffer pretty print + */ + if (!of_property_read_u32(np, "ibm,chip-id", &id)) + n += snprintf(sdata->label + n, sizeof(sdata->label) - n, + " %d", id & 0xffff); } static int get_sensor_index_attr(const char *name, u32 *index,