| .. | .. |
|---|
| 38 | 38 | { |
|---|
| 39 | 39 | } |
|---|
| 40 | 40 | |
|---|
| 41 | | -static int mock_bind_ppgtt(struct i915_vma *vma, |
|---|
| 42 | | - enum i915_cache_level cache_level, |
|---|
| 43 | | - u32 flags) |
|---|
| 41 | +static void mock_bind_ppgtt(struct i915_address_space *vm, |
|---|
| 42 | + struct i915_vm_pt_stash *stash, |
|---|
| 43 | + struct i915_vma *vma, |
|---|
| 44 | + enum i915_cache_level cache_level, |
|---|
| 45 | + u32 flags) |
|---|
| 44 | 46 | { |
|---|
| 45 | 47 | GEM_BUG_ON(flags & I915_VMA_GLOBAL_BIND); |
|---|
| 46 | | - vma->flags |= I915_VMA_LOCAL_BIND; |
|---|
| 47 | | - return 0; |
|---|
| 48 | + set_bit(I915_VMA_LOCAL_BIND_BIT, __i915_vma_flags(vma)); |
|---|
| 48 | 49 | } |
|---|
| 49 | 50 | |
|---|
| 50 | | -static void mock_unbind_ppgtt(struct i915_vma *vma) |
|---|
| 51 | +static void mock_unbind_ppgtt(struct i915_address_space *vm, |
|---|
| 52 | + struct i915_vma *vma) |
|---|
| 51 | 53 | { |
|---|
| 52 | 54 | } |
|---|
| 53 | 55 | |
|---|
| .. | .. |
|---|
| 55 | 57 | { |
|---|
| 56 | 58 | } |
|---|
| 57 | 59 | |
|---|
| 58 | | -struct i915_hw_ppgtt * |
|---|
| 59 | | -mock_ppgtt(struct drm_i915_private *i915, |
|---|
| 60 | | - const char *name) |
|---|
| 60 | +static void mock_clear_range(struct i915_address_space *vm, |
|---|
| 61 | + u64 start, u64 length) |
|---|
| 61 | 62 | { |
|---|
| 62 | | - struct i915_hw_ppgtt *ppgtt; |
|---|
| 63 | +} |
|---|
| 64 | + |
|---|
| 65 | +struct i915_ppgtt *mock_ppgtt(struct drm_i915_private *i915, const char *name) |
|---|
| 66 | +{ |
|---|
| 67 | + struct i915_ppgtt *ppgtt; |
|---|
| 63 | 68 | |
|---|
| 64 | 69 | ppgtt = kzalloc(sizeof(*ppgtt), GFP_KERNEL); |
|---|
| 65 | 70 | if (!ppgtt) |
|---|
| 66 | 71 | return NULL; |
|---|
| 67 | 72 | |
|---|
| 68 | | - kref_init(&ppgtt->ref); |
|---|
| 73 | + ppgtt->vm.gt = &i915->gt; |
|---|
| 69 | 74 | ppgtt->vm.i915 = i915; |
|---|
| 70 | 75 | ppgtt->vm.total = round_down(U64_MAX, PAGE_SIZE); |
|---|
| 71 | 76 | ppgtt->vm.file = ERR_PTR(-ENODEV); |
|---|
| 77 | + ppgtt->vm.dma = &i915->drm.pdev->dev; |
|---|
| 72 | 78 | |
|---|
| 73 | | - i915_address_space_init(&ppgtt->vm, i915); |
|---|
| 79 | + i915_address_space_init(&ppgtt->vm, VM_CLASS_PPGTT); |
|---|
| 74 | 80 | |
|---|
| 75 | | - ppgtt->vm.clear_range = nop_clear_range; |
|---|
| 81 | + ppgtt->vm.alloc_pt_dma = alloc_pt_dma; |
|---|
| 82 | + |
|---|
| 83 | + ppgtt->vm.clear_range = mock_clear_range; |
|---|
| 76 | 84 | ppgtt->vm.insert_page = mock_insert_page; |
|---|
| 77 | 85 | ppgtt->vm.insert_entries = mock_insert_entries; |
|---|
| 78 | 86 | ppgtt->vm.cleanup = mock_cleanup; |
|---|
| .. | .. |
|---|
| 85 | 93 | return ppgtt; |
|---|
| 86 | 94 | } |
|---|
| 87 | 95 | |
|---|
| 88 | | -static int mock_bind_ggtt(struct i915_vma *vma, |
|---|
| 89 | | - enum i915_cache_level cache_level, |
|---|
| 90 | | - u32 flags) |
|---|
| 91 | | -{ |
|---|
| 92 | | - vma->flags |= I915_VMA_GLOBAL_BIND | I915_VMA_LOCAL_BIND; |
|---|
| 93 | | - return 0; |
|---|
| 94 | | -} |
|---|
| 95 | | - |
|---|
| 96 | | -static void mock_unbind_ggtt(struct i915_vma *vma) |
|---|
| 96 | +static void mock_bind_ggtt(struct i915_address_space *vm, |
|---|
| 97 | + struct i915_vm_pt_stash *stash, |
|---|
| 98 | + struct i915_vma *vma, |
|---|
| 99 | + enum i915_cache_level cache_level, |
|---|
| 100 | + u32 flags) |
|---|
| 97 | 101 | { |
|---|
| 98 | 102 | } |
|---|
| 99 | 103 | |
|---|
| 100 | | -void mock_init_ggtt(struct drm_i915_private *i915) |
|---|
| 104 | +static void mock_unbind_ggtt(struct i915_address_space *vm, |
|---|
| 105 | + struct i915_vma *vma) |
|---|
| 101 | 106 | { |
|---|
| 102 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
|---|
| 107 | +} |
|---|
| 103 | 108 | |
|---|
| 109 | +void mock_init_ggtt(struct drm_i915_private *i915, struct i915_ggtt *ggtt) |
|---|
| 110 | +{ |
|---|
| 111 | + memset(ggtt, 0, sizeof(*ggtt)); |
|---|
| 112 | + |
|---|
| 113 | + ggtt->vm.gt = &i915->gt; |
|---|
| 104 | 114 | ggtt->vm.i915 = i915; |
|---|
| 115 | + ggtt->vm.is_ggtt = true; |
|---|
| 105 | 116 | |
|---|
| 106 | 117 | ggtt->gmadr = (struct resource) DEFINE_RES_MEM(0, 2048 * PAGE_SIZE); |
|---|
| 107 | 118 | ggtt->mappable_end = resource_size(&ggtt->gmadr); |
|---|
| 108 | 119 | ggtt->vm.total = 4096 * PAGE_SIZE; |
|---|
| 109 | 120 | |
|---|
| 110 | | - ggtt->vm.clear_range = nop_clear_range; |
|---|
| 121 | + ggtt->vm.alloc_pt_dma = alloc_pt_dma; |
|---|
| 122 | + |
|---|
| 123 | + ggtt->vm.clear_range = mock_clear_range; |
|---|
| 111 | 124 | ggtt->vm.insert_page = mock_insert_page; |
|---|
| 112 | 125 | ggtt->vm.insert_entries = mock_insert_entries; |
|---|
| 113 | 126 | ggtt->vm.cleanup = mock_cleanup; |
|---|
| .. | .. |
|---|
| 117 | 130 | ggtt->vm.vma_ops.set_pages = ggtt_set_pages; |
|---|
| 118 | 131 | ggtt->vm.vma_ops.clear_pages = clear_pages; |
|---|
| 119 | 132 | |
|---|
| 120 | | - i915_address_space_init(&ggtt->vm, i915); |
|---|
| 133 | + i915_address_space_init(&ggtt->vm, VM_CLASS_GGTT); |
|---|
| 134 | + i915->gt.ggtt = ggtt; |
|---|
| 121 | 135 | } |
|---|
| 122 | 136 | |
|---|
| 123 | | -void mock_fini_ggtt(struct drm_i915_private *i915) |
|---|
| 137 | +void mock_fini_ggtt(struct i915_ggtt *ggtt) |
|---|
| 124 | 138 | { |
|---|
| 125 | | - struct i915_ggtt *ggtt = &i915->ggtt; |
|---|
| 126 | | - |
|---|
| 127 | 139 | i915_address_space_fini(&ggtt->vm); |
|---|
| 128 | 140 | } |
|---|