[RFC,2/4] drm/i915/pmu: Convert engine sampling to uncore mmio
diff mbox series

Message ID 20190801101825.2784-3-tvrtko.ursulin@linux.intel.com
State New
Headers show
Series
  • PMU update for more than one card
Related show

Commit Message

Tvrtko Ursulin Aug. 1, 2019, 10:18 a.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Drops one macro using implicit dev_priv.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_pmu.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

Comments

Chris Wilson Aug. 1, 2019, 10:33 a.m. UTC | #1
Quoting Tvrtko Ursulin (2019-08-01 11:18:23)
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 
> Drops one macro using implicit dev_priv.
> 
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_pmu.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
> index 12008966b00e..bd9ad4f2b4e4 100644
> --- a/drivers/gpu/drm/i915/i915_pmu.c
> +++ b/drivers/gpu/drm/i915/i915_pmu.c
> @@ -162,29 +162,30 @@ add_sample(struct i915_pmu_sample *sample, u32 val)
>  }
>  
>  static void
> -engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
> +engines_sample(struct drm_i915_private *i915, unsigned int period_ns)
>  {
> +       struct intel_uncore *uncore = &i915->uncore;
>         struct intel_engine_cs *engine;
>         enum intel_engine_id id;
>         intel_wakeref_t wakeref;
>         unsigned long flags;
>  
> -       if ((dev_priv->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
> +       if ((i915->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
>                 return;
>  
>         wakeref = 0;
> -       if (READ_ONCE(dev_priv->gt.awake))
> -               wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
> +       if (READ_ONCE(i915->gt.awake))
> +               wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
>         if (!wakeref)
>                 return;
>  
> -       spin_lock_irqsave(&dev_priv->uncore.lock, flags);
> -       for_each_engine(engine, dev_priv, id) {
> +       spin_lock_irqsave(&uncore->lock, flags);
> +       for_each_engine(engine, i915, id) {
>                 struct intel_engine_pmu *pmu = &engine->pmu;
>                 bool busy;
>                 u32 val;
>  
> -               val = I915_READ_FW(RING_CTL(engine->mmio_base));
> +               val = intel_uncore_read_fw(uncore, RING_CTL(engine->mmio_base));

Could use ENGINE_READ_FW(engine, RING_CTL) ?

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
Tvrtko Ursulin Aug. 1, 2019, 12:03 p.m. UTC | #2
On 01/08/2019 11:33, Chris Wilson wrote:
> Quoting Tvrtko Ursulin (2019-08-01 11:18:23)
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> Drops one macro using implicit dev_priv.
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_pmu.c | 23 +++++++++++++----------
>>   1 file changed, 13 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
>> index 12008966b00e..bd9ad4f2b4e4 100644
>> --- a/drivers/gpu/drm/i915/i915_pmu.c
>> +++ b/drivers/gpu/drm/i915/i915_pmu.c
>> @@ -162,29 +162,30 @@ add_sample(struct i915_pmu_sample *sample, u32 val)
>>   }
>>   
>>   static void
>> -engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
>> +engines_sample(struct drm_i915_private *i915, unsigned int period_ns)
>>   {
>> +       struct intel_uncore *uncore = &i915->uncore;
>>          struct intel_engine_cs *engine;
>>          enum intel_engine_id id;
>>          intel_wakeref_t wakeref;
>>          unsigned long flags;
>>   
>> -       if ((dev_priv->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
>> +       if ((i915->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
>>                  return;
>>   
>>          wakeref = 0;
>> -       if (READ_ONCE(dev_priv->gt.awake))
>> -               wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
>> +       if (READ_ONCE(i915->gt.awake))
>> +               wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
>>          if (!wakeref)
>>                  return;
>>   
>> -       spin_lock_irqsave(&dev_priv->uncore.lock, flags);
>> -       for_each_engine(engine, dev_priv, id) {
>> +       spin_lock_irqsave(&uncore->lock, flags);
>> +       for_each_engine(engine, i915, id) {
>>                  struct intel_engine_pmu *pmu = &engine->pmu;
>>                  bool busy;
>>                  u32 val;
>>   
>> -               val = I915_READ_FW(RING_CTL(engine->mmio_base));
>> +               val = intel_uncore_read_fw(uncore, RING_CTL(engine->mmio_base));
> 
> Could use ENGINE_READ_FW(engine, RING_CTL) ?

D-oh!

> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thanks!

Tvrtko

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/i915_pmu.c b/drivers/gpu/drm/i915/i915_pmu.c
index 12008966b00e..bd9ad4f2b4e4 100644
--- a/drivers/gpu/drm/i915/i915_pmu.c
+++ b/drivers/gpu/drm/i915/i915_pmu.c
@@ -162,29 +162,30 @@  add_sample(struct i915_pmu_sample *sample, u32 val)
 }
 
 static void
-engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
+engines_sample(struct drm_i915_private *i915, unsigned int period_ns)
 {
+	struct intel_uncore *uncore = &i915->uncore;
 	struct intel_engine_cs *engine;
 	enum intel_engine_id id;
 	intel_wakeref_t wakeref;
 	unsigned long flags;
 
-	if ((dev_priv->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
+	if ((i915->pmu.enable & ENGINE_SAMPLE_MASK) == 0)
 		return;
 
 	wakeref = 0;
-	if (READ_ONCE(dev_priv->gt.awake))
-		wakeref = intel_runtime_pm_get_if_in_use(&dev_priv->runtime_pm);
+	if (READ_ONCE(i915->gt.awake))
+		wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
 	if (!wakeref)
 		return;
 
-	spin_lock_irqsave(&dev_priv->uncore.lock, flags);
-	for_each_engine(engine, dev_priv, id) {
+	spin_lock_irqsave(&uncore->lock, flags);
+	for_each_engine(engine, i915, id) {
 		struct intel_engine_pmu *pmu = &engine->pmu;
 		bool busy;
 		u32 val;
 
-		val = I915_READ_FW(RING_CTL(engine->mmio_base));
+		val = intel_uncore_read_fw(uncore, RING_CTL(engine->mmio_base));
 		if (val == 0) /* powerwell off => engine idle */
 			continue;
 
@@ -202,15 +203,17 @@  engines_sample(struct drm_i915_private *dev_priv, unsigned int period_ns)
 		 */
 		busy = val & (RING_WAIT_SEMAPHORE | RING_WAIT);
 		if (!busy) {
-			val = I915_READ_FW(RING_MI_MODE(engine->mmio_base));
+			val =
+			  intel_uncore_read_fw(uncore,
+					       RING_MI_MODE(engine->mmio_base));
 			busy = !(val & MODE_IDLE);
 		}
 		if (busy)
 			add_sample(&pmu->sample[I915_SAMPLE_BUSY], period_ns);
 	}
-	spin_unlock_irqrestore(&dev_priv->uncore.lock, flags);
+	spin_unlock_irqrestore(&uncore->lock, flags);
 
-	intel_runtime_pm_put(&dev_priv->runtime_pm, wakeref);
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
 }
 
 static void