All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karol Herbst <karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 3/3] hwmon: expose power_max and power_crit
Date: Mon, 24 Oct 2016 23:11:13 +0200	[thread overview]
Message-ID: <20161024211113.5876-4-karolherbst@gmail.com> (raw)
In-Reply-To: <20161024211113.5876-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
---
 drm/nouveau/nouveau_hwmon.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/drm/nouveau/nouveau_hwmon.c b/drm/nouveau/nouveau_hwmon.c
index 71f764b..3d4672a 100644
--- a/drm/nouveau/nouveau_hwmon.c
+++ b/drm/nouveau/nouveau_hwmon.c
@@ -596,6 +596,32 @@ nouveau_hwmon_get_power1_input(struct device *d, struct device_attribute *a,
 static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO,
 			  nouveau_hwmon_get_power1_input, NULL, 0);
 
+static ssize_t
+nouveau_hwmon_get_power1_max(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);
+	return sprintf(buf, "%i\n", iccsense->power_w_max);
+}
+
+static SENSOR_DEVICE_ATTR(power1_max, S_IRUGO,
+			  nouveau_hwmon_get_power1_max, NULL, 0);
+
+static ssize_t
+nouveau_hwmon_get_power1_crit(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);
+	return sprintf(buf, "%i\n", iccsense->power_w_crit);
+}
+
+static SENSOR_DEVICE_ATTR(power1_crit, S_IRUGO,
+			  nouveau_hwmon_get_power1_crit, NULL, 0);
+
 static struct attribute *hwmon_default_attributes[] = {
 	&sensor_dev_attr_name.dev_attr.attr,
 	&sensor_dev_attr_update_rate.dev_attr.attr,
@@ -639,6 +665,12 @@ static struct attribute *hwmon_power_attributes[] = {
 	NULL
 };
 
+static struct attribute *hwmon_power_caps_attributes[] = {
+	&sensor_dev_attr_power1_max.dev_attr.attr,
+	&sensor_dev_attr_power1_crit.dev_attr.attr,
+	NULL
+};
+
 static const struct attribute_group hwmon_default_attrgroup = {
 	.attrs = hwmon_default_attributes,
 };
@@ -657,6 +689,9 @@ static const struct attribute_group hwmon_in0_attrgroup = {
 static const struct attribute_group hwmon_power_attrgroup = {
 	.attrs = hwmon_power_attributes,
 };
+static const struct attribute_group hwmon_power_caps_attrgroup = {
+	.attrs = hwmon_power_caps_attributes,
+};
 #endif
 
 int
@@ -728,8 +763,16 @@ nouveau_hwmon_init(struct drm_device *dev)
 	if (iccsense && iccsense->data_valid && !list_empty(&iccsense->rails)) {
 		ret = sysfs_create_group(&hwmon_dev->kobj,
 					 &hwmon_power_attrgroup);
+
 		if (ret)
 			goto error;
+
+		if (iccsense->power_w_max && iccsense->power_w_crit) {
+			ret = sysfs_create_group(&hwmon_dev->kobj,
+						 &hwmon_power_caps_attrgroup);
+			if (ret)
+				goto error;
+		}
 	}
 
 	hwmon->hwmon = hwmon_dev;
@@ -759,6 +802,7 @@ nouveau_hwmon_fini(struct drm_device *dev)
 		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);
+		sysfs_remove_group(&hwmon->hwmon->kobj, &hwmon_power_caps_attrgroup);
 
 		hwmon_device_unregister(hwmon->hwmon);
 	}
-- 
2.10.0

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

  parent reply	other threads:[~2016-10-24 21:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-24 21:11 RFC [PATCH 0/3] Expose power budget cap via hwmon Karol Herbst
     [not found] ` <20161024211113.5876-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-24 21:11   ` [PATCH 1/3] nvbios/power_budget: Add basic power budget parsing Karol Herbst
     [not found]     ` <20161024211113.5876-2-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-25  5:25       ` Martin Peres
     [not found]         ` <992054de-6e21-0edb-ade2-ab135787d461-GANU6spQydw@public.gmane.org>
2016-10-25  6:04           ` Karol Herbst
2016-10-24 21:11   ` [PATCH 2/3] subdev/iccsense: Parse max and crit power level Karol Herbst
     [not found]     ` <20161024211113.5876-3-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-25  5:28       ` Martin Peres
     [not found]         ` <e62aa5a5-d856-4e6c-7fba-d56043ba498f-GANU6spQydw@public.gmane.org>
2016-10-25  6:06           ` Karol Herbst
2016-10-24 21:11   ` Karol Herbst [this message]
     [not found]     ` <20161024211113.5876-4-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-25  5:33       ` [PATCH 3/3] hwmon: expose power_max and power_crit Martin Peres
     [not found]         ` <a270c96c-d792-8dd1-eaea-b63fe3a61e3a-GANU6spQydw@public.gmane.org>
2016-10-25  6:22           ` Karol Herbst
2016-10-25  5:23   ` RFC [PATCH 0/3] Expose power budget cap via hwmon Martin Peres
  -- strict thread matches above, loose matches on Subject: below --
2016-11-12 10:55 Karol Herbst
     [not found] ` <20161112105532.5030-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-12 10:55   ` [PATCH 3/3] hwmon: expose power_max and power_crit Karol Herbst

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=20161024211113.5876-4-karolherbst@gmail.com \
    --to=karolherbst-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@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.