--- /dev/null
+From b2ea8ef559b4d94190009f3651b5b3ab7c05afd3 Mon Sep 17 00:00:00 2001
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+Date: Mon, 4 Nov 2013 08:13:45 +0100
+Subject: drm/i915: flush cursors harder
+
+From: Daniel Vetter <daniel.vetter@ffwll.ch>
+
+commit b2ea8ef559b4d94190009f3651b5b3ab7c05afd3 upstream.
+
+Apparently they need the same treatment as primary planes. This fixes
+modesetting failures because of stuck cursors (!) on Thomas' i830M
+machine.
+
+I've figured while at it I'll also roll it out for the ivb 3 pipe
+version of this function. I didn't do this for i845/i865 since Bspec
+says the update mechanism works differently, and there's some
+additional rules about what can be updated in which order.
+
+Tested-by: Thomas Richter <thor@math.tu-berlin.de>
+Cc: Thomas Richter <thor@math.tu-berlin.de>
+Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
+Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/i915/intel_display.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/drivers/gpu/drm/i915/intel_display.c
++++ b/drivers/gpu/drm/i915/intel_display.c
+@@ -6262,7 +6262,9 @@ static void i9xx_update_cursor(struct dr
+ intel_crtc->cursor_visible = visible;
+ }
+ /* and commit changes on next vblank */
++ POSTING_READ(CURCNTR(pipe));
+ I915_WRITE(CURBASE(pipe), base);
++ POSTING_READ(CURBASE(pipe));
+ }
+
+ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base)
+@@ -6289,7 +6291,9 @@ static void ivb_update_cursor(struct drm
+ intel_crtc->cursor_visible = visible;
+ }
+ /* and commit changes on next vblank */
++ POSTING_READ(CURCNTR_IVB(pipe));
+ I915_WRITE(CURBASE_IVB(pipe), base);
++ POSTING_READ(CURBASE_IVB(pipe));
+ }
+
+ /* If no-part of the cursor is visible on the framebuffer, then the GPU may hang... */
--- /dev/null
+From 9360bd1112d8874d21942e2ae74f5416b00a8db6 Mon Sep 17 00:00:00 2001
+From: Ben Skeggs <bskeggs@redhat.com>
+Date: Wed, 13 Nov 2013 15:18:32 +1000
+Subject: drm/nouveau: when bailing out of a pushbuf ioctl, do not remove previous fence
+
+From: Ben Skeggs <bskeggs@redhat.com>
+
+commit 9360bd1112d8874d21942e2ae74f5416b00a8db6 upstream.
+
+Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
++++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
+@@ -287,7 +287,8 @@ validate_fini_list(struct list_head *lis
+ list_for_each_safe(entry, tmp, list) {
+ nvbo = list_entry(entry, struct nouveau_bo, entry);
+
+- nouveau_bo_fence(nvbo, fence);
++ if (likely(fence))
++ nouveau_bo_fence(nvbo, fence);
+
+ if (unlikely(nvbo->validate_mapped)) {
+ ttm_bo_kunmap(&nvbo->kmap);
--- /dev/null
+From 59c8e66378fb78adbcd05f0d09783dde6fef282b Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Mon, 28 Oct 2013 02:02:19 -0700
+Subject: drm/ttm: Fix memory type compatibility check
+
+From: Thomas Hellstrom <thellstrom@vmware.com>
+
+commit 59c8e66378fb78adbcd05f0d09783dde6fef282b upstream.
+
+Also check the busy placements before deciding to move a buffer object.
+Failing to do this may result in a completely unneccessary move within a
+single memory type.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/ttm/ttm_bo.c | 32 ++++++++++++++++++++------------
+ 1 file changed, 20 insertions(+), 12 deletions(-)
+
+--- a/drivers/gpu/drm/ttm/ttm_bo.c
++++ b/drivers/gpu/drm/ttm/ttm_bo.c
+@@ -1153,24 +1153,32 @@ out_unlock:
+ return ret;
+ }
+
+-static int ttm_bo_mem_compat(struct ttm_placement *placement,
+- struct ttm_mem_reg *mem)
++static bool ttm_bo_mem_compat(struct ttm_placement *placement,
++ struct ttm_mem_reg *mem,
++ uint32_t *new_flags)
+ {
+ int i;
+
+ if (mem->mm_node && placement->lpfn != 0 &&
+ (mem->start < placement->fpfn ||
+ mem->start + mem->num_pages > placement->lpfn))
+- return -1;
++ return false;
+
+ for (i = 0; i < placement->num_placement; i++) {
+- if ((placement->placement[i] & mem->placement &
+- TTM_PL_MASK_CACHING) &&
+- (placement->placement[i] & mem->placement &
+- TTM_PL_MASK_MEM))
+- return i;
++ *new_flags = placement->placement[i];
++ if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
++ (*new_flags & mem->placement & TTM_PL_MASK_MEM))
++ return true;
+ }
+- return -1;
++
++ for (i = 0; i < placement->num_busy_placement; i++) {
++ *new_flags = placement->busy_placement[i];
++ if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
++ (*new_flags & mem->placement & TTM_PL_MASK_MEM))
++ return true;
++ }
++
++ return false;
+ }
+
+ int ttm_bo_validate(struct ttm_buffer_object *bo,
+@@ -1179,6 +1187,7 @@ int ttm_bo_validate(struct ttm_buffer_ob
+ bool no_wait_gpu)
+ {
+ int ret;
++ uint32_t new_flags;
+
+ BUG_ON(!ttm_bo_is_reserved(bo));
+ /* Check that range is valid */
+@@ -1189,8 +1198,7 @@ int ttm_bo_validate(struct ttm_buffer_ob
+ /*
+ * Check whether we need to move buffer.
+ */
+- ret = ttm_bo_mem_compat(placement, &bo->mem);
+- if (ret < 0) {
++ if (!ttm_bo_mem_compat(placement, &bo->mem, &new_flags)) {
+ ret = ttm_bo_move_buffer(bo, placement, interruptible,
+ no_wait_gpu);
+ if (ret)
+@@ -1200,7 +1208,7 @@ int ttm_bo_validate(struct ttm_buffer_ob
+ * Use the access and other non-mapping-related flag bits from
+ * the compatible memory placement flags to the active flags
+ */
+- ttm_flag_masked(&bo->mem.placement, placement->placement[ret],
++ ttm_flag_masked(&bo->mem.placement, new_flags,
+ ~TTM_PL_MASK_MEMTYPE);
+ }
+ /*
--- /dev/null
+From da95c788ef0c645378ffccb7060a0df1a33aee38 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Wed, 30 Oct 2013 03:29:50 -0700
+Subject: drm/ttm: Fix ttm_bo_move_memcpy
+
+From: Thomas Hellstrom <thellstrom@vmware.com>
+
+commit da95c788ef0c645378ffccb7060a0df1a33aee38 upstream.
+
+All error paths will want to keep the mm node, so handle this at the
+function exit. This fixes an ioremap failure error path.
+Also add some comments to make the function a bit easier to understand.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/ttm/ttm_bo_util.c | 28 +++++++++++++++++-----------
+ 1 file changed, 17 insertions(+), 11 deletions(-)
+
+--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
++++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
+@@ -342,21 +342,25 @@ int ttm_bo_move_memcpy(struct ttm_buffer
+ if (ret)
+ goto out;
+
++ /*
++ * Single TTM move. NOP.
++ */
+ if (old_iomap == NULL && new_iomap == NULL)
+ goto out2;
++
++ /*
++ * Move nonexistent data. NOP.
++ */
+ if (old_iomap == NULL && ttm == NULL)
+ goto out2;
+
+- /* TTM might be null for moves within the same region.
++ /*
++ * TTM might be null for moves within the same region.
+ */
+ if (ttm && ttm->state == tt_unpopulated) {
+ ret = ttm->bdev->driver->ttm_tt_populate(ttm);
+- if (ret) {
+- /* if we fail here don't nuke the mm node
+- * as the bo still owns it */
+- old_copy.mm_node = NULL;
++ if (ret)
+ goto out1;
+- }
+ }
+
+ add = 0;
+@@ -382,11 +386,8 @@ int ttm_bo_move_memcpy(struct ttm_buffer
+ prot);
+ } else
+ ret = ttm_copy_io_page(new_iomap, old_iomap, page);
+- if (ret) {
+- /* failing here, means keep old copy as-is */
+- old_copy.mm_node = NULL;
++ if (ret)
+ goto out1;
+- }
+ }
+ mb();
+ out2:
+@@ -404,7 +405,12 @@ out1:
+ ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
+ out:
+ ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
+- ttm_bo_mem_put(bo, &old_copy);
++
++ /*
++ * On error, keep the mm node!
++ */
++ if (!ret)
++ ttm_bo_mem_put(bo, &old_copy);
+ return ret;
+ }
+ EXPORT_SYMBOL(ttm_bo_move_memcpy);
--- /dev/null
+From 9a0599ddeae012a771bba5e23393fc52d8a59d89 Mon Sep 17 00:00:00 2001
+From: Jakob Bornecrantz <jakob@vmware.com>
+Date: Wed, 30 Oct 2013 02:46:56 -0700
+Subject: drm/ttm: Handle in-memory region copies
+
+From: Jakob Bornecrantz <jakob@vmware.com>
+
+commit 9a0599ddeae012a771bba5e23393fc52d8a59d89 upstream.
+
+Fix the case where the ttm pointer may be NULL causing
+a NULL pointer dereference.
+
+Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
+Signed-off-by: Thomas Hellström <thellstrom@vmware.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/ttm/ttm_bo_util.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
++++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
+@@ -347,7 +347,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer
+ if (old_iomap == NULL && ttm == NULL)
+ goto out2;
+
+- if (ttm->state == tt_unpopulated) {
++ /* TTM might be null for moves within the same region.
++ */
++ if (ttm && ttm->state == tt_unpopulated) {
+ ret = ttm->bdev->driver->ttm_tt_populate(ttm);
+ if (ret) {
+ /* if we fail here don't nuke the mm node
avr32-fix-out-of-range-jump-in-large-kernels.patch
prism54-set-netdev-type-to-wlan.patch
ftrace-fix-function-graph-with-loading-of-modules.patch
+drm-ttm-fix-memory-type-compatibility-check.patch
+drm-ttm-handle-in-memory-region-copies.patch
+drm-ttm-fix-ttm_bo_move_memcpy.patch
+drm-i915-flush-cursors-harder.patch
+drm-nouveau-when-bailing-out-of-a-pushbuf-ioctl-do-not-remove-previous-fence.patch