Commit d0418894 authored by Alex Deucher's avatar Alex Deucher

drm/radeon: switch get_gpu_clock() to a callback (v2)

Cleans up the code for future asics

v2: rebase, fix some missing radeon_asic updates
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 454d2e2a
...@@ -4461,14 +4461,14 @@ static void r600_pcie_gen2_enable(struct radeon_device *rdev) ...@@ -4461,14 +4461,14 @@ static void r600_pcie_gen2_enable(struct radeon_device *rdev)
} }
/** /**
* r600_get_gpu_clock - return GPU clock counter snapshot * r600_get_gpu_clock_counter - return GPU clock counter snapshot
* *
* @rdev: radeon_device pointer * @rdev: radeon_device pointer
* *
* Fetches a GPU clock counter snapshot (R6xx-cayman). * Fetches a GPU clock counter snapshot (R6xx-cayman).
* Returns the 64 bit clock counter snapshot. * Returns the 64 bit clock counter snapshot.
*/ */
uint64_t r600_get_gpu_clock(struct radeon_device *rdev) uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev)
{ {
uint64_t clock; uint64_t clock;
......
...@@ -1181,6 +1181,8 @@ struct radeon_asic { ...@@ -1181,6 +1181,8 @@ struct radeon_asic {
int (*mc_wait_for_idle)(struct radeon_device *rdev); int (*mc_wait_for_idle)(struct radeon_device *rdev);
/* get the reference clock */ /* get the reference clock */
u32 (*get_xclk)(struct radeon_device *rdev); u32 (*get_xclk)(struct radeon_device *rdev);
/* get the gpu clock counter */
uint64_t (*get_gpu_clock_counter)(struct radeon_device *rdev);
/* gart */ /* gart */
struct { struct {
void (*tlb_flush)(struct radeon_device *rdev); void (*tlb_flush)(struct radeon_device *rdev);
...@@ -1863,6 +1865,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v); ...@@ -1863,6 +1865,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
#define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc)) #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc))
#define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev))
#define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev)) #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev))
#define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev))
/* Common functions */ /* Common functions */
/* AGP */ /* AGP */
......
...@@ -935,6 +935,7 @@ static struct radeon_asic r600_asic = { ...@@ -935,6 +935,7 @@ static struct radeon_asic r600_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk, .get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1020,6 +1021,7 @@ static struct radeon_asic rs780_asic = { ...@@ -1020,6 +1021,7 @@ static struct radeon_asic rs780_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &r600_get_xclk, .get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1105,6 +1107,7 @@ static struct radeon_asic rv770_asic = { ...@@ -1105,6 +1107,7 @@ static struct radeon_asic rv770_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &r600_mc_wait_for_idle, .mc_wait_for_idle = &r600_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk, .get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &r600_pcie_gart_tlb_flush, .tlb_flush = &r600_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1190,6 +1193,7 @@ static struct radeon_asic evergreen_asic = { ...@@ -1190,6 +1193,7 @@ static struct radeon_asic evergreen_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk, .get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1275,6 +1279,7 @@ static struct radeon_asic sumo_asic = { ...@@ -1275,6 +1279,7 @@ static struct radeon_asic sumo_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk, .get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1360,6 +1365,7 @@ static struct radeon_asic btc_asic = { ...@@ -1360,6 +1365,7 @@ static struct radeon_asic btc_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk, .get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &evergreen_pcie_gart_tlb_flush, .tlb_flush = &evergreen_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1445,6 +1451,7 @@ static struct radeon_asic cayman_asic = { ...@@ -1445,6 +1451,7 @@ static struct radeon_asic cayman_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &rv770_get_xclk, .get_xclk = &rv770_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush, .tlb_flush = &cayman_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1573,6 +1580,7 @@ static struct radeon_asic trinity_asic = { ...@@ -1573,6 +1580,7 @@ static struct radeon_asic trinity_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &r600_get_xclk, .get_xclk = &r600_get_xclk,
.get_gpu_clock_counter = &r600_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &cayman_pcie_gart_tlb_flush, .tlb_flush = &cayman_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
...@@ -1701,6 +1709,7 @@ static struct radeon_asic si_asic = { ...@@ -1701,6 +1709,7 @@ static struct radeon_asic si_asic = {
.gui_idle = &r600_gui_idle, .gui_idle = &r600_gui_idle,
.mc_wait_for_idle = &evergreen_mc_wait_for_idle, .mc_wait_for_idle = &evergreen_mc_wait_for_idle,
.get_xclk = &si_get_xclk, .get_xclk = &si_get_xclk,
.get_gpu_clock_counter = &si_get_gpu_clock_counter,
.gart = { .gart = {
.tlb_flush = &si_pcie_gart_tlb_flush, .tlb_flush = &si_pcie_gart_tlb_flush,
.set_page = &rs600_gart_set_page, .set_page = &rs600_gart_set_page,
......
...@@ -389,8 +389,8 @@ void r600_kms_blit_copy(struct radeon_device *rdev, ...@@ -389,8 +389,8 @@ void r600_kms_blit_copy(struct radeon_device *rdev,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_sa_bo *vb); struct radeon_sa_bo *vb);
int r600_mc_wait_for_idle(struct radeon_device *rdev); int r600_mc_wait_for_idle(struct radeon_device *rdev);
uint64_t r600_get_gpu_clock(struct radeon_device *rdev);
u32 r600_get_xclk(struct radeon_device *rdev); u32 r600_get_xclk(struct radeon_device *rdev);
uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev);
/* /*
* rv770,rv730,rv710,rv740 * rv770,rv730,rv710,rv740
...@@ -517,12 +517,12 @@ void si_vm_set_page(struct radeon_device *rdev, ...@@ -517,12 +517,12 @@ void si_vm_set_page(struct radeon_device *rdev,
uint32_t incr, uint32_t flags); uint32_t incr, uint32_t flags);
void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib); int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib);
uint64_t si_get_gpu_clock(struct radeon_device *rdev);
int si_copy_dma(struct radeon_device *rdev, int si_copy_dma(struct radeon_device *rdev,
uint64_t src_offset, uint64_t dst_offset, uint64_t src_offset, uint64_t dst_offset,
unsigned num_gpu_pages, unsigned num_gpu_pages,
struct radeon_fence **fence); struct radeon_fence **fence);
void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm);
u32 si_get_xclk(struct radeon_device *rdev); u32 si_get_xclk(struct radeon_device *rdev);
uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev);
#endif #endif
...@@ -185,11 +185,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) ...@@ -185,11 +185,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
if (info->request == RADEON_INFO_TIMESTAMP) { if (info->request == RADEON_INFO_TIMESTAMP) {
if (rdev->family >= CHIP_R600) { if (rdev->family >= CHIP_R600) {
value_ptr64 = (uint64_t*)((unsigned long)info->value); value_ptr64 = (uint64_t*)((unsigned long)info->value);
if (rdev->family >= CHIP_TAHITI) { value64 = radeon_get_gpu_clock_counter(rdev);
value64 = si_get_gpu_clock(rdev);
} else {
value64 = r600_get_gpu_clock(rdev);
}
if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) { if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) {
DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__);
......
...@@ -4609,14 +4609,14 @@ void si_fini(struct radeon_device *rdev) ...@@ -4609,14 +4609,14 @@ void si_fini(struct radeon_device *rdev)
} }
/** /**
* si_get_gpu_clock - return GPU clock counter snapshot * si_get_gpu_clock_counter - return GPU clock counter snapshot
* *
* @rdev: radeon_device pointer * @rdev: radeon_device pointer
* *
* Fetches a GPU clock counter snapshot (SI). * Fetches a GPU clock counter snapshot (SI).
* Returns the 64 bit clock counter snapshot. * Returns the 64 bit clock counter snapshot.
*/ */
uint64_t si_get_gpu_clock(struct radeon_device *rdev) uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev)
{ {
uint64_t clock; uint64_t clock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment