From: Cedric Le Goater <clg@fr.ibm.com>
To: Guenter Roeck <linux@roeck-us.net>, lm-sensors@lm-sensors.org
Cc: Stewart Smith <stewart@linux.vnet.ibm.com>,
Neelesh Gupta <neelegup@linux.vnet.ibm.com>,
skiboot@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org,
Jean Delvare <jdelvare@suse.de>
Subject: Re: [lm-sensors] [PATCH v3] hwmon: (ibmpowernv) pretty print labels
Date: Wed, 08 Apr 2015 13:33:03 +0000 [thread overview]
Message-ID: <55252E0F.8080200@fr.ibm.com> (raw)
In-Reply-To: <55252C9A.4050505@roeck-us.net>
T24gMDQvMDgvMjAxNSAwMzoyNiBQTSwgR3VlbnRlciBSb2VjayB3cm90ZToKPiBPbiAwNC8wOC8y
MDE1IDEyOjAwIEFNLCBDw6lkcmljIExlIEdvYXRlciB3cm90ZToKPj4gVGhlIG5ldyBPUEFMIGRl
dmljZSB0cmVlIGFkZHMgYSBmZXcgcHJvcGVydGllcyB3aGljaCBjYW4gYmUgdXNlZCB0byBhZGQK
Pj4gZXh0cmEgaW5mb3JtYXRpb24gb24gdGhlIHNlbnNvciBsYWJlbC4KPj4KPj4gSW4gdGhlIGNh
c2Ugb2YgYSBjcHUgY29yZSBzZW5zb3IsIHRoZSBmaXJtd2FyZSBleHBvc2VzIHRoZSBwaHlzaWNh
bAo+PiBpZGVudGlmaWVyIG9mIHRoZSBjb3JlIGluIHRoZSAiaWJtLHBpciIgcHJvcGVydHkuIFRo
ZSBkcml2ZXIKPj4gdHJhbnNsYXRlcyB0aGlzIGlkZW50aWZpZXIgaW4gYSBsaW51eCBjcHUgbnVt
YmVyIGFuZCBwcmludHMgb3V0IGEKPj4gcmFuZ2UgY29ycmVzcG9uZGluZyB0byB0aGUgaGFyZHdh
cmUgdGhyZWFkcyBvZiB0aGUgY29yZSAoYXMgdGhleQo+PiBzaGFyZSB0aGUgc2FtZSBzZW5zb3Ip
Lgo+Pgo+PiBUaGUgbnVtYmVyaW5nIGdpdmVz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yZSBhc3NvY2lhdGVkCj4+ICsgICAg
ICAgICAgICAgKiB3aXRoIGEgY29yZS4gTGV0J3MgcHJpbnQgb3V0IHRoZSByYW5nZSBvZgo+PiAr
ICAgICAgICAgICAgICogY3B1IGlkcyBjb3JyZXNwb25kaW5nIHRvIHRoZSBoYXJkd2FyZQo+PiAr
ICAgICAgICAgICAgICogdGhyZWFkcyBvZiB0aGUgY29yZS4KPj4gKyAgICAgICAgICAgICAqLwo+
PiArICAgICAgICAgICAgbiArPSBzbnByaW50ZihzZGF0YS0+bGFiZWwgKyBuLAo+PiArICAgICAg
ICAgICAgICAgICAgICAgIHNpemVvZihzZGF0YS0+bGFiZWwpIC0gbiwgIiAlZC0lZCIsCj4+ICsg
ICAgICAgICAgICAgICAgICAgICAgY3B1aWQsIGNwdWlkICsgdGhyZWFkc19wZXJfY29yZSAtIDEp
Owo+PiArICAgICAgICBlbHNlCj4+ICsgICAgICAgICAgICBuICs9IHNucHJpbnRmKHNkYXRhLT5s
YWJlbCArIG4sCj4+ICsgICAgICAgICAgICAgICAgICAgICAgc2l6ZW9mKHNkYXRhLT5sYWJlbCkg
LSBuLCAiIHBoeSVkIiwgaWQpOwo+PiArICAgIH0KPj4gKwo+PiArICAgIC8qCj4+ICsgICAgICog
TWVtYnVmZmVyIHByZXR0eSBwcmludAo+PiArICAgICAqLwo+PiArICAgIGlmICghb2ZfcHJvcGVy
dHlfcmVhZF91MzIobnAsICJpYm0sY2hpcC1pZCIsICZpZCkpCj4+ICsgICAgICAgIG4gKz0gc25w
cmludGYoc2RhdGEtPmxhYmVsICsgbiwgc2l6ZW9mKHNkYXRhLT5sYWJlbCkgLSBuLAo+PiArICAg
ICAgICAgICAgICAgICAgIiAlZCIsIGlkICYgMHhmZmZmKTsKPj4gICB9Cj4+Cj4+ICAgc3RhdGlj
IGludCBnZXRfc2Vuc29yX2luZGV4X2F0dHIoY29uc3QgY2hhciAqbmFtZSwgdTMyICppbmRleCwK
Pj4KPj4KPiAKCgpfX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f
XwpsbS1zZW5zb3JzIG1haWxpbmcgbGlzdApsbS1zZW5zb3JzQGxtLXNlbnNvcnMub3JnCmh0dHA6
Ly9saXN0cy5sbS1zZW5zb3JzLm9yZy9tYWlsbWFuL2xpc3RpbmZvL2xtLXNlbnNvcnM
WARNING: multiple messages have this Message-ID (diff)
From: Cedric Le Goater <clg@fr.ibm.com>
To: Guenter Roeck <linux@roeck-us.net>, lm-sensors@lm-sensors.org
Cc: Stewart Smith <stewart@linux.vnet.ibm.com>,
Neelesh Gupta <neelegup@linux.vnet.ibm.com>,
skiboot@lists.ozlabs.org, linuxppc-dev@lists.ozlabs.org,
Jean Delvare <jdelvare@suse.de>
Subject: Re: [PATCH v3] hwmon: (ibmpowernv) pretty print labels
Date: Wed, 08 Apr 2015 15:33:03 +0200 [thread overview]
Message-ID: <55252E0F.8080200@fr.ibm.com> (raw)
In-Reply-To: <55252C9A.4050505@roeck-us.net>
On 04/08/2015 03:26 PM, Guenter Roeck wrote:
> On 04/08/2015 12:00 AM, 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 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 | 43 +++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 43 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,54 @@ 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;
>> +
>> + pr_err("%s: could not find a cpu with physical id 0x%x\n",
>> + __func__, hwcpu);
>
> I like moving this into a function, but I really dislike this error
> message. If the devicetree data is wrong/bad, the log and the console
> will be clogged with that message. And the user will not be able
> to do anything about it.
yes. It is not super useful anyway and it is redundant with the "phy"
prefix below. Do you want me to kill it in a v4 ?
Thanks,
C.
>
> Guenter
>
>> + 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,
>>
>>
>
next prev parent reply other threads:[~2015-04-08 13:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-08 7:00 [lm-sensors] [PATCH v3] hwmon: (ibmpowernv) pretty print labels Cédric Le Goater
2015-04-08 7:00 ` Cédric Le Goater
2015-04-08 13:26 ` [lm-sensors] " Guenter Roeck
2015-04-08 13:26 ` Guenter Roeck
2015-04-08 13:33 ` Cedric Le Goater [this message]
2015-04-08 13:33 ` Cedric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55252E0F.8080200@fr.ibm.com \
--to=clg@fr.ibm.com \
--cc=jdelvare@suse.de \
--cc=linux@roeck-us.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lm-sensors@lm-sensors.org \
--cc=neelegup@linux.vnet.ibm.com \
--cc=skiboot@lists.ozlabs.org \
--cc=stewart@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.