Rev 2997 | Rev 5078 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2997 | Rev 3031 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright 2009 Jerome Glisse. |
2 | * Copyright 2009 Jerome Glisse. |
3 | * |
3 | * |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
5 | * copy of this software and associated documentation files (the "Software"), |
5 | * copy of this software and associated documentation files (the "Software"), |
6 | * to deal in the Software without restriction, including without limitation |
6 | * to deal in the Software without restriction, including without limitation |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
8 | * and/or sell copies of the Software, and to permit persons to whom the |
8 | * and/or sell copies of the Software, and to permit persons to whom the |
9 | * Software is furnished to do so, subject to the following conditions: |
9 | * Software is furnished to do so, subject to the following conditions: |
10 | * |
10 | * |
11 | * The above copyright notice and this permission notice shall be included in |
11 | * The above copyright notice and this permission notice shall be included in |
12 | * all copies or substantial portions of the Software. |
12 | * all copies or substantial portions of the Software. |
13 | * |
13 | * |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
17 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
18 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
19 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 | * OTHER DEALINGS IN THE SOFTWARE. |
20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | * |
21 | * |
22 | * Authors: Jerome Glisse |
22 | * Authors: Jerome Glisse |
23 | */ |
23 | */ |
24 | #include |
24 | #include |
25 | #include |
25 | #include |
26 | #include "radeon_reg.h" |
26 | #include "radeon_reg.h" |
27 | #include "radeon.h" |
27 | #include "radeon.h" |
28 | 28 | ||
29 | #define RADEON_BENCHMARK_COPY_BLIT 1 |
29 | #define RADEON_BENCHMARK_COPY_BLIT 1 |
30 | #define RADEON_BENCHMARK_COPY_DMA 0 |
30 | #define RADEON_BENCHMARK_COPY_DMA 0 |
31 | 31 | ||
32 | #define RADEON_BENCHMARK_ITERATIONS 1024 |
32 | #define RADEON_BENCHMARK_ITERATIONS 1024 |
33 | #define RADEON_BENCHMARK_COMMON_MODES_N 17 |
33 | #define RADEON_BENCHMARK_COMMON_MODES_N 17 |
34 | 34 | ||
35 | static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size, |
35 | static int radeon_benchmark_do_move(struct radeon_device *rdev, unsigned size, |
36 | uint64_t saddr, uint64_t daddr, |
36 | uint64_t saddr, uint64_t daddr, |
37 | int flag, int n) |
37 | int flag, int n) |
38 | { |
38 | { |
39 | unsigned long start_jiffies; |
39 | unsigned long start_jiffies; |
40 | unsigned long end_jiffies; |
40 | unsigned long end_jiffies; |
41 | struct radeon_fence *fence = NULL; |
41 | struct radeon_fence *fence = NULL; |
42 | int i, r; |
42 | int i, r; |
43 | 43 | ||
44 | start_jiffies = jiffies; |
44 | start_jiffies = GetTimerTicks(); |
45 | for (i = 0; i < n; i++) { |
45 | for (i = 0; i < n; i++) { |
46 | switch (flag) { |
46 | switch (flag) { |
47 | case RADEON_BENCHMARK_COPY_DMA: |
47 | case RADEON_BENCHMARK_COPY_DMA: |
48 | r = radeon_copy_dma(rdev, saddr, daddr, |
48 | r = radeon_copy_dma(rdev, saddr, daddr, |
49 | size / RADEON_GPU_PAGE_SIZE, |
49 | size / RADEON_GPU_PAGE_SIZE, |
50 | &fence); |
50 | &fence); |
51 | break; |
51 | break; |
52 | case RADEON_BENCHMARK_COPY_BLIT: |
52 | case RADEON_BENCHMARK_COPY_BLIT: |
53 | r = radeon_copy_blit(rdev, saddr, daddr, |
53 | r = radeon_copy_blit(rdev, saddr, daddr, |
54 | size / RADEON_GPU_PAGE_SIZE, |
54 | size / RADEON_GPU_PAGE_SIZE, |
55 | &fence); |
55 | &fence); |
56 | break; |
56 | break; |
57 | default: |
57 | default: |
58 | DRM_ERROR("Unknown copy method\n"); |
58 | DRM_ERROR("Unknown copy method\n"); |
59 | r = -EINVAL; |
59 | r = -EINVAL; |
60 | } |
60 | } |
61 | if (r) |
61 | if (r) |
62 | goto exit_do_move; |
62 | goto exit_do_move; |
63 | r = radeon_fence_wait(fence, false); |
63 | r = radeon_fence_wait(fence, false); |
64 | if (r) |
64 | if (r) |
65 | goto exit_do_move; |
65 | goto exit_do_move; |
66 | radeon_fence_unref(&fence); |
66 | radeon_fence_unref(&fence); |
67 | } |
67 | } |
68 | end_jiffies = GetTimerTicks(); |
68 | end_jiffies = GetTimerTicks(); |
69 | r = jiffies_to_msecs(end_jiffies - start_jiffies); |
69 | r = jiffies_to_msecs(end_jiffies - start_jiffies); |
70 | 70 | ||
71 | exit_do_move: |
71 | exit_do_move: |
72 | if (fence) |
72 | if (fence) |
73 | radeon_fence_unref(&fence); |
73 | radeon_fence_unref(&fence); |
74 | return r; |
74 | return r; |
75 | } |
75 | } |
76 | 76 | ||
77 | 77 | ||
78 | static void radeon_benchmark_log_results(int n, unsigned size, |
78 | static void radeon_benchmark_log_results(int n, unsigned size, |
79 | unsigned int time, |
79 | unsigned int time, |
80 | unsigned sdomain, unsigned ddomain, |
80 | unsigned sdomain, unsigned ddomain, |
81 | char *kind) |
81 | char *kind) |
82 | { |
82 | { |
83 | unsigned int throughput = (n * (size >> 10)) / time; |
83 | unsigned int throughput = (n * (size >> 10)) / time; |
84 | DRM_INFO("radeon: %s %u bo moves of %u kB from" |
84 | DRM_INFO("radeon: %s %u bo moves of %u kB from" |
85 | " %d to %d in %u ms, throughput: %u Mb/s or %u MB/s\n", |
85 | " %d to %d in %u ms, throughput: %u Mb/s or %u MB/s\n", |
86 | kind, n, size >> 10, sdomain, ddomain, time, |
86 | kind, n, size >> 10, sdomain, ddomain, time, |
87 | throughput * 8, throughput); |
87 | throughput * 8, throughput); |
88 | } |
88 | } |
89 | 89 | ||
90 | static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, |
90 | static void radeon_benchmark_move(struct radeon_device *rdev, unsigned size, |
91 | unsigned sdomain, unsigned ddomain) |
91 | unsigned sdomain, unsigned ddomain) |
92 | { |
92 | { |
93 | struct radeon_bo *dobj = NULL; |
93 | struct radeon_bo *dobj = NULL; |
94 | struct radeon_bo *sobj = NULL; |
94 | struct radeon_bo *sobj = NULL; |
95 | uint64_t saddr, daddr; |
95 | uint64_t saddr, daddr; |
96 | int r, n; |
96 | int r, n; |
97 | int time; |
97 | int time; |
98 | 98 | ||
99 | 99 | ||
100 | ENTER(); |
100 | ENTER(); |
101 | 101 | ||
102 | n = RADEON_BENCHMARK_ITERATIONS; |
102 | n = RADEON_BENCHMARK_ITERATIONS; |
103 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, NULL, &sobj); |
103 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, NULL, &sobj); |
104 | if (r) { |
104 | if (r) { |
105 | goto out_cleanup; |
105 | goto out_cleanup; |
106 | } |
106 | } |
107 | r = radeon_bo_reserve(sobj, false); |
107 | r = radeon_bo_reserve(sobj, false); |
108 | if (unlikely(r != 0)) |
108 | if (unlikely(r != 0)) |
109 | goto out_cleanup; |
109 | goto out_cleanup; |
110 | r = radeon_bo_pin(sobj, sdomain, &saddr); |
110 | r = radeon_bo_pin(sobj, sdomain, &saddr); |
111 | // radeon_bo_unreserve(sobj); |
111 | // radeon_bo_unreserve(sobj); |
112 | if (r) { |
112 | if (r) { |
113 | goto out_cleanup; |
113 | goto out_cleanup; |
114 | } |
114 | } |
115 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, NULL, &dobj); |
115 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, NULL, &dobj); |
116 | if (r) { |
116 | if (r) { |
117 | goto out_cleanup; |
117 | goto out_cleanup; |
118 | } |
118 | } |
119 | r = radeon_bo_reserve(dobj, false); |
119 | r = radeon_bo_reserve(dobj, false); |
120 | if (unlikely(r != 0)) |
120 | if (unlikely(r != 0)) |
121 | goto out_cleanup; |
121 | goto out_cleanup; |
122 | r = radeon_bo_pin(dobj, ddomain, &daddr); |
122 | r = radeon_bo_pin(dobj, ddomain, &daddr); |
123 | // radeon_bo_unreserve(dobj); |
123 | // radeon_bo_unreserve(dobj); |
124 | if (r) { |
124 | if (r) { |
125 | goto out_cleanup; |
125 | goto out_cleanup; |
126 | } |
126 | } |
127 | dbgprintf("done\n"); |
127 | dbgprintf("done\n"); |
128 | 128 | ||
129 | /* r100 doesn't have dma engine so skip the test */ |
129 | /* r100 doesn't have dma engine so skip the test */ |
130 | /* also, VRAM-to-VRAM test doesn't make much sense for DMA */ |
130 | /* also, VRAM-to-VRAM test doesn't make much sense for DMA */ |
131 | /* skip it as well if domains are the same */ |
131 | /* skip it as well if domains are the same */ |
132 | if ((rdev->asic->copy.dma) && (sdomain != ddomain)) { |
132 | if ((rdev->asic->copy.dma) && (sdomain != ddomain)) { |
133 | time = radeon_benchmark_do_move(rdev, size, saddr, daddr, |
133 | time = radeon_benchmark_do_move(rdev, size, saddr, daddr, |
134 | RADEON_BENCHMARK_COPY_DMA, n); |
134 | RADEON_BENCHMARK_COPY_DMA, n); |
135 | if (time < 0) |
135 | if (time < 0) |
136 | goto out_cleanup; |
136 | goto out_cleanup; |
137 | if (time > 0) |
137 | if (time > 0) |
138 | radeon_benchmark_log_results(n, size, time, |
138 | radeon_benchmark_log_results(n, size, time, |
139 | sdomain, ddomain, "dma"); |
139 | sdomain, ddomain, "dma"); |
140 | } |
140 | } |
141 | 141 | ||
142 | time = radeon_benchmark_do_move(rdev, size, saddr, daddr, |
142 | time = radeon_benchmark_do_move(rdev, size, saddr, daddr, |
143 | RADEON_BENCHMARK_COPY_BLIT, n); |
143 | RADEON_BENCHMARK_COPY_BLIT, n); |
144 | if (time < 0) |
144 | if (time < 0) |
145 | goto out_cleanup; |
145 | goto out_cleanup; |
146 | if (time > 0) |
146 | if (time > 0) |
147 | radeon_benchmark_log_results(n, size, time, |
147 | radeon_benchmark_log_results(n, size, time, |
148 | sdomain, ddomain, "blit"); |
148 | sdomain, ddomain, "blit"); |
149 | 149 | ||
150 | out_cleanup: |
150 | out_cleanup: |
151 | if (sobj) { |
151 | if (sobj) { |
152 | r = radeon_bo_reserve(sobj, false); |
152 | r = radeon_bo_reserve(sobj, false); |
153 | if (likely(r == 0)) { |
153 | if (likely(r == 0)) { |
154 | radeon_bo_unpin(sobj); |
154 | radeon_bo_unpin(sobj); |
155 | radeon_bo_unreserve(sobj); |
155 | radeon_bo_unreserve(sobj); |
156 | } |
156 | } |
157 | radeon_bo_unref(&sobj); |
157 | radeon_bo_unref(&sobj); |
158 | } |
158 | } |
159 | if (dobj) { |
159 | if (dobj) { |
160 | r = radeon_bo_reserve(dobj, false); |
160 | r = radeon_bo_reserve(dobj, false); |
161 | if (likely(r == 0)) { |
161 | if (likely(r == 0)) { |
162 | radeon_bo_unpin(dobj); |
162 | radeon_bo_unpin(dobj); |
163 | radeon_bo_unreserve(dobj); |
163 | radeon_bo_unreserve(dobj); |
164 | } |
164 | } |
165 | radeon_bo_unref(&dobj); |
165 | radeon_bo_unref(&dobj); |
166 | } |
166 | } |
167 | 167 | ||
168 | if (r) { |
168 | if (r) { |
169 | DRM_ERROR("Error while benchmarking BO move.\n"); |
169 | DRM_ERROR("Error while benchmarking BO move.\n"); |
170 | } |
170 | } |
171 | 171 | ||
172 | LEAVE(); |
172 | LEAVE(); |
173 | 173 | ||
174 | } |
174 | } |
175 | 175 | ||
176 | void radeon_benchmark(struct radeon_device *rdev, int test_number) |
176 | void radeon_benchmark(struct radeon_device *rdev, int test_number) |
177 | { |
177 | { |
178 | int i; |
178 | int i; |
179 | int common_modes[RADEON_BENCHMARK_COMMON_MODES_N] = { |
179 | int common_modes[RADEON_BENCHMARK_COMMON_MODES_N] = { |
180 | 640 * 480 * 4, |
180 | 640 * 480 * 4, |
181 | 720 * 480 * 4, |
181 | 720 * 480 * 4, |
182 | 800 * 600 * 4, |
182 | 800 * 600 * 4, |
183 | 848 * 480 * 4, |
183 | 848 * 480 * 4, |
184 | 1024 * 768 * 4, |
184 | 1024 * 768 * 4, |
185 | 1152 * 768 * 4, |
185 | 1152 * 768 * 4, |
186 | 1280 * 720 * 4, |
186 | 1280 * 720 * 4, |
187 | 1280 * 800 * 4, |
187 | 1280 * 800 * 4, |
188 | 1280 * 854 * 4, |
188 | 1280 * 854 * 4, |
189 | 1280 * 960 * 4, |
189 | 1280 * 960 * 4, |
190 | 1280 * 1024 * 4, |
190 | 1280 * 1024 * 4, |
191 | 1440 * 900 * 4, |
191 | 1440 * 900 * 4, |
192 | 1400 * 1050 * 4, |
192 | 1400 * 1050 * 4, |
193 | 1680 * 1050 * 4, |
193 | 1680 * 1050 * 4, |
194 | 1600 * 1200 * 4, |
194 | 1600 * 1200 * 4, |
195 | 1920 * 1080 * 4, |
195 | 1920 * 1080 * 4, |
196 | 1920 * 1200 * 4 |
196 | 1920 * 1200 * 4 |
197 | }; |
197 | }; |
198 | 198 | ||
199 | switch (test_number) { |
199 | switch (test_number) { |
200 | case 1: |
200 | case 1: |
201 | /* simple test, VRAM to GTT and GTT to VRAM */ |
201 | /* simple test, VRAM to GTT and GTT to VRAM */ |
202 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_GTT, |
202 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_GTT, |
203 | RADEON_GEM_DOMAIN_VRAM); |
203 | RADEON_GEM_DOMAIN_VRAM); |
204 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_VRAM, |
204 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_VRAM, |
205 | RADEON_GEM_DOMAIN_GTT); |
205 | RADEON_GEM_DOMAIN_GTT); |
206 | break; |
206 | break; |
207 | case 2: |
207 | case 2: |
208 | /* simple test, VRAM to VRAM */ |
208 | /* simple test, VRAM to VRAM */ |
209 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_VRAM, |
209 | radeon_benchmark_move(rdev, 1024*1024, RADEON_GEM_DOMAIN_VRAM, |
210 | RADEON_GEM_DOMAIN_VRAM); |
210 | RADEON_GEM_DOMAIN_VRAM); |
211 | break; |
211 | break; |
212 | case 3: |
212 | case 3: |
213 | /* GTT to VRAM, buffer size sweep, powers of 2 */ |
213 | /* GTT to VRAM, buffer size sweep, powers of 2 */ |
214 | for (i = 1; i <= 16384; i <<= 1) |
214 | for (i = 1; i <= 16384; i <<= 1) |
215 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
215 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
216 | RADEON_GEM_DOMAIN_GTT, |
216 | RADEON_GEM_DOMAIN_GTT, |
217 | RADEON_GEM_DOMAIN_VRAM); |
217 | RADEON_GEM_DOMAIN_VRAM); |
218 | break; |
218 | break; |
219 | case 4: |
219 | case 4: |
220 | /* VRAM to GTT, buffer size sweep, powers of 2 */ |
220 | /* VRAM to GTT, buffer size sweep, powers of 2 */ |
221 | for (i = 1; i <= 16384; i <<= 1) |
221 | for (i = 1; i <= 16384; i <<= 1) |
222 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
222 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
223 | RADEON_GEM_DOMAIN_VRAM, |
223 | RADEON_GEM_DOMAIN_VRAM, |
224 | RADEON_GEM_DOMAIN_GTT); |
224 | RADEON_GEM_DOMAIN_GTT); |
225 | break; |
225 | break; |
226 | case 5: |
226 | case 5: |
227 | /* VRAM to VRAM, buffer size sweep, powers of 2 */ |
227 | /* VRAM to VRAM, buffer size sweep, powers of 2 */ |
228 | for (i = 1; i <= 16384; i <<= 1) |
228 | for (i = 1; i <= 16384; i <<= 1) |
229 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
229 | radeon_benchmark_move(rdev, i * RADEON_GPU_PAGE_SIZE, |
230 | RADEON_GEM_DOMAIN_VRAM, |
230 | RADEON_GEM_DOMAIN_VRAM, |
231 | RADEON_GEM_DOMAIN_VRAM); |
231 | RADEON_GEM_DOMAIN_VRAM); |
232 | break; |
232 | break; |
233 | case 6: |
233 | case 6: |
234 | /* GTT to VRAM, buffer size sweep, common modes */ |
234 | /* GTT to VRAM, buffer size sweep, common modes */ |
235 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
235 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
236 | radeon_benchmark_move(rdev, common_modes[i], |
236 | radeon_benchmark_move(rdev, common_modes[i], |
237 | RADEON_GEM_DOMAIN_GTT, |
237 | RADEON_GEM_DOMAIN_GTT, |
238 | RADEON_GEM_DOMAIN_VRAM); |
238 | RADEON_GEM_DOMAIN_VRAM); |
239 | break; |
239 | break; |
240 | case 7: |
240 | case 7: |
241 | /* VRAM to GTT, buffer size sweep, common modes */ |
241 | /* VRAM to GTT, buffer size sweep, common modes */ |
242 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
242 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
243 | radeon_benchmark_move(rdev, common_modes[i], |
243 | radeon_benchmark_move(rdev, common_modes[i], |
244 | RADEON_GEM_DOMAIN_VRAM, |
244 | RADEON_GEM_DOMAIN_VRAM, |
245 | RADEON_GEM_DOMAIN_GTT); |
245 | RADEON_GEM_DOMAIN_GTT); |
246 | break; |
246 | break; |
247 | case 8: |
247 | case 8: |
248 | /* VRAM to VRAM, buffer size sweep, common modes */ |
248 | /* VRAM to VRAM, buffer size sweep, common modes */ |
249 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
249 | for (i = 0; i < RADEON_BENCHMARK_COMMON_MODES_N; i++) |
250 | radeon_benchmark_move(rdev, common_modes[i], |
250 | radeon_benchmark_move(rdev, common_modes[i], |
251 | RADEON_GEM_DOMAIN_VRAM, |
251 | RADEON_GEM_DOMAIN_VRAM, |
252 | RADEON_GEM_DOMAIN_VRAM); |
252 | RADEON_GEM_DOMAIN_VRAM); |
253 | break; |
253 | break; |
254 | 254 | ||
255 | default: |
255 | default: |
256 | DRM_ERROR("Unknown benchmark\n"); |
256 | DRM_ERROR("Unknown benchmark\n"); |
257 | } |
257 | } |
258 | }>>>=><=>=>=><=>=>=><=>=>>>> |
258 | }>>>=><=>=>=><=>=>=><=>=>>>> |