gt_pm selftest calculates engine ticks cycles and wall time
cycles by delta of respective engine elapsed TIMESTAMP and ktime
for period of 1000us.
It compares the engine ticks cycles with wall time cycles.

Disable local cpu interrupt so that interrupt handler does not
switch out the thread during measure_clocks() and prevent
miscalculation of engine tick cycles.

Suggested-by: Chris P Wilson <chris.p.wil...@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gu...@intel.com>
Reviewed-by: Badal Nilawar <badal.nila...@intel.com>
---
 drivers/gpu/drm/i915/gt/selftest_gt_pm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c 
b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
index b9441217ca3d..4c4953044548 100644
--- a/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/selftest_gt_pm.c
@@ -40,9 +40,11 @@ static void measure_clocks(struct intel_engine_cs *engine,
 {
        ktime_t dt[5];
        u32 cycles[5];
+       unsigned long flags;
        int i;
 
        for (i = 0; i < 5; i++) {
+               local_irq_save(flags);
                preempt_disable();
                cycles[i] = -ENGINE_READ_FW(engine, RING_TIMESTAMP);
                dt[i] = ktime_get();
@@ -52,6 +54,7 @@ static void measure_clocks(struct intel_engine_cs *engine,
                dt[i] = ktime_sub(ktime_get(), dt[i]);
                cycles[i] += ENGINE_READ_FW(engine, RING_TIMESTAMP);
                preempt_enable();
+               local_irq_restore(flags);
        }
 
        /* Use the median of both cycle/dt; close enough */
-- 
2.26.2

Reply via email to