OSDN Git Service

i915: wait for buffer idle before writing relocations
authorKeith Packard <keithp@keithp.com>
Thu, 6 Dec 2007 23:12:21 +0000 (15:12 -0800)
committerKeith Packard <keithp@keithp.com>
Wed, 12 Dec 2007 04:23:00 +0000 (20:23 -0800)
When writing a relocation entry, make sure the target buffer is idle,
otherwise the GPU may see inconsistent data.

shared-core/i915_dma.c

index 090ac80..18d2482 100644 (file)
@@ -751,6 +751,13 @@ int i915_apply_reloc(struct drm_file *file_priv, int num_buffers,
            !drm_bo_same_page(relocatee->offset, new_cmd_offset)) {
                drm_bo_kunmap(&relocatee->kmap);
                relocatee->offset = new_cmd_offset;
+               mutex_lock (&relocatee->buf->mutex);
+               ret = drm_bo_wait (relocatee->buf, 0, 0, FALSE);
+               mutex_unlock (&relocatee->buf->mutex);
+               if (ret) {
+                       DRM_ERROR("Could not wait for buffer to apply relocs\n %08lx", new_cmd_offset);
+                       return ret;
+               }
                ret = drm_bo_kmap(relocatee->buf, new_cmd_offset >> PAGE_SHIFT,
                                  1, &relocatee->kmap);
                if (ret) {