drm/radeon: add get_gpu_clock_counter() callback for cik
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 19 Dec 2012 03:17:00 +0000 (22:17 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 26 Jun 2013 20:11:45 +0000 (16:11 -0400)
Used for GPU clock counter snapshots.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/cik.c
drivers/gpu/drm/radeon/cikd.h
drivers/gpu/drm/radeon/radeon_asic.h

index f17e4912eb6adbcb6517188987485ed3693179a4..7aae670080d3dc90d8ce058382963b423eacebb0 100644 (file)
@@ -5554,3 +5554,24 @@ void dce8_bandwidth_update(struct radeon_device *rdev)
                dce8_program_watermarks(rdev, rdev->mode_info.crtcs[i], lb_size, num_heads);
        }
 }
+
+/**
+ * cik_get_gpu_clock_counter - return GPU clock counter snapshot
+ *
+ * @rdev: radeon_device pointer
+ *
+ * Fetches a GPU clock counter snapshot (SI).
+ * Returns the 64 bit clock counter snapshot.
+ */
+uint64_t cik_get_gpu_clock_counter(struct radeon_device *rdev)
+{
+       uint64_t clock;
+
+       mutex_lock(&rdev->gpu_clock_mutex);
+       WREG32(RLC_CAPTURE_GPU_CLOCK_COUNT, 1);
+       clock = (uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_LSB) |
+               ((uint64_t)RREG32(RLC_GPU_CLOCK_COUNT_MSB) << 32ULL);
+       mutex_unlock(&rdev->gpu_clock_mutex);
+       return clock;
+}
+
index 3349e37a60ef78fb680d070519fc7dd7ffcdf07c..daa51ac8522b7293c4dc5e3aa66b581c48390dbf 100644 (file)
 
 #define RLC_GPM_UCODE_ADDR                                0xC388
 #define RLC_GPM_UCODE_DATA                                0xC38C
-
+#define RLC_GPU_CLOCK_COUNT_LSB                           0xC390
+#define RLC_GPU_CLOCK_COUNT_MSB                           0xC394
+#define RLC_CAPTURE_GPU_CLOCK_COUNT                       0xC398
 #define RLC_UCODE_CNTL                                    0xC39C
 
 #define RLC_CGCG_CGLS_CTRL                                0xC424
index a72759ede7538390a9360c0764670fcf161018c7..248da7205a091ea2f3b4d7455b534139f48ad1ac 100644 (file)
@@ -553,4 +553,9 @@ u32 si_get_xclk(struct radeon_device *rdev);
 uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev);
 int si_set_uvd_clocks(struct radeon_device *rdev, u32 vclk, u32 dclk);
 
+/*
+ * cik
+ */
+uint64_t cik_get_gpu_clock_counter(struct radeon_device *rdev);
+
 #endif