diff mbox series

drm/i915/pmu: Use existing uncore helper to read gpm_timestamp

Message ID 20220427003515.3944267-1-umesh.nerlige.ramappa@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/pmu: Use existing uncore helper to read gpm_timestamp | expand

Commit Message

Umesh Nerlige Ramappa April 27, 2022, 12:35 a.m. UTC
Use intel_uncore_read64_2x32 to read upper and lower fields of the GPM
timestamp.

v2: Fix compile error

Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
---
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c   | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)

Comments

Tvrtko Ursulin April 27, 2022, 7:55 a.m. UTC | #1
On 27/04/2022 01:35, Umesh Nerlige Ramappa wrote:
> Use intel_uncore_read64_2x32 to read upper and lower fields of the GPM
> timestamp.
> 
> v2: Fix compile error
> 
> Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
> ---
>   .../gpu/drm/i915/gt/uc/intel_guc_submission.c   | 17 ++---------------
>   1 file changed, 2 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index 61a6f2424e24..33e695adfd6a 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -1200,20 +1200,6 @@ static u32 gpm_timestamp_shift(struct intel_gt *gt)
>   	return 3 - shift;
>   }
>   
> -static u64 gpm_timestamp(struct intel_gt *gt)
> -{
> -	u32 lo, hi, old_hi, loop = 0;
> -
> -	hi = intel_uncore_read(gt->uncore, MISC_STATUS1);
> -	do {
> -		lo = intel_uncore_read(gt->uncore, MISC_STATUS0);
> -		old_hi = hi;
> -		hi = intel_uncore_read(gt->uncore, MISC_STATUS1);
> -	} while (old_hi != hi && loop++ < 2);
> -
> -	return ((u64)hi << 32) | lo;
> -}
> -
>   static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)
>   {
>   	struct intel_gt *gt = guc_to_gt(guc);
> @@ -1223,7 +1209,8 @@ static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)
>   	lockdep_assert_held(&guc->timestamp.lock);
>   
>   	gt_stamp_hi = upper_32_bits(guc->timestamp.gt_stamp);
> -	gpm_ts = gpm_timestamp(gt) >> guc->timestamp.shift;
> +	gpm_ts = intel_uncore_read64_2x32(gt->uncore, MISC_STATUS0,
> +					  MISC_STATUS1) >> guc->timestamp.shift;
>   	gt_stamp_lo = lower_32_bits(gpm_ts);
>   	*now = ktime_get();
>   

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index 61a6f2424e24..33e695adfd6a 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -1200,20 +1200,6 @@  static u32 gpm_timestamp_shift(struct intel_gt *gt)
 	return 3 - shift;
 }
 
-static u64 gpm_timestamp(struct intel_gt *gt)
-{
-	u32 lo, hi, old_hi, loop = 0;
-
-	hi = intel_uncore_read(gt->uncore, MISC_STATUS1);
-	do {
-		lo = intel_uncore_read(gt->uncore, MISC_STATUS0);
-		old_hi = hi;
-		hi = intel_uncore_read(gt->uncore, MISC_STATUS1);
-	} while (old_hi != hi && loop++ < 2);
-
-	return ((u64)hi << 32) | lo;
-}
-
 static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)
 {
 	struct intel_gt *gt = guc_to_gt(guc);
@@ -1223,7 +1209,8 @@  static void guc_update_pm_timestamp(struct intel_guc *guc, ktime_t *now)
 	lockdep_assert_held(&guc->timestamp.lock);
 
 	gt_stamp_hi = upper_32_bits(guc->timestamp.gt_stamp);
-	gpm_ts = gpm_timestamp(gt) >> guc->timestamp.shift;
+	gpm_ts = intel_uncore_read64_2x32(gt->uncore, MISC_STATUS0,
+					  MISC_STATUS1) >> guc->timestamp.shift;
 	gt_stamp_lo = lower_32_bits(gpm_ts);
 	*now = ktime_get();