diff options
| -rw-r--r-- | drivers/gpu/drm/i915/i915_pmu.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index d8feb9053e0c..f0519e31543a 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c | |||
| @@ -473,20 +473,37 @@ static u64 get_rc6(struct drm_i915_private *i915) | |||
| 473 | spin_lock_irqsave(&i915->pmu.lock, flags); | 473 | spin_lock_irqsave(&i915->pmu.lock, flags); |
| 474 | spin_lock(&kdev->power.lock); | 474 | spin_lock(&kdev->power.lock); |
| 475 | 475 | ||
| 476 | if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) | 476 | /* |
| 477 | i915->pmu.suspended_jiffies_last = | 477 | * After the above branch intel_runtime_pm_get_if_in_use failed |
| 478 | kdev->power.suspended_jiffies; | 478 | * to get the runtime PM reference we cannot assume we are in |
| 479 | * runtime suspend since we can either: a) race with coming out | ||
| 480 | * of it before we took the power.lock, or b) there are other | ||
| 481 | * states than suspended which can bring us here. | ||
| 482 | * | ||
| 483 | * We need to double-check that we are indeed currently runtime | ||
| 484 | * suspended and if not we cannot do better than report the last | ||
| 485 | * known RC6 value. | ||
| 486 | */ | ||
| 487 | if (kdev->power.runtime_status == RPM_SUSPENDED) { | ||
| 488 | if (!i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) | ||
| 489 | i915->pmu.suspended_jiffies_last = | ||
| 490 | kdev->power.suspended_jiffies; | ||
| 479 | 491 | ||
| 480 | val = kdev->power.suspended_jiffies - | 492 | val = kdev->power.suspended_jiffies - |
| 481 | i915->pmu.suspended_jiffies_last; | 493 | i915->pmu.suspended_jiffies_last; |
| 482 | val += jiffies - kdev->power.accounting_timestamp; | 494 | val += jiffies - kdev->power.accounting_timestamp; |
| 483 | 495 | ||
| 484 | spin_unlock(&kdev->power.lock); | 496 | val = jiffies_to_nsecs(val); |
| 497 | val += i915->pmu.sample[__I915_SAMPLE_RC6].cur; | ||
| 485 | 498 | ||
| 486 | val = jiffies_to_nsecs(val); | 499 | i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; |
| 487 | val += i915->pmu.sample[__I915_SAMPLE_RC6].cur; | 500 | } else if (i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur) { |
| 488 | i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur = val; | 501 | val = i915->pmu.sample[__I915_SAMPLE_RC6_ESTIMATED].cur; |
| 502 | } else { | ||
| 503 | val = i915->pmu.sample[__I915_SAMPLE_RC6].cur; | ||
| 504 | } | ||
| 489 | 505 | ||
| 506 | spin_unlock(&kdev->power.lock); | ||
| 490 | spin_unlock_irqrestore(&i915->pmu.lock, flags); | 507 | spin_unlock_irqrestore(&i915->pmu.lock, flags); |
| 491 | } | 508 | } |
| 492 | 509 | ||
