diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2013-01-24 10:35:23 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2013-02-20 08:51:21 -0500 |
commit | d0418894142f88041d2b7b5aa4f8bf3178d89514 (patch) | |
tree | 4f5fd10c72b8ea4203535a11731db50a36911e81 | |
parent | 454d2e2a32f02a4f8e0364ba0e8ce4f8dbe9810c (diff) |
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: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/radeon/r600.c | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon.h | 3 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_asic.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_kms.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/radeon/si.c | 4 |
6 files changed, 19 insertions, 11 deletions
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index 37d81fd09555..6d4b5611daf4 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
@@ -4461,14 +4461,14 @@ static void r600_pcie_gen2_enable(struct radeon_device *rdev) | |||
4461 | } | 4461 | } |
4462 | 4462 | ||
4463 | /** | 4463 | /** |
4464 | * r600_get_gpu_clock - return GPU clock counter snapshot | 4464 | * r600_get_gpu_clock_counter - return GPU clock counter snapshot |
4465 | * | 4465 | * |
4466 | * @rdev: radeon_device pointer | 4466 | * @rdev: radeon_device pointer |
4467 | * | 4467 | * |
4468 | * Fetches a GPU clock counter snapshot (R6xx-cayman). | 4468 | * Fetches a GPU clock counter snapshot (R6xx-cayman). |
4469 | * Returns the 64 bit clock counter snapshot. | 4469 | * Returns the 64 bit clock counter snapshot. |
4470 | */ | 4470 | */ |
4471 | uint64_t r600_get_gpu_clock(struct radeon_device *rdev) | 4471 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev) |
4472 | { | 4472 | { |
4473 | uint64_t clock; | 4473 | uint64_t clock; |
4474 | 4474 | ||
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index e425b412f246..081e55f66c40 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
@@ -1181,6 +1181,8 @@ struct radeon_asic { | |||
1181 | int (*mc_wait_for_idle)(struct radeon_device *rdev); | 1181 | int (*mc_wait_for_idle)(struct radeon_device *rdev); |
1182 | /* get the reference clock */ | 1182 | /* get the reference clock */ |
1183 | u32 (*get_xclk)(struct radeon_device *rdev); | 1183 | u32 (*get_xclk)(struct radeon_device *rdev); |
1184 | /* get the gpu clock counter */ | ||
1185 | uint64_t (*get_gpu_clock_counter)(struct radeon_device *rdev); | ||
1184 | /* gart */ | 1186 | /* gart */ |
1185 | struct { | 1187 | struct { |
1186 | void (*tlb_flush)(struct radeon_device *rdev); | 1188 | void (*tlb_flush)(struct radeon_device *rdev); |
@@ -1863,6 +1865,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v); | |||
1863 | #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc)) | 1865 | #define radeon_wait_for_vblank(rdev, crtc) (rdev)->asic->display.wait_for_vblank((rdev), (crtc)) |
1864 | #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) | 1866 | #define radeon_mc_wait_for_idle(rdev) (rdev)->asic->mc_wait_for_idle((rdev)) |
1865 | #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev)) | 1867 | #define radeon_get_xclk(rdev) (rdev)->asic->get_xclk((rdev)) |
1868 | #define radeon_get_gpu_clock_counter(rdev) (rdev)->asic->get_gpu_clock_counter((rdev)) | ||
1866 | 1869 | ||
1867 | /* Common functions */ | 1870 | /* Common functions */ |
1868 | /* AGP */ | 1871 | /* AGP */ |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.c b/drivers/gpu/drm/radeon/radeon_asic.c index e1b4a6832312..aba0a893ea98 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.c +++ b/drivers/gpu/drm/radeon/radeon_asic.c | |||
@@ -935,6 +935,7 @@ static struct radeon_asic r600_asic = { | |||
935 | .gui_idle = &r600_gui_idle, | 935 | .gui_idle = &r600_gui_idle, |
936 | .mc_wait_for_idle = &r600_mc_wait_for_idle, | 936 | .mc_wait_for_idle = &r600_mc_wait_for_idle, |
937 | .get_xclk = &r600_get_xclk, | 937 | .get_xclk = &r600_get_xclk, |
938 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
938 | .gart = { | 939 | .gart = { |
939 | .tlb_flush = &r600_pcie_gart_tlb_flush, | 940 | .tlb_flush = &r600_pcie_gart_tlb_flush, |
940 | .set_page = &rs600_gart_set_page, | 941 | .set_page = &rs600_gart_set_page, |
@@ -1020,6 +1021,7 @@ static struct radeon_asic rs780_asic = { | |||
1020 | .gui_idle = &r600_gui_idle, | 1021 | .gui_idle = &r600_gui_idle, |
1021 | .mc_wait_for_idle = &r600_mc_wait_for_idle, | 1022 | .mc_wait_for_idle = &r600_mc_wait_for_idle, |
1022 | .get_xclk = &r600_get_xclk, | 1023 | .get_xclk = &r600_get_xclk, |
1024 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1023 | .gart = { | 1025 | .gart = { |
1024 | .tlb_flush = &r600_pcie_gart_tlb_flush, | 1026 | .tlb_flush = &r600_pcie_gart_tlb_flush, |
1025 | .set_page = &rs600_gart_set_page, | 1027 | .set_page = &rs600_gart_set_page, |
@@ -1105,6 +1107,7 @@ static struct radeon_asic rv770_asic = { | |||
1105 | .gui_idle = &r600_gui_idle, | 1107 | .gui_idle = &r600_gui_idle, |
1106 | .mc_wait_for_idle = &r600_mc_wait_for_idle, | 1108 | .mc_wait_for_idle = &r600_mc_wait_for_idle, |
1107 | .get_xclk = &rv770_get_xclk, | 1109 | .get_xclk = &rv770_get_xclk, |
1110 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1108 | .gart = { | 1111 | .gart = { |
1109 | .tlb_flush = &r600_pcie_gart_tlb_flush, | 1112 | .tlb_flush = &r600_pcie_gart_tlb_flush, |
1110 | .set_page = &rs600_gart_set_page, | 1113 | .set_page = &rs600_gart_set_page, |
@@ -1190,6 +1193,7 @@ static struct radeon_asic evergreen_asic = { | |||
1190 | .gui_idle = &r600_gui_idle, | 1193 | .gui_idle = &r600_gui_idle, |
1191 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1194 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1192 | .get_xclk = &rv770_get_xclk, | 1195 | .get_xclk = &rv770_get_xclk, |
1196 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1193 | .gart = { | 1197 | .gart = { |
1194 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, | 1198 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, |
1195 | .set_page = &rs600_gart_set_page, | 1199 | .set_page = &rs600_gart_set_page, |
@@ -1275,6 +1279,7 @@ static struct radeon_asic sumo_asic = { | |||
1275 | .gui_idle = &r600_gui_idle, | 1279 | .gui_idle = &r600_gui_idle, |
1276 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1280 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1277 | .get_xclk = &r600_get_xclk, | 1281 | .get_xclk = &r600_get_xclk, |
1282 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1278 | .gart = { | 1283 | .gart = { |
1279 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, | 1284 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, |
1280 | .set_page = &rs600_gart_set_page, | 1285 | .set_page = &rs600_gart_set_page, |
@@ -1360,6 +1365,7 @@ static struct radeon_asic btc_asic = { | |||
1360 | .gui_idle = &r600_gui_idle, | 1365 | .gui_idle = &r600_gui_idle, |
1361 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1366 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1362 | .get_xclk = &rv770_get_xclk, | 1367 | .get_xclk = &rv770_get_xclk, |
1368 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1363 | .gart = { | 1369 | .gart = { |
1364 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, | 1370 | .tlb_flush = &evergreen_pcie_gart_tlb_flush, |
1365 | .set_page = &rs600_gart_set_page, | 1371 | .set_page = &rs600_gart_set_page, |
@@ -1445,6 +1451,7 @@ static struct radeon_asic cayman_asic = { | |||
1445 | .gui_idle = &r600_gui_idle, | 1451 | .gui_idle = &r600_gui_idle, |
1446 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1452 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1447 | .get_xclk = &rv770_get_xclk, | 1453 | .get_xclk = &rv770_get_xclk, |
1454 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1448 | .gart = { | 1455 | .gart = { |
1449 | .tlb_flush = &cayman_pcie_gart_tlb_flush, | 1456 | .tlb_flush = &cayman_pcie_gart_tlb_flush, |
1450 | .set_page = &rs600_gart_set_page, | 1457 | .set_page = &rs600_gart_set_page, |
@@ -1573,6 +1580,7 @@ static struct radeon_asic trinity_asic = { | |||
1573 | .gui_idle = &r600_gui_idle, | 1580 | .gui_idle = &r600_gui_idle, |
1574 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1581 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1575 | .get_xclk = &r600_get_xclk, | 1582 | .get_xclk = &r600_get_xclk, |
1583 | .get_gpu_clock_counter = &r600_get_gpu_clock_counter, | ||
1576 | .gart = { | 1584 | .gart = { |
1577 | .tlb_flush = &cayman_pcie_gart_tlb_flush, | 1585 | .tlb_flush = &cayman_pcie_gart_tlb_flush, |
1578 | .set_page = &rs600_gart_set_page, | 1586 | .set_page = &rs600_gart_set_page, |
@@ -1701,6 +1709,7 @@ static struct radeon_asic si_asic = { | |||
1701 | .gui_idle = &r600_gui_idle, | 1709 | .gui_idle = &r600_gui_idle, |
1702 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, | 1710 | .mc_wait_for_idle = &evergreen_mc_wait_for_idle, |
1703 | .get_xclk = &si_get_xclk, | 1711 | .get_xclk = &si_get_xclk, |
1712 | .get_gpu_clock_counter = &si_get_gpu_clock_counter, | ||
1704 | .gart = { | 1713 | .gart = { |
1705 | .tlb_flush = &si_pcie_gart_tlb_flush, | 1714 | .tlb_flush = &si_pcie_gart_tlb_flush, |
1706 | .set_page = &rs600_gart_set_page, | 1715 | .set_page = &rs600_gart_set_page, |
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h index f15758c7a262..3535f73ad3e2 100644 --- a/drivers/gpu/drm/radeon/radeon_asic.h +++ b/drivers/gpu/drm/radeon/radeon_asic.h | |||
@@ -389,8 +389,8 @@ void r600_kms_blit_copy(struct radeon_device *rdev, | |||
389 | unsigned num_gpu_pages, | 389 | unsigned num_gpu_pages, |
390 | struct radeon_sa_bo *vb); | 390 | struct radeon_sa_bo *vb); |
391 | int r600_mc_wait_for_idle(struct radeon_device *rdev); | 391 | int r600_mc_wait_for_idle(struct radeon_device *rdev); |
392 | uint64_t r600_get_gpu_clock(struct radeon_device *rdev); | ||
393 | u32 r600_get_xclk(struct radeon_device *rdev); | 392 | u32 r600_get_xclk(struct radeon_device *rdev); |
393 | uint64_t r600_get_gpu_clock_counter(struct radeon_device *rdev); | ||
394 | 394 | ||
395 | /* | 395 | /* |
396 | * rv770,rv730,rv710,rv740 | 396 | * rv770,rv730,rv710,rv740 |
@@ -517,12 +517,12 @@ void si_vm_set_page(struct radeon_device *rdev, | |||
517 | uint32_t incr, uint32_t flags); | 517 | uint32_t incr, uint32_t flags); |
518 | void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); | 518 | void si_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); |
519 | int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib); | 519 | int si_ib_parse(struct radeon_device *rdev, struct radeon_ib *ib); |
520 | uint64_t si_get_gpu_clock(struct radeon_device *rdev); | ||
521 | int si_copy_dma(struct radeon_device *rdev, | 520 | int si_copy_dma(struct radeon_device *rdev, |
522 | uint64_t src_offset, uint64_t dst_offset, | 521 | uint64_t src_offset, uint64_t dst_offset, |
523 | unsigned num_gpu_pages, | 522 | unsigned num_gpu_pages, |
524 | struct radeon_fence **fence); | 523 | struct radeon_fence **fence); |
525 | void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); | 524 | void si_dma_vm_flush(struct radeon_device *rdev, int ridx, struct radeon_vm *vm); |
526 | u32 si_get_xclk(struct radeon_device *rdev); | 525 | u32 si_get_xclk(struct radeon_device *rdev); |
526 | uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev); | ||
527 | 527 | ||
528 | #endif | 528 | #endif |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 96f05cde116a..c75cb2c6ba71 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
@@ -185,11 +185,7 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) | |||
185 | if (info->request == RADEON_INFO_TIMESTAMP) { | 185 | if (info->request == RADEON_INFO_TIMESTAMP) { |
186 | if (rdev->family >= CHIP_R600) { | 186 | if (rdev->family >= CHIP_R600) { |
187 | value_ptr64 = (uint64_t*)((unsigned long)info->value); | 187 | value_ptr64 = (uint64_t*)((unsigned long)info->value); |
188 | if (rdev->family >= CHIP_TAHITI) { | 188 | value64 = radeon_get_gpu_clock_counter(rdev); |
189 | value64 = si_get_gpu_clock(rdev); | ||
190 | } else { | ||
191 | value64 = r600_get_gpu_clock(rdev); | ||
192 | } | ||
193 | 189 | ||
194 | if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) { | 190 | if (DRM_COPY_TO_USER(value_ptr64, &value64, sizeof(value64))) { |
195 | DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); | 191 | DRM_ERROR("copy_to_user %s:%u\n", __func__, __LINE__); |
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index b5064fae0726..80979ed951eb 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c | |||
@@ -4609,14 +4609,14 @@ void si_fini(struct radeon_device *rdev) | |||
4609 | } | 4609 | } |
4610 | 4610 | ||
4611 | /** | 4611 | /** |
4612 | * si_get_gpu_clock - return GPU clock counter snapshot | 4612 | * si_get_gpu_clock_counter - return GPU clock counter snapshot |
4613 | * | 4613 | * |
4614 | * @rdev: radeon_device pointer | 4614 | * @rdev: radeon_device pointer |
4615 | * | 4615 | * |
4616 | * Fetches a GPU clock counter snapshot (SI). | 4616 | * Fetches a GPU clock counter snapshot (SI). |
4617 | * Returns the 64 bit clock counter snapshot. | 4617 | * Returns the 64 bit clock counter snapshot. |
4618 | */ | 4618 | */ |
4619 | uint64_t si_get_gpu_clock(struct radeon_device *rdev) | 4619 | uint64_t si_get_gpu_clock_counter(struct radeon_device *rdev) |
4620 | { | 4620 | { |
4621 | uint64_t clock; | 4621 | uint64_t clock; |
4622 | 4622 | ||