aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2013-06-06 17:51:21 -0400
committerAlex Deucher <alexander.deucher@amd.com>2013-06-12 08:16:29 -0400
commit089920f21db0108fb105ecfd81de4c92d88f06d0 (patch)
tree2bdece83b9d396767ff6795b110af36a2dd0c388 /drivers/gpu
parent3813f5ca9ab7a00e80a17aab34f155453c66c78a (diff)
drm/radeon: fix write back suspend regression with uvd v2
UVD ring can't use scratch thus it does need writeback buffer to keep a valid address or radeon_ring_backup will trigger a kernel fault. It's ok to not unpin the write back buffer on suspend as it leave in gtt and thus does not need eviction. v2: Fix the uvd case. Reported and tracked by Wojtek <wojtask9@wp.pl> Signed-off-by: Jerome Glisse <jglisse@redhat.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c53
-rw-r--r--drivers/gpu/drm/radeon/radeon_fence.c10
-rw-r--r--drivers/gpu/drm/radeon/radeon_uvd.c14
3 files changed, 46 insertions, 31 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 189973836cff..b0dc0b6cb4e0 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -244,16 +244,6 @@ void radeon_scratch_free(struct radeon_device *rdev, uint32_t reg)
244 */ 244 */
245void radeon_wb_disable(struct radeon_device *rdev) 245void radeon_wb_disable(struct radeon_device *rdev)
246{ 246{
247 int r;
248
249 if (rdev->wb.wb_obj) {
250 r = radeon_bo_reserve(rdev->wb.wb_obj, false);
251 if (unlikely(r != 0))
252 return;
253 radeon_bo_kunmap(rdev->wb.wb_obj);
254 radeon_bo_unpin(rdev->wb.wb_obj);
255 radeon_bo_unreserve(rdev->wb.wb_obj);
256 }
257 rdev->wb.enabled = false; 247 rdev->wb.enabled = false;
258} 248}
259 249
@@ -269,6 +259,11 @@ void radeon_wb_fini(struct radeon_device *rdev)
269{ 259{
270 radeon_wb_disable(rdev); 260 radeon_wb_disable(rdev);
271 if (rdev->wb.wb_obj) { 261 if (rdev->wb.wb_obj) {
262 if (!radeon_bo_reserve(rdev->wb.wb_obj, false)) {
263 radeon_bo_kunmap(rdev->wb.wb_obj);
264 radeon_bo_unpin(rdev->wb.wb_obj);
265 radeon_bo_unreserve(rdev->wb.wb_obj);
266 }
272 radeon_bo_unref(&rdev->wb.wb_obj); 267 radeon_bo_unref(&rdev->wb.wb_obj);
273 rdev->wb.wb = NULL; 268 rdev->wb.wb = NULL;
274 rdev->wb.wb_obj = NULL; 269 rdev->wb.wb_obj = NULL;
@@ -295,26 +290,26 @@ int radeon_wb_init(struct radeon_device *rdev)
295 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r); 290 dev_warn(rdev->dev, "(%d) create WB bo failed\n", r);
296 return r; 291 return r;
297 } 292 }
298 } 293 r = radeon_bo_reserve(rdev->wb.wb_obj, false);
299 r = radeon_bo_reserve(rdev->wb.wb_obj, false); 294 if (unlikely(r != 0)) {
300 if (unlikely(r != 0)) { 295 radeon_wb_fini(rdev);
301 radeon_wb_fini(rdev); 296 return r;
302 return r; 297 }
303 } 298 r = radeon_bo_pin(rdev->wb.wb_obj, RADEON_GEM_DOMAIN_GTT,
304 r = radeon_bo_pin(rdev->wb.wb_obj, RADEON_GEM_DOMAIN_GTT, 299 &rdev->wb.gpu_addr);
305 &rdev->wb.gpu_addr); 300 if (r) {
306 if (r) { 301 radeon_bo_unreserve(rdev->wb.wb_obj);
302 dev_warn(rdev->dev, "(%d) pin WB bo failed\n", r);
303 radeon_wb_fini(rdev);
304 return r;
305 }
306 r = radeon_bo_kmap(rdev->wb.wb_obj, (void **)&rdev->wb.wb);
307 radeon_bo_unreserve(rdev->wb.wb_obj); 307 radeon_bo_unreserve(rdev->wb.wb_obj);
308 dev_warn(rdev->dev, "(%d) pin WB bo failed\n", r); 308 if (r) {
309 radeon_wb_fini(rdev); 309 dev_warn(rdev->dev, "(%d) map WB bo failed\n", r);
310 return r; 310 radeon_wb_fini(rdev);
311 } 311 return r;
312 r = radeon_bo_kmap(rdev->wb.wb_obj, (void **)&rdev->wb.wb); 312 }
313 radeon_bo_unreserve(rdev->wb.wb_obj);
314 if (r) {
315 dev_warn(rdev->dev, "(%d) map WB bo failed\n", r);
316 radeon_wb_fini(rdev);
317 return r;
318 } 313 }
319 314
320 /* clear wb memory */ 315 /* clear wb memory */
diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
index 5b937dfe6f65..ddb8f8e04eb5 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -63,7 +63,9 @@ static void radeon_fence_write(struct radeon_device *rdev, u32 seq, int ring)
63{ 63{
64 struct radeon_fence_driver *drv = &rdev->fence_drv[ring]; 64 struct radeon_fence_driver *drv = &rdev->fence_drv[ring];
65 if (likely(rdev->wb.enabled || !drv->scratch_reg)) { 65 if (likely(rdev->wb.enabled || !drv->scratch_reg)) {
66 *drv->cpu_addr = cpu_to_le32(seq); 66 if (drv->cpu_addr) {
67 *drv->cpu_addr = cpu_to_le32(seq);
68 }
67 } else { 69 } else {
68 WREG32(drv->scratch_reg, seq); 70 WREG32(drv->scratch_reg, seq);
69 } 71 }
@@ -84,7 +86,11 @@ static u32 radeon_fence_read(struct radeon_device *rdev, int ring)
84 u32 seq = 0; 86 u32 seq = 0;
85 87
86 if (likely(rdev->wb.enabled || !drv->scratch_reg)) { 88 if (likely(rdev->wb.enabled || !drv->scratch_reg)) {
87 seq = le32_to_cpu(*drv->cpu_addr); 89 if (drv->cpu_addr) {
90 seq = le32_to_cpu(*drv->cpu_addr);
91 } else {
92 seq = lower_32_bits(atomic64_read(&drv->last_seq));
93 }
88 } else { 94 } else {
89 seq = RREG32(drv->scratch_reg); 95 seq = RREG32(drv->scratch_reg);
90 } 96 }
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 906e5c0ca3b9..9f55adefa8e0 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -159,7 +159,17 @@ int radeon_uvd_suspend(struct radeon_device *rdev)
159 if (!r) { 159 if (!r) {
160 radeon_bo_kunmap(rdev->uvd.vcpu_bo); 160 radeon_bo_kunmap(rdev->uvd.vcpu_bo);
161 radeon_bo_unpin(rdev->uvd.vcpu_bo); 161 radeon_bo_unpin(rdev->uvd.vcpu_bo);
162 rdev->uvd.cpu_addr = NULL;
163 if (!radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_CPU, NULL)) {
164 radeon_bo_kmap(rdev->uvd.vcpu_bo, &rdev->uvd.cpu_addr);
165 }
162 radeon_bo_unreserve(rdev->uvd.vcpu_bo); 166 radeon_bo_unreserve(rdev->uvd.vcpu_bo);
167
168 if (rdev->uvd.cpu_addr) {
169 radeon_fence_driver_start_ring(rdev, R600_RING_TYPE_UVD_INDEX);
170 } else {
171 rdev->fence_drv[R600_RING_TYPE_UVD_INDEX].cpu_addr = NULL;
172 }
163 } 173 }
164 return r; 174 return r;
165} 175}
@@ -178,6 +188,10 @@ int radeon_uvd_resume(struct radeon_device *rdev)
178 return r; 188 return r;
179 } 189 }
180 190
191 /* Have been pin in cpu unmap unpin */
192 radeon_bo_kunmap(rdev->uvd.vcpu_bo);
193 radeon_bo_unpin(rdev->uvd.vcpu_bo);
194
181 r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM, 195 r = radeon_bo_pin(rdev->uvd.vcpu_bo, RADEON_GEM_DOMAIN_VRAM,
182 &rdev->uvd.gpu_addr); 196 &rdev->uvd.gpu_addr);
183 if (r) { 197 if (r) {