IPS driver: add GPU busy and turbo checking
Subsystems (3)
PATCH 1/2 IPS driver: add GPU busy and turbo checking
Be sure to enable GPU turbo by default at load time and check GPU busy and MCP exceeded status correctly. Also fix up CPU power comparison and work around buggy MCH temp reporting.
--- drivers/platform/x86/intel_ips.c | 30 +++++++++++++++++------------- 1 files changed, 17 insertions(+), 13 deletions(-)
drivers/platform/x86/intel_ips.c +17 -13
@@ -515,7 +515,10 @@ static void ips_disable_cpu_turbo(struct ips_driver *ips)*/ static bool ips_gpu_busy (struct ips_driver *ips) { -return false; +if (!ips->gpu_turbo_enabled) +return false; + +return ips->gpu_busy (); }/**
@@ -627,7 +630,7 @@ static bool cpu_exceeded(struct ips_driver *ips, int cpu) avg = cpu ? ips->ctv2_avg_temp : ips->ctv1_avg_temp;if (avg > (ips->limits->core_temp_limit *100 )) ret = true; -if (ips->cpu_avg_power > ips->core_power_limit) +if (ips->cpu_avg_power > ips->core_power_limit *100 ) ret = true;spin_unlock_irqrestore (&ips->turbo_status_lock, flags);
@@ -652,6 +655,8 @@ static bool mch_exceeded(struct ips_driver *ips)spin_lock_irqsave (&ips->turbo_status_lock, flags);if (ips->mch_avg_temp > (ips->limits->mch_temp_limit *100 )) ret = true; +if (ips->mch_avg_power > ips->mch_power_limit) + ret = true;spin_unlock_irqrestore (&ips->turbo_status_lock, flags);return ret;
@@ -747,7 +752,7 @@ static int ips_adjust(void *data)ips_disable_gpu_turbo (ips);/* We're outside our comfort zone, crank them down */ -if (!mcp_exceeded (ips)) { +if (mcp_exceeded (ips)) {ips_cpu_lower (ips);ips_gpu_lower (ips); goto sleep;
@@ -808,8 +813,7 @@ static u16 read_mgtv(struct ips_driver *ips) ret = ((val * slope +0x40 ) >>7 ) + offset; - -return ret; +return 0 ;/* MCH temp reporting buggy */ }static u16 read_ptv (struct ips_driver *ips)
@@ -1471,14 +1475,6 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)if (trc &TRC_CORE2_EN ) ips->second_cpu = true; -if (!ips_get_i915_syms (ips)) { -dev_err (&dev->dev,"failed to get i915 symbols, graphics turbo disabled\n" ); - ips->gpu_turbo_enabled = false; - }else { -dev_dbg (&dev->dev,"graphics turbo enabled\n" ); - ips->gpu_turbo_enabled = true; - } -update_turbo_limits (ips);dev_dbg (&dev->dev,"max cpu power clamp: %dW\n" , ips->mcp_power_limit /10 );
@@ -1488,6 +1484,14 @@ static int ips_probe(struct pci_dev *dev, const struct pci_device_id *id)if (thm_readl (THM_PSC ) &PSP_PBRT ) ips->poll_turbo_status = true; +if (!ips_get_i915_syms (ips)) { +dev_err (&dev->dev,"failed to get i915 symbols, graphics turbo disabled\n" ); + ips->gpu_turbo_enabled = false; + }else { +dev_dbg (&dev->dev,"graphics turbo enabled\n" ); + ips->gpu_turbo_enabled = true; + } +/* * Check PLATFORM_INFO MSR to make sure this chip is * turbo capable.
Signature · 1 line
1.7.0.1
PATCH 2/2 drm/i915: add power monitoring support
Add power monitoring support to the i915 driver for use by the IPS driver. Export the available power info to the IPS driver through a few new inter-driver hooks. When used together, the IPS driver and this patch can significantly increase graphics performance on Ironlake class chips.
--- drivers/gpu/drm/i915/i915_debugfs.c | 56 ++++- drivers/gpu/drm/i915/i915_dma.c | 529 +++++++++++++++++++++++++++++++++- drivers/gpu/drm/i915/i915_drv.h | 20 ++- drivers/gpu/drm/i915/i915_irq.c | 28 +-- drivers/gpu/drm/i915/i915_reg.h | 41 +++ drivers/gpu/drm/i915/intel_display.c | 147 +++++++++- 6 files changed, 768 insertions(+), 53 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +49 -7
@@ -489,11 +489,14 @@ static int i915_cur_delayinfo(struct seq_file *m, void *unused)struct drm_device *dev = node->minor->dev;drm_i915_private_t *dev_priv = dev->dev_private;u16 rgvswctl =I915_READ16 (MEMSWCTL ); +u16 rgvstat =I915_READ16 (MEMSTAT_ILK ); -seq_printf (m,"Last command: 0x%01x\n" , (rgvswctl >>13 ) &0x3 ); -seq_printf (m,"Command status: %d\n" , (rgvswctl >>12 ) &1 ); -seq_printf (m,"P%d DELAY 0x%02x\n" , (rgvswctl >>8 ) &0xf , - rgvswctl &0x3f ); +seq_printf (m,"Requested P-state: %d\n" , (rgvswctl >>8 ) &0xf ); +seq_printf (m,"Requested VID: %d\n" , rgvswctl &0x3f ); +seq_printf (m,"Current VID: %d\n" , (rgvstat &MEMSTAT_VID_MASK ) >> +MEMSTAT_VID_SHIFT ); +seq_printf (m,"Current P-state: %d\n" , + (rgvstat &MEMSTAT_PSTATE_MASK ) >>MEMSTAT_PSTATE_SHIFT );return 0 ; }
@@ -508,7 +511,8 @@ static int i915_delayfreq_table(struct seq_file *m, void *unused)for (i =0 ; i <16 ; i++) { delayfreq =I915_READ (PXVFREQ_BASE + i *4 ); -seq_printf (m,"P%02dVIDFREQ: 0x%08x\n" , i, delayfreq); +seq_printf (m,"P%02dVIDFREQ: 0x%08x (VID: %d)\n" , i, delayfreq, + (delayfreq &PXVFREQ_PX_MASK ) >>PXVFREQ_PX_SHIFT ); }return 0 ;
@@ -541,6 +545,8 @@ static int i915_drpc_info(struct seq_file *m, void *unused)struct drm_device *dev = node->minor->dev;drm_i915_private_t *dev_priv = dev->dev_private;u32 rgvmodectl =I915_READ (MEMMODECTL ); +u32 rstdbyctl =I915_READ (MCHBAR_RENDER_STANDBY ); +u16 crstandvid =I915_READ16 (CRSTANDVID );seq_printf (m,"HD boost: %s\n" , (rgvmodectl &MEMMODE_BOOST_EN ) ?"yes" :"no" );
@@ -555,9 +561,13 @@ static int i915_drpc_info(struct seq_file *m, void *unused) rgvmodectl & MEMMODE_RCLK_GATE ? "yes" : "no");seq_printf (m,"Starting frequency: P%d\n" , (rgvmodectl &MEMMODE_FSTART_MASK ) >>MEMMODE_FSTART_SHIFT ); -seq_printf (m,"Max frequency: P%d\n" , +seq_printf (m,"Max P-state: P%d\n" , (rgvmodectl &MEMMODE_FMAX_MASK ) >>MEMMODE_FMAX_SHIFT ); -seq_printf (m,"Min frequency: P%d\n" , (rgvmodectl &MEMMODE_FMIN_MASK )); +seq_printf (m,"Min P-state: P%d\n" , (rgvmodectl &MEMMODE_FMIN_MASK )); +seq_printf (m,"RS1 VID: %d\n" , (crstandvid &0x3f )); +seq_printf (m,"RS2 VID: %d\n" , ((crstandvid >>8 ) &0x3f )); +seq_printf (m,"Render standby enabled: %s\n" , + (rstdbyctl &RCX_SW_EXIT ) ?"no" :"yes" );return 0 ; }
@@ -621,6 +631,36 @@ static int i915_sr_status(struct seq_file *m, void *unused)return 0 ; } +static int i915_emon_status (struct seq_file *m,void *unused) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +drm_i915_private_t *dev_priv = dev->dev_private; +unsigned long temp, chipset, gfx; + + temp =i915_mch_val (dev_priv); + chipset =i915_chipset_val (dev_priv); + gfx =i915_gfx_val (dev_priv); + +seq_printf (m,"GMCH temp: %ld\n" , temp); +seq_printf (m,"Chipset power: %ld\n" , chipset); +seq_printf (m,"GFX power: %ld\n" , gfx); +seq_printf (m,"Total power: %ld\n" , chipset + gfx); + +return 0 ; +} + +static int i915_gfxec (struct seq_file *m,void *unused) +{ +struct drm_info_node *node = (struct drm_info_node *) m->private; +struct drm_device *dev = node->minor->dev; +drm_i915_private_t *dev_priv = dev->dev_private; + +seq_printf (m,"GFXEC: %ld\n" , (unsigned long )I915_READ (0x112f4 )); + +return 0 ; +} +static int i915_wedged_open (struct inode *inode,struct file *filp)
@@ -743,6 +783,8 @@ static struct drm_info_list i915_debugfs_list[] = { {"i915_delayfreq_table", i915_delayfreq_table, 0}, {"i915_inttoext_table", i915_inttoext_table, 0}, {"i915_drpc_info", i915_drpc_info, 0}, + {"i915_emon_status", i915_emon_status, 0}, + {"i915_gfxec", i915_gfxec, 0}, {"i915_fbc_status", i915_fbc_status, 0}, {"i915_sr_status", i915_sr_status, 0}, };
drivers/gpu/drm/i915/i915_dma.c +524 -5
563 lines not on this page · raw message
drivers/gpu/drm/i915/i915_drv.h +19 -1
@@ -644,6 +644,18 @@ typedef struct drm_i915_private {u8 cur_delay;u8 min_delay;u8 max_delay; +u8 fmax; +u8 fstart; + +u64 last_count1; +unsigned long last_time1; +u64 last_count2; +struct timespec last_time2; +unsigned long gfx_power; +int c_m; +int r_t; +u8 corr; +spinlock_t *mchdev_lock;enum no_fbc_reason no_fbc_reason;
@@ -821,6 +833,11 @@ extern int i915_emit_box(struct drm_device *dev,struct drm_clip_rect *boxes, int i, int DR1, int DR4);extern int i965_reset (struct drm_device *dev,u8 flags); +extern unsigned long i915_chipset_val (struct drm_i915_private *dev_priv); +extern unsigned long i915_mch_val (struct drm_i915_private *dev_priv); +extern unsigned long i915_gfx_val (struct drm_i915_private *dev_priv); +extern void i915_update_gfx_val (struct drm_i915_private *dev_priv); +/* i915_irq.c */ void i915_hangcheck_elapsed (unsigned long data);
@@ -1015,7 +1032,7 @@ extern void g4x_disable_fbc(struct drm_device *dev);extern void intel_disable_fbc (struct drm_device *dev);extern void intel_enable_fbc (struct drm_crtc *crtc,unsigned long interval);extern bool intel_fbc_enabled (struct drm_device *dev); - +extern bool ironlake_set_drps (struct drm_device *dev,u8 val);extern void intel_detect_pch (struct drm_device *dev);extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);
@@ -1039,6 +1056,7 @@ extern int intel_trans_dp_port_sel (struct drm_crtc *crtc);#define I915_WRITE64 (reg, val) writeq(val, dev_priv->regs + (reg))#define I915_READ64 (reg) readq(dev_priv->regs + (reg))#define POSTING_READ (reg) (void)I915_READ(reg) +#define POSTING_READ16 (reg) (void)I915_READ16(reg)#define I915_VERBOSE 0
drivers/gpu/drm/i915/i915_irq.c +4 -24
@@ -279,10 +279,9 @@ static void i915_handle_rps_change(struct drm_device *dev) {drm_i915_private_t *dev_priv = dev->dev_private;u32 busy_up, busy_down, max_avg, min_avg; -u16 rgvswctl;u8 new_delay = dev_priv->cur_delay; -I915_WRITE (MEMINTRSTS ,I915_READ (MEMINTRSTS ) & ~MEMINT_EVAL_CHG ); +I915_WRITE16 (MEMINTRSTS ,MEMINT_EVAL_CHG ); busy_up =I915_READ (RCPREVBSYTUPAVG ); busy_down =I915_READ (RCPREVBSYTDNAVG ); max_avg =I915_READ (RCBMAXAVG );
@@ -301,27 +300,8 @@ static void i915_handle_rps_change(struct drm_device *dev) new_delay = dev_priv->min_delay; } -DRM_DEBUG ("rps change requested: %d -> %d\n" , - dev_priv->cur_delay, new_delay); - - rgvswctl =I915_READ (MEMSWCTL ); -if (rgvswctl &MEMCTL_CMD_STS ) { -DRM_ERROR ("gpu busy, RCS change rejected\n" ); -return ;/* still busy with another command */ - } - -/* Program the new state */ - rgvswctl = (MEMCTL_CMD_CHFREQ <<MEMCTL_CMD_SHIFT ) | - (new_delay <<MEMCTL_FREQ_SHIFT ) |MEMCTL_SFCAVM ; -I915_WRITE (MEMSWCTL , rgvswctl); -POSTING_READ (MEMSWCTL ); - - rgvswctl |=MEMCTL_CMD_STS ; -I915_WRITE (MEMSWCTL , rgvswctl); - - dev_priv->cur_delay = new_delay; - -DRM_DEBUG ("rps changed\n" ); +if (ironlake_set_drps (dev, new_delay)) + dev_priv->cur_delay = new_delay;return ; }
@@ -389,7 +369,7 @@ irqreturn_t ironlake_irq_handler(struct drm_device *dev) }if (de_iir &DE_PCU_EVENT ) { -I915_WRITE (MEMINTRSTS ,I915_READ (MEMINTRSTS )); +I915_WRITE16 (MEMINTRSTS ,I915_READ (MEMINTRSTS ));i915_handle_rps_change (dev); }
drivers/gpu/drm/i915/i915_reg.h +41 -0
53 lines not on this page · raw message
drivers/gpu/drm/i915/intel_display.c +131 -16
205 lines not on this page · raw message
Signature · 1 line
1.7.0.1
Re: [PATCH 2/2] drm/i915: add power monitoring support
Jesse,
This patch seems to have a lot of magical numbers in it. In particular, v_table and cparams both seem rather cryptic. Would it be possible to add a few comments saying what these numbers mean or where they came from?
Thanks,
--Kenneth