diff options
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 183 |
1 files changed, 85 insertions, 98 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index 6327cfc36805..cff2bf9db9d2 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |||
@@ -30,66 +30,101 @@ | |||
30 | #include <drm/ttm/ttm_placement.h> | 30 | #include <drm/ttm/ttm_placement.h> |
31 | #include <drm/ttm/ttm_page_alloc.h> | 31 | #include <drm/ttm/ttm_page_alloc.h> |
32 | 32 | ||
33 | static uint32_t vram_placement_flags = TTM_PL_FLAG_VRAM | | 33 | static struct ttm_place vram_placement_flags = { |
34 | TTM_PL_FLAG_CACHED; | 34 | .fpfn = 0, |
35 | 35 | .lpfn = 0, | |
36 | static uint32_t vram_ne_placement_flags = TTM_PL_FLAG_VRAM | | 36 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED |
37 | TTM_PL_FLAG_CACHED | | 37 | }; |
38 | TTM_PL_FLAG_NO_EVICT; | ||
39 | 38 | ||
40 | static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM | | 39 | static struct ttm_place vram_ne_placement_flags = { |
41 | TTM_PL_FLAG_CACHED; | 40 | .fpfn = 0, |
41 | .lpfn = 0, | ||
42 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT | ||
43 | }; | ||
42 | 44 | ||
43 | static uint32_t sys_ne_placement_flags = TTM_PL_FLAG_SYSTEM | | 45 | static struct ttm_place sys_placement_flags = { |
44 | TTM_PL_FLAG_CACHED | | 46 | .fpfn = 0, |
45 | TTM_PL_FLAG_NO_EVICT; | 47 | .lpfn = 0, |
48 | .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED | ||
49 | }; | ||
46 | 50 | ||
47 | static uint32_t gmr_placement_flags = VMW_PL_FLAG_GMR | | 51 | static struct ttm_place sys_ne_placement_flags = { |
48 | TTM_PL_FLAG_CACHED; | 52 | .fpfn = 0, |
53 | .lpfn = 0, | ||
54 | .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT | ||
55 | }; | ||
49 | 56 | ||
50 | static uint32_t gmr_ne_placement_flags = VMW_PL_FLAG_GMR | | 57 | static struct ttm_place gmr_placement_flags = { |
51 | TTM_PL_FLAG_CACHED | | 58 | .fpfn = 0, |
52 | TTM_PL_FLAG_NO_EVICT; | 59 | .lpfn = 0, |
60 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | ||
61 | }; | ||
53 | 62 | ||
54 | static uint32_t mob_placement_flags = VMW_PL_FLAG_MOB | | 63 | static struct ttm_place gmr_ne_placement_flags = { |
55 | TTM_PL_FLAG_CACHED; | 64 | .fpfn = 0, |
65 | .lpfn = 0, | ||
66 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT | ||
67 | }; | ||
56 | 68 | ||
57 | struct ttm_placement vmw_vram_placement = { | 69 | static struct ttm_place mob_placement_flags = { |
58 | .fpfn = 0, | 70 | .fpfn = 0, |
59 | .lpfn = 0, | 71 | .lpfn = 0, |
72 | .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED | ||
73 | }; | ||
74 | |||
75 | struct ttm_placement vmw_vram_placement = { | ||
60 | .num_placement = 1, | 76 | .num_placement = 1, |
61 | .placement = &vram_placement_flags, | 77 | .placement = &vram_placement_flags, |
62 | .num_busy_placement = 1, | 78 | .num_busy_placement = 1, |
63 | .busy_placement = &vram_placement_flags | 79 | .busy_placement = &vram_placement_flags |
64 | }; | 80 | }; |
65 | 81 | ||
66 | static uint32_t vram_gmr_placement_flags[] = { | 82 | static struct ttm_place vram_gmr_placement_flags[] = { |
67 | TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED, | 83 | { |
68 | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | 84 | .fpfn = 0, |
85 | .lpfn = 0, | ||
86 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | ||
87 | }, { | ||
88 | .fpfn = 0, | ||
89 | .lpfn = 0, | ||
90 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | ||
91 | } | ||
69 | }; | 92 | }; |
70 | 93 | ||
71 | static uint32_t gmr_vram_placement_flags[] = { | 94 | static struct ttm_place gmr_vram_placement_flags[] = { |
72 | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED, | 95 | { |
73 | TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | 96 | .fpfn = 0, |
97 | .lpfn = 0, | ||
98 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | ||
99 | }, { | ||
100 | .fpfn = 0, | ||
101 | .lpfn = 0, | ||
102 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | ||
103 | } | ||
74 | }; | 104 | }; |
75 | 105 | ||
76 | struct ttm_placement vmw_vram_gmr_placement = { | 106 | struct ttm_placement vmw_vram_gmr_placement = { |
77 | .fpfn = 0, | ||
78 | .lpfn = 0, | ||
79 | .num_placement = 2, | 107 | .num_placement = 2, |
80 | .placement = vram_gmr_placement_flags, | 108 | .placement = vram_gmr_placement_flags, |
81 | .num_busy_placement = 1, | 109 | .num_busy_placement = 1, |
82 | .busy_placement = &gmr_placement_flags | 110 | .busy_placement = &gmr_placement_flags |
83 | }; | 111 | }; |
84 | 112 | ||
85 | static uint32_t vram_gmr_ne_placement_flags[] = { | 113 | static struct ttm_place vram_gmr_ne_placement_flags[] = { |
86 | TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT, | 114 | { |
87 | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | TTM_PL_FLAG_NO_EVICT | 115 | .fpfn = 0, |
116 | .lpfn = 0, | ||
117 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | | ||
118 | TTM_PL_FLAG_NO_EVICT | ||
119 | }, { | ||
120 | .fpfn = 0, | ||
121 | .lpfn = 0, | ||
122 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | | ||
123 | TTM_PL_FLAG_NO_EVICT | ||
124 | } | ||
88 | }; | 125 | }; |
89 | 126 | ||
90 | struct ttm_placement vmw_vram_gmr_ne_placement = { | 127 | struct ttm_placement vmw_vram_gmr_ne_placement = { |
91 | .fpfn = 0, | ||
92 | .lpfn = 0, | ||
93 | .num_placement = 2, | 128 | .num_placement = 2, |
94 | .placement = vram_gmr_ne_placement_flags, | 129 | .placement = vram_gmr_ne_placement_flags, |
95 | .num_busy_placement = 1, | 130 | .num_busy_placement = 1, |
@@ -97,8 +132,6 @@ struct ttm_placement vmw_vram_gmr_ne_placement = { | |||
97 | }; | 132 | }; |
98 | 133 | ||
99 | struct ttm_placement vmw_vram_sys_placement = { | 134 | struct ttm_placement vmw_vram_sys_placement = { |
100 | .fpfn = 0, | ||
101 | .lpfn = 0, | ||
102 | .num_placement = 1, | 135 | .num_placement = 1, |
103 | .placement = &vram_placement_flags, | 136 | .placement = &vram_placement_flags, |
104 | .num_busy_placement = 1, | 137 | .num_busy_placement = 1, |
@@ -106,8 +139,6 @@ struct ttm_placement vmw_vram_sys_placement = { | |||
106 | }; | 139 | }; |
107 | 140 | ||
108 | struct ttm_placement vmw_vram_ne_placement = { | 141 | struct ttm_placement vmw_vram_ne_placement = { |
109 | .fpfn = 0, | ||
110 | .lpfn = 0, | ||
111 | .num_placement = 1, | 142 | .num_placement = 1, |
112 | .placement = &vram_ne_placement_flags, | 143 | .placement = &vram_ne_placement_flags, |
113 | .num_busy_placement = 1, | 144 | .num_busy_placement = 1, |
@@ -115,8 +146,6 @@ struct ttm_placement vmw_vram_ne_placement = { | |||
115 | }; | 146 | }; |
116 | 147 | ||
117 | struct ttm_placement vmw_sys_placement = { | 148 | struct ttm_placement vmw_sys_placement = { |
118 | .fpfn = 0, | ||
119 | .lpfn = 0, | ||
120 | .num_placement = 1, | 149 | .num_placement = 1, |
121 | .placement = &sys_placement_flags, | 150 | .placement = &sys_placement_flags, |
122 | .num_busy_placement = 1, | 151 | .num_busy_placement = 1, |
@@ -124,24 +153,33 @@ struct ttm_placement vmw_sys_placement = { | |||
124 | }; | 153 | }; |
125 | 154 | ||
126 | struct ttm_placement vmw_sys_ne_placement = { | 155 | struct ttm_placement vmw_sys_ne_placement = { |
127 | .fpfn = 0, | ||
128 | .lpfn = 0, | ||
129 | .num_placement = 1, | 156 | .num_placement = 1, |
130 | .placement = &sys_ne_placement_flags, | 157 | .placement = &sys_ne_placement_flags, |
131 | .num_busy_placement = 1, | 158 | .num_busy_placement = 1, |
132 | .busy_placement = &sys_ne_placement_flags | 159 | .busy_placement = &sys_ne_placement_flags |
133 | }; | 160 | }; |
134 | 161 | ||
135 | static uint32_t evictable_placement_flags[] = { | 162 | static struct ttm_place evictable_placement_flags[] = { |
136 | TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED, | 163 | { |
137 | TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED, | 164 | .fpfn = 0, |
138 | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED, | 165 | .lpfn = 0, |
139 | VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED | 166 | .flags = TTM_PL_FLAG_SYSTEM | TTM_PL_FLAG_CACHED |
167 | }, { | ||
168 | .fpfn = 0, | ||
169 | .lpfn = 0, | ||
170 | .flags = TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED | ||
171 | }, { | ||
172 | .fpfn = 0, | ||
173 | .lpfn = 0, | ||
174 | .flags = VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | ||
175 | }, { | ||
176 | .fpfn = 0, | ||
177 | .lpfn = 0, | ||
178 | .flags = VMW_PL_FLAG_MOB | TTM_PL_FLAG_CACHED | ||
179 | } | ||
140 | }; | 180 | }; |
141 | 181 | ||
142 | struct ttm_placement vmw_evictable_placement = { | 182 | struct ttm_placement vmw_evictable_placement = { |
143 | .fpfn = 0, | ||
144 | .lpfn = 0, | ||
145 | .num_placement = 4, | 183 | .num_placement = 4, |
146 | .placement = evictable_placement_flags, | 184 | .placement = evictable_placement_flags, |
147 | .num_busy_placement = 1, | 185 | .num_busy_placement = 1, |
@@ -149,8 +187,6 @@ struct ttm_placement vmw_evictable_placement = { | |||
149 | }; | 187 | }; |
150 | 188 | ||
151 | struct ttm_placement vmw_srf_placement = { | 189 | struct ttm_placement vmw_srf_placement = { |
152 | .fpfn = 0, | ||
153 | .lpfn = 0, | ||
154 | .num_placement = 1, | 190 | .num_placement = 1, |
155 | .num_busy_placement = 2, | 191 | .num_busy_placement = 2, |
156 | .placement = &gmr_placement_flags, | 192 | .placement = &gmr_placement_flags, |
@@ -158,8 +194,6 @@ struct ttm_placement vmw_srf_placement = { | |||
158 | }; | 194 | }; |
159 | 195 | ||
160 | struct ttm_placement vmw_mob_placement = { | 196 | struct ttm_placement vmw_mob_placement = { |
161 | .fpfn = 0, | ||
162 | .lpfn = 0, | ||
163 | .num_placement = 1, | 197 | .num_placement = 1, |
164 | .num_busy_placement = 1, | 198 | .num_busy_placement = 1, |
165 | .placement = &mob_placement_flags, | 199 | .placement = &mob_placement_flags, |
@@ -768,44 +802,6 @@ static int vmw_ttm_fault_reserve_notify(struct ttm_buffer_object *bo) | |||
768 | } | 802 | } |
769 | 803 | ||
770 | /** | 804 | /** |
771 | * FIXME: We're using the old vmware polling method to sync. | ||
772 | * Do this with fences instead. | ||
773 | */ | ||
774 | |||
775 | static void *vmw_sync_obj_ref(void *sync_obj) | ||
776 | { | ||
777 | |||
778 | return (void *) | ||
779 | vmw_fence_obj_reference((struct vmw_fence_obj *) sync_obj); | ||
780 | } | ||
781 | |||
782 | static void vmw_sync_obj_unref(void **sync_obj) | ||
783 | { | ||
784 | vmw_fence_obj_unreference((struct vmw_fence_obj **) sync_obj); | ||
785 | } | ||
786 | |||
787 | static int vmw_sync_obj_flush(void *sync_obj) | ||
788 | { | ||
789 | vmw_fence_obj_flush((struct vmw_fence_obj *) sync_obj); | ||
790 | return 0; | ||
791 | } | ||
792 | |||
793 | static bool vmw_sync_obj_signaled(void *sync_obj) | ||
794 | { | ||
795 | return vmw_fence_obj_signaled((struct vmw_fence_obj *) sync_obj, | ||
796 | DRM_VMW_FENCE_FLAG_EXEC); | ||
797 | |||
798 | } | ||
799 | |||
800 | static int vmw_sync_obj_wait(void *sync_obj, bool lazy, bool interruptible) | ||
801 | { | ||
802 | return vmw_fence_obj_wait((struct vmw_fence_obj *) sync_obj, | ||
803 | DRM_VMW_FENCE_FLAG_EXEC, | ||
804 | lazy, interruptible, | ||
805 | VMW_FENCE_WAIT_TIMEOUT); | ||
806 | } | ||
807 | |||
808 | /** | ||
809 | * vmw_move_notify - TTM move_notify_callback | 805 | * vmw_move_notify - TTM move_notify_callback |
810 | * | 806 | * |
811 | * @bo: The TTM buffer object about to move. | 807 | * @bo: The TTM buffer object about to move. |
@@ -829,11 +825,7 @@ static void vmw_move_notify(struct ttm_buffer_object *bo, | |||
829 | */ | 825 | */ |
830 | static void vmw_swap_notify(struct ttm_buffer_object *bo) | 826 | static void vmw_swap_notify(struct ttm_buffer_object *bo) |
831 | { | 827 | { |
832 | struct ttm_bo_device *bdev = bo->bdev; | ||
833 | |||
834 | spin_lock(&bdev->fence_lock); | ||
835 | ttm_bo_wait(bo, false, false, false); | 828 | ttm_bo_wait(bo, false, false, false); |
836 | spin_unlock(&bdev->fence_lock); | ||
837 | } | 829 | } |
838 | 830 | ||
839 | 831 | ||
@@ -846,11 +838,6 @@ struct ttm_bo_driver vmw_bo_driver = { | |||
846 | .evict_flags = vmw_evict_flags, | 838 | .evict_flags = vmw_evict_flags, |
847 | .move = NULL, | 839 | .move = NULL, |
848 | .verify_access = vmw_verify_access, | 840 | .verify_access = vmw_verify_access, |
849 | .sync_obj_signaled = vmw_sync_obj_signaled, | ||
850 | .sync_obj_wait = vmw_sync_obj_wait, | ||
851 | .sync_obj_flush = vmw_sync_obj_flush, | ||
852 | .sync_obj_unref = vmw_sync_obj_unref, | ||
853 | .sync_obj_ref = vmw_sync_obj_ref, | ||
854 | .move_notify = vmw_move_notify, | 841 | .move_notify = vmw_move_notify, |
855 | .swap_notify = vmw_swap_notify, | 842 | .swap_notify = vmw_swap_notify, |
856 | .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, | 843 | .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, |