aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_device.c
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2010-08-27 18:25:25 -0400
committerDave Airlie <airlied@redhat.com>2010-10-05 21:38:08 -0400
commit724c80e1d630296d1324859e964d80d35007d83c (patch)
tree954e86447e1c259160d09c732ac0eb0289b2ec8b /drivers/gpu/drm/radeon/radeon_device.c
parentb70d6bb3f67b2e2964abafb0117f1733f062cba5 (diff)
drm/radeon/kms: enable writeback (v2)
When writeback is enabled, the GPU shadows writes to certain registers into a buffer in memory. The driver can then read the values from the shadow rather than reading back from the register across the bus. Writeback can be disabled by setting the no_wb module param to 1. On r6xx/r7xx/evergreen, the following registers are shadowed: - CP scratch registers - CP read pointer - IH write pointer On r1xx-rr5xx, the following registers are shadowed: - CP scratch registers - CP read pointer v2: - Combine wb patches for r6xx-evergreen and r1xx-r5xx - Writeback is disabled on AGP boards since it tends to be unreliable on AGP using the gart. - Check radeon_wb_init return values properly. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_device.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c77
1 files changed, 76 insertions, 1 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 256d204a6d24..cfc162d05010 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -117,9 +117,10 @@ void radeon_scratch_init(struct radeon_device *rdev)
117 } else { 117 } else {
118 rdev->scratch.num_reg = 7; 118 rdev->scratch.num_reg = 7;
119 } 119 }
120 rdev->scratch.reg_base = RADEON_SCRATCH_REG0;
120 for (i = 0; i < rdev->scratch.num_reg; i++) { 121 for (i = 0; i < rdev->scratch.num_reg; i++) {
121 rdev->scratch.free[i] = true; 122 rdev->scratch.free[i] = true;
122 rdev->scratch.reg[i] = RADEON_SCRATCH_REG0 + (i * 4); 123 rdev->scratch.reg[i] = rdev->scratch.reg_base + (i * 4);
123 } 124 }
124} 125}
125 126
@@ -149,6 +150,80 @@ void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg)
149 } 150 }
150} 151}
151 152
153void radeon_wb_disable(struct radeon_device *rdev)
154{
155 int r;
156
157 if (rdev->wb.wb_obj) {
158 r = radeon_bo_reserve(rdev->wb.wb_obj, false);
159 if (unlikely(r != 0))
160 return;
161 radeon_bo_kunmap(rdev->wb.wb_obj);
162 radeon_bo_unpin(rdev->wb.wb_obj);
163 radeon_bo_unreserve(rdev->wb.wb_obj);
164 }
165 rdev->wb.enabled = false;
166}
167
168void radeon_wb_fini(struct radeon_device *rdev)
169{
170 radeon_wb_disable(rdev);
171 if (rdev->wb.wb_obj) {
172 radeon_bo_unref(&rdev->wb.wb_obj);
173 rdev->wb.wb = NULL;
174 rdev->wb.wb_obj = NULL;
175 }
176}
177
178int radeon_wb_init(struct radeon_device *rdev)
179{
180 int r;
181
182 if (rdev->wb.wb_obj == NULL) {
183 r = radeon_bo_create(rdev, NULL, RADEON_GPU_PAGE_SIZE, true,
184 RADEON_GEM_DOMAIN_GTT, &rdev->wb.wb_obj);
185 if (r) {
186 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
187 return r;
188 }
189 }
190 r = radeon_bo_reserve(rdev->wb.wb_obj, false);
191 if (unlikely(r != 0)) {
192 radeon_wb_fini(rdev);
193 return r;
194 }
195 r = radeon_bo_pin(rdev->wb.wb_obj, RADEON_GEM_DOMAIN_GTT,
196 &rdev->wb.gpu_addr);
197 if (r) {
198 radeon_bo_unreserve(rdev->wb.wb_obj);
199 dev_warn(rdev->dev, "(%d) pin WB bo failed\n", r);
200 radeon_wb_fini(rdev);
201 return r;
202 }
203 r = radeon_bo_kmap(rdev->wb.wb_obj, (void **)&rdev->wb.wb);
204 radeon_bo_unreserve(rdev->wb.wb_obj);
205 if (r) {
206 dev_warn(rdev->dev, "(%d) map WB bo failed\n", r);
207 radeon_wb_fini(rdev);
208 return r;
209 }
210
211 /* disabled via module param */
212 if (radeon_no_wb == 1)
213 rdev->wb.enabled = false;
214 else {
215 /* often unreliable on AGP */
216 if (rdev->flags & RADEON_IS_AGP) {
217 rdev->wb.enabled = false;
218 } else
219 rdev->wb.enabled = true;
220 }
221
222 dev_info(rdev->dev, "WB %sabled\n", rdev->wb.enabled ? "en" : "dis");
223
224 return 0;
225}
226
152/** 227/**
153 * radeon_vram_location - try to find VRAM location 228 * radeon_vram_location - try to find VRAM location
154 * @rdev: radeon device structure holding all necessary informations 229 * @rdev: radeon device structure holding all necessary informations