* [lm-sensors] [PATCH v4] hwmon: (ibmpowernv) pretty print labels
@ 2015-04-08 13:42 ` Cédric Le Goater
0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2015-04-08 13:42 UTC (permalink / raw)
To: lm-sensors
Cc: Stewart Smith, Cédric Le Goater, Jean Delvare, Neelesh Gupta,
skiboot, linuxppc-dev, Guenter Roeck
VGhlIG5ldyBPUEFMIGRldmljZSB0cmVlIGFkZHMgYSBmZXcgcHJvcGVydGllcyB3aGljaCBjYW4g
YmUgdXNlZCB0byBhZGQKZXh0cmEgaW5mb3JtYXRpb24gb24gdGhlIHNlbnNvciBsYWJlbC4KCklu
IHRoZSBjYXNlIG9mIGEgY3B1IGNvcmUgc2Vuc29yLCB0aGUgZmlybXdhcmUgZXhwb3NlcyB0aGUg
cGh5c2ljYWwgCmlkZW50aWZpZXIgb2YgdGhlIGNvcmUgaW4gdGhlICJpYm0scGlyIiBwcm9wZXJ0
eS4gVGhlIGRyaXZlciAKdHJhbnNsYXRlcyB0aGlzIGlkZW50aWZpZXIgaW4gYSBsaW51eCBjcHUg
bnVtYmVyIGFuZCBwcmludHMgb3V0IGEgCnJhbmdlIGNvcnJlc3BvbmRpbmcgdG8gdGhlIGhhcmR3
YXJlIHRocmVhZHMgb2YgdGhlIGNvcmUgKGFzIHRoZXkKc2hhcmUgdGhlIHNhbWUgc2Vuc29yKS4K
ClRoZSBudW1iZXJpbmcgZ2l2ZXMgYSBoaW50IG9uIHRoZSBsb2NhbGl6YXRpb24gb2YgdGhlIGNv
cmUgaW4gdGhlIApzeXN0ZW0gKHdoaWNoIHNvY2tldCwgd2hpY2ggY2hpcCkuIAoKU2lnbmVkLW9m
Zi1ieTogQ8OpZHJpYyBMZSBHb2F0ZXIgPGNsZ0Bmci5pYm0uY29tPgotLS0KCiBDaGFuZ2VzIHNp
bmNlIHYzOgoKIC0gcmVtb3ZlZCBlcnJvciBtZXNzYWdlIGluIGNhc2Ugb2YgYW4gdW5rbm93biBw
aH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gdGhlIGNvcmUuCisJCQkgKi8KKwkJ
CW4gKz0gc25wcmludGYoc2RhdGEtPmxhYmVsICsgbiwKKwkJCQkgICAgICBzaXplb2Yoc2RhdGEt
PmxhYmVsKSAtIG4sICIgJWQtJWQiLAorCQkJCSAgICAgIGNwdWlkLCBjcHVpZCArIHRocmVhZHNf
cGVyX2NvcmUgLSAxKTsKKwkJZWxzZQorCQkJbiArPSBzbnByaW50ZihzZGF0YS0+bGFiZWwgKyBu
LAorCQkJCSAgICAgIHNpemVvZihzZGF0YS0+bGFiZWwpIC0gbiwgIiBwaHklZCIsIGlkKTsKKwl9
CisKKwkvKgorCSAqIE1lbWJ1ZmZlciBwcmV0dHkgcHJpbnQKKwkgKi8KKwlpZiAoIW9mX3Byb3Bl
cnR5X3JlYWRfdTMyKG5wLCAiaWJtLGNoaXAtaWQiLCAmaWQpKQorCQluICs9IHNucHJpbnRmKHNk
YXRhLT5sYWJlbCArIG4sIHNpemVvZihzZGF0YS0+bGFiZWwpIC0gbiwKKwkJCSAgICAgICIgJWQi
LCBpZCAmIDB4ZmZmZik7CiB9CiAKIHN0YXRpYyBpbnQgZ2V0X3NlbnNvcl9pbmRleF9hdHRyKGNv
bnN0IGNoYXIgKm5hbWUsIHUzMiAqaW5kZXgsCgoKX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fX19fX18KbG0tc2Vuc29ycyBtYWlsaW5nIGxpc3QKbG0tc2Vuc29yc0Bs
bS1zZW5zb3JzLm9yZwpodHRwOi8vbGlzdHMubG0tc2Vuc29ycy5vcmcvbWFpbG1hbi9saXN0aW5m
by9sbS1zZW5zb3Jz
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v4] hwmon: (ibmpowernv) pretty print labels
@ 2015-04-08 13:42 ` Cédric Le Goater
0 siblings, 0 replies; 4+ messages in thread
From: Cédric Le Goater @ 2015-04-08 13:42 UTC (permalink / raw)
To: lm-sensors
Cc: Stewart Smith, Cédric Le Goater, Jean Delvare, Neelesh Gupta,
skiboot, linuxppc-dev, Guenter Roeck
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 <clg@fr.ibm.com>
---
Changes since v3:
- removed error message in case of an unknown physical cpu number
Changes since v2:
- fix bogus logical cpu retrieval
- use 'threads_per_core' to print out cpu range
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 | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
Index: linux.git/drivers/hwmon/ibmpowernv.c
===================================================================
--- linux.git.orig/drivers/hwmon/ibmpowernv.c
+++ linux.git/drivers/hwmon/ibmpowernv.c
@@ -30,6 +30,7 @@
#include <linux/platform_device.h>
#include <asm/opal.h>
#include <linux/err.h>
+#include <asm/cputhreads.h>
#define MAX_ATTR_LEN 32
#define MAX_LABEL_LEN 64
@@ -110,12 +111,52 @@ static ssize_t show_label(struct device
return sprintf(buf, "%s\n", sdata->label);
}
+static int __init get_logical_cpu(unsigned int hwcpu)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu)
+ if (get_hard_smp_processor_id(cpu) == hwcpu)
+ return cpu;
+
+ return -ENOENT;
+}
+
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 cpuid = get_logical_cpu(id);
+
+ if (cpuid >= 0)
+ /*
+ * 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",
+ cpuid, cpuid + threads_per_core - 1);
+ 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,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [lm-sensors] [v4] hwmon: (ibmpowernv) pretty print labels
2015-04-08 13:42 ` Cédric Le Goater
@ 2015-04-08 15:21 ` Guenter Roeck
-1 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2015-04-08 15:21 UTC (permalink / raw)
To: Cédric Le Goater
Cc: Stewart Smith, lm-sensors, Neelesh Gupta, skiboot, linuxppc-dev
On Wed, Apr 08, 2015 at 03:42:07PM +0200, Cédric Le Goater wrote:
> 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 <clg@fr.ibm.com>
> ---
>
> Changes since v3:
>
> - removed error message in case of an unknown physical cpu number
>
> Changes since v2:
>
> - fix bogus logical cpu retrieval
> - use 'threads_per_core' to print out cpu range
>
> 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 | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> Index: linux.git/drivers/hwmon/ibmpowernv.c
> ===================================================================
> --- linux.git.orig/drivers/hwmon/ibmpowernv.c
> +++ linux.git/drivers/hwmon/ibmpowernv.c
> @@ -30,6 +30,7 @@
> #include <linux/platform_device.h>
> #include <asm/opal.h>
> #include <linux/err.h>
> +#include <asm/cputhreads.h>
>
> #define MAX_ATTR_LEN 32
> #define MAX_LABEL_LEN 64
> @@ -110,12 +111,52 @@ static ssize_t show_label(struct device
> return sprintf(buf, "%s\n", sdata->label);
> }
>
> +static int __init get_logical_cpu(unsigned int hwcpu)
> +{
> + int cpu;
> +
> + for_each_possible_cpu(cpu)
> + if (get_hard_smp_processor_id(cpu) == hwcpu)
drivers/hwmon/ibmpowernv.c: In function 'get_logical_cpu':
drivers/hwmon/ibmpowernv.c:119:38: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
if (get_hard_smp_processor_id(cpu) == hwcpu)
^
Guenter
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [v4] hwmon: (ibmpowernv) pretty print labels
@ 2015-04-08 15:21 ` Guenter Roeck
0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2015-04-08 15:21 UTC (permalink / raw)
To: Cédric Le Goater
Cc: Stewart Smith, lm-sensors, Neelesh Gupta, skiboot, linuxppc-dev
On Wed, Apr 08, 2015 at 03:42:07PM +0200, Cédric Le Goater wrote:
> 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 <clg@fr.ibm.com>
> ---
>
> Changes since v3:
>
> - removed error message in case of an unknown physical cpu number
>
> Changes since v2:
>
> - fix bogus logical cpu retrieval
> - use 'threads_per_core' to print out cpu range
>
> 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 | 41 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 41 insertions(+)
>
> Index: linux.git/drivers/hwmon/ibmpowernv.c
> ===================================================================
> --- linux.git.orig/drivers/hwmon/ibmpowernv.c
> +++ linux.git/drivers/hwmon/ibmpowernv.c
> @@ -30,6 +30,7 @@
> #include <linux/platform_device.h>
> #include <asm/opal.h>
> #include <linux/err.h>
> +#include <asm/cputhreads.h>
>
> #define MAX_ATTR_LEN 32
> #define MAX_LABEL_LEN 64
> @@ -110,12 +111,52 @@ static ssize_t show_label(struct device
> return sprintf(buf, "%s\n", sdata->label);
> }
>
> +static int __init get_logical_cpu(unsigned int hwcpu)
> +{
> + int cpu;
> +
> + for_each_possible_cpu(cpu)
> + if (get_hard_smp_processor_id(cpu) == hwcpu)
drivers/hwmon/ibmpowernv.c: In function 'get_logical_cpu':
drivers/hwmon/ibmpowernv.c:119:38: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
if (get_hard_smp_processor_id(cpu) == hwcpu)
^
Guenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-08 15:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-08 13:42 [lm-sensors] [PATCH v4] hwmon: (ibmpowernv) pretty print labels Cédric Le Goater
2015-04-08 13:42 ` Cédric Le Goater
2015-04-08 15:21 ` [lm-sensors] [v4] " Guenter Roeck
2015-04-08 15:21 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.