diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-08-08 17:35:39 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-09-03 04:09:27 -0400 |
commit | 20e4d407fbe39bd15f6d4ded25e8c307789ecc80 (patch) | |
tree | 75c09cd9f0b9b2327d387f941a9e26126d4b75aa | |
parent | f39876317a69a104eeaed002d4085348e871bfd1 (diff) |
drm/ips: move drps/ips/ilk related variables into dev_priv->ips
Like with the equivalent change for gen6+ rps state, this helps in
clarifying the code (and in fixing a few places that have fallen through
the cracks in the locking review).
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 36 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_irq.c | 20 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_pm.c | 86 |
3 files changed, 70 insertions, 72 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 58b43db0a134..f16ab5e25aef 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -839,22 +839,26 @@ typedef struct drm_i915_private { | |||
839 | u8 max_delay; | 839 | u8 max_delay; |
840 | } rps; | 840 | } rps; |
841 | 841 | ||
842 | 842 | /* ilk-only ips/rps state. Everything in here is protected by the global | |
843 | u8 cur_delay; | 843 | * mchdev_lock in intel_pm.c */ |
844 | u8 min_delay; | 844 | struct { |
845 | u8 max_delay; | 845 | u8 cur_delay; |
846 | u8 fmax; | 846 | u8 min_delay; |
847 | u8 fstart; | 847 | u8 max_delay; |
848 | 848 | u8 fmax; | |
849 | u64 last_count1; | 849 | u8 fstart; |
850 | unsigned long last_time1; | 850 | |
851 | unsigned long chipset_power; | 851 | u64 last_count1; |
852 | u64 last_count2; | 852 | unsigned long last_time1; |
853 | struct timespec last_time2; | 853 | unsigned long chipset_power; |
854 | unsigned long gfx_power; | 854 | u64 last_count2; |
855 | int c_m; | 855 | struct timespec last_time2; |
856 | int r_t; | 856 | unsigned long gfx_power; |
857 | u8 corr; | 857 | u8 corr; |
858 | |||
859 | int c_m; | ||
860 | int r_t; | ||
861 | } ips; | ||
858 | 862 | ||
859 | enum no_fbc_reason no_fbc_reason; | 863 | enum no_fbc_reason no_fbc_reason; |
860 | 864 | ||
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index a9f74f3b4073..d6010135e404 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c | |||
@@ -310,7 +310,7 @@ static void ironlake_handle_rps_change(struct drm_device *dev) | |||
310 | 310 | ||
311 | I915_WRITE16(MEMINTRSTS, I915_READ(MEMINTRSTS)); | 311 | I915_WRITE16(MEMINTRSTS, I915_READ(MEMINTRSTS)); |
312 | 312 | ||
313 | new_delay = dev_priv->cur_delay; | 313 | new_delay = dev_priv->ips.cur_delay; |
314 | 314 | ||
315 | I915_WRITE16(MEMINTRSTS, MEMINT_EVAL_CHG); | 315 | I915_WRITE16(MEMINTRSTS, MEMINT_EVAL_CHG); |
316 | busy_up = I915_READ(RCPREVBSYTUPAVG); | 316 | busy_up = I915_READ(RCPREVBSYTUPAVG); |
@@ -320,19 +320,19 @@ static void ironlake_handle_rps_change(struct drm_device *dev) | |||
320 | 320 | ||
321 | /* Handle RCS change request from hw */ | 321 | /* Handle RCS change request from hw */ |
322 | if (busy_up > max_avg) { | 322 | if (busy_up > max_avg) { |
323 | if (dev_priv->cur_delay != dev_priv->max_delay) | 323 | if (dev_priv->ips.cur_delay != dev_priv->ips.max_delay) |
324 | new_delay = dev_priv->cur_delay - 1; | 324 | new_delay = dev_priv->ips.cur_delay - 1; |
325 | if (new_delay < dev_priv->max_delay) | 325 | if (new_delay < dev_priv->ips.max_delay) |
326 | new_delay = dev_priv->max_delay; | 326 | new_delay = dev_priv->ips.max_delay; |
327 | } else if (busy_down < min_avg) { | 327 | } else if (busy_down < min_avg) { |
328 | if (dev_priv->cur_delay != dev_priv->min_delay) | 328 | if (dev_priv->ips.cur_delay != dev_priv->ips.min_delay) |
329 | new_delay = dev_priv->cur_delay + 1; | 329 | new_delay = dev_priv->ips.cur_delay + 1; |
330 | if (new_delay > dev_priv->min_delay) | 330 | if (new_delay > dev_priv->ips.min_delay) |
331 | new_delay = dev_priv->min_delay; | 331 | new_delay = dev_priv->ips.min_delay; |
332 | } | 332 | } |
333 | 333 | ||
334 | if (ironlake_set_drps(dev, new_delay)) | 334 | if (ironlake_set_drps(dev, new_delay)) |
335 | dev_priv->cur_delay = new_delay; | 335 | dev_priv->ips.cur_delay = new_delay; |
336 | 336 | ||
337 | spin_unlock_irqrestore(&mchdev_lock, flags); | 337 | spin_unlock_irqrestore(&mchdev_lock, flags); |
338 | 338 | ||
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c index a465debdfcf7..8dc802c4ec74 100644 --- a/drivers/gpu/drm/i915/intel_pm.c +++ b/drivers/gpu/drm/i915/intel_pm.c | |||
@@ -593,7 +593,7 @@ static void i915_ironlake_get_mem_freq(struct drm_device *dev) | |||
593 | break; | 593 | break; |
594 | } | 594 | } |
595 | 595 | ||
596 | dev_priv->r_t = dev_priv->mem_freq; | 596 | dev_priv->ips.r_t = dev_priv->mem_freq; |
597 | 597 | ||
598 | switch (csipll & 0x3ff) { | 598 | switch (csipll & 0x3ff) { |
599 | case 0x00c: | 599 | case 0x00c: |
@@ -625,11 +625,11 @@ static void i915_ironlake_get_mem_freq(struct drm_device *dev) | |||
625 | } | 625 | } |
626 | 626 | ||
627 | if (dev_priv->fsb_freq == 3200) { | 627 | if (dev_priv->fsb_freq == 3200) { |
628 | dev_priv->c_m = 0; | 628 | dev_priv->ips.c_m = 0; |
629 | } else if (dev_priv->fsb_freq > 3200 && dev_priv->fsb_freq <= 4800) { | 629 | } else if (dev_priv->fsb_freq > 3200 && dev_priv->fsb_freq <= 4800) { |
630 | dev_priv->c_m = 1; | 630 | dev_priv->ips.c_m = 1; |
631 | } else { | 631 | } else { |
632 | dev_priv->c_m = 2; | 632 | dev_priv->ips.c_m = 2; |
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
@@ -2162,12 +2162,6 @@ err_unref: | |||
2162 | 2162 | ||
2163 | /** | 2163 | /** |
2164 | * Lock protecting IPS related data structures | 2164 | * Lock protecting IPS related data structures |
2165 | * - i915_mch_dev | ||
2166 | * - dev_priv->max_delay | ||
2167 | * - dev_priv->min_delay | ||
2168 | * - dev_priv->fmax | ||
2169 | * - dev_priv->gpu_busy | ||
2170 | * - dev_priv->gfx_power | ||
2171 | */ | 2165 | */ |
2172 | DEFINE_SPINLOCK(mchdev_lock); | 2166 | DEFINE_SPINLOCK(mchdev_lock); |
2173 | 2167 | ||
@@ -2230,12 +2224,12 @@ static void ironlake_enable_drps(struct drm_device *dev) | |||
2230 | vstart = (I915_READ(PXVFREQ_BASE + (fstart * 4)) & PXVFREQ_PX_MASK) >> | 2224 | vstart = (I915_READ(PXVFREQ_BASE + (fstart * 4)) & PXVFREQ_PX_MASK) >> |
2231 | PXVFREQ_PX_SHIFT; | 2225 | PXVFREQ_PX_SHIFT; |
2232 | 2226 | ||
2233 | dev_priv->fmax = fmax; /* IPS callback will increase this */ | 2227 | dev_priv->ips.fmax = fmax; /* IPS callback will increase this */ |
2234 | dev_priv->fstart = fstart; | 2228 | dev_priv->ips.fstart = fstart; |
2235 | 2229 | ||
2236 | dev_priv->max_delay = fstart; | 2230 | dev_priv->ips.max_delay = fstart; |
2237 | dev_priv->min_delay = fmin; | 2231 | dev_priv->ips.min_delay = fmin; |
2238 | dev_priv->cur_delay = fstart; | 2232 | dev_priv->ips.cur_delay = fstart; |
2239 | 2233 | ||
2240 | DRM_DEBUG_DRIVER("fmax: %d, fmin: %d, fstart: %d\n", | 2234 | DRM_DEBUG_DRIVER("fmax: %d, fmin: %d, fstart: %d\n", |
2241 | fmax, fmin, fstart); | 2235 | fmax, fmin, fstart); |
@@ -2258,11 +2252,11 @@ static void ironlake_enable_drps(struct drm_device *dev) | |||
2258 | 2252 | ||
2259 | ironlake_set_drps(dev, fstart); | 2253 | ironlake_set_drps(dev, fstart); |
2260 | 2254 | ||
2261 | dev_priv->last_count1 = I915_READ(0x112e4) + I915_READ(0x112e8) + | 2255 | dev_priv->ips.last_count1 = I915_READ(0x112e4) + I915_READ(0x112e8) + |
2262 | I915_READ(0x112e0); | 2256 | I915_READ(0x112e0); |
2263 | dev_priv->last_time1 = jiffies_to_msecs(jiffies); | 2257 | dev_priv->ips.last_time1 = jiffies_to_msecs(jiffies); |
2264 | dev_priv->last_count2 = I915_READ(0x112f4); | 2258 | dev_priv->ips.last_count2 = I915_READ(0x112f4); |
2265 | getrawmonotonic(&dev_priv->last_time2); | 2259 | getrawmonotonic(&dev_priv->ips.last_time2); |
2266 | 2260 | ||
2267 | spin_unlock_irq(&mchdev_lock); | 2261 | spin_unlock_irq(&mchdev_lock); |
2268 | } | 2262 | } |
@@ -2284,7 +2278,7 @@ static void ironlake_disable_drps(struct drm_device *dev) | |||
2284 | I915_WRITE(DEIMR, I915_READ(DEIMR) | DE_PCU_EVENT); | 2278 | I915_WRITE(DEIMR, I915_READ(DEIMR) | DE_PCU_EVENT); |
2285 | 2279 | ||
2286 | /* Go back to the starting frequency */ | 2280 | /* Go back to the starting frequency */ |
2287 | ironlake_set_drps(dev, dev_priv->fstart); | 2281 | ironlake_set_drps(dev, dev_priv->ips.fstart); |
2288 | mdelay(1); | 2282 | mdelay(1); |
2289 | rgvswctl |= MEMCTL_CMD_STS; | 2283 | rgvswctl |= MEMCTL_CMD_STS; |
2290 | I915_WRITE(MEMSWCTL, rgvswctl); | 2284 | I915_WRITE(MEMSWCTL, rgvswctl); |
@@ -2741,7 +2735,7 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv) | |||
2741 | 2735 | ||
2742 | assert_spin_locked(&mchdev_lock); | 2736 | assert_spin_locked(&mchdev_lock); |
2743 | 2737 | ||
2744 | diff1 = now - dev_priv->last_time1; | 2738 | diff1 = now - dev_priv->ips.last_time1; |
2745 | 2739 | ||
2746 | /* Prevent division-by-zero if we are asking too fast. | 2740 | /* Prevent division-by-zero if we are asking too fast. |
2747 | * Also, we don't get interesting results if we are polling | 2741 | * Also, we don't get interesting results if we are polling |
@@ -2749,7 +2743,7 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv) | |||
2749 | * in such cases. | 2743 | * in such cases. |
2750 | */ | 2744 | */ |
2751 | if (diff1 <= 10) | 2745 | if (diff1 <= 10) |
2752 | return dev_priv->chipset_power; | 2746 | return dev_priv->ips.chipset_power; |
2753 | 2747 | ||
2754 | count1 = I915_READ(DMIEC); | 2748 | count1 = I915_READ(DMIEC); |
2755 | count2 = I915_READ(DDREC); | 2749 | count2 = I915_READ(DDREC); |
@@ -2758,16 +2752,16 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv) | |||
2758 | total_count = count1 + count2 + count3; | 2752 | total_count = count1 + count2 + count3; |
2759 | 2753 | ||
2760 | /* FIXME: handle per-counter overflow */ | 2754 | /* FIXME: handle per-counter overflow */ |
2761 | if (total_count < dev_priv->last_count1) { | 2755 | if (total_count < dev_priv->ips.last_count1) { |
2762 | diff = ~0UL - dev_priv->last_count1; | 2756 | diff = ~0UL - dev_priv->ips.last_count1; |
2763 | diff += total_count; | 2757 | diff += total_count; |
2764 | } else { | 2758 | } else { |
2765 | diff = total_count - dev_priv->last_count1; | 2759 | diff = total_count - dev_priv->ips.last_count1; |
2766 | } | 2760 | } |
2767 | 2761 | ||
2768 | for (i = 0; i < ARRAY_SIZE(cparams); i++) { | 2762 | for (i = 0; i < ARRAY_SIZE(cparams); i++) { |
2769 | if (cparams[i].i == dev_priv->c_m && | 2763 | if (cparams[i].i == dev_priv->ips.c_m && |
2770 | cparams[i].t == dev_priv->r_t) { | 2764 | cparams[i].t == dev_priv->ips.r_t) { |
2771 | m = cparams[i].m; | 2765 | m = cparams[i].m; |
2772 | c = cparams[i].c; | 2766 | c = cparams[i].c; |
2773 | break; | 2767 | break; |
@@ -2778,10 +2772,10 @@ unsigned long i915_chipset_val(struct drm_i915_private *dev_priv) | |||
2778 | ret = ((m * diff) + c); | 2772 | ret = ((m * diff) + c); |
2779 | ret = div_u64(ret, 10); | 2773 | ret = div_u64(ret, 10); |
2780 | 2774 | ||
2781 | dev_priv->last_count1 = total_count; | 2775 | dev_priv->ips.last_count1 = total_count; |
2782 | dev_priv->last_time1 = now; | 2776 | dev_priv->ips.last_time1 = now; |
2783 | 2777 | ||
2784 | dev_priv->chipset_power = ret; | 2778 | dev_priv->ips.chipset_power = ret; |
2785 | 2779 | ||
2786 | return ret; | 2780 | return ret; |
2787 | } | 2781 | } |
@@ -2952,7 +2946,7 @@ static void __i915_update_gfx_val(struct drm_i915_private *dev_priv) | |||
2952 | assert_spin_locked(&mchdev_lock); | 2946 | assert_spin_locked(&mchdev_lock); |
2953 | 2947 | ||
2954 | getrawmonotonic(&now); | 2948 | getrawmonotonic(&now); |
2955 | diff1 = timespec_sub(now, dev_priv->last_time2); | 2949 | diff1 = timespec_sub(now, dev_priv->ips.last_time2); |
2956 | 2950 | ||
2957 | /* Don't divide by 0 */ | 2951 | /* Don't divide by 0 */ |
2958 | diffms = diff1.tv_sec * 1000 + diff1.tv_nsec / 1000000; | 2952 | diffms = diff1.tv_sec * 1000 + diff1.tv_nsec / 1000000; |
@@ -2961,20 +2955,20 @@ static void __i915_update_gfx_val(struct drm_i915_private *dev_priv) | |||
2961 | 2955 | ||
2962 | count = I915_READ(GFXEC); | 2956 | count = I915_READ(GFXEC); |
2963 | 2957 | ||
2964 | if (count < dev_priv->last_count2) { | 2958 | if (count < dev_priv->ips.last_count2) { |
2965 | diff = ~0UL - dev_priv->last_count2; | 2959 | diff = ~0UL - dev_priv->ips.last_count2; |
2966 | diff += count; | 2960 | diff += count; |
2967 | } else { | 2961 | } else { |
2968 | diff = count - dev_priv->last_count2; | 2962 | diff = count - dev_priv->ips.last_count2; |
2969 | } | 2963 | } |
2970 | 2964 | ||
2971 | dev_priv->last_count2 = count; | 2965 | dev_priv->ips.last_count2 = count; |
2972 | dev_priv->last_time2 = now; | 2966 | dev_priv->ips.last_time2 = now; |
2973 | 2967 | ||
2974 | /* More magic constants... */ | 2968 | /* More magic constants... */ |
2975 | diff = diff * 1181; | 2969 | diff = diff * 1181; |
2976 | diff = div_u64(diff, diffms * 10); | 2970 | diff = div_u64(diff, diffms * 10); |
2977 | dev_priv->gfx_power = diff; | 2971 | dev_priv->ips.gfx_power = diff; |
2978 | } | 2972 | } |
2979 | 2973 | ||
2980 | void i915_update_gfx_val(struct drm_i915_private *dev_priv) | 2974 | void i915_update_gfx_val(struct drm_i915_private *dev_priv) |
@@ -3016,14 +3010,14 @@ unsigned long i915_gfx_val(struct drm_i915_private *dev_priv) | |||
3016 | 3010 | ||
3017 | corr = corr * ((150142 * state1) / 10000 - 78642); | 3011 | corr = corr * ((150142 * state1) / 10000 - 78642); |
3018 | corr /= 100000; | 3012 | corr /= 100000; |
3019 | corr2 = (corr * dev_priv->corr); | 3013 | corr2 = (corr * dev_priv->ips.corr); |
3020 | 3014 | ||
3021 | state2 = (corr2 * state1) / 10000; | 3015 | state2 = (corr2 * state1) / 10000; |
3022 | state2 /= 100; /* convert to mW */ | 3016 | state2 /= 100; /* convert to mW */ |
3023 | 3017 | ||
3024 | __i915_update_gfx_val(dev_priv); | 3018 | __i915_update_gfx_val(dev_priv); |
3025 | 3019 | ||
3026 | return dev_priv->gfx_power + state2; | 3020 | return dev_priv->ips.gfx_power + state2; |
3027 | } | 3021 | } |
3028 | 3022 | ||
3029 | /** | 3023 | /** |
@@ -3071,8 +3065,8 @@ bool i915_gpu_raise(void) | |||
3071 | } | 3065 | } |
3072 | dev_priv = i915_mch_dev; | 3066 | dev_priv = i915_mch_dev; |
3073 | 3067 | ||
3074 | if (dev_priv->max_delay > dev_priv->fmax) | 3068 | if (dev_priv->ips.max_delay > dev_priv->ips.fmax) |
3075 | dev_priv->max_delay--; | 3069 | dev_priv->ips.max_delay--; |
3076 | 3070 | ||
3077 | out_unlock: | 3071 | out_unlock: |
3078 | spin_unlock_irq(&mchdev_lock); | 3072 | spin_unlock_irq(&mchdev_lock); |
@@ -3099,8 +3093,8 @@ bool i915_gpu_lower(void) | |||
3099 | } | 3093 | } |
3100 | dev_priv = i915_mch_dev; | 3094 | dev_priv = i915_mch_dev; |
3101 | 3095 | ||
3102 | if (dev_priv->max_delay < dev_priv->min_delay) | 3096 | if (dev_priv->ips.max_delay < dev_priv->ips.min_delay) |
3103 | dev_priv->max_delay++; | 3097 | dev_priv->ips.max_delay++; |
3104 | 3098 | ||
3105 | out_unlock: | 3099 | out_unlock: |
3106 | spin_unlock_irq(&mchdev_lock); | 3100 | spin_unlock_irq(&mchdev_lock); |
@@ -3154,9 +3148,9 @@ bool i915_gpu_turbo_disable(void) | |||
3154 | } | 3148 | } |
3155 | dev_priv = i915_mch_dev; | 3149 | dev_priv = i915_mch_dev; |
3156 | 3150 | ||
3157 | dev_priv->max_delay = dev_priv->fstart; | 3151 | dev_priv->ips.max_delay = dev_priv->ips.fstart; |
3158 | 3152 | ||
3159 | if (!ironlake_set_drps(dev_priv->dev, dev_priv->fstart)) | 3153 | if (!ironlake_set_drps(dev_priv->dev, dev_priv->ips.fstart)) |
3160 | ret = false; | 3154 | ret = false; |
3161 | 3155 | ||
3162 | out_unlock: | 3156 | out_unlock: |
@@ -3271,7 +3265,7 @@ static void intel_init_emon(struct drm_device *dev) | |||
3271 | 3265 | ||
3272 | lcfuse = I915_READ(LCFUSE02); | 3266 | lcfuse = I915_READ(LCFUSE02); |
3273 | 3267 | ||
3274 | dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK); | 3268 | dev_priv->ips.corr = (lcfuse & LCFUSE_HIV_MASK); |
3275 | } | 3269 | } |
3276 | 3270 | ||
3277 | void intel_disable_gt_powersave(struct drm_device *dev) | 3271 | void intel_disable_gt_powersave(struct drm_device *dev) |