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 2/3] subdev/iccsense: Parse max and crit power level
Date: Sat, 12 Nov 2016 11:55:31 +0100	[thread overview]
Message-ID: <20161112105532.5030-3-karolherbst@gmail.com> (raw)
In-Reply-To: <20161112105532.5030-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

Signed-off-by: Karol Herbst <karolherbst@gmail.com>
---
 drm/nouveau/include/nvkm/subdev/iccsense.h |  3 +++
 drm/nouveau/nvkm/subdev/iccsense/base.c    | 20 ++++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drm/nouveau/include/nvkm/subdev/iccsense.h b/drm/nouveau/include/nvkm/subdev/iccsense.h
index 3c2ddd9..b7a9b04 100644
--- a/drm/nouveau/include/nvkm/subdev/iccsense.h
+++ b/drm/nouveau/include/nvkm/subdev/iccsense.h
@@ -8,6 +8,9 @@ struct nvkm_iccsense {
 	bool data_valid;
 	struct list_head sensors;
 	struct list_head rails;
+
+	u32 power_w_max;
+	u32 power_w_crit;
 };
 
 int gf100_iccsense_new(struct nvkm_device *, int index, struct nvkm_iccsense **);
diff --git a/drm/nouveau/nvkm/subdev/iccsense/base.c b/drm/nouveau/nvkm/subdev/iccsense/base.c
index f0af2a3..fecfa6a 100644
--- a/drm/nouveau/nvkm/subdev/iccsense/base.c
+++ b/drm/nouveau/nvkm/subdev/iccsense/base.c
@@ -26,6 +26,7 @@
 #include <subdev/bios.h>
 #include <subdev/bios/extdev.h>
 #include <subdev/bios/iccsense.h>
+#include <subdev/bios/power_budget.h>
 #include <subdev/i2c.h>
 
 static bool
@@ -216,10 +217,25 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
 {
 	struct nvkm_iccsense *iccsense = nvkm_iccsense(subdev);
 	struct nvkm_bios *bios = subdev->device->bios;
+	struct nvbios_power_budget budget;
 	struct nvbios_iccsense stbl;
-	int i;
+	int i, ret;
 
-	if (!bios || nvbios_iccsense_parse(bios, &stbl) || !stbl.nr_entry)
+	if (!bios)
+		return 0;
+
+	ret = nvbios_power_budget_header(bios, &budget);
+	if (!ret && budget.cap_entry != 0xff) {
+		struct nvbios_power_budget_entry entry;
+		ret = nvbios_power_budget_entry(bios, &budget,
+		                                budget.cap_entry, &entry);
+		if (!ret) {
+			iccsense->power_w_max  = entry.avg_w;
+			iccsense->power_w_crit = entry.max_w;
+		}
+	}
+
+	if (nvbios_iccsense_parse(bios, &stbl) || !stbl.nr_entry)
 		return 0;
 
 	iccsense->data_valid = true;
-- 
2.10.2

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

  parent reply	other threads:[~2016-11-12 10:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-12 10:55 [PATCH 0/3] Expose power budget cap via hwmon Karol Herbst
     [not found] ` <20161112105532.5030-1-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-12 10:55   ` [PATCH 1/3] nvbios/power_budget: Add basic power budget parsing Karol Herbst
     [not found]     ` <20161112105532.5030-2-karolherbst-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-11-12 11:58       ` Pierre Moreau
     [not found]         ` <20161112115805.jzhmo23bexc723ca-WLoDKDh+7sdAfugRpC6u6w@public.gmane.org>
2016-11-12 12:34           ` Karol Herbst
2016-11-12 10:55   ` Karol Herbst [this message]
2016-11-12 10:55   ` [PATCH 3/3] hwmon: expose power_max and power_crit Karol Herbst
  -- strict thread matches above, loose matches on Subject: below --
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 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

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=20161112105532.5030-3-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.