Rev 2005 | Rev 2997 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2005 | serge | 1 | /* |
2 | * Copyright 2009 Jerome Glisse. |
||
3 | * |
||
4 | * Permission is hereby granted, free of charge, to any person obtaining a |
||
5 | * copy of this software and associated documentation files (the "Software"), |
||
6 | * to deal in the Software without restriction, including without limitation |
||
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 |
||
9 | * Software is furnished to do so, subject to the following conditions: |
||
10 | * |
||
11 | * The above copyright notice and this permission notice shall be included in |
||
12 | * all copies or substantial portions of the Software. |
||
13 | * |
||
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, |
||
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 |
||
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 |
||
20 | * OTHER DEALINGS IN THE SOFTWARE. |
||
21 | * |
||
22 | * Authors: Jerome Glisse |
||
23 | */ |
||
24 | #include |
||
25 | #include |
||
26 | #include "radeon_reg.h" |
||
27 | #include "radeon.h" |
||
28 | |||
29 | unsigned int inline jiffies_to_msecs(const unsigned long j) |
||
30 | { |
||
31 | return (10 * j); |
||
32 | }; |
||
33 | |||
34 | |||
35 | void radeon_benchmark_move(struct radeon_device *rdev, unsigned bsize, |
||
36 | unsigned sdomain, unsigned ddomain) |
||
37 | { |
||
38 | struct radeon_bo *dobj = NULL; |
||
39 | struct radeon_bo *sobj = NULL; |
||
40 | struct radeon_fence *fence = NULL; |
||
41 | uint64_t saddr, daddr; |
||
42 | unsigned long start_jiffies; |
||
43 | unsigned long end_jiffies; |
||
44 | unsigned long time; |
||
45 | unsigned i, n, size; |
||
46 | int r; |
||
47 | |||
48 | ENTER(); |
||
49 | |||
50 | size = bsize; |
||
2007 | serge | 51 | n = 4; //1024; |
2005 | serge | 52 | |
53 | dbgprintf("source domain %x\n", sdomain); |
||
54 | |||
55 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, sdomain, &sobj); |
||
56 | if (r) { |
||
57 | goto out_cleanup; |
||
58 | } |
||
59 | r = radeon_bo_reserve(sobj, false); |
||
60 | if (unlikely(r != 0)) |
||
61 | goto out_cleanup; |
||
62 | r = radeon_bo_pin(sobj, sdomain, &saddr); |
||
63 | // radeon_bo_unreserve(sobj); |
||
64 | if (r) { |
||
65 | goto out_cleanup; |
||
66 | } |
||
67 | |||
68 | dbgprintf("destination domain %x\n", ddomain); |
||
69 | |||
70 | r = radeon_bo_create(rdev, size, PAGE_SIZE, true, ddomain, &dobj); |
||
71 | if (r) { |
||
72 | goto out_cleanup; |
||
73 | } |
||
74 | r = radeon_bo_reserve(dobj, false); |
||
75 | if (unlikely(r != 0)) |
||
76 | goto out_cleanup; |
||
77 | r = radeon_bo_pin(dobj, ddomain, &daddr); |
||
78 | // radeon_bo_unreserve(dobj); |
||
79 | if (r) { |
||
80 | goto out_cleanup; |
||
81 | } |
||
82 | dbgprintf("done\n"); |
||
83 | |||
84 | /* r100 doesn't have dma engine so skip the test */ |
||
85 | if (rdev->asic->copy_dma) { |
||
86 | |||
87 | dbgprintf("copy dma\n"); |
||
88 | |||
89 | start_jiffies = GetTimerTicks(); |
||
90 | for (i = 0; i < n; i++) { |
||
91 | r = radeon_fence_create(rdev, &fence); |
||
92 | if (r) { |
||
93 | goto out_cleanup; |
||
94 | } |
||
95 | |||
96 | r = radeon_copy_dma(rdev, saddr, daddr, |
||
97 | size / RADEON_GPU_PAGE_SIZE, fence); |
||
98 | |||
99 | if (r) { |
||
100 | goto out_cleanup; |
||
101 | } |
||
2007 | serge | 102 | } |
103 | |||
2005 | serge | 104 | r = radeon_fence_wait(fence, false); |
105 | if (r) { |
||
106 | goto out_cleanup; |
||
107 | } |
||
108 | radeon_fence_unref(&fence); |
||
2007 | serge | 109 | |
2005 | serge | 110 | end_jiffies = GetTimerTicks(); |
111 | time = end_jiffies - start_jiffies; |
||
112 | time = jiffies_to_msecs(time); |
||
113 | if (time > 0) { |
||
114 | i = ((n * size) >> 10) / time; |
||
115 | printk(KERN_INFO "radeon: dma %u bo moves of %ukb from" |
||
116 | " %d to %d in %lums (%ukb/ms %ukb/s %uM/s)\n", |
||
117 | n, size >> 10, |
||
118 | sdomain, ddomain, time, |
||
119 | i, i * 1000, (i * 1000) / 1024); |
||
120 | } |
||
121 | } |
||
122 | |||
123 | start_jiffies = GetTimerTicks(); |
||
124 | for (i = 0; i < n; i++) { |
||
125 | r = radeon_fence_create(rdev, &fence); |
||
126 | if (r) { |
||
127 | goto out_cleanup; |
||
128 | } |
||
129 | r = radeon_copy_blit(rdev, saddr, daddr, size / RADEON_GPU_PAGE_SIZE, fence); |
||
130 | if (r) { |
||
131 | goto out_cleanup; |
||
132 | } |
||
2007 | serge | 133 | } |
134 | |||
2005 | serge | 135 | r = radeon_fence_wait(fence, false); |
136 | if (r) { |
||
137 | goto out_cleanup; |
||
138 | } |
||
139 | radeon_fence_unref(&fence); |
||
2007 | serge | 140 | |
2005 | serge | 141 | end_jiffies = GetTimerTicks(); |
142 | time = end_jiffies - start_jiffies; |
||
143 | time = jiffies_to_msecs(time); |
||
144 | if (time > 0) { |
||
145 | i = ((n * size) >> 10) / time; |
||
146 | printk(KERN_INFO "radeon: blit %u bo moves of %ukb from %d to %d" |
||
147 | " in %lums (%ukb/ms %ukb/s %uM/s)\n", n, size >> 10, |
||
148 | sdomain, ddomain, time, i, i * 1000, (i * 1000) / 1024); |
||
149 | } |
||
150 | out_cleanup: |
||
151 | |||
152 | dbgprintf("cleanup\n"); |
||
153 | |||
154 | if (sobj) { |
||
155 | r = radeon_bo_reserve(sobj, false); |
||
156 | if (likely(r == 0)) { |
||
157 | radeon_bo_unpin(sobj); |
||
158 | radeon_bo_unreserve(sobj); |
||
159 | } |
||
160 | radeon_bo_unref(&sobj); |
||
161 | } |
||
162 | if (dobj) { |
||
163 | r = radeon_bo_reserve(dobj, false); |
||
164 | if (likely(r == 0)) { |
||
165 | radeon_bo_unpin(dobj); |
||
166 | radeon_bo_unreserve(dobj); |
||
167 | } |
||
168 | radeon_bo_unref(&dobj); |
||
169 | } |
||
170 | if (fence) { |
||
171 | radeon_fence_unref(&fence); |
||
172 | } |
||
173 | if (r) { |
||
174 | printk(KERN_WARNING "Error while benchmarking BO move.\n"); |
||
175 | } |
||
176 | |||
177 | LEAVE(); |
||
178 | |||
179 | } |
||
180 | |||
181 | void radeon_benchmark(struct radeon_device *rdev) |
||
182 | { |
||
2007 | serge | 183 | radeon_benchmark_move(rdev, 4096*4096, RADEON_GEM_DOMAIN_GTT, |
2005 | serge | 184 | RADEON_GEM_DOMAIN_VRAM); |
2007 | serge | 185 | radeon_benchmark_move(rdev, 4096*4096, RADEON_GEM_DOMAIN_VRAM, |
2005 | serge | 186 | RADEON_GEM_DOMAIN_GTT); |
2007 | serge | 187 | radeon_benchmark_move(rdev, 4096*4096, RADEON_GEM_DOMAIN_VRAM, |
2005 | serge | 188 | RADEON_GEM_DOMAIN_VRAM); |
189 | }>> |