imamnurby/smpl_train_seed8 huggingface dataset:
--- initial
+++ final
@@ -1,34 +1,35 @@
 int radeon_bo_fault_reserve_notify(struct ttm_buffer_object *bo) {
+  struct ttm_operation_ctx ctx = {false, false};
   struct radeon_device *rdev;
   struct radeon_bo *rbo;
   unsigned long offset, size, lpfn;
   int i, r;
   if (!radeon_ttm_bo_is_radeon_bo(bo)) return 0;
   rbo = container_of(bo, struct radeon_bo, tbo);
   radeon_bo_check_tiling(rbo, 0, 0);
   rdev = rbo->rdev;
   if (bo->mem.mem_type != TTM_PL_VRAM) return 0;
   size = bo->mem.num_pages << PAGE_SHIFT;
   offset = bo->mem.start << PAGE_SHIFT;
   if ((offset + size) <= rdev->mc.visible_vram_size) return 0;
   /* Can't move a pinned BO to visible VRAM */
   if (rbo->pin_count > 0) return -EINVAL;
   /* hurrah the memory is not visible ! */
   radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_VRAM);
   lpfn = rdev->mc.visible_vram_size >> PAGE_SHIFT;
   for (i = 0; i < rbo->placement.num_placement; i++) {
     /* Force into visible VRAM */
     if ((rbo->placements[i].flags & TTM_PL_FLAG_VRAM) && (!rbo->placements[i].lpfn || rbo->placements[i].lpfn > lpfn)) rbo->placements[i].lpfn = lpfn;
   }
