From: Martin Peres <martin.peres-GANU6spQydw@public.gmane.org>
To: Karol Herbst <nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>,
nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: Re: [PATCH v4 4/6] hwmon: add power consumption
Date: Sun, 21 Feb 2016 23:23:18 +0200 [thread overview]
Message-ID: <56CA2AC6.3040708@free.fr> (raw)
In-Reply-To: <1455988299-2300-5-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
On 20/02/16 19:11, Karol Herbst wrote:
> Signed-off-by: Karol Herbst <nouveau@karolherbst.de>
> ---
> drm/nouveau/include/nvif/device.h | 1 +
> drm/nouveau/nouveau_hwmon.c | 39 +++++++++++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+)
>
> diff --git a/drm/nouveau/include/nvif/device.h b/drm/nouveau/include/nvif/device.h
> index e0ed2f4..bcb9817 100644
> --- a/drm/nouveau/include/nvif/device.h
> +++ b/drm/nouveau/include/nvif/device.h
> @@ -62,6 +62,7 @@ u64 nvif_device_time(struct nvif_device *);
> #define nvxx_gpio(a) nvxx_device(a)->gpio
> #define nvxx_clk(a) nvxx_device(a)->clk
> #define nvxx_i2c(a) nvxx_device(a)->i2c
> +#define nvxx_iccsense(a) nvxx_device(a)->iccsense
> #define nvxx_therm(a) nvxx_device(a)->therm
> #define nvxx_volt(a) nvxx_device(a)->volt
>
> diff --git a/drm/nouveau/nouveau_hwmon.c b/drm/nouveau/nouveau_hwmon.c
> index 8e13467..c4f77f5 100644
> --- a/drm/nouveau/nouveau_hwmon.c
> +++ b/drm/nouveau/nouveau_hwmon.c
> @@ -34,6 +34,7 @@
> #include "nouveau_drm.h"
> #include "nouveau_hwmon.h"
>
> +#include <nvkm/subdev/iccsense.h>
> #include <nvkm/subdev/volt.h>
>
> #if defined(CONFIG_HWMON) || (defined(MODULE) && defined(CONFIG_HWMON_MODULE))
> @@ -543,6 +544,27 @@ nouveau_hwmon_get_in0_label(struct device *d,
> static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO,
> nouveau_hwmon_get_in0_label, NULL, 0);
>
> +static ssize_t
> +nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a,
> + char *buf)
> +{
> + struct drm_device *dev = dev_get_drvdata(d);
> + struct nouveau_drm *drm = nouveau_drm(dev);
> + struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
> + int result = 0, i;
> +
> + for (i = 0; i < iccsense->rail_count; ++i) {
> + int res = nkvm_iccsense_read(iccsense, i);
> + if (res > 0)
> + result += res;
> + }
The code above should be moved to the icc_sense I would say, as we will
likely need
to read the power from other places.
With such function added to the previous patch,
Reviewed-by: Martin Peres <martin.peres@free.fr>
> +
> + return sprintf(buf, "%i\n", result);
> +}
> +
> +static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO,
> + nouveau_hwmon_get_power1_input, NULL, 0);
> +
> static struct attribute *hwmon_default_attributes[] = {
> &sensor_dev_attr_name.dev_attr.attr,
> &sensor_dev_attr_update_rate.dev_attr.attr,
> @@ -579,6 +601,11 @@ static struct attribute *hwmon_in0_attributes[] = {
> NULL
> };
>
> +static struct attribute *hwmon_power_attributes[] = {
> + &sensor_dev_attr_power1_input.dev_attr.attr,
> + NULL
> +};
> +
> static const struct attribute_group hwmon_default_attrgroup = {
> .attrs = hwmon_default_attributes,
> };
> @@ -594,6 +621,9 @@ static const struct attribute_group hwmon_pwm_fan_attrgroup = {
> static const struct attribute_group hwmon_in0_attrgroup = {
> .attrs = hwmon_in0_attributes,
> };
> +static const struct attribute_group hwmon_power_attrgroup = {
> + .attrs = hwmon_power_attributes,
> +};
> #endif
>
> int
> @@ -603,6 +633,7 @@ nouveau_hwmon_init(struct drm_device *dev)
> struct nouveau_drm *drm = nouveau_drm(dev);
> struct nvkm_therm *therm = nvxx_therm(&drm->device);
> struct nvkm_volt *volt = nvxx_volt(&drm->device);
> + struct nvkm_iccsense *iccsense = nvxx_iccsense(&drm->device);
> struct nouveau_hwmon *hwmon;
> struct device *hwmon_dev;
> int ret = 0;
> @@ -662,6 +693,13 @@ nouveau_hwmon_init(struct drm_device *dev)
> goto error;
> }
>
> + if (iccsense && iccsense->rail_count) {
> + ret = sysfs_create_group(&hwmon_dev->kobj,
> + &hwmon_power_attrgroup);
> + if (ret)
> + goto error;
> + }
> +
> hwmon->hwmon = hwmon_dev;
>
> return 0;
> @@ -688,6 +726,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
> sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_pwm_fan_attrgroup);
> sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_fan_rpm_attrgroup);
> sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_in0_attrgroup);
> + sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_attrgroup);
>
> hwmon_device_unregister(hwmon->hwmon);
> }
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
next prev parent reply other threads:[~2016-02-21 21:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-20 17:11 [PATCH v4 0/6] Suppor for various power sensors on GF100+ Karol Herbst
[not found] ` <1455988299-2300-1-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-20 17:11 ` [PATCH v4 1/6] subdev/iccsense: add new subdev for power sensors Karol Herbst
[not found] ` <1455988299-2300-2-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:07 ` Martin Peres
2016-02-20 17:11 ` [PATCH v4 2/6] nvbios/iccsense: add parsing of the SENSE table Karol Herbst
[not found] ` <1455988299-2300-3-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:09 ` Martin Peres
2016-02-20 17:11 ` [PATCH v4 3/6] iccsense: implement for ina209, ina219 and ina3221 Karol Herbst
[not found] ` <1455988299-2300-4-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:21 ` Martin Peres
2016-02-20 17:11 ` [PATCH v4 4/6] hwmon: add power consumption Karol Herbst
[not found] ` <1455988299-2300-5-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:23 ` Martin Peres [this message]
2016-02-20 17:11 ` [PATCH v4 5/6] hwmon: don't require therm to be valid to get any data Karol Herbst
[not found] ` <1455988299-2300-6-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:27 ` Martin Peres
2016-02-20 17:11 ` [PATCH v4 6/6] bios/extdev: also parse v4.1 table Karol Herbst
[not found] ` <1455988299-2300-7-git-send-email-nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org>
2016-02-21 21:28 ` Martin Peres
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=56CA2AC6.3040708@free.fr \
--to=martin.peres-ganu6spqydw@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=nouveau-lIBOoy2+GI7scQ4cX5LuPg@public.gmane.org \
/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.