[PATCH 25/70] drm/i915/gt: Reduce GT runtime stats from seqlock to a latch
Chris Wilson
chris at chris-wilson.co.uk
Sun Jan 10 19:09:10 UTC 2021
Since we can compute the elapsed time to add to the total, during the
PMU sample we only need to have a consistent view of the (start, total,
active) tuple to be able to locally determine the runtime. That can be
arrange by a pair of memory bariiers and carefully sequencing of the
writes and reads.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/i915/gt/intel_gt_pm.c | 34 ++++++------------------
drivers/gpu/drm/i915/gt/intel_gt_types.h | 5 ----
2 files changed, 8 insertions(+), 31 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
index c94e8ac884eb..49aba3588fe7 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
@@ -41,24 +41,18 @@ static void user_forcewake(struct intel_gt *gt, bool suspend)
static void runtime_begin(struct intel_gt *gt)
{
- local_irq_disable();
- write_seqcount_begin(>->stats.lock);
gt->stats.start = ktime_get();
- gt->stats.active = true;
- write_seqcount_end(>->stats.lock);
- local_irq_enable();
+ smp_wmb(); /* pairs with intel_gt_get_busy_time() */
+ WRITE_ONCE(gt->stats.active, true);
}
static void runtime_end(struct intel_gt *gt)
{
- local_irq_disable();
- write_seqcount_begin(>->stats.lock);
- gt->stats.active = false;
gt->stats.total =
ktime_add(gt->stats.total,
ktime_sub(ktime_get(), gt->stats.start));
- write_seqcount_end(>->stats.lock);
- local_irq_enable();
+ smp_wmb(); /* pairs with intel_gt_get_busy_time() */
+ WRITE_ONCE(gt->stats.active, false);
}
static int __gt_unpark(struct intel_wakeref *wf)
@@ -130,7 +124,6 @@ static const struct intel_wakeref_ops wf_ops = {
void intel_gt_pm_init_early(struct intel_gt *gt)
{
intel_wakeref_init(>->wakeref, gt->uncore->rpm, &wf_ops);
- seqcount_mutex_init(>->stats.lock, >->wakeref.mutex);
}
void intel_gt_pm_init(struct intel_gt *gt)
@@ -364,26 +357,15 @@ int intel_gt_runtime_resume(struct intel_gt *gt)
return intel_uc_runtime_resume(>->uc);
}
-static ktime_t __intel_gt_get_awake_time(const struct intel_gt *gt)
+ktime_t intel_gt_get_awake_time(const struct intel_gt *gt)
{
ktime_t total = gt->stats.total;
- if (gt->stats.active)
+ if (READ_ONCE(gt->stats.active)) {
+ smp_rmb(); /* pairs with runtime_begin/end */
total = ktime_add(total,
ktime_sub(ktime_get(), gt->stats.start));
-
- return total;
-}
-
-ktime_t intel_gt_get_awake_time(const struct intel_gt *gt)
-{
- unsigned int seq;
- ktime_t total;
-
- do {
- seq = read_seqcount_begin(>->stats.lock);
- total = __intel_gt_get_awake_time(gt);
- } while (read_seqcount_retry(>->stats.lock, seq));
+ }
return total;
}
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index a83d3e18254d..4205c3f022ad 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -91,11 +91,6 @@ struct intel_gt {
struct {
bool active;
- /**
- * @lock: Lock protecting the below fields.
- */
- seqcount_mutex_t lock;
-
/**
* @total: Total time this engine was busy.
*
--
2.20.1
More information about the Intel-gfx-trybot
mailing list