-  r = ttm_bo_validate(bo, &rbo->placement, false, false);
+  r = ttm_bo_validate(bo, &rbo->placement, &ctx);
   if (unlikely(r == -ENOMEM)) {
     radeon_ttm_placement_from_domain(rbo, RADEON_GEM_DOMAIN_GTT);
-    return ttm_bo_validate(bo, &rbo->placement, false, false);
+    return ttm_bo_validate(bo, &rbo->placement, &ctx);
   } else if (unlikely(r != 0)) {
     return r;
   }
   offset = bo->mem.start << PAGE_SHIFT;
   /* this should never happen */
   if ((offset + size) > rdev->mc.visible_vram_size) return -EINVAL;
   return 0;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,52 +1,53 @@
 int radeon_bo_list_validate(struct radeon_device *rdev, struct ww_acquire_ctx *ticket, struct list_head *head, int ring) {
+  struct ttm_operation_ctx ctx = {true, false};
   struct radeon_bo_list *lobj;
   struct list_head duplicates;
   int r;
   u64 bytes_moved = 0, initial_bytes_moved;
   u64 bytes_moved_threshold = radeon_bo_get_threshold_for_moves(rdev);
   INIT_LIST_HEAD(&duplicates);
   r = ttm_eu_reserve_buffers(ticket, head, true, &duplicates);
   if (unlikely(r != 0)) { return r; }
   list_for_each_entry(lobj, head, tv.head) {
     struct radeon_bo *bo = lobj->robj;
     if (!bo->pin_count) {
       u32 domain = lobj->preferred_domains;
       u32 allowed = lobj->allowed_domains;
       u32 current_domain = radeon_mem_type_to_domain(bo->tbo.mem.mem_type);
       /* Check if this buffer will be moved and don't move it
        * if we have moved too many buffers for this IB already.
        *
        * Note that this allows moving at least one buffer of
        * any size, because it doesn't take the current "bo"
        * into account. We don't want to disallow buffer moves
        * completely.
        */
       if ((allowed & current_domain) != 0 && (domain & current_domain) == 0 && /* will be moved */
           bytes_moved > bytes_moved_threshold) {
         /* don't move it */
         domain = current_domain;
       }
     retry:
       radeon_ttm_placement_from_domain(bo, domain);
       if (ring == R600_RING_TYPE_UVD_INDEX) radeon_uvd_force_into_uvd_segment(bo, allowed);
       initial_bytes_moved = atomic64_read(&rdev->num_bytes_moved);
-      r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
+      r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
       bytes_moved += atomic64_read(&rdev->num_bytes_moved) - initial_bytes_moved;
       if (unlikely(r)) {
         if (r != -ERESTARTSYS && domain != lobj->allowed_domains) {
           domain = lobj->allowed_domains;
           goto retry;
         }
         ttm_eu_backoff_reservation(ticket, head);
         return r;
       }
     }
     lobj->gpu_offset = radeon_bo_gpu_offset(bo);
     lobj->tiling_flags = bo->tiling_flags;
   }
   list_for_each_entry(lobj, &duplicates, tv.head) {
     lobj->gpu_offset = radeon_bo_gpu_offset(lobj->robj);
     lobj->tiling_flags = lobj->robj->tiling_flags;
   }
   return 0;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,42 +1,43 @@
 int radeon_bo_pin_restricted(struct radeon_bo *bo, u32 domain, u64 max_offset, u64 *gpu_addr) {
+  struct ttm_operation_ctx ctx = {false, false};
   int r, i;
   if (radeon_ttm_tt_has_userptr(bo->tbo.ttm)) return -EPERM;
   if (bo->pin_count) {
     bo->pin_count++;
     if (gpu_addr) *gpu_addr = radeon_bo_gpu_offset(bo);
     if (max_offset != 0) {
       u64 domain_start;
       if (domain == RADEON_GEM_DOMAIN_VRAM)
         domain_start = bo->rdev->mc.vram_start;
       else
         domain_start = bo->rdev->mc.gtt_start;
       WARN_ON_ONCE(max_offset < (radeon_bo_gpu_offset(bo) - domain_start));
     }
     return 0;
   }
   if (bo->prime_shared_count && domain == RADEON_GEM_DOMAIN_VRAM) {
     /* A BO shared as a dma-buf cannot be sensibly migrated to VRAM */
     return -EINVAL;
   }
   radeon_ttm_placement_from_domain(bo, domain);
   for (i = 0; i < bo->placement.num_placement; i++) {
     /* force to pin into visible video ram */
     if ((bo->placements[i].flags & TTM_PL_FLAG_VRAM) && !(bo->flags & RADEON_GEM_NO_CPU_ACCESS) && (!max_offset || max_offset > bo->rdev->mc.visible_vram_size))
       bo->placements[i].lpfn = bo->rdev->mc.visible_vram_size >> PAGE_SHIFT;
     else
       bo->placements[i].lpfn = max_offset >> PAGE_SHIFT;
     bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
   }
-  r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
+  r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
   if (likely(r == 0)) {
     bo->pin_count = 1;
     if (gpu_addr != NULL) *gpu_addr = radeon_bo_gpu_offset(bo);
     if (domain == RADEON_GEM_DOMAIN_VRAM)
       bo->rdev->vram_pin_size += radeon_bo_size(bo);
     else
       bo->rdev->gart_pin_size += radeon_bo_size(bo);
   } else {
     dev_err(bo->rdev->dev, "%p pin failed\n", bo);
   }
   return r;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,23 +1,24 @@
 int radeon_bo_unpin(struct radeon_bo *bo) {
+  struct ttm_operation_ctx ctx = {false, false};
   int r, i;
   if (!bo->pin_count) {
     dev_warn(bo->rdev->dev, "%p unpin not necessary\n", bo);
     return 0;
   }
   bo->pin_count--;
   if (bo->pin_count) return 0;
   for (i = 0; i < bo->placement.num_placement; i++) {
     bo->placements[i].lpfn = 0;
     bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
   }
-  r = ttm_bo_validate(&bo->tbo, &bo->placement, false, false);
+  r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
   if (likely(r == 0)) {
     if (bo->tbo.mem.mem_type == TTM_PL_VRAM)
       bo->rdev->vram_pin_size -= radeon_bo_size(bo);
     else
       bo->rdev->gart_pin_size -= radeon_bo_size(bo);
   } else {
     dev_err(bo->rdev->dev, "%p validate failed for unpin\n", bo);
   }
   return r;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,27 +1,28 @@
 static int radeon_vm_clear_bo(struct radeon_device *rdev, struct radeon_bo *bo) {
+  struct ttm_operation_ctx ctx = {true, false};
   struct radeon_ib ib;
   unsigned entries;
   uint64_t addr;
   int r;
   r = radeon_bo_reserve(bo, false);
   if (r) return r;
-  r = ttm_bo_validate(&bo->tbo, &bo->placement, true, false);
+  r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
   if (r) goto error_unreserve;
   addr = radeon_bo_gpu_offset(bo);
   entries = radeon_bo_size(bo) / 8;
   r = radeon_ib_get(rdev, R600_RING_TYPE_DMA_INDEX, &ib, NULL, 256);
   if (r) goto error_unreserve;
   ib.length_dw = 0;
   radeon_vm_set_pages(rdev, &ib, addr, 0, entries, 0, 0);
   radeon_asic_vm_pad_ib(rdev, &ib);
   WARN_ON(ib.length_dw > 64);
   r = radeon_ib_schedule(rdev, &ib, NULL, false);
   if (r) goto error_free;
   ib.fence->is_vm_update = true;
   radeon_bo_fence(bo, ib.fence, false);
 error_free:
   radeon_ib_free(rdev, &ib);
 error_unreserve:
   radeon_bo_unreserve(bo);
   return r;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,18 +1,19 @@
 static int virtio_gpu_object_list_validate(struct ww_acquire_ctx *ticket, struct list_head *head) {
+  struct ttm_operation_ctx ctx = {false, false};
   struct ttm_validate_buffer *buf;
   struct ttm_buffer_object *bo;
   struct virtio_gpu_object *qobj;
   int ret;
   ret = ttm_eu_reserve_buffers(ticket, head, true, NULL);
   if (ret != 0) return ret;
   list_for_each_entry(buf, head, head) {
     bo = buf->bo;
     qobj = container_of(bo, struct virtio_gpu_object, tbo);
-    ret = ttm_bo_validate(bo, &qobj->placement, false, false);
+    ret = ttm_bo_validate(bo, &qobj->placement, &ctx);
     if (ret) {
       ttm_eu_backoff_reservation(ticket, head);
       return ret;
     }
   }
   return 0;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,28 +1,29 @@
 static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev, void *data, struct drm_file *file) {
+  struct ttm_operation_ctx ctx = {true, false};
   struct virtio_gpu_device *vgdev = dev->dev_private;
   struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
   struct drm_virtgpu_3d_transfer_from_host *args = data;
   struct drm_gem_object *gobj = NULL;
   struct virtio_gpu_object *qobj = NULL;
   struct virtio_gpu_fence *fence;
   int ret;
   u32 offset = args->offset;
   struct virtio_gpu_box box;
   if (vgdev->has_virgl_3d == false) return -ENOSYS;
   gobj = drm_gem_object_lookup(file, args->bo_handle);
   if (gobj == NULL) return -ENOENT;
   qobj = gem_to_virtio_gpu_obj(gobj);
   ret = virtio_gpu_object_reserve(qobj, false);
   if (ret) goto out;
-  ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, true, false);
+  ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, &ctx);
   if (unlikely(ret)) goto out_unres;
   convert_to_hw_box(&box, &args->box);
   virtio_gpu_cmd_transfer_from_host_3d(vgdev, qobj->hw_res_handle, vfpriv->ctx_id, offset, args->level, &box, &fence);
   reservation_object_add_excl_fence(qobj->tbo.resv, &fence->f);
   dma_fence_put(&fence->f);
 out_unres:
   virtio_gpu_object_unreserve(qobj);
 out:
   drm_gem_object_put_unlocked(gobj);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,31 +1,32 @@
 static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data, struct drm_file *file) {
+  struct ttm_operation_ctx ctx = {true, false};
   struct virtio_gpu_device *vgdev = dev->dev_private;
   struct virtio_gpu_fpriv *vfpriv = file->driver_priv;
   struct drm_virtgpu_3d_transfer_to_host *args = data;
   struct drm_gem_object *gobj = NULL;
   struct virtio_gpu_object *qobj = NULL;
   struct virtio_gpu_fence *fence;
   struct virtio_gpu_box box;
   int ret;
   u32 offset = args->offset;
   gobj = drm_gem_object_lookup(file, args->bo_handle);
   if (gobj == NULL) return -ENOENT;
   qobj = gem_to_virtio_gpu_obj(gobj);
   ret = virtio_gpu_object_reserve(qobj, false);
   if (ret) goto out;
-  ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, true, false);
+  ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, &ctx);
   if (unlikely(ret)) goto out_unres;
   convert_to_hw_box(&box, &args->box);
   if (!vgdev->has_virgl_3d) {
     virtio_gpu_cmd_transfer_to_host_2d(vgdev, qobj->hw_res_handle, offset, box.w, box.h, box.x, box.y, NULL);
   } else {
     virtio_gpu_cmd_transfer_to_host_3d(vgdev, qobj->hw_res_handle, vfpriv ? vfpriv->ctx_id : 0, offset, args->level, &box, &fence);
     reservation_object_add_excl_fence(qobj->tbo.resv, &fence->f);
     dma_fence_put(&fence->f);
   }
 out_unres:
   virtio_gpu_object_unreserve(qobj);
 out:
   drm_gem_object_put_unlocked(gobj);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,23 +1,24 @@
 void vmw_bo_pin_reserved(struct vmw_dma_buffer *vbo, bool pin) {
+  struct ttm_operation_ctx ctx = {false, true};
   struct ttm_place pl;
   struct ttm_placement placement;
   struct ttm_buffer_object *bo = &vbo->base;
   uint32_t old_mem_type = bo->mem.mem_type;
   int ret;
   lockdep_assert_held(&bo->resv->lock.base);
   if (pin) {
     if (vbo->pin_count++ > 0) return;
   } else {
     WARN_ON(vbo->pin_count <= 0);
     if (--vbo->pin_count > 0) return;
   }
   pl.fpfn = 0;
   pl.lpfn = 0;
   pl.flags = TTM_PL_FLAG_VRAM | VMW_PL_FLAG_GMR | VMW_PL_FLAG_MOB | TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED;
   if (pin) pl.flags |= TTM_PL_FLAG_NO_EVICT;
   memset(&placement, 0, sizeof(placement));
   placement.num_placement = 1;
   placement.placement = &pl;
-  ret = ttm_bo_validate(bo, &placement, false, true);
+  ret = ttm_bo_validate(bo, &placement, &ctx);
   BUG_ON(ret != 0 || bo->mem.mem_type != old_mem_type);
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,19 +1,20 @@
 int vmw_dmabuf_pin_in_placement(struct vmw_private *dev_priv, struct vmw_dma_buffer *buf, struct ttm_placement *placement, bool interruptible) {
+  struct ttm_operation_ctx ctx = {interruptible, false};
   struct ttm_buffer_object *bo = &buf->base;
   int ret;
   uint32_t new_flags;
   ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
   if (unlikely(ret != 0)) return ret;
   vmw_execbuf_release_pinned_bo(dev_priv);
   ret = ttm_bo_reserve(bo, interruptible, false, NULL);
   if (unlikely(ret != 0)) goto err;
   if (buf->pin_count > 0)
     ret = ttm_bo_mem_compat(placement, &bo->mem, &new_flags) == true ? 0 : -EINVAL;
   else
-    ret = ttm_bo_validate(bo, placement, interruptible, false);
+    ret = ttm_bo_validate(bo, placement, &ctx);
   if (!ret) vmw_bo_pin_reserved(buf, true);
   ttm_bo_unreserve(bo);
 err:
   ttm_write_unlock(&dev_priv->reservation_sem);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,35 +1,37 @@
 int vmw_dmabuf_pin_in_start_of_vram(struct vmw_private *dev_priv, struct vmw_dma_buffer *buf, bool interruptible) {
+  struct ttm_operation_ctx ctx = {false, false};
+  struct ttm_operation_ctx ctx = {interruptible, false};
   struct ttm_buffer_object *bo = &buf->base;
   struct ttm_placement placement;
   struct ttm_place place;
   int ret = 0;
   uint32_t new_flags;
   place = vmw_vram_placement.placement[0];
   place.lpfn = bo->num_pages;
   placement.num_placement = 1;
   placement.placement = &place;
   placement.num_busy_placement = 1;
   placement.busy_placement = &place;
   ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
   if (unlikely(ret != 0)) return ret;
   vmw_execbuf_release_pinned_bo(dev_priv);
   ret = ttm_bo_reserve(bo, interruptible, false, NULL);
   if (unlikely(ret != 0)) goto err_unlock;
   /*
    * Is this buffer already in vram but not at the start of it?
    * In that case, evict it first because TTM isn't good at handling
    * that situation.
    */
-  if (bo->mem.mem_type == TTM_PL_VRAM && bo->mem.start < bo->num_pages && bo->mem.start > 0 && buf->pin_count == 0) (void)ttm_bo_validate(bo, &vmw_sys_placement, false, false);
+  if (bo->mem.mem_type == TTM_PL_VRAM && bo->mem.start < bo->num_pages && bo->mem.start > 0 && buf->pin_count == 0) (void)ttm_bo_validate(bo, &vmw_sys_placement, &ctx);
   if (buf->pin_count > 0)
     ret = ttm_bo_mem_compat(&placement, &bo->mem, &new_flags) == true ? 0 : -EINVAL;
   else
-    ret = ttm_bo_validate(bo, &placement, interruptible, false);
+    ret = ttm_bo_validate(bo, &placement, &ctx);
   /* For some reason we didn't end up at the start of vram */
   WARN_ON(ret == 0 && bo->offset != 0);
   if (!ret) vmw_bo_pin_reserved(buf, true);
   ttm_bo_unreserve(bo);
 err_unlock:
   ttm_write_unlock(&dev_priv->reservation_sem);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,23 +1,24 @@
 int vmw_dmabuf_pin_in_vram_or_gmr(struct vmw_private *dev_priv, struct vmw_dma_buffer *buf, bool interruptible) {
+  struct ttm_operation_ctx ctx = {interruptible, false};
   struct ttm_buffer_object *bo = &buf->base;
   int ret;
   uint32_t new_flags;
   ret = ttm_write_lock(&dev_priv->reservation_sem, interruptible);
   if (unlikely(ret != 0)) return ret;
   vmw_execbuf_release_pinned_bo(dev_priv);
   ret = ttm_bo_reserve(bo, interruptible, false, NULL);
   if (unlikely(ret != 0)) goto err;
   if (buf->pin_count > 0) {
     ret = ttm_bo_mem_compat(&vmw_vram_gmr_placement, &bo->mem, &new_flags) == true ? 0 : -EINVAL;
     goto out_unreserve;
   }
-  ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible, false);
+  ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, &ctx);
   if (likely(ret == 0) || ret == -ERESTARTSYS) goto out_unreserve;
-  ret = ttm_bo_validate(bo, &vmw_vram_placement, interruptible, false);
+  ret = ttm_bo_validate(bo, &vmw_vram_placement, &ctx);
 out_unreserve:
   if (!ret) vmw_bo_pin_reserved(buf, true);
   ttm_bo_unreserve(bo);
 err:
   ttm_write_unlock(&dev_priv->reservation_sem);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,20 +1,21 @@
 int vmw_validate_single_buffer(struct vmw_private *dev_priv, struct ttm_buffer_object *bo, bool interruptible, bool validate_as_mob) {
+  struct ttm_operation_ctx ctx = {interruptible, false};
   struct vmw_dma_buffer *vbo = container_of(bo, struct vmw_dma_buffer, base);
   int ret;
   if (vbo->pin_count > 0) return 0;
-  if (validate_as_mob) return ttm_bo_validate(bo, &vmw_mob_placement, interruptible, false);
+  if (validate_as_mob) return ttm_bo_validate(bo, &vmw_mob_placement, &ctx);
   /**
    * Put BO in VRAM if there is space, otherwise as a GMR.
    * If there is no space in VRAM and GMR ids are all used up,
    * start evicting GMRs to make room. If the DMA buffer can't be
    * used as a GMR, this will return -ENOMEM.
    */
-  ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, interruptible, false);
+  ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, &ctx);
   if (likely(ret == 0 || ret == -ERESTARTSYS)) return ret;
   /**
    * If that failed, try VRAM again, this time evicting
    * previous contents.
    */
-  ret = ttm_bo_validate(bo, &vmw_vram_placement, interruptible, false);
+  ret = ttm_bo_validate(bo, &vmw_vram_placement, &ctx);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,26 +1,27 @@
 static int vmw_resource_check_buffer(struct vmw_resource *res, bool interruptible, struct ttm_validate_buffer *val_buf) {
+  struct ttm_operation_ctx ctx = {true, false};
   struct list_head val_list;
   bool backup_dirty = false;
   int ret;
   if (unlikely(res->backup == NULL)) {
     ret = vmw_resource_buf_alloc(res, interruptible);
     if (unlikely(ret != 0)) return ret;
   }
   INIT_LIST_HEAD(&val_list);
   val_buf->bo = ttm_bo_reference(&res->backup->base);
   val_buf->shared = false;
   list_add_tail(&val_buf->head, &val_list);
   ret = ttm_eu_reserve_buffers(NULL, &val_list, interruptible, NULL);
   if (unlikely(ret != 0)) goto out_no_reserve;
   if (res->func->needs_backup && list_empty(&res->mob_head)) return 0;
   backup_dirty = res->backup_dirty;
-  ret = ttm_bo_validate(&res->backup->base, res->func->backup_placement, true, false);
+  ret = ttm_bo_validate(&res->backup->base, res->func->backup_placement, &ctx);
   if (unlikely(ret != 0)) goto out_no_validate;
   return 0;
 out_no_validate:
   ttm_eu_backoff_reservation(NULL, &val_list);
 out_no_reserve:
   ttm_bo_unref(&val_buf->bo);
   if (backup_dirty) vmw_dmabuf_unreference(&res->backup);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }
--- initial
+++ final
@@ -1,34 +1,35 @@
 int vmw_resource_pin(struct vmw_resource *res, bool interruptible) {
+  struct ttm_operation_ctx ctx = {interruptible, false};
   struct vmw_private *dev_priv = res->dev_priv;
   int ret;
   ttm_write_lock(&dev_priv->reservation_sem, interruptible);
   mutex_lock(&dev_priv->cmdbuf_mutex);
   ret = vmw_resource_reserve(res, interruptible, false);
   if (ret) goto out_no_reserve;
   if (res->pin_count == 0) {
     struct vmw_dma_buffer *vbo = NULL;
     if (res->backup) {
       vbo = res->backup;
       ttm_bo_reserve(&vbo->base, interruptible, false, NULL);
       if (!vbo->pin_count) {
-        ret = ttm_bo_validate(&vbo->base, res->func->backup_placement, interruptible, false);
+        ret = ttm_bo_validate(&vbo->base, res->func->backup_placement, &ctx);
         if (ret) {
           ttm_bo_unreserve(&vbo->base);
           goto out_no_validate;
         }
       }
       /* Do we really need to pin the MOB as well? */
       vmw_bo_pin_reserved(vbo, true);
     }
     ret = vmw_resource_validate(res);
     if (vbo) ttm_bo_unreserve(&vbo->base);
     if (ret) goto out_no_validate;
   }
   res->pin_count++;
 out_no_validate:
   vmw_resource_unreserve(res, false, NULL, 0UL);
 out_no_reserve:
   mutex_unlock(&dev_priv->cmdbuf_mutex);
   ttm_write_unlock(&dev_priv->reservation_sem);
   return ret;
 }<sep>@@
identifier f;
expression e1,e2,x,y;
symbol ctx;
@@

f(...) {
++ struct ttm_operation_ctx ctx = { e1,e2 };
<+...
               ttm_bo_validate(x,y,
-                               e1,e2
+              			&ctx
			      )
...+> }