* [PATCH] drm/i915: Expose energy counter on SNB+ through debugfs
@ 2013-08-20 9:29 Chris Wilson
2013-08-20 13:16 ` Daniel Vetter
0 siblings, 1 reply; 2+ messages in thread
From: Chris Wilson @ 2013-08-20 9:29 UTC (permalink / raw)
To: intel-gfx; +Cc: Ben Widawsky
From: Jesse Barnes <jbarnes@virtuousgeek.org>
On SNB and IVB, there's an MSR (also exposed through MCHBAR) we can use
to read out the amount of energy used over time. Expose this in sysfs
to make it easy to do power comparisons with different configurations.
If the platform supports it, the file will show up under the
drm/card0/power subdirectory of the PCI device in sysfs as gt_energy_uJ.
The value in the file is a running total of energy (in microjoules)
consumed by the graphics device.
v2: move to sysfs (Ben, Daniel)
expose a simple value (Chris)
drop unrelated hunk (Ben)
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
v3: by Ben
Tied it into existing rc6 sysfs entries and named that a more generic
"power attrs." Fixed rebase conflicts.
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
v4: Since RAPL is a real driver that already exists to serve power
monitoring, place our entry in debugfs. This gives me a fallback
location for systems that do not expose it otherwise.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/gpu/drm/i915/i915_debugfs.c | 23 +++++++++++++++++++++++
drivers/gpu/drm/i915/i915_reg.h | 2 ++
2 files changed, 25 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index f716f57..721604e 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -31,6 +31,7 @@
#include <linux/slab.h>
#include <linux/export.h>
#include <linux/list_sort.h>
+#include <asm/msr-index.h>
#include <drm/drmP.h>
#include "intel_drv.h"
#include "intel_ringbuffer.h"
@@ -1817,6 +1818,27 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
return 0;
}
+static int i915_energy_uJ(struct seq_file *m, void *data)
+{
+ struct drm_info_node *node = m->private;
+ struct drm_device *dev = node->minor->dev;
+ struct drm_i915_private *dev_priv = dev->dev_private;
+ u64 power;
+ u32 units;
+
+ if (INTEL_INFO(dev)->gen < 6)
+ return -ENODEV;
+
+ rdmsrl(MSR_RAPL_POWER_UNIT, power);
+ power = (power & 0x1f00) >> 8;
+ units = 1000000 / (1 << power); /* convert to uJ */
+ power = I915_READ(MCH_SECP_NRG_STTS);
+ power *= units;
+
+ seq_printf(m, "%llu", (long long unsigned)power);
+ return 0;
+}
+
static int
i915_wedged_get(void *data, u64 *val)
{
@@ -2256,6 +2278,7 @@ static struct drm_info_list i915_debugfs_list[] = {
{"i915_dpio", i915_dpio_info, 0},
{"i915_llc", i915_llc, 0},
{"i915_edp_psr_status", i915_edp_psr_status, 0},
+ {"i915_energy_uJ", i915_energy_uJ, 0},
};
#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 730510d..3f5bddd 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1452,6 +1452,8 @@
#define MCH_SSKPD_WM0_MASK 0x3f
#define MCH_SSKPD_WM0_VAL 0xc
+#define MCH_SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c)
+
/* Clocking configuration register */
#define CLKCFG 0x10c00
#define CLKCFG_FSB_400 (5 << 0) /* hrawclk 100 */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/i915: Expose energy counter on SNB+ through debugfs
2013-08-20 9:29 [PATCH] drm/i915: Expose energy counter on SNB+ through debugfs Chris Wilson
@ 2013-08-20 13:16 ` Daniel Vetter
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2013-08-20 13:16 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx, Ben Widawsky
On Tue, Aug 20, 2013 at 10:29:23AM +0100, Chris Wilson wrote:
> From: Jesse Barnes <jbarnes@virtuousgeek.org>
>
> On SNB and IVB, there's an MSR (also exposed through MCHBAR) we can use
> to read out the amount of energy used over time. Expose this in sysfs
> to make it easy to do power comparisons with different configurations.
>
> If the platform supports it, the file will show up under the
> drm/card0/power subdirectory of the PCI device in sysfs as gt_energy_uJ.
> The value in the file is a running total of energy (in microjoules)
> consumed by the graphics device.
>
> v2: move to sysfs (Ben, Daniel)
> expose a simple value (Chris)
> drop unrelated hunk (Ben)
>
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
>
> v3: by Ben
> Tied it into existing rc6 sysfs entries and named that a more generic
> "power attrs." Fixed rebase conflicts.
>
> Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
>
> v4: Since RAPL is a real driver that already exists to serve power
> monitoring, place our entry in debugfs. This gives me a fallback
> location for systems that do not expose it otherwise.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Yeah, makes sense to keep this handy for our own tooling. Queued for
-next, thanks for the patch.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-08-20 13:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 9:29 [PATCH] drm/i915: Expose energy counter on SNB+ through debugfs Chris Wilson
2013-08-20 13:16 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox