drm/i915: add energy counter support for IVB
Subsystems (2)
PATCH 1/1 drm/i915: add energy counter support for IVB
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 debugfs to make it easy to do power comparisons with different configurations.
drivers/gpu/drm/i915/i915_debugfs.c +38 -0
@@ -1897,6 +1897,41 @@ static const struct file_operations i915_cache_sharing_fops = { .llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ + +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp); +else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before dev->dev_private is * allocated we need to hook into the minor for release. */ static int
@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[] = { {"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)
@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) 1, minor);drm_debugfs_remove_files ((struct drm_info_list *) &i915_ring_stop_fops,1 , minor); +drm_debugfs_remove_files ((struct drm_info_list *) &i915_error_state_fops, + 1, minor); }#endif /* CONFIG_DEBUG_FS */
drivers/gpu/drm/i915/i915_drv.h +2 -0
@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;
drivers/gpu/drm/i915/i915_reg.h +2 -0
@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4) +#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006
Quoted 3 lines · On Tue, 19 Jun 2012 13:20:50 -0700 Jesse Barnes <[email protected]>…
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 debugfs to make it easy to do power comparisons with different configurations.
I'd like some more explanation of why this belongs in i915. Furthermore, it seems like something which belongs in sysfs, not debugfs.
Quoted 96 lines
Signed-off-by Jesse Barnes <[email protected]>drivers/gpu/drm/i915/i915_debugfs.c +38
-0@@ -1897,6 +1897,41 @@ static const struct file_operations i915_cache_sharing_fops = { .llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ + +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp); +else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before dev->dev_private is * allocated we need to hook into the minor for release. */ static int@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[] = { {"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) 1, minor);drm_debugfs_remove_files ((struct drm_info_list *) &i915_ring_stop_fops,1 , minor); +drm_debugfs_remove_files ((struct drm_info_list *) &i915_error_state_fops, + 1, minor); }#endif /* CONFIG_DEBUG_FS */ drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;drivers/gpu/drm/i915/i915_reg.h +2
-0@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4) +#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 110 lines · Ben Widawsky
Quoted 1 line · On Tue, 19 Jun 2012 13:20:50 -0700 Jesse Barnes <[email protected]>…
On SNB and IVB, there's an MSR (also exposed through MCHBAR) we can
use
Quoted 1 line
to read out the amount of energy used over time. Expose this in
debugfs
Quoted 1 line
to make it easy to do power comparisons with different
configurations.
I'd like some more explanation of why this belongs in i915. Furthermore,
it seems like something which belongs in sysfs, not debugfs.Review
Quoted 4 lines
Signed-off-by Jesse Barnes <[email protected]>(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_debugfs.cdrivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations
Quoted 4 lines
index c0b7688..c8998b4 100644
drivers/gpu/drm/i915/i915_debugfs.c +0
-0@@ -1897,6 +1897,41 @@ static const struct file_operations
i915_cache_sharing_fops= {Quoted 29 lines
drivers/gpu/drm/i915/i915_debugfs.c +26
-0.llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ + +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp);drivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations i915_cache_sharing_fops = {
Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +9
-0+else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before
dev->dev_privateisdrivers/gpu/drm/i915/i915_debugfs.c static struct drm_info_list i915_debugfs_list[]
Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-0* allocated we need to hook into the minor for release. */ static int@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[]= {
drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor
Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +1
-0{"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor*minor)
drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor · line 2139
Quoted 2 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-01, minor); drm_debugfs_remove_files((struct drm_info_list *)
&i915_ring_stop_fops,drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor · line 2141
Quoted 2 lines
drivers/gpu/drm/i915/i915_debugfs.c +1
-01, minor); + drm_debugfs_remove_files((struct drm_info_list *)
&i915_error_state_fops,Review
Quoted 5 lines
drivers/gpu/drm/i915/i915_debugfs.c +1
-0+ 1, minor); }#endif /* CONFIG_DEBUG_FS */ (quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.hReview
Quoted 13 lines
index 11c7a6a..fb07415 100644
drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hQuoted 7 lines
index 0f45a18..b7d1310 100644
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4)
Quoted 14 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 1 line
Ben Widawsky, Intel Open Source Technology Center
The power reported here is for the GT, so I think i915 is appropriate. As for sysfs vs debugfs, I'm a wimp and don't want to define a new ABI.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 79 lines · On Tue, 19 Jun 2012 17:59:13 -0700 Jesse Barnes <[email protected]>…
Quoted 77 lines · Ben Widawsky
Quoted 1 line · On Tue, 19 Jun 2012 13:20:50 -0700 Jesse Barnes <[email protected]>…
On SNB and IVB, there's an MSR (also exposed through MCHBAR) we can
use
Quoted 1 line
to read out the amount of energy used over time. Expose this in
debugfs
Quoted 1 line
to make it easy to do power comparisons with different
configurations.
I'd like some more explanation of why this belongs in i915. Furthermore,
it seems like something which belongs in sysfs, not debugfs.Review
Quoted 4 lines
Signed-off-by Jesse Barnes <[email protected]>(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_debugfs.cdrivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations
Quoted 4 lines
index c0b7688..c8998b4 100644
drivers/gpu/drm/i915/i915_debugfs.c +0
-0@@ -1897,6 +1897,41 @@ static const struct file_operations
i915_cache_sharing_fops= {Quoted 29 lines
drivers/gpu/drm/i915/i915_debugfs.c +26
-0.llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ + +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp);drivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations i915_cache_sharing_fops = {
Quoted 10 lines
drivers/gpu/drm/i915/i915_debugfs.c +9
-0+else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before
dev->dev_privateisdrivers/gpu/drm/i915/i915_debugfs.c static struct drm_info_list i915_debugfs_list[]
Quoted 3 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-0* allocated we need to hook into the minor for release. */ static int@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[]= {
drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor
Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c +1
-0{"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor*minor)
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor · line 2139
Quoted 2 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-01, minor); drm_debugfs_remove_files((struct drm_info_list *)
&i915_ring_stop_fops,drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor · line 2141
Quoted 2 lines
drivers/gpu/drm/i915/i915_debugfs.c +1
-01, minor); + drm_debugfs_remove_files((struct drm_info_list *)
&i915_error_state_fops,drivers/gpu/drm/i915/i915_debugfs.c void i915_debugfs_cleanup(struct drm_minor *minor) · line 2142
Quoted 1 line
drivers/gpu/drm/i915/i915_debugfs.c +1
-0+ 1, minor);
What is up with this hunk?
Quoted 41 lines
Quoted 26 lines
Review
Quoted 4 lines
drivers/gpu/drm/i915/i915_debugfs.c +0
-0}#endif /* CONFIG_DEBUG_FS */ (quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_drv.hReview
Quoted 13 lines
index 11c7a6a..fb07415 100644
drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;(quoted diff) +0
-0
b/drivers/gpu/drm/i915/i915_reg.hQuoted 7 lines
index 0f45a18..b7d1310 100644
drivers/gpu/drm/i915/i915_reg.h +0
-0@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4)Quoted 14 lines
Quoted 9 lines
drivers/gpu/drm/i915/i915_reg.h +2
-0+#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Quoted 1 line
The power reported here is for the GT, so I think i915 is appropriate. As for sysfs vs debugfs, I'm a wimp and don't want to define a new ABI.
Ah, okay the MSR just give the units. I apologize for reading over it too quickly.
Signature · 1 line
Ben Widawsky, Intel Open Source Technology Center
Jani Nikula
maintainerQuoted 41 lines · Jesse Barnes
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 debugfs to make it easy to do power comparisons with different configurations.
Signed-off-by Jesse Barnes <[email protected]>drivers/gpu/drm/i915/i915_debugfs.c +26
-0@@ -1897,6 +1897,41 @@ static const struct file_operations i915_cache_sharing_fops = { .llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ + +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp);
Quoted 1 line
From the nitpickery dept.: I think that's off-by-one. But nobody will
ever notice from the output. ;)
Jani.
Quoted 59 lines
drivers/gpu/drm/i915/i915_debugfs.c +12
-0+else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before dev->dev_private is * allocated we need to hook into the minor for release. */ static int@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[] = { {"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) 1, minor);drm_debugfs_remove_files ((struct drm_info_list *) &i915_ring_stop_fops,1 , minor); +drm_debugfs_remove_files ((struct drm_info_list *) &i915_error_state_fops, + 1, minor); }#endif /* CONFIG_DEBUG_FS */ drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;drivers/gpu/drm/i915/i915_reg.h +2
-0@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4) +#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 36 lines · Jani Nikula
Quoted 35 lines · Jesse Barnes
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 debugfs to make it easy to do power comparisons with different configurations.
Signed-off-by Jesse Barnes <[email protected]>drivers/gpu/drm/i915/i915_debugfs.c +21
-0@@ -1897,6 +1897,41 @@ static const struct file_operations i915_cache_sharing_fops = { .llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */
Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations i915_cache_sharing_fops = { · line 1925
Quoted 5 lines
drivers/gpu/drm/i915/i915_debugfs.c +5
-0+ +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp);From the nitpickery dept.: I think that's off-by-one. But nobody will ever notice from the output. ;)
And from the bikeshed departement: Can't we just print a running number? I know, substraction is bloody hard, but for anything else than total power consumption (e.g. graphing power over time) the running thing is imo simpler. We've had the same discussion for the rc6 sysfs residency timers and concluded (after Arjan yelled at us) that doing the substraction in userspace is better, least it allows multiple userspace tools to read this.
-Daniel
Quoted 67 lines
Jani.
Quoted 55 lines
drivers/gpu/drm/i915/i915_debugfs.c +12
-0+else + diff = val - dev_priv->last_secp; + dev_priv->last_secp = val; +seq_printf (m,"Energy since last read: %u uJ\n" , diff * units); +mutex_unlock (&dev->struct_mutex); + +return 0 ; +} +/* As the drm_debugfs_init() routines are called before dev->dev_private is * allocated we need to hook into the minor for release. */ static int@@ -2035,6 +2070,7 @@ static struct drm_info_list i915_debugfs_list[] = { {"i915_swizzle_info", i915_swizzle_info, 0}, {"i915_ppgtt_info", i915_ppgtt_info, 0}, {"i915_dpio", i915_dpio_info, 0}, + {"i915_energy", i915_energy_status, 0}, };#define I915_DEBUGFS_ENTRIES ARRAY_SIZE(i915_debugfs_list)@@ -2102,6 +2138,8 @@ void i915_debugfs_cleanup(struct drm_minor *minor) 1, minor);drm_debugfs_remove_files ((struct drm_info_list *) &i915_ring_stop_fops,1 , minor); +drm_debugfs_remove_files ((struct drm_info_list *) &i915_error_state_fops, + 1, minor); }#endif /* CONFIG_DEBUG_FS */ drivers/gpu/drm/i915/i915_drv.h +2
-0@@ -802,6 +802,8 @@ typedef struct drm_i915_private {u8 corr;spinlock_t *mchdev_lock; +u32 last_secp; +enum no_fbc_reason no_fbc_reason;struct drm_mm_node *compressed_fb;drivers/gpu/drm/i915/i915_reg.h +2
-0@@ -1219,6 +1219,8 @@#define CLKCFG_MEM_800 (3 << 4)#define CLKCFG_MEM_MASK (7 << 4) +#define SECP_NRG_STTS (MCHBAR_MIRROR_BASE_SNB + 0x592c) +#define TSC1 0x11001#define TSE (1<<0)#define TR1 0x11006Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Mail: [email protected] Mobile: +41 (0)79 365 57 48
Quoted 46 lines · On Wed, 20 Jun 2012 09:38:25 +0200 Daniel Vetter <[email protected]> wrote:
Quoted 36 lines · Jani Nikula
Quoted 35 lines · Jesse Barnes
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 debugfs to make it easy to do power comparisons with different configurations.
Signed-off-by Jesse Barnes <[email protected]>drivers/gpu/drm/i915/i915_debugfs.c +21
-0@@ -1897,6 +1897,41 @@ static const struct file_operations i915_cache_sharing_fops = { .llseek = default_llseek, }; +#define MSR_IA32_PACKAGE_POWER_SKU_UNIT 0x00000606 + +static int +i915_energy_status (struct seq_file *m,void *data) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +struct drm_i915_private *dev_priv = dev->dev_private; +u64 ppsu; +u32 val, diff, units; + +if (!(IS_GEN6 (dev) ||IS_GEN7 (dev))) { +seq_printf (m,"Unsupported platform\n" ); +return 0 ; + } + +rdmsrl (MSR_IA32_PACKAGE_POWER_SKU_UNIT , ppsu); + + ppsu = (ppsu &0x1f00 ) >>8 ; + + units =1000000 / (1 << ppsu);/* convert to uJ */ Quoted 8 lines
drivers/gpu/drm/i915/i915_debugfs.c static const struct file_operations i915_cache_sharing_fops = { · line 1925
Quoted 5 lines
drivers/gpu/drm/i915/i915_debugfs.c +5
-0+ +mutex_lock (&dev->struct_mutex); + val =I915_READ (SECP_NRG_STTS ); +if (val < dev_priv->last_secp) + diff = val + (0xffffffff - dev_priv->last_secp);From the nitpickery dept.: I think that's off-by-one. But nobody will ever notice from the output. ;)
Quoted 8 lines
And from the bikeshed departement: Can't we just print a running number? I know, substraction is bloody hard, but for anything else than total power consumption (e.g. graphing power over time) the running thing is imo simpler. We've had the same discussion for the rc6 sysfs residency timers and concluded (after Arjan yelled at us) that doing the substraction in userspace is better, least it allows multiple userspace tools to read this.
Yeah that's a good point; this way happened to be simpler for what I was doing, but just exposing the cooked register value (converted to ujoules) is better. Will fix.
I'll also drop the bug fix hunk that Ben noticed.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 20 Jun 2012 09:38:25 +0200 Daniel Vetter <[email protected]> wrote:
And from the bikeshed departement: Can't we just print a running number? I know, substraction is bloody hard, but for anything else than total power consumption (e.g. graphing power over time) the running thing is imo simpler. We've had the same discussion for the rc6 sysfs residency timers and concluded (after Arjan yelled at us) that doing the substraction in userspace is better, least it allows multiple userspace tools to read this.
Quoted 3 lines
Yeah that's a good point; this way happened to be simpler for what I was doing, but just exposing the cooked register value (converted to ujoules) is better. Will fix.
And to keep it easy to parse, just make it return -ENODEV on older platforms and a simple number for gen6+.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 20 Jun 2012 09:38:25 +0200 Daniel Vetter <[email protected]> wrote:
And from the bikeshed departement: Can't we just print a running number? I know, substraction is bloody hard, but for anything else than total power consumption (e.g. graphing power over time) the running thing is imo simpler. We've had the same discussion for the rc6 sysfs residency timers and concluded (after Arjan yelled at us) that doing the substraction in userspace is better, least it allows multiple userspace tools to read this.
Quoted 6 lines
Quoted 3 lines
Yeah that's a good point; this way happened to be simpler for what I was doing, but just exposing the cooked register value (converted to ujoules) is better. Will fix.
And to keep it easy to parse, just make it return
-ENODEVon older platforms and a simple number for gen6+.
At that point you might also add the uJ suffix and move it to sysfs ;-) -Daniel
Signature · 2 lines
Daniel Vetter [email protected] - +41 (0) 79 364 57 48 - http://blog.ffwll.ch
Quoted 13 lines · Daniel Vetter
Quoted 12 lines · Chris Wilson
Quoted 11 lines · Jesse Barnes
Quoted 8 lines · On Wed, 20 Jun 2012 09:38:25 +0200 Daniel Vetter <[email protected]> wrote:
And from the bikeshed departement: Can't we just print a running number? I know, substraction is bloody hard, but for anything else than total power consumption (e.g. graphing power over time) the running thing is imo simpler. We've had the same discussion for the rc6 sysfs residency timers and concluded (after Arjan yelled at us) that doing the substraction in userspace is better, least it allows multiple userspace tools to read this.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Yeah that's a good point; this way happened to be simpler for what I was doing, but just exposing the cooked register value (converted to ujoules) is better. Will fix.
And to keep it easy to parse, just make it return
-ENODEVon older platforms and a simple number for gen6+.At that point you might also add the uJ suffix and move it to sysfs ;-)
And as a final minor suggestion, could we integrate this with the /sys/kernel/debug/dri/0/i915_emon_status we have on ILK, so we could have just one file for power readings?
Eugeni