diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2015-01-23 14:04:26 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-01-27 03:51:17 -0500 |
commit | 7c59a9c133868b0c028a04562a1c2b2dbbad5284 (patch) | |
tree | 7ceeaa6c7cd4cf234a6babf01d7a9ddcea0b6bcb /drivers/gpu/drm | |
parent | 616bc8202da4a8f7e5382f28a03271772bad658a (diff) |
drm/i915: Use intel_gpu_freq() and intel_freq_opcode()
Replace all the vlv_gpu_freq(), vlv_freq_opcode(),
*GT_FREQUENCY_MULTIPLIER, and /GT_FREQUENCY_MULTIPLIER instances
with intel_gpu_freq() and intel_freq_opcode() calls.
Most of the change was performed with the following semantic patch:
@@
expression E;
@@
(
- E * GT_FREQUENCY_MULTIPLIER
+ intel_gpu_freq(dev_priv, E)
|
- E *= GT_FREQUENCY_MULTIPLIER
+ E = intel_gpu_freq(dev_priv, E)
|
- E /= GT_FREQUENCY_MULTIPLIER
+ E = intel_freq_opcode(dev_priv, E)
|
- do_div(E, GT_FREQUENCY_MULTIPLIER)
+ E = intel_freq_opcode(dev_priv, E)
)
@@
expression E1, E2;
@@
(
- vlv_gpu_freq(E1, E2)
+ intel_gpu_freq(E1, E2)
|
- vlv_freq_opcode(E1, E2)
+ intel_freq_opcode(E1, E2)
)
@@
expression E1, E2, E3, E4;
@@
(
- if (IS_VALLEYVIEW(E1)) {
- E2 = intel_gpu_freq(E3, E4);
- } else {
- E2 = intel_gpu_freq(E3, E4);
- }
+ E2 = intel_gpu_freq(E3, E4);
|
- if (IS_VALLEYVIEW(E1)) {
- E2 = intel_freq_opcode(E3, E4);
- } else {
- E2 = intel_freq_opcode(E3, E4);
- }
+ E2 = intel_freq_opcode(E3, E4);
)
One hunk was manually undone as intel_gpu_freq() ended up
calling itself. Supposedly it would be possible to exclude
certain functions via !=~, but I couldn't get that to work.
Also the removal of vlv_gpu_freq() and vlv_opcode_freq() compat
wrappers was done manually.
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/i915/i915_debugfs.c | 43 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_sysfs.c | 52 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_pm.c | 36 |
4 files changed, 52 insertions, 81 deletions
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index 2ad4c48c8cb7..b315f0196636 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c | |||
@@ -1113,7 +1113,7 @@ static int i915_frequency_info(struct seq_file *m, void *unused) | |||
1113 | reqf >>= 24; | 1113 | reqf >>= 24; |
1114 | else | 1114 | else |
1115 | reqf >>= 25; | 1115 | reqf >>= 25; |
1116 | reqf *= GT_FREQUENCY_MULTIPLIER; | 1116 | reqf = intel_gpu_freq(dev_priv, reqf); |
1117 | 1117 | ||
1118 | rpmodectl = I915_READ(GEN6_RP_CONTROL); | 1118 | rpmodectl = I915_READ(GEN6_RP_CONTROL); |
1119 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); | 1119 | rpinclimit = I915_READ(GEN6_RP_UP_THRESHOLD); |
@@ -1130,7 +1130,7 @@ static int i915_frequency_info(struct seq_file *m, void *unused) | |||
1130 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; | 1130 | cagf = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
1131 | else | 1131 | else |
1132 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; | 1132 | cagf = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
1133 | cagf *= GT_FREQUENCY_MULTIPLIER; | 1133 | cagf = intel_gpu_freq(dev_priv, cagf); |
1134 | 1134 | ||
1135 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); | 1135 | intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); |
1136 | mutex_unlock(&dev->struct_mutex); | 1136 | mutex_unlock(&dev->struct_mutex); |
@@ -1178,18 +1178,18 @@ static int i915_frequency_info(struct seq_file *m, void *unused) | |||
1178 | 1178 | ||
1179 | max_freq = (rp_state_cap & 0xff0000) >> 16; | 1179 | max_freq = (rp_state_cap & 0xff0000) >> 16; |
1180 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", | 1180 | seq_printf(m, "Lowest (RPN) frequency: %dMHz\n", |
1181 | max_freq * GT_FREQUENCY_MULTIPLIER); | 1181 | intel_gpu_freq(dev_priv, max_freq)); |
1182 | 1182 | ||
1183 | max_freq = (rp_state_cap & 0xff00) >> 8; | 1183 | max_freq = (rp_state_cap & 0xff00) >> 8; |
1184 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", | 1184 | seq_printf(m, "Nominal (RP1) frequency: %dMHz\n", |
1185 | max_freq * GT_FREQUENCY_MULTIPLIER); | 1185 | intel_gpu_freq(dev_priv, max_freq)); |
1186 | 1186 | ||
1187 | max_freq = rp_state_cap & 0xff; | 1187 | max_freq = rp_state_cap & 0xff; |
1188 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", | 1188 | seq_printf(m, "Max non-overclocked (RP0) frequency: %dMHz\n", |
1189 | max_freq * GT_FREQUENCY_MULTIPLIER); | 1189 | intel_gpu_freq(dev_priv, max_freq)); |
1190 | 1190 | ||
1191 | seq_printf(m, "Max overclocked frequency: %dMHz\n", | 1191 | seq_printf(m, "Max overclocked frequency: %dMHz\n", |
1192 | dev_priv->rps.max_freq * GT_FREQUENCY_MULTIPLIER); | 1192 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
1193 | } else if (IS_VALLEYVIEW(dev)) { | 1193 | } else if (IS_VALLEYVIEW(dev)) { |
1194 | u32 freq_sts; | 1194 | u32 freq_sts; |
1195 | 1195 | ||
@@ -1199,16 +1199,17 @@ static int i915_frequency_info(struct seq_file *m, void *unused) | |||
1199 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); | 1199 | seq_printf(m, "DDR freq: %d MHz\n", dev_priv->mem_freq); |
1200 | 1200 | ||
1201 | seq_printf(m, "max GPU freq: %d MHz\n", | 1201 | seq_printf(m, "max GPU freq: %d MHz\n", |
1202 | vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq)); | 1202 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq)); |
1203 | 1203 | ||
1204 | seq_printf(m, "min GPU freq: %d MHz\n", | 1204 | seq_printf(m, "min GPU freq: %d MHz\n", |
1205 | vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq)); | 1205 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq)); |
1206 | 1206 | ||
1207 | seq_printf(m, "efficient (RPe) frequency: %d MHz\n", | 1207 | seq_printf(m, |
1208 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); | 1208 | "efficient (RPe) frequency: %d MHz\n", |
1209 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); | ||
1209 | 1210 | ||
1210 | seq_printf(m, "current GPU freq: %d MHz\n", | 1211 | seq_printf(m, "current GPU freq: %d MHz\n", |
1211 | vlv_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); | 1212 | intel_gpu_freq(dev_priv, (freq_sts >> 8) & 0xff)); |
1212 | mutex_unlock(&dev_priv->rps.hw_lock); | 1213 | mutex_unlock(&dev_priv->rps.hw_lock); |
1213 | } else { | 1214 | } else { |
1214 | seq_puts(m, "no P-state info available\n"); | 1215 | seq_puts(m, "no P-state info available\n"); |
@@ -1677,7 +1678,7 @@ static int i915_ring_freq_table(struct seq_file *m, void *unused) | |||
1677 | GEN6_PCODE_READ_MIN_FREQ_TABLE, | 1678 | GEN6_PCODE_READ_MIN_FREQ_TABLE, |
1678 | &ia_freq); | 1679 | &ia_freq); |
1679 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", | 1680 | seq_printf(m, "%d\t\t%d\t\t\t\t%d\n", |
1680 | gpu_freq * GT_FREQUENCY_MULTIPLIER, | 1681 | intel_gpu_freq(dev_priv, gpu_freq), |
1681 | ((ia_freq >> 0) & 0xff) * 100, | 1682 | ((ia_freq >> 0) & 0xff) * 100, |
1682 | ((ia_freq >> 8) & 0xff) * 100); | 1683 | ((ia_freq >> 8) & 0xff) * 100); |
1683 | } | 1684 | } |
@@ -4119,10 +4120,7 @@ i915_max_freq_get(void *data, u64 *val) | |||
4119 | if (ret) | 4120 | if (ret) |
4120 | return ret; | 4121 | return ret; |
4121 | 4122 | ||
4122 | if (IS_VALLEYVIEW(dev)) | 4123 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
4123 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); | ||
4124 | else | ||
4125 | *val = dev_priv->rps.max_freq_softlimit * GT_FREQUENCY_MULTIPLIER; | ||
4126 | mutex_unlock(&dev_priv->rps.hw_lock); | 4124 | mutex_unlock(&dev_priv->rps.hw_lock); |
4127 | 4125 | ||
4128 | return 0; | 4126 | return 0; |
@@ -4151,12 +4149,12 @@ i915_max_freq_set(void *data, u64 val) | |||
4151 | * Turbo will still be enabled, but won't go above the set value. | 4149 | * Turbo will still be enabled, but won't go above the set value. |
4152 | */ | 4150 | */ |
4153 | if (IS_VALLEYVIEW(dev)) { | 4151 | if (IS_VALLEYVIEW(dev)) { |
4154 | val = vlv_freq_opcode(dev_priv, val); | 4152 | val = intel_freq_opcode(dev_priv, val); |
4155 | 4153 | ||
4156 | hw_max = dev_priv->rps.max_freq; | 4154 | hw_max = dev_priv->rps.max_freq; |
4157 | hw_min = dev_priv->rps.min_freq; | 4155 | hw_min = dev_priv->rps.min_freq; |
4158 | } else { | 4156 | } else { |
4159 | do_div(val, GT_FREQUENCY_MULTIPLIER); | 4157 | val = intel_freq_opcode(dev_priv, val); |
4160 | 4158 | ||
4161 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); | 4159 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
4162 | hw_max = dev_priv->rps.max_freq; | 4160 | hw_max = dev_priv->rps.max_freq; |
@@ -4200,10 +4198,7 @@ i915_min_freq_get(void *data, u64 *val) | |||
4200 | if (ret) | 4198 | if (ret) |
4201 | return ret; | 4199 | return ret; |
4202 | 4200 | ||
4203 | if (IS_VALLEYVIEW(dev)) | 4201 | *val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
4204 | *val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); | ||
4205 | else | ||
4206 | *val = dev_priv->rps.min_freq_softlimit * GT_FREQUENCY_MULTIPLIER; | ||
4207 | mutex_unlock(&dev_priv->rps.hw_lock); | 4202 | mutex_unlock(&dev_priv->rps.hw_lock); |
4208 | 4203 | ||
4209 | return 0; | 4204 | return 0; |
@@ -4232,12 +4227,12 @@ i915_min_freq_set(void *data, u64 val) | |||
4232 | * Turbo will still be enabled, but won't go below the set value. | 4227 | * Turbo will still be enabled, but won't go below the set value. |
4233 | */ | 4228 | */ |
4234 | if (IS_VALLEYVIEW(dev)) { | 4229 | if (IS_VALLEYVIEW(dev)) { |
4235 | val = vlv_freq_opcode(dev_priv, val); | 4230 | val = intel_freq_opcode(dev_priv, val); |
4236 | 4231 | ||
4237 | hw_max = dev_priv->rps.max_freq; | 4232 | hw_max = dev_priv->rps.max_freq; |
4238 | hw_min = dev_priv->rps.min_freq; | 4233 | hw_min = dev_priv->rps.min_freq; |
4239 | } else { | 4234 | } else { |
4240 | do_div(val, GT_FREQUENCY_MULTIPLIER); | 4235 | val = intel_freq_opcode(dev_priv, val); |
4241 | 4236 | ||
4242 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); | 4237 | rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); |
4243 | hw_max = dev_priv->rps.max_freq; | 4238 | hw_max = dev_priv->rps.max_freq; |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 5f36c6c81ced..3e81d9aaa50a 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -3236,8 +3236,6 @@ void vlv_flisdsi_write(struct drm_i915_private *dev_priv, u32 reg, u32 val); | |||
3236 | 3236 | ||
3237 | int intel_gpu_freq(struct drm_i915_private *dev_priv, int val); | 3237 | int intel_gpu_freq(struct drm_i915_private *dev_priv, int val); |
3238 | int intel_freq_opcode(struct drm_i915_private *dev_priv, int val); | 3238 | int intel_freq_opcode(struct drm_i915_private *dev_priv, int val); |
3239 | int vlv_gpu_freq(struct drm_i915_private *dev_priv, int val); | ||
3240 | int vlv_freq_opcode(struct drm_i915_private *dev_priv, int val); | ||
3241 | 3239 | ||
3242 | #define I915_READ8(reg) dev_priv->uncore.funcs.mmio_readb(dev_priv, (reg), true) | 3240 | #define I915_READ8(reg) dev_priv->uncore.funcs.mmio_readb(dev_priv, (reg), true) |
3243 | #define I915_WRITE8(reg, val) dev_priv->uncore.funcs.mmio_writeb(dev_priv, (reg), (val), true) | 3241 | #define I915_WRITE8(reg, val) dev_priv->uncore.funcs.mmio_writeb(dev_priv, (reg), (val), true) |
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index 532ad3477997..49f5ade0edb7 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c | |||
@@ -297,14 +297,14 @@ static ssize_t gt_act_freq_mhz_show(struct device *kdev, | |||
297 | if (IS_VALLEYVIEW(dev_priv->dev)) { | 297 | if (IS_VALLEYVIEW(dev_priv->dev)) { |
298 | u32 freq; | 298 | u32 freq; |
299 | freq = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); | 299 | freq = vlv_punit_read(dev_priv, PUNIT_REG_GPU_FREQ_STS); |
300 | ret = vlv_gpu_freq(dev_priv, (freq >> 8) & 0xff); | 300 | ret = intel_gpu_freq(dev_priv, (freq >> 8) & 0xff); |
301 | } else { | 301 | } else { |
302 | u32 rpstat = I915_READ(GEN6_RPSTAT1); | 302 | u32 rpstat = I915_READ(GEN6_RPSTAT1); |
303 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) | 303 | if (IS_HASWELL(dev_priv) || IS_BROADWELL(dev_priv)) |
304 | ret = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; | 304 | ret = (rpstat & HSW_CAGF_MASK) >> HSW_CAGF_SHIFT; |
305 | else | 305 | else |
306 | ret = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; | 306 | ret = (rpstat & GEN6_CAGF_MASK) >> GEN6_CAGF_SHIFT; |
307 | ret *= GT_FREQUENCY_MULTIPLIER; | 307 | ret = intel_gpu_freq(dev_priv, ret); |
308 | } | 308 | } |
309 | mutex_unlock(&dev_priv->rps.hw_lock); | 309 | mutex_unlock(&dev_priv->rps.hw_lock); |
310 | 310 | ||
@@ -326,11 +326,7 @@ static ssize_t gt_cur_freq_mhz_show(struct device *kdev, | |||
326 | intel_runtime_pm_get(dev_priv); | 326 | intel_runtime_pm_get(dev_priv); |
327 | 327 | ||
328 | mutex_lock(&dev_priv->rps.hw_lock); | 328 | mutex_lock(&dev_priv->rps.hw_lock); |
329 | if (IS_VALLEYVIEW(dev_priv->dev)) { | 329 | ret = intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq); |
330 | ret = vlv_gpu_freq(dev_priv, dev_priv->rps.cur_freq); | ||
331 | } else { | ||
332 | ret = dev_priv->rps.cur_freq * GT_FREQUENCY_MULTIPLIER; | ||
333 | } | ||
334 | mutex_unlock(&dev_priv->rps.hw_lock); | 330 | mutex_unlock(&dev_priv->rps.hw_lock); |
335 | 331 | ||
336 | intel_runtime_pm_put(dev_priv); | 332 | intel_runtime_pm_put(dev_priv); |
@@ -345,8 +341,9 @@ static ssize_t vlv_rpe_freq_mhz_show(struct device *kdev, | |||
345 | struct drm_device *dev = minor->dev; | 341 | struct drm_device *dev = minor->dev; |
346 | struct drm_i915_private *dev_priv = dev->dev_private; | 342 | struct drm_i915_private *dev_priv = dev->dev_private; |
347 | 343 | ||
348 | return snprintf(buf, PAGE_SIZE, "%d\n", | 344 | return snprintf(buf, PAGE_SIZE, |
349 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); | 345 | "%d\n", |
346 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq)); | ||
350 | } | 347 | } |
351 | 348 | ||
352 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) | 349 | static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf) |
@@ -359,10 +356,7 @@ static ssize_t gt_max_freq_mhz_show(struct device *kdev, struct device_attribute | |||
359 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); | 356 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
360 | 357 | ||
361 | mutex_lock(&dev_priv->rps.hw_lock); | 358 | mutex_lock(&dev_priv->rps.hw_lock); |
362 | if (IS_VALLEYVIEW(dev_priv->dev)) | 359 | ret = intel_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); |
363 | ret = vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq_softlimit); | ||
364 | else | ||
365 | ret = dev_priv->rps.max_freq_softlimit * GT_FREQUENCY_MULTIPLIER; | ||
366 | mutex_unlock(&dev_priv->rps.hw_lock); | 360 | mutex_unlock(&dev_priv->rps.hw_lock); |
367 | 361 | ||
368 | return snprintf(buf, PAGE_SIZE, "%d\n", ret); | 362 | return snprintf(buf, PAGE_SIZE, "%d\n", ret); |
@@ -386,10 +380,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
386 | 380 | ||
387 | mutex_lock(&dev_priv->rps.hw_lock); | 381 | mutex_lock(&dev_priv->rps.hw_lock); |
388 | 382 | ||
389 | if (IS_VALLEYVIEW(dev_priv->dev)) | 383 | val = intel_freq_opcode(dev_priv, val); |
390 | val = vlv_freq_opcode(dev_priv, val); | ||
391 | else | ||
392 | val /= GT_FREQUENCY_MULTIPLIER; | ||
393 | 384 | ||
394 | if (val < dev_priv->rps.min_freq || | 385 | if (val < dev_priv->rps.min_freq || |
395 | val > dev_priv->rps.max_freq || | 386 | val > dev_priv->rps.max_freq || |
@@ -400,7 +391,7 @@ static ssize_t gt_max_freq_mhz_store(struct device *kdev, | |||
400 | 391 | ||
401 | if (val > dev_priv->rps.rp0_freq) | 392 | if (val > dev_priv->rps.rp0_freq) |
402 | DRM_DEBUG("User requested overclocking to %d\n", | 393 | DRM_DEBUG("User requested overclocking to %d\n", |
403 | val * GT_FREQUENCY_MULTIPLIER); | 394 | intel_gpu_freq(dev_priv, val)); |
404 | 395 | ||
405 | dev_priv->rps.max_freq_softlimit = val; | 396 | dev_priv->rps.max_freq_softlimit = val; |
406 | 397 | ||
@@ -431,10 +422,7 @@ static ssize_t gt_min_freq_mhz_show(struct device *kdev, struct device_attribute | |||
431 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); | 422 | flush_delayed_work(&dev_priv->rps.delayed_resume_work); |
432 | 423 | ||
433 | mutex_lock(&dev_priv->rps.hw_lock); | 424 | mutex_lock(&dev_priv->rps.hw_lock); |
434 | if (IS_VALLEYVIEW(dev_priv->dev)) | 425 | ret = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); |
435 | ret = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq_softlimit); | ||
436 | else | ||
437 | ret = dev_priv->rps.min_freq_softlimit * GT_FREQUENCY_MULTIPLIER; | ||
438 | mutex_unlock(&dev_priv->rps.hw_lock); | 426 | mutex_unlock(&dev_priv->rps.hw_lock); |
439 | 427 | ||
440 | return snprintf(buf, PAGE_SIZE, "%d\n", ret); | 428 | return snprintf(buf, PAGE_SIZE, "%d\n", ret); |
@@ -458,10 +446,7 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev, | |||
458 | 446 | ||
459 | mutex_lock(&dev_priv->rps.hw_lock); | 447 | mutex_lock(&dev_priv->rps.hw_lock); |
460 | 448 | ||
461 | if (IS_VALLEYVIEW(dev)) | 449 | val = intel_freq_opcode(dev_priv, val); |
462 | val = vlv_freq_opcode(dev_priv, val); | ||
463 | else | ||
464 | val /= GT_FREQUENCY_MULTIPLIER; | ||
465 | 450 | ||
466 | if (val < dev_priv->rps.min_freq || | 451 | if (val < dev_priv->rps.min_freq || |
467 | val > dev_priv->rps.max_freq || | 452 | val > dev_priv->rps.max_freq || |
@@ -521,19 +506,22 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr | |||
521 | 506 | ||
522 | if (attr == &dev_attr_gt_RP0_freq_mhz) { | 507 | if (attr == &dev_attr_gt_RP0_freq_mhz) { |
523 | if (IS_VALLEYVIEW(dev)) | 508 | if (IS_VALLEYVIEW(dev)) |
524 | val = vlv_gpu_freq(dev_priv, dev_priv->rps.rp0_freq); | 509 | val = intel_gpu_freq(dev_priv, dev_priv->rps.rp0_freq); |
525 | else | 510 | else |
526 | val = ((rp_state_cap & 0x0000ff) >> 0) * GT_FREQUENCY_MULTIPLIER; | 511 | val = intel_gpu_freq(dev_priv, |
512 | ((rp_state_cap & 0x0000ff) >> 0)); | ||
527 | } else if (attr == &dev_attr_gt_RP1_freq_mhz) { | 513 | } else if (attr == &dev_attr_gt_RP1_freq_mhz) { |
528 | if (IS_VALLEYVIEW(dev)) | 514 | if (IS_VALLEYVIEW(dev)) |
529 | val = vlv_gpu_freq(dev_priv, dev_priv->rps.rp1_freq); | 515 | val = intel_gpu_freq(dev_priv, dev_priv->rps.rp1_freq); |
530 | else | 516 | else |
531 | val = ((rp_state_cap & 0x00ff00) >> 8) * GT_FREQUENCY_MULTIPLIER; | 517 | val = intel_gpu_freq(dev_priv, |
518 | ((rp_state_cap & 0x00ff00) >> 8)); | ||
532 | } else if (attr == &dev_attr_gt_RPn_freq_mhz) { | 519 | } else if (attr == &dev_attr_gt_RPn_freq_mhz) { |
533 | if (IS_VALLEYVIEW(dev)) | 520 | if (IS_VALLEYVIEW(dev)) |
534 | val = vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq); | 521 | val = intel_gpu_freq(dev_priv, dev_priv->rps.min_freq); |
535 | else | 522 | else |
536 | val = ((rp_state_cap & 0xff0000) >> 16) * GT_FREQUENCY_MULTIPLIER; | 523 | val = intel_gpu_freq(dev_priv, |
524 | ((rp_state_cap & 0xff0000) >> 16)); | ||
537 | } else { | 525 | } else { |
538 | BUG(); | 526 | BUG(); |
539 | } | 527 | } |
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index bc243a2840c4..dbeecb03c9e1 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
@@ -3883,7 +3883,7 @@ void valleyview_set_rps(struct drm_device *dev, u8 val) | |||
3883 | I915_WRITE(GEN6_PMINTRMSK, gen6_rps_pm_mask(dev_priv, val)); | 3883 | I915_WRITE(GEN6_PMINTRMSK, gen6_rps_pm_mask(dev_priv, val)); |
3884 | 3884 | ||
3885 | dev_priv->rps.cur_freq = val; | 3885 | dev_priv->rps.cur_freq = val; |
3886 | trace_intel_gpu_freq_change(vlv_gpu_freq(dev_priv, val)); | 3886 | trace_intel_gpu_freq_change(intel_gpu_freq(dev_priv, val)); |
3887 | } | 3887 | } |
3888 | 3888 | ||
3889 | static void gen9_disable_rps(struct drm_device *dev) | 3889 | static void gen9_disable_rps(struct drm_device *dev) |
@@ -4619,22 +4619,22 @@ static void valleyview_init_gt_powersave(struct drm_device *dev) | |||
4619 | dev_priv->rps.max_freq = valleyview_rps_max_freq(dev_priv); | 4619 | dev_priv->rps.max_freq = valleyview_rps_max_freq(dev_priv); |
4620 | dev_priv->rps.rp0_freq = dev_priv->rps.max_freq; | 4620 | dev_priv->rps.rp0_freq = dev_priv->rps.max_freq; |
4621 | DRM_DEBUG_DRIVER("max GPU freq: %d MHz (%u)\n", | 4621 | DRM_DEBUG_DRIVER("max GPU freq: %d MHz (%u)\n", |
4622 | vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq), | 4622 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq), |
4623 | dev_priv->rps.max_freq); | 4623 | dev_priv->rps.max_freq); |
4624 | 4624 | ||
4625 | dev_priv->rps.efficient_freq = valleyview_rps_rpe_freq(dev_priv); | 4625 | dev_priv->rps.efficient_freq = valleyview_rps_rpe_freq(dev_priv); |
4626 | DRM_DEBUG_DRIVER("RPe GPU freq: %d MHz (%u)\n", | 4626 | DRM_DEBUG_DRIVER("RPe GPU freq: %d MHz (%u)\n", |
4627 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), | 4627 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
4628 | dev_priv->rps.efficient_freq); | 4628 | dev_priv->rps.efficient_freq); |
4629 | 4629 | ||
4630 | dev_priv->rps.rp1_freq = valleyview_rps_guar_freq(dev_priv); | 4630 | dev_priv->rps.rp1_freq = valleyview_rps_guar_freq(dev_priv); |
4631 | DRM_DEBUG_DRIVER("RP1(Guar Freq) GPU freq: %d MHz (%u)\n", | 4631 | DRM_DEBUG_DRIVER("RP1(Guar Freq) GPU freq: %d MHz (%u)\n", |
4632 | vlv_gpu_freq(dev_priv, dev_priv->rps.rp1_freq), | 4632 | intel_gpu_freq(dev_priv, dev_priv->rps.rp1_freq), |
4633 | dev_priv->rps.rp1_freq); | 4633 | dev_priv->rps.rp1_freq); |
4634 | 4634 | ||
4635 | dev_priv->rps.min_freq = valleyview_rps_min_freq(dev_priv); | 4635 | dev_priv->rps.min_freq = valleyview_rps_min_freq(dev_priv); |
4636 | DRM_DEBUG_DRIVER("min GPU freq: %d MHz (%u)\n", | 4636 | DRM_DEBUG_DRIVER("min GPU freq: %d MHz (%u)\n", |
4637 | vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq), | 4637 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
4638 | dev_priv->rps.min_freq); | 4638 | dev_priv->rps.min_freq); |
4639 | 4639 | ||
4640 | /* Preserve min/max settings in case of re-init */ | 4640 | /* Preserve min/max settings in case of re-init */ |
@@ -4688,22 +4688,22 @@ static void cherryview_init_gt_powersave(struct drm_device *dev) | |||
4688 | dev_priv->rps.max_freq = cherryview_rps_max_freq(dev_priv); | 4688 | dev_priv->rps.max_freq = cherryview_rps_max_freq(dev_priv); |
4689 | dev_priv->rps.rp0_freq = dev_priv->rps.max_freq; | 4689 | dev_priv->rps.rp0_freq = dev_priv->rps.max_freq; |
4690 | DRM_DEBUG_DRIVER("max GPU freq: %d MHz (%u)\n", | 4690 | DRM_DEBUG_DRIVER("max GPU freq: %d MHz (%u)\n", |
4691 | vlv_gpu_freq(dev_priv, dev_priv->rps.max_freq), | 4691 | intel_gpu_freq(dev_priv, dev_priv->rps.max_freq), |
4692 | dev_priv->rps.max_freq); | 4692 | dev_priv->rps.max_freq); |
4693 | 4693 | ||
4694 | dev_priv->rps.efficient_freq = cherryview_rps_rpe_freq(dev_priv); | 4694 | dev_priv->rps.efficient_freq = cherryview_rps_rpe_freq(dev_priv); |
4695 | DRM_DEBUG_DRIVER("RPe GPU freq: %d MHz (%u)\n", | 4695 | DRM_DEBUG_DRIVER("RPe GPU freq: %d MHz (%u)\n", |
4696 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), | 4696 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
4697 | dev_priv->rps.efficient_freq); | 4697 | dev_priv->rps.efficient_freq); |
4698 | 4698 | ||
4699 | dev_priv->rps.rp1_freq = cherryview_rps_guar_freq(dev_priv); | 4699 | dev_priv->rps.rp1_freq = cherryview_rps_guar_freq(dev_priv); |
4700 | DRM_DEBUG_DRIVER("RP1(Guar) GPU freq: %d MHz (%u)\n", | 4700 | DRM_DEBUG_DRIVER("RP1(Guar) GPU freq: %d MHz (%u)\n", |
4701 | vlv_gpu_freq(dev_priv, dev_priv->rps.rp1_freq), | 4701 | intel_gpu_freq(dev_priv, dev_priv->rps.rp1_freq), |
4702 | dev_priv->rps.rp1_freq); | 4702 | dev_priv->rps.rp1_freq); |
4703 | 4703 | ||
4704 | dev_priv->rps.min_freq = cherryview_rps_min_freq(dev_priv); | 4704 | dev_priv->rps.min_freq = cherryview_rps_min_freq(dev_priv); |
4705 | DRM_DEBUG_DRIVER("min GPU freq: %d MHz (%u)\n", | 4705 | DRM_DEBUG_DRIVER("min GPU freq: %d MHz (%u)\n", |
4706 | vlv_gpu_freq(dev_priv, dev_priv->rps.min_freq), | 4706 | intel_gpu_freq(dev_priv, dev_priv->rps.min_freq), |
4707 | dev_priv->rps.min_freq); | 4707 | dev_priv->rps.min_freq); |
4708 | 4708 | ||
4709 | WARN_ONCE((dev_priv->rps.max_freq | | 4709 | WARN_ONCE((dev_priv->rps.max_freq | |
@@ -4807,11 +4807,11 @@ static void cherryview_enable_rps(struct drm_device *dev) | |||
4807 | 4807 | ||
4808 | dev_priv->rps.cur_freq = (val >> 8) & 0xff; | 4808 | dev_priv->rps.cur_freq = (val >> 8) & 0xff; |
4809 | DRM_DEBUG_DRIVER("current GPU freq: %d MHz (%u)\n", | 4809 | DRM_DEBUG_DRIVER("current GPU freq: %d MHz (%u)\n", |
4810 | vlv_gpu_freq(dev_priv, dev_priv->rps.cur_freq), | 4810 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
4811 | dev_priv->rps.cur_freq); | 4811 | dev_priv->rps.cur_freq); |
4812 | 4812 | ||
4813 | DRM_DEBUG_DRIVER("setting GPU freq to %d MHz (%u)\n", | 4813 | DRM_DEBUG_DRIVER("setting GPU freq to %d MHz (%u)\n", |
4814 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), | 4814 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
4815 | dev_priv->rps.efficient_freq); | 4815 | dev_priv->rps.efficient_freq); |
4816 | 4816 | ||
4817 | valleyview_set_rps(dev_priv->dev, dev_priv->rps.efficient_freq); | 4817 | valleyview_set_rps(dev_priv->dev, dev_priv->rps.efficient_freq); |
@@ -4891,11 +4891,11 @@ static void valleyview_enable_rps(struct drm_device *dev) | |||
4891 | 4891 | ||
4892 | dev_priv->rps.cur_freq = (val >> 8) & 0xff; | 4892 | dev_priv->rps.cur_freq = (val >> 8) & 0xff; |
4893 | DRM_DEBUG_DRIVER("current GPU freq: %d MHz (%u)\n", | 4893 | DRM_DEBUG_DRIVER("current GPU freq: %d MHz (%u)\n", |
4894 | vlv_gpu_freq(dev_priv, dev_priv->rps.cur_freq), | 4894 | intel_gpu_freq(dev_priv, dev_priv->rps.cur_freq), |
4895 | dev_priv->rps.cur_freq); | 4895 | dev_priv->rps.cur_freq); |
4896 | 4896 | ||
4897 | DRM_DEBUG_DRIVER("setting GPU freq to %d MHz (%u)\n", | 4897 | DRM_DEBUG_DRIVER("setting GPU freq to %d MHz (%u)\n", |
4898 | vlv_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), | 4898 | intel_gpu_freq(dev_priv, dev_priv->rps.efficient_freq), |
4899 | dev_priv->rps.efficient_freq); | 4899 | dev_priv->rps.efficient_freq); |
4900 | 4900 | ||
4901 | valleyview_set_rps(dev_priv->dev, dev_priv->rps.efficient_freq); | 4901 | valleyview_set_rps(dev_priv->dev, dev_priv->rps.efficient_freq); |
@@ -6625,11 +6625,6 @@ int intel_gpu_freq(struct drm_i915_private *dev_priv, int val) | |||
6625 | return val * GT_FREQUENCY_MULTIPLIER; | 6625 | return val * GT_FREQUENCY_MULTIPLIER; |
6626 | } | 6626 | } |
6627 | 6627 | ||
6628 | int vlv_gpu_freq(struct drm_i915_private *dev_priv, int val) | ||
6629 | { | ||
6630 | return intel_gpu_freq(dev_priv, val); | ||
6631 | } | ||
6632 | |||
6633 | int intel_freq_opcode(struct drm_i915_private *dev_priv, int val) | 6628 | int intel_freq_opcode(struct drm_i915_private *dev_priv, int val) |
6634 | { | 6629 | { |
6635 | if (IS_CHERRYVIEW(dev_priv->dev)) | 6630 | if (IS_CHERRYVIEW(dev_priv->dev)) |
@@ -6640,11 +6635,6 @@ int intel_freq_opcode(struct drm_i915_private *dev_priv, int val) | |||
6640 | return val / GT_FREQUENCY_MULTIPLIER; | 6635 | return val / GT_FREQUENCY_MULTIPLIER; |
6641 | } | 6636 | } |
6642 | 6637 | ||
6643 | int vlv_freq_opcode(struct drm_i915_private *dev_priv, int val) | ||
6644 | { | ||
6645 | return intel_freq_opcode(dev_priv, val); | ||
6646 | } | ||
6647 | |||
6648 | void intel_pm_setup(struct drm_device *dev) | 6638 | void intel_pm_setup(struct drm_device *dev) |
6649 | { | 6639 | { |
6650 | struct drm_i915_private *dev_priv = dev->dev_private; | 6640 | struct drm_i915_private *dev_priv = dev->dev_private; |