Commit 9fcee2f7 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Report the failure to write to the punit

The write to the punit may fail, so propagate the error code back to its
callers. Of particular interest are the RPS writes, so add appropriate
user error codes and logging.

v2: Add DEBUG for failed frequency changes during RPS.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170126101919.13211-1-chris@chris-wilson.co.ukReviewed-by: default avatarMika Kuoppala <mika.kuoppala@intel.com>
parent 611032bf
...@@ -4278,7 +4278,8 @@ i915_max_freq_set(void *data, u64 val) ...@@ -4278,7 +4278,8 @@ i915_max_freq_set(void *data, u64 val)
dev_priv->rps.max_freq_softlimit = val; dev_priv->rps.max_freq_softlimit = val;
intel_set_rps(dev_priv, val); if (intel_set_rps(dev_priv, val))
DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
...@@ -4333,7 +4334,8 @@ i915_min_freq_set(void *data, u64 val) ...@@ -4333,7 +4334,8 @@ i915_min_freq_set(void *data, u64 val)
dev_priv->rps.min_freq_softlimit = val; dev_priv->rps.min_freq_softlimit = val;
intel_set_rps(dev_priv, val); if (intel_set_rps(dev_priv, val))
DRM_DEBUG_DRIVER("failed to update RPS to new softlimit\n");
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
......
...@@ -3701,7 +3701,7 @@ extern void i915_redisable_vga(struct drm_i915_private *dev_priv); ...@@ -3701,7 +3701,7 @@ extern void i915_redisable_vga(struct drm_i915_private *dev_priv);
extern void i915_redisable_vga_power_on(struct drm_i915_private *dev_priv); extern void i915_redisable_vga_power_on(struct drm_i915_private *dev_priv);
extern bool ironlake_set_drps(struct drm_i915_private *dev_priv, u8 val); extern bool ironlake_set_drps(struct drm_i915_private *dev_priv, u8 val);
extern void intel_init_pch_refclk(struct drm_i915_private *dev_priv); extern void intel_init_pch_refclk(struct drm_i915_private *dev_priv);
extern void intel_set_rps(struct drm_i915_private *dev_priv, u8 val); extern int intel_set_rps(struct drm_i915_private *dev_priv, u8 val);
extern bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv, extern bool intel_set_memory_cxsr(struct drm_i915_private *dev_priv,
bool enable); bool enable);
...@@ -3727,7 +3727,7 @@ int skl_pcode_request(struct drm_i915_private *dev_priv, u32 mbox, u32 request, ...@@ -3727,7 +3727,7 @@ int skl_pcode_request(struct drm_i915_private *dev_priv, u32 mbox, u32 request,
/* intel_sideband.c */ /* intel_sideband.c */
u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr); u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr);
void vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val); int vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val);
u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr); u32 vlv_nc_read(struct drm_i915_private *dev_priv, u8 addr);
u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg); u32 vlv_iosf_sb_read(struct drm_i915_private *dev_priv, u8 port, u32 reg);
void vlv_iosf_sb_write(struct drm_i915_private *dev_priv, u8 port, u32 reg, u32 val); void vlv_iosf_sb_write(struct drm_i915_private *dev_priv, u8 port, u32 reg, u32 val);
......
...@@ -1209,7 +1209,10 @@ static void gen6_pm_rps_work(struct work_struct *work) ...@@ -1209,7 +1209,10 @@ static void gen6_pm_rps_work(struct work_struct *work)
new_delay += adj; new_delay += adj;
new_delay = clamp_t(int, new_delay, min, max); new_delay = clamp_t(int, new_delay, min, max);
intel_set_rps(dev_priv, new_delay); if (intel_set_rps(dev_priv, new_delay)) {
DRM_DEBUG_DRIVER("Failed to set new GPU frequency\n");
dev_priv->rps.last_adj = 0;
}
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
} }
......
...@@ -395,13 +395,13 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, ...@@ -395,13 +395,13 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev,
/* We still need *_set_rps to process the new max_delay and /* We still need *_set_rps to process the new max_delay and
* update the interrupt limits and PMINTRMSK even though * update the interrupt limits and PMINTRMSK even though
* frequency request may be unchanged. */ * frequency request may be unchanged. */
intel_set_rps(dev_priv, val); ret = intel_set_rps(dev_priv, val);
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
intel_runtime_pm_put(dev_priv); intel_runtime_pm_put(dev_priv);
return count; return ret ?: count;
} }
static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf)
...@@ -448,14 +448,13 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, ...@@ -448,14 +448,13 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
/* We still need *_set_rps to process the new min_delay and /* We still need *_set_rps to process the new min_delay and
* update the interrupt limits and PMINTRMSK even though * update the interrupt limits and PMINTRMSK even though
* frequency request may be unchanged. */ * frequency request may be unchanged. */
intel_set_rps(dev_priv, val); ret = intel_set_rps(dev_priv, val);
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
intel_runtime_pm_put(dev_priv); intel_runtime_pm_put(dev_priv);
return count; return ret ?: count;
} }
static DEVICE_ATTR(gt_act_freq_mhz, S_IRUGO, gt_act_freq_mhz_show, NULL); static DEVICE_ATTR(gt_act_freq_mhz, S_IRUGO, gt_act_freq_mhz_show, NULL);
......
...@@ -4933,7 +4933,7 @@ static u32 gen6_rps_pm_mask(struct drm_i915_private *dev_priv, u8 val) ...@@ -4933,7 +4933,7 @@ static u32 gen6_rps_pm_mask(struct drm_i915_private *dev_priv, u8 val)
/* gen6_set_rps is called to update the frequency request, but should also be /* gen6_set_rps is called to update the frequency request, but should also be
* called when the range (min_delay and max_delay) is modified so that we can * called when the range (min_delay and max_delay) is modified so that we can
* update the GEN6_RP_INTERRUPT_LIMITS register accordingly. */ * update the GEN6_RP_INTERRUPT_LIMITS register accordingly. */
static void gen6_set_rps(struct drm_i915_private *dev_priv, u8 val) static int gen6_set_rps(struct drm_i915_private *dev_priv, u8 val)
{ {
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
WARN_ON(val > dev_priv->rps.max_freq); WARN_ON(val > dev_priv->rps.max_freq);
...@@ -4968,10 +4968,14 @@ static void gen6_set_rps(struct drm_i915_private *dev_priv, u8 val) ...@@ -4968,10 +4968,14 @@ static void gen6_set_rps(struct drm_i915_private *dev_priv, u8 val)
dev_priv->rps.cur_freq = val; dev_priv->rps.cur_freq = val;
trace_intel_gpu_freq_change(intel_gpu_freq(dev_priv, val)); trace_intel_gpu_freq_change(intel_gpu_freq(dev_priv, val));
return 0;
} }
static void valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val) static int valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val)
{ {
int err;
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
WARN_ON(val > dev_priv->rps.max_freq); WARN_ON(val > dev_priv->rps.max_freq);
WARN_ON(val < dev_priv->rps.min_freq); WARN_ON(val < dev_priv->rps.min_freq);
...@@ -4983,13 +4987,18 @@ static void valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val) ...@@ -4983,13 +4987,18 @@ static void valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val)
I915_WRITE(GEN6_PMINTRMSK, gen6_rps_pm_mask(dev_priv, val)); I915_WRITE(GEN6_PMINTRMSK, gen6_rps_pm_mask(dev_priv, val));
if (val != dev_priv->rps.cur_freq) { if (val != dev_priv->rps.cur_freq) {
vlv_punit_write(dev_priv, PUNIT_REG_GPU_FREQ_REQ, val); err = vlv_punit_write(dev_priv, PUNIT_REG_GPU_FREQ_REQ, val);
if (err)
return err;
if (!IS_CHERRYVIEW(dev_priv)) if (!IS_CHERRYVIEW(dev_priv))
gen6_set_rps_thresholds(dev_priv, val); gen6_set_rps_thresholds(dev_priv, val);
} }
dev_priv->rps.cur_freq = val; dev_priv->rps.cur_freq = val;
trace_intel_gpu_freq_change(intel_gpu_freq(dev_priv, val)); trace_intel_gpu_freq_change(intel_gpu_freq(dev_priv, val));
return 0;
} }
/* vlv_set_rps_idle: Set the frequency to idle, if Gfx clocks are down /* vlv_set_rps_idle: Set the frequency to idle, if Gfx clocks are down
...@@ -5002,6 +5011,7 @@ static void valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val) ...@@ -5002,6 +5011,7 @@ static void valleyview_set_rps(struct drm_i915_private *dev_priv, u8 val)
static void vlv_set_rps_idle(struct drm_i915_private *dev_priv) static void vlv_set_rps_idle(struct drm_i915_private *dev_priv)
{ {
u32 val = dev_priv->rps.idle_freq; u32 val = dev_priv->rps.idle_freq;
int err;
if (dev_priv->rps.cur_freq <= val) if (dev_priv->rps.cur_freq <= val)
return; return;
...@@ -5019,8 +5029,11 @@ static void vlv_set_rps_idle(struct drm_i915_private *dev_priv) ...@@ -5019,8 +5029,11 @@ static void vlv_set_rps_idle(struct drm_i915_private *dev_priv)
* power than the render powerwell. * power than the render powerwell.
*/ */
intel_uncore_forcewake_get(dev_priv, FORCEWAKE_MEDIA); intel_uncore_forcewake_get(dev_priv, FORCEWAKE_MEDIA);
valleyview_set_rps(dev_priv, val); err = valleyview_set_rps(dev_priv, val);
intel_uncore_forcewake_put(dev_priv, FORCEWAKE_MEDIA); intel_uncore_forcewake_put(dev_priv, FORCEWAKE_MEDIA);
if (err)
DRM_ERROR("Failed to set RPS for idle\n");
} }
void gen6_rps_busy(struct drm_i915_private *dev_priv) void gen6_rps_busy(struct drm_i915_private *dev_priv)
...@@ -5035,10 +5048,11 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv) ...@@ -5035,10 +5048,11 @@ void gen6_rps_busy(struct drm_i915_private *dev_priv)
gen6_enable_rps_interrupts(dev_priv); gen6_enable_rps_interrupts(dev_priv);
/* Ensure we start at the user's desired frequency */ /* Ensure we start at the user's desired frequency */
intel_set_rps(dev_priv, if (intel_set_rps(dev_priv,
clamp(dev_priv->rps.cur_freq, clamp(dev_priv->rps.cur_freq,
dev_priv->rps.min_freq_softlimit, dev_priv->rps.min_freq_softlimit,
dev_priv->rps.max_freq_softlimit)); dev_priv->rps.max_freq_softlimit)))
DRM_DEBUG_DRIVER("Failed to set idle frequency\n");
} }
mutex_unlock(&dev_priv->rps.hw_lock); mutex_unlock(&dev_priv->rps.hw_lock);
} }
...@@ -5106,12 +5120,16 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv, ...@@ -5106,12 +5120,16 @@ void gen6_rps_boost(struct drm_i915_private *dev_priv,
spin_unlock(&dev_priv->rps.client_lock); spin_unlock(&dev_priv->rps.client_lock);
} }
void intel_set_rps(struct drm_i915_private *dev_priv, u8 val) int intel_set_rps(struct drm_i915_private *dev_priv, u8 val)
{ {
int err;
if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
valleyview_set_rps(dev_priv, val); err = valleyview_set_rps(dev_priv, val);
else else
gen6_set_rps(dev_priv, val); err = gen6_set_rps(dev_priv, val);
return err;
} }
static void gen9_disable_rc6(struct drm_i915_private *dev_priv) static void gen9_disable_rc6(struct drm_i915_private *dev_priv)
...@@ -5315,7 +5333,7 @@ static void gen6_init_rps_frequencies(struct drm_i915_private *dev_priv) ...@@ -5315,7 +5333,7 @@ static void gen6_init_rps_frequencies(struct drm_i915_private *dev_priv)
} }
static void reset_rps(struct drm_i915_private *dev_priv, static void reset_rps(struct drm_i915_private *dev_priv,
void (*set)(struct drm_i915_private *, u8)) int (*set)(struct drm_i915_private *, u8))
{ {
u8 freq = dev_priv->rps.cur_freq; u8 freq = dev_priv->rps.cur_freq;
...@@ -5323,7 +5341,8 @@ static void reset_rps(struct drm_i915_private *dev_priv, ...@@ -5323,7 +5341,8 @@ static void reset_rps(struct drm_i915_private *dev_priv,
dev_priv->rps.power = -1; dev_priv->rps.power = -1;
dev_priv->rps.cur_freq = -1; dev_priv->rps.cur_freq = -1;
set(dev_priv, freq); if (set(dev_priv, freq))
DRM_ERROR("Failed to reset RPS to initial values\n");
} }
/* See the Gen9_GT_PM_Programming_Guide doc for the below */ /* See the Gen9_GT_PM_Programming_Guide doc for the below */
......
...@@ -93,14 +93,18 @@ u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr) ...@@ -93,14 +93,18 @@ u32 vlv_punit_read(struct drm_i915_private *dev_priv, u32 addr)
return val; return val;
} }
void vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val) int vlv_punit_write(struct drm_i915_private *dev_priv, u32 addr, u32 val)
{ {
int err;
WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock)); WARN_ON(!mutex_is_locked(&dev_priv->rps.hw_lock));
mutex_lock(&dev_priv->sb_lock); mutex_lock(&dev_priv->sb_lock);
vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_PUNIT, err = vlv_sideband_rw(dev_priv, PCI_DEVFN(0, 0), IOSF_PORT_PUNIT,
SB_CRWRDA_NP, addr, &val); SB_CRWRDA_NP, addr, &val);
mutex_unlock(&dev_priv->sb_lock); mutex_unlock(&dev_priv->sb_lock);
return err;
} }
u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg) u32 vlv_bunit_read(struct drm_i915_private *dev_priv, u32 reg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment