aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlija Hadzic <ihadzic@research.bell-labs.com>2011-10-12 23:29:38 -0400
committerDave Airlie <airlied@redhat.com>2011-10-18 05:06:23 -0400
commitcc3405151572c4920ac187a9ef601c838fac077b (patch)
tree54f0ed01e5fe1b2c05608c01ac815d5418006c8e
parent3a38612e329ffe5183122a9523eacae33e7cbb07 (diff)
drm/radeon/kms: cleanup benchmark code
factor out repeated code into functions fix units in which the throughput is reported (megabytes per second and megabits per second make sense, others are kind of confusing) make report more amenable to awk and friends (e.g. whitespace is always the separator, unit is separated from the number, etc) add #defines for some hard coded constants besides "beautification" this reorg is done in preparation for writing more elaborate benchmarks Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/radeon/radeon_benchmark.c156
1 files changed, 86 insertions, 70 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_benchmark.c b/drivers/gpu/drm/radeon/radeon_benchmark.c
index 10191d9372d8..6951426dbb12 100644
--- a/drivers/gpu/drm/radeon/radeon_benchmark.c
+++ b/drivers/gpu/drm/radeon/radeon_benchmark.c
@@ -26,21 +26,80 @@
26#include "radeon_reg.h" 26#include "radeon_reg.h"
27#include "radeon.h" 27#include "radeon.h"
28 28
29void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize, 29#define RADEON_BENCHMARK_COPY_BLIT 1
30 unsigned sdomain, unsigned ddomain) 30#define RADEON_BENCHMARK_COPY_DMA 0
31
32#define RADEON_BENCHMARK_ITERATIONS 1024
33
34static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size,
35 uint64_t saddr, uint64_t daddr,
36 int flag, int n)
37{
38 unsigned long start_jiffies;
39 unsigned long end_jiffies;
40 struct radeon_fence *fence = NULL;
41 int i, r;
42
43 start_jiffies = jiffies;
44 for (i = 0; i < n; i++) {
45 r = radeon_fence_create(rdev, &fence);
46 if (r)
47 return r;
48
49 switch (flag) {
50 case RADEON_BENCHMARK_COPY_DMA:
51 r = radeon_copy_dma(rdev, saddr, daddr,
52 size / RADEON_GPU_PAGE_SIZE,
53 fence);
54 break;
55 case RADEON_BENCHMARK_COPY_BLIT:
56 r = radeon_copy_blit(rdev, saddr, daddr,
57 size / RADEON_GPU_PAGE_SIZE,
58 fence);
59 break;
60 default:
61 DRM_ERROR("Unknown copy method\n");
62 r = -EINVAL;
63 }
64 if (r)
65 goto exit_do_move;
66 r = radeon_fence_wait(fence, false);
67 if (r)
68 goto exit_do_move;
69 radeon_fence_unref(&fence);
70 }
71 end_jiffies = jiffies;
72 r = jiffies_to_msecs(end_jiffies - start_jiffies);
73
74exit_do_move:
75 if (fence)
76 radeon_fence_unref(&fence);
77 return r;
78}
79
80
81static void radeon_benchmark_log_results(int n, unsigned size,
82 unsigned int time,
83 unsigned sdomain, unsigned ddomain,
84 char *kind)
85{
86 unsigned int throughput = (n * (size >> 10)) / time;
87 DRM_INFO("radeon: %s %u bo moves of %u kB from"
88 " %d to %d in %u ms, throughput: %u Mb/s or %u MB/s\n",
89 kind, n, size >> 10, sdomain, ddomain, time,
90 throughput * 8, throughput);
91}
92
93static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size,
94 unsigned sdomain, unsigned ddomain)
31{ 95{
32 struct radeon_bo *dobj = NULL; 96 struct radeon_bo *dobj = NULL;
33 struct radeon_bo *sobj = NULL; 97 struct radeon_bo *sobj = NULL;
34 struct radeon_fence *fence = NULL;
35 uint64_t saddr, daddr; 98 uint64_t saddr, daddr;
36 unsigned long start_jiffies; 99 int r, n;
37 unsigned long end_jiffies; 100 unsigned int time;
38 unsigned long time;
39 unsigned i, n, size;
40 int r;
41 101
42 size = bsize; 102 n = RADEON_BENCHMARK_ITERATIONS;
43 n = 1024;
44 r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, &sobj); 103 r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, &sobj);
45 if (r) { 104 if (r) {
46 goto out_cleanup; 105 goto out_cleanup;
@@ -68,64 +127,23 @@ void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize,
68 127
69 /* r100 doesn't have dma engine so skip the test */ 128 /* r100 doesn't have dma engine so skip the test */
70 if (rdev->asic->copy_dma) { 129 if (rdev->asic->copy_dma) {
71 130 time = radeon_benchmark_do_move(rdev, size, saddr, daddr,
72 start_jiffies = jiffies; 131 RADEON_BENCHMARK_COPY_DMA, n);
73 for (i = 0; i < n; i++) { 132 if (time < 0)
74 r = radeon_fence_create(rdev, &fence);
75 if (r) {
76 goto out_cleanup;
77 }
78
79 r = radeon_copy_dma(rdev, saddr, daddr,
80 size / RADEON_GPU_PAGE_SIZE, fence);
81
82 if (r) {
83 goto out_cleanup;
84 }
85 r = radeon_fence_wait(fence, false);
86 if (r) {
87 goto out_cleanup;
88 }
89 radeon_fence_unref(&fence);
90 }
91 end_jiffies = jiffies;
92 time = end_jiffies - start_jiffies;
93 time = jiffies_to_msecs(time);
94 if (time > 0) {
95 i = ((n * size) >> 10) / time;
96 printk(KERN_INFO "radeon: dma %u bo moves of %ukb from"
97 " %d to %d in %lums (%ukb/ms %ukb/s %uM/s)\n",
98 n, size >> 10,
99 sdomain, ddomain, time,
100 i, i * 1000, (i * 1000) / 1024);
101 }
102 }
103
104 start_jiffies = jiffies;
105 for (i = 0; i < n; i++) {
106 r = radeon_fence_create(rdev, &fence);
107 if (r) {
108 goto out_cleanup;
109 }
110 r = radeon_copy_blit(rdev, saddr, daddr, size / RADEON_GPU_PAGE_SIZE, fence);
111 if (r) {
112 goto out_cleanup; 133 goto out_cleanup;
113 } 134 if (time > 0)
114 r = radeon_fence_wait(fence, false); 135 radeon_benchmark_log_results(n, size, time,
115 if (r) { 136 sdomain, ddomain, "dma");
116 goto out_cleanup;
117 }
118 radeon_fence_unref(&fence);
119 }
120 end_jiffies = jiffies;
121 time = end_jiffies - start_jiffies;
122 time = jiffies_to_msecs(time);
123 if (time > 0) {
124 i = ((n * size) >> 10) / time;
125 printk(KERN_INFO "radeon: blit %u bo moves of %ukb from %d to %d"
126 " in %lums (%ukb/ms %ukb/s %uM/s)\n", n, size >> 10,
127 sdomain, ddomain, time, i, i * 1000, (i * 1000) / 1024);
128 } 137 }
138
139 time = radeon_benchmark_do_move(rdev, size, saddr, daddr,
140 RADEON_BENCHMARK_COPY_BLIT, n);
141 if (time < 0)
142 goto out_cleanup;
143 if (time > 0)
144 radeon_benchmark_log_results(n, size, time,
145 sdomain, ddomain, "blit");
146
129out_cleanup: 147out_cleanup:
130 if (sobj) { 148 if (sobj) {
131 r = radeon_bo_reserve(sobj, false); 149 r = radeon_bo_reserve(sobj, false);
@@ -143,11 +161,9 @@ out_cleanup:
143 } 161 }
144 radeon_bo_unref(&dobj); 162 radeon_bo_unref(&dobj);
145 } 163 }
146 if (fence) { 164
147 radeon_fence_unref(&fence);
148 }
149 if (r) { 165 if (r) {
150 printk(KERN_WARNING "Error while benchmarking BO move.\n"); 166 DRM_ERROR("Error while benchmarking BO move.\n");
151 } 167 }
152} 168}
153 169