diff options
author | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-11-29 05:28:05 -0500 |
---|---|---|
committer | Tvrtko Ursulin <tvrtko.ursulin@intel.com> | 2017-11-29 07:29:40 -0500 |
commit | cf669b4e9fdce4cf1a7bef4e7ab8b3db0da021a2 (patch) | |
tree | 2ee9133c5a24319204869fb9ef69b7da3567a9be | |
parent | 439e2ee4ca520e72870e4fa44aa0076060ad6857 (diff) |
drm/i915: Consolidate checks for engine stats availability
Sagar noticed the check can be consolidated between the engine stats
implementation and the PMU.
My first choice was a static inline helper but that got into include
ordering mess quickly fast so I went with a macro instead. At some point
we should perhaps looking into taking out the non-ringubffer bits from
intel_ringbuffer.h into a new intel_engine.h or something.
v2: Use engine->flags. (Chris Wilson)
v3: Rebase and mark GuC as not yet supported. (Chris Wilson)
v4: Move flag setting to intel_engines_reset_default_submission.
(Chris Wilson)
v5: Move flag setting to logical_ring_setup.
v6: intel_engines_reset_default_submission is the wrong place to set the
flag - it needs to be in execlists_set_default_submission. (Sagar)
v7: Flag setting in logical_ring_setup is not required. (Chris)
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Suggested-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Cc: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Sagar Arun Kamble <sagar.a.kamble@intel.com> (v6)
Link: https://patchwork.freedesktop.org/patch/msgid/20171129102805.22690-1-tvrtko.ursulin@linux.intel.com
-rw-r--r-- | drivers/gpu/drm/i915/i915_pmu.c | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_engine_cs.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_guc_submission.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_lrc.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_ringbuffer.h | 6 |
5 files changed, 16 insertions, 9 deletions
diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c index 1c0ee9d68b04..e8e2faf4982f 100644 --- a/drivers/gpu/drm/i915/i915_pmu.c +++ b/drivers/gpu/drm/i915/i915_pmu.c | |||
@@ -90,11 +90,6 @@ static unsigned int event_enabled_bit(struct perf_event *event) | |||
90 | return config_enabled_bit(event->attr.config); | 90 | return config_enabled_bit(event->attr.config); |
91 | } | 91 | } |
92 | 92 | ||
93 | static bool supports_busy_stats(struct drm_i915_private *i915) | ||
94 | { | ||
95 | return INTEL_GEN(i915) >= 8; | ||
96 | } | ||
97 | |||
98 | static bool pmu_needs_timer(struct drm_i915_private *i915, bool gpu_active) | 93 | static bool pmu_needs_timer(struct drm_i915_private *i915, bool gpu_active) |
99 | { | 94 | { |
100 | u64 enable; | 95 | u64 enable; |
@@ -123,8 +118,10 @@ static bool pmu_needs_timer(struct drm_i915_private *i915, bool gpu_active) | |||
123 | /* | 118 | /* |
124 | * Also there is software busyness tracking available we do not | 119 | * Also there is software busyness tracking available we do not |
125 | * need the timer for I915_SAMPLE_BUSY counter. | 120 | * need the timer for I915_SAMPLE_BUSY counter. |
121 | * | ||
122 | * Use RCS as proxy for all engines. | ||
126 | */ | 123 | */ |
127 | else if (supports_busy_stats(i915)) | 124 | else if (intel_engine_supports_stats(i915->engine[RCS])) |
128 | enable &= ~BIT(I915_SAMPLE_BUSY); | 125 | enable &= ~BIT(I915_SAMPLE_BUSY); |
129 | 126 | ||
130 | /* | 127 | /* |
@@ -447,7 +444,7 @@ again: | |||
447 | 444 | ||
448 | static bool engine_needs_busy_stats(struct intel_engine_cs *engine) | 445 | static bool engine_needs_busy_stats(struct intel_engine_cs *engine) |
449 | { | 446 | { |
450 | return supports_busy_stats(engine->i915) && | 447 | return intel_engine_supports_stats(engine) && |
451 | (engine->pmu.enable & BIT(I915_SAMPLE_BUSY)); | 448 | (engine->pmu.enable & BIT(I915_SAMPLE_BUSY)); |
452 | } | 449 | } |
453 | 450 | ||
diff --git a/drivers/gpu/drm/i915/intel_engine_cs.c b/drivers/gpu/drm/i915/intel_engine_cs.c index fede62daf3e1..cffd0c812b7e 100644 --- a/drivers/gpu/drm/i915/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/intel_engine_cs.c | |||
@@ -1863,7 +1863,7 @@ int intel_enable_engine_stats(struct intel_engine_cs *engine) | |||
1863 | { | 1863 | { |
1864 | unsigned long flags; | 1864 | unsigned long flags; |
1865 | 1865 | ||
1866 | if (INTEL_GEN(engine->i915) < 8) | 1866 | if (!intel_engine_supports_stats(engine)) |
1867 | return -ENODEV; | 1867 | return -ENODEV; |
1868 | 1868 | ||
1869 | spin_lock_irqsave(&engine->stats.lock, flags); | 1869 | spin_lock_irqsave(&engine->stats.lock, flags); |
@@ -1924,7 +1924,7 @@ void intel_disable_engine_stats(struct intel_engine_cs *engine) | |||
1924 | { | 1924 | { |
1925 | unsigned long flags; | 1925 | unsigned long flags; |
1926 | 1926 | ||
1927 | if (INTEL_GEN(engine->i915) < 8) | 1927 | if (!intel_engine_supports_stats(engine)) |
1928 | return; | 1928 | return; |
1929 | 1929 | ||
1930 | spin_lock_irqsave(&engine->stats.lock, flags); | 1930 | spin_lock_irqsave(&engine->stats.lock, flags); |
diff --git a/drivers/gpu/drm/i915/intel_guc_submission.c b/drivers/gpu/drm/i915/intel_guc_submission.c index cf1cc2cb6722..912ff143d531 100644 --- a/drivers/gpu/drm/i915/intel_guc_submission.c +++ b/drivers/gpu/drm/i915/intel_guc_submission.c | |||
@@ -1453,6 +1453,8 @@ int intel_guc_submission_enable(struct intel_guc *guc) | |||
1453 | execlists->tasklet.func = guc_submission_tasklet; | 1453 | execlists->tasklet.func = guc_submission_tasklet; |
1454 | engine->park = guc_submission_park; | 1454 | engine->park = guc_submission_park; |
1455 | engine->unpark = guc_submission_unpark; | 1455 | engine->unpark = guc_submission_unpark; |
1456 | |||
1457 | engine->flags &= ~I915_ENGINE_SUPPORTS_STATS; | ||
1456 | } | 1458 | } |
1457 | 1459 | ||
1458 | return 0; | 1460 | return 0; |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 570864583e28..2a8160f603ab 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
@@ -1919,6 +1919,8 @@ static void execlists_set_default_submission(struct intel_engine_cs *engine) | |||
1919 | 1919 | ||
1920 | engine->park = NULL; | 1920 | engine->park = NULL; |
1921 | engine->unpark = NULL; | 1921 | engine->unpark = NULL; |
1922 | |||
1923 | engine->flags |= I915_ENGINE_SUPPORTS_STATS; | ||
1922 | } | 1924 | } |
1923 | 1925 | ||
1924 | static void | 1926 | static void |
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h index 2b978b363c0b..3d097bbeb2d9 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.h +++ b/drivers/gpu/drm/i915/intel_ringbuffer.h | |||
@@ -539,6 +539,7 @@ struct intel_engine_cs { | |||
539 | struct intel_engine_hangcheck hangcheck; | 539 | struct intel_engine_hangcheck hangcheck; |
540 | 540 | ||
541 | #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0) | 541 | #define I915_ENGINE_NEEDS_CMD_PARSER BIT(0) |
542 | #define I915_ENGINE_SUPPORTS_STATS BIT(1) | ||
542 | unsigned int flags; | 543 | unsigned int flags; |
543 | 544 | ||
544 | /* | 545 | /* |
@@ -603,6 +604,11 @@ static inline bool intel_engine_needs_cmd_parser(struct intel_engine_cs *engine) | |||
603 | return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER; | 604 | return engine->flags & I915_ENGINE_NEEDS_CMD_PARSER; |
604 | } | 605 | } |
605 | 606 | ||
607 | static inline bool intel_engine_supports_stats(struct intel_engine_cs *engine) | ||
608 | { | ||
609 | return engine->flags & I915_ENGINE_SUPPORTS_STATS; | ||
610 | } | ||
611 | |||
606 | static inline void | 612 | static inline void |
607 | execlists_set_active(struct intel_engine_execlists *execlists, | 613 | execlists_set_active(struct intel_engine_execlists *execlists, |
608 | unsigned int bit) | 614 | unsigned int bit) |