diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 87 |
1 files changed, 66 insertions, 21 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index c4f5114aee7c..87e43e0733bf 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |||
@@ -39,6 +39,9 @@ static uint32_t vram_ne_placement_flags = TTM_PL_FLAG_VRAM | | |||
39 | static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM | | 39 | static uint32_t sys_placement_flags = TTM_PL_FLAG_SYSTEM | |
40 | TTM_PL_FLAG_CACHED; | 40 | TTM_PL_FLAG_CACHED; |
41 | 41 | ||
42 | static uint32_t gmr_placement_flags = VMW_PL_FLAG_GMR | | ||
43 | TTM_PL_FLAG_CACHED; | ||
44 | |||
42 | struct ttm_placement vmw_vram_placement = { | 45 | struct ttm_placement vmw_vram_placement = { |
43 | .fpfn = 0, | 46 | .fpfn = 0, |
44 | .lpfn = 0, | 47 | .lpfn = 0, |
@@ -48,6 +51,20 @@ struct ttm_placement vmw_vram_placement = { | |||
48 | .busy_placement = &vram_placement_flags | 51 | .busy_placement = &vram_placement_flags |
49 | }; | 52 | }; |
50 | 53 | ||
54 | static uint32_t vram_gmr_placement_flags[] = { | ||
55 | TTM_PL_FLAG_VRAM | TTM_PL_FLAG_CACHED, | ||
56 | VMW_PL_FLAG_GMR | TTM_PL_FLAG_CACHED | ||
57 | }; | ||
58 | |||
59 | struct ttm_placement vmw_vram_gmr_placement = { | ||
60 | .fpfn = 0, | ||
61 | .lpfn = 0, | ||
62 | .num_placement = 2, | ||
63 | .placement = vram_gmr_placement_flags, | ||
64 | .num_busy_placement = 1, | ||
65 | .busy_placement = &gmr_placement_flags | ||
66 | }; | ||
67 | |||
51 | struct ttm_placement vmw_vram_sys_placement = { | 68 | struct ttm_placement vmw_vram_sys_placement = { |
52 | .fpfn = 0, | 69 | .fpfn = 0, |
53 | .lpfn = 0, | 70 | .lpfn = 0, |
@@ -77,27 +94,53 @@ struct ttm_placement vmw_sys_placement = { | |||
77 | 94 | ||
78 | struct vmw_ttm_backend { | 95 | struct vmw_ttm_backend { |
79 | struct ttm_backend backend; | 96 | struct ttm_backend backend; |
97 | struct page **pages; | ||
98 | unsigned long num_pages; | ||
99 | struct vmw_private *dev_priv; | ||
100 | int gmr_id; | ||
80 | }; | 101 | }; |
81 | 102 | ||
82 | static int vmw_ttm_populate(struct ttm_backend *backend, | 103 | static int vmw_ttm_populate(struct ttm_backend *backend, |
83 | unsigned long num_pages, struct page **pages, | 104 | unsigned long num_pages, struct page **pages, |
84 | struct page *dummy_read_page) | 105 | struct page *dummy_read_page, |
106 | dma_addr_t *dma_addrs) | ||
85 | { | 107 | { |
108 | struct vmw_ttm_backend *vmw_be = | ||
109 | container_of(backend, struct vmw_ttm_backend, backend); | ||
110 | |||
111 | vmw_be->pages = pages; | ||
112 | vmw_be->num_pages = num_pages; | ||
113 | |||
86 | return 0; | 114 | return 0; |
87 | } | 115 | } |
88 | 116 | ||
89 | static int vmw_ttm_bind(struct ttm_backend *backend, struct ttm_mem_reg *bo_mem) | 117 | static int vmw_ttm_bind(struct ttm_backend *backend, struct ttm_mem_reg *bo_mem) |
90 | { | 118 | { |
91 | return 0; | 119 | struct vmw_ttm_backend *vmw_be = |
120 | container_of(backend, struct vmw_ttm_backend, backend); | ||
121 | |||
122 | vmw_be->gmr_id = bo_mem->start; | ||
123 | |||
124 | return vmw_gmr_bind(vmw_be->dev_priv, vmw_be->pages, | ||
125 | vmw_be->num_pages, vmw_be->gmr_id); | ||
92 | } | 126 | } |
93 | 127 | ||
94 | static int vmw_ttm_unbind(struct ttm_backend *backend) | 128 | static int vmw_ttm_unbind(struct ttm_backend *backend) |
95 | { | 129 | { |
130 | struct vmw_ttm_backend *vmw_be = | ||
131 | container_of(backend, struct vmw_ttm_backend, backend); | ||
132 | |||
133 | vmw_gmr_unbind(vmw_be->dev_priv, vmw_be->gmr_id); | ||
96 | return 0; | 134 | return 0; |
97 | } | 135 | } |
98 | 136 | ||
99 | static void vmw_ttm_clear(struct ttm_backend *backend) | 137 | static void vmw_ttm_clear(struct ttm_backend *backend) |
100 | { | 138 | { |
139 | struct vmw_ttm_backend *vmw_be = | ||
140 | container_of(backend, struct vmw_ttm_backend, backend); | ||
141 | |||
142 | vmw_be->pages = NULL; | ||
143 | vmw_be->num_pages = 0; | ||
101 | } | 144 | } |
102 | 145 | ||
103 | static void vmw_ttm_destroy(struct ttm_backend *backend) | 146 | static void vmw_ttm_destroy(struct ttm_backend *backend) |
@@ -125,6 +168,7 @@ struct ttm_backend *vmw_ttm_backend_init(struct ttm_bo_device *bdev) | |||
125 | return NULL; | 168 | return NULL; |
126 | 169 | ||
127 | vmw_be->backend.func = &vmw_ttm_func; | 170 | vmw_be->backend.func = &vmw_ttm_func; |
171 | vmw_be->dev_priv = container_of(bdev, struct vmw_private, bdev); | ||
128 | 172 | ||
129 | return &vmw_be->backend; | 173 | return &vmw_be->backend; |
130 | } | 174 | } |
@@ -142,15 +186,28 @@ int vmw_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, | |||
142 | /* System memory */ | 186 | /* System memory */ |
143 | 187 | ||
144 | man->flags = TTM_MEMTYPE_FLAG_MAPPABLE; | 188 | man->flags = TTM_MEMTYPE_FLAG_MAPPABLE; |
145 | man->available_caching = TTM_PL_MASK_CACHING; | 189 | man->available_caching = TTM_PL_FLAG_CACHED; |
146 | man->default_caching = TTM_PL_FLAG_CACHED; | 190 | man->default_caching = TTM_PL_FLAG_CACHED; |
147 | break; | 191 | break; |
148 | case TTM_PL_VRAM: | 192 | case TTM_PL_VRAM: |
149 | /* "On-card" video ram */ | 193 | /* "On-card" video ram */ |
194 | man->func = &ttm_bo_manager_func; | ||
150 | man->gpu_offset = 0; | 195 | man->gpu_offset = 0; |
151 | man->flags = TTM_MEMTYPE_FLAG_FIXED | TTM_MEMTYPE_FLAG_MAPPABLE; | 196 | man->flags = TTM_MEMTYPE_FLAG_FIXED | TTM_MEMTYPE_FLAG_MAPPABLE; |
152 | man->available_caching = TTM_PL_MASK_CACHING; | 197 | man->available_caching = TTM_PL_FLAG_CACHED; |
153 | man->default_caching = TTM_PL_FLAG_WC; | 198 | man->default_caching = TTM_PL_FLAG_CACHED; |
199 | break; | ||
200 | case VMW_PL_GMR: | ||
201 | /* | ||
202 | * "Guest Memory Regions" is an aperture like feature with | ||
203 | * one slot per bo. There is an upper limit of the number of | ||
204 | * slots as well as the bo size. | ||
205 | */ | ||
206 | man->func = &vmw_gmrid_manager_func; | ||
207 | man->gpu_offset = 0; | ||
208 | man->flags = TTM_MEMTYPE_FLAG_CMA | TTM_MEMTYPE_FLAG_MAPPABLE; | ||
209 | man->available_caching = TTM_PL_FLAG_CACHED; | ||
210 | man->default_caching = TTM_PL_FLAG_CACHED; | ||
154 | break; | 211 | break; |
155 | default: | 212 | default: |
156 | DRM_ERROR("Unsupported memory type %u\n", (unsigned)type); | 213 | DRM_ERROR("Unsupported memory type %u\n", (unsigned)type); |
@@ -174,18 +231,6 @@ static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp) | |||
174 | return 0; | 231 | return 0; |
175 | } | 232 | } |
176 | 233 | ||
177 | static void vmw_move_notify(struct ttm_buffer_object *bo, | ||
178 | struct ttm_mem_reg *new_mem) | ||
179 | { | ||
180 | if (new_mem->mem_type != TTM_PL_SYSTEM) | ||
181 | vmw_dmabuf_gmr_unbind(bo); | ||
182 | } | ||
183 | |||
184 | static void vmw_swap_notify(struct ttm_buffer_object *bo) | ||
185 | { | ||
186 | vmw_dmabuf_gmr_unbind(bo); | ||
187 | } | ||
188 | |||
189 | static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) | 234 | static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) |
190 | { | 235 | { |
191 | struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; | 236 | struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; |
@@ -200,10 +245,10 @@ static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg | |||
200 | return -EINVAL; | 245 | return -EINVAL; |
201 | switch (mem->mem_type) { | 246 | switch (mem->mem_type) { |
202 | case TTM_PL_SYSTEM: | 247 | case TTM_PL_SYSTEM: |
203 | /* System memory */ | 248 | case VMW_PL_GMR: |
204 | return 0; | 249 | return 0; |
205 | case TTM_PL_VRAM: | 250 | case TTM_PL_VRAM: |
206 | mem->bus.offset = mem->mm_node->start << PAGE_SHIFT; | 251 | mem->bus.offset = mem->start << PAGE_SHIFT; |
207 | mem->bus.base = dev_priv->vram_start; | 252 | mem->bus.base = dev_priv->vram_start; |
208 | mem->bus.is_iomem = true; | 253 | mem->bus.is_iomem = true; |
209 | break; | 254 | break; |
@@ -276,8 +321,8 @@ struct ttm_bo_driver vmw_bo_driver = { | |||
276 | .sync_obj_flush = vmw_sync_obj_flush, | 321 | .sync_obj_flush = vmw_sync_obj_flush, |
277 | .sync_obj_unref = vmw_sync_obj_unref, | 322 | .sync_obj_unref = vmw_sync_obj_unref, |
278 | .sync_obj_ref = vmw_sync_obj_ref, | 323 | .sync_obj_ref = vmw_sync_obj_ref, |
279 | .move_notify = vmw_move_notify, | 324 | .move_notify = NULL, |
280 | .swap_notify = vmw_swap_notify, | 325 | .swap_notify = NULL, |
281 | .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, | 326 | .fault_reserve_notify = &vmw_ttm_fault_reserve_notify, |
282 | .io_mem_reserve = &vmw_ttm_io_mem_reserve, | 327 | .io_mem_reserve = &vmw_ttm_io_mem_reserve, |
283 | .io_mem_free = &vmw_ttm_io_mem_free, | 328 | .io_mem_free = &vmw_ttm_io_mem_free, |