aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_debugfs.c
diff options
context:
space:
mode:
authorJesse Barnes <jbarnes@virtuousgeek.org>2013-08-20 05:29:23 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-23 08:52:25 -0400
commitec013e7f491cceef0e87190a3c6b132ce49f7ce4 (patch)
treebd157fb038274acf22d08daae0f236b645285788 /drivers/gpu/drm/i915/i915_debugfs.c
parente3ce7633ba38a97c2203ab60f381ce1642940328 (diff)
drm/i915: Expose energy counter on SNB+ through debugfs
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> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_debugfs.c')
-rw-r--r--drivers/gpu/drm/i915/i915_debugfs.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 4785d8c14654..236d97e51c3a 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -31,6 +31,7 @@
31#include <linux/slab.h> 31#include <linux/slab.h>
32#include <linux/export.h> 32#include <linux/export.h>
33#include <linux/list_sort.h> 33#include <linux/list_sort.h>
34#include <asm/msr-index.h>
34#include <drm/drmP.h> 35#include <drm/drmP.h>
35#include "intel_drv.h" 36#include "intel_drv.h"
36#include "intel_ringbuffer.h" 37#include "intel_ringbuffer.h"
@@ -1769,6 +1770,27 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
1769 return 0; 1770 return 0;
1770} 1771}
1771 1772
1773static int i915_energy_uJ(struct seq_file *m, void *data)
1774{
1775 struct drm_info_node *node = m->private;
1776 struct drm_device *dev = node->minor->dev;
1777 struct drm_i915_private *dev_priv = dev->dev_private;
1778 u64 power;
1779 u32 units;
1780
1781 if (INTEL_INFO(dev)->gen < 6)
1782 return -ENODEV;
1783
1784 rdmsrl(MSR_RAPL_POWER_UNIT, power);
1785 power = (power & 0x1f00) >> 8;
1786 units = 1000000 / (1 << power); /* convert to uJ */
1787 power = I915_READ(MCH_SECP_NRG_STTS);
1788 power *= units;
1789
1790 seq_printf(m, "%llu", (long long unsigned)power);
1791 return 0;
1792}
1793
1772static int 1794static int
1773i915_wedged_get(void *data, u64 *val) 1795i915_wedged_get(void *data, u64 *val)
1774{ 1796{
@@ -2208,6 +2230,7 @@ static struct drm_info_list i915_debugfs_list[] = {
2208 {"i915_dpio", i915_dpio_info, 0}, 2230 {"i915_dpio", i915_dpio_info, 0},
2209 {"i915_llc", i915_llc, 0}, 2231 {"i915_llc", i915_llc, 0},
2210 {"i915_edp_psr_status", i915_edp_psr_status, 0}, 2232 {"i915_edp_psr_status", i915_edp_psr_status, 0},
2233 {"i915_energy_uJ", i915_energy_uJ, 0},
2211}; 2234};
2212#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list) 2235#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
2213 2236