diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_gem.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_gem.c | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 9c4f895a026e..e927f998f76f 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c | |||
@@ -38,22 +38,21 @@ int radeon_gem_object_init(struct drm_gem_object *obj) | |||
38 | 38 | ||
39 | void radeon_gem_object_free(struct drm_gem_object *gobj) | 39 | void radeon_gem_object_free(struct drm_gem_object *gobj) |
40 | { | 40 | { |
41 | struct radeon_object *robj = gobj->driver_private; | 41 | struct radeon_bo *robj = gobj->driver_private; |
42 | 42 | ||
43 | gobj->driver_private = NULL; | 43 | gobj->driver_private = NULL; |
44 | if (robj) { | 44 | if (robj) { |
45 | radeon_object_unref(&robj); | 45 | radeon_bo_unref(&robj); |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | int radeon_gem_object_create(struct radeon_device *rdev, int size, | 49 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
50 | int alignment, int initial_domain, | 50 | int alignment, int initial_domain, |
51 | bool discardable, bool kernel, | 51 | bool discardable, bool kernel, |
52 | bool interruptible, | 52 | struct drm_gem_object **obj) |
53 | struct drm_gem_object **obj) | ||
54 | { | 53 | { |
55 | struct drm_gem_object *gobj; | 54 | struct drm_gem_object *gobj; |
56 | struct radeon_object *robj; | 55 | struct radeon_bo *robj; |
57 | int r; | 56 | int r; |
58 | 57 | ||
59 | *obj = NULL; | 58 | *obj = NULL; |
@@ -65,8 +64,7 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, | |||
65 | if (alignment < PAGE_SIZE) { | 64 | if (alignment < PAGE_SIZE) { |
66 | alignment = PAGE_SIZE; | 65 | alignment = PAGE_SIZE; |
67 | } | 66 | } |
68 | r = radeon_object_create(rdev, gobj, size, kernel, initial_domain, | 67 | r = radeon_bo_create(rdev, gobj, size, kernel, initial_domain, &robj); |
69 | interruptible, &robj); | ||
70 | if (r) { | 68 | if (r) { |
71 | DRM_ERROR("Failed to allocate GEM object (%d, %d, %u)\n", | 69 | DRM_ERROR("Failed to allocate GEM object (%d, %d, %u)\n", |
72 | size, initial_domain, alignment); | 70 | size, initial_domain, alignment); |
@@ -83,33 +81,33 @@ int radeon_gem_object_create(struct radeon_device *rdev, int size, | |||
83 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, | 81 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, |
84 | uint64_t *gpu_addr) | 82 | uint64_t *gpu_addr) |
85 | { | 83 | { |
86 | struct radeon_object *robj = obj->driver_private; | 84 | struct radeon_bo *robj = obj->driver_private; |
87 | uint32_t flags; | 85 | int r; |
88 | 86 | ||
89 | switch (pin_domain) { | 87 | r = radeon_bo_reserve(robj, false); |
90 | case RADEON_GEM_DOMAIN_VRAM: | 88 | if (unlikely(r != 0)) |
91 | flags = TTM_PL_FLAG_VRAM; | 89 | return r; |
92 | break; | 90 | r = radeon_bo_pin(robj, pin_domain, gpu_addr); |
93 | case RADEON_GEM_DOMAIN_GTT: | 91 | radeon_bo_unreserve(robj); |
94 | flags = TTM_PL_FLAG_TT; | 92 | return r; |
95 | break; | ||
96 | default: | ||
97 | flags = TTM_PL_FLAG_SYSTEM; | ||
98 | break; | ||
99 | } | ||
100 | return radeon_object_pin(robj, flags, gpu_addr); | ||
101 | } | 93 | } |
102 | 94 | ||
103 | void radeon_gem_object_unpin(struct drm_gem_object *obj) | 95 | void radeon_gem_object_unpin(struct drm_gem_object *obj) |
104 | { | 96 | { |
105 | struct radeon_object *robj = obj->driver_private; | 97 | struct radeon_bo *robj = obj->driver_private; |
106 | radeon_object_unpin(robj); | 98 | int r; |
99 | |||
100 | r = radeon_bo_reserve(robj, false); | ||
101 | if (likely(r == 0)) { | ||
102 | radeon_bo_unpin(robj); | ||
103 | radeon_bo_unreserve(robj); | ||
104 | } | ||
107 | } | 105 | } |
108 | 106 | ||
109 | int radeon_gem_set_domain(struct drm_gem_object *gobj, | 107 | int radeon_gem_set_domain(struct drm_gem_object *gobj, |
110 | uint32_t rdomain, uint32_t wdomain) | 108 | uint32_t rdomain, uint32_t wdomain) |
111 | { | 109 | { |
112 | struct radeon_object *robj; | 110 | struct radeon_bo *robj; |
113 | uint32_t domain; | 111 | uint32_t domain; |
114 | int r; | 112 | int r; |
115 | 113 | ||
@@ -127,11 +125,12 @@ int radeon_gem_set_domain(struct drm_gem_object *gobj, | |||
127 | } | 125 | } |
128 | if (domain == RADEON_GEM_DOMAIN_CPU) { | 126 | if (domain == RADEON_GEM_DOMAIN_CPU) { |
129 | /* Asking for cpu access wait for object idle */ | 127 | /* Asking for cpu access wait for object idle */ |
130 | r = radeon_object_wait(robj); | 128 | r = radeon_bo_wait(robj, NULL, false); |
131 | if (r) { | 129 | if (r) { |
132 | printk(KERN_ERR "Failed to wait for object !\n"); | 130 | printk(KERN_ERR "Failed to wait for object !\n"); |
133 | return r; | 131 | return r; |
134 | } | 132 | } |
133 | radeon_hdp_flush(robj->rdev); | ||
135 | } | 134 | } |
136 | return 0; | 135 | return 0; |
137 | } | 136 | } |
@@ -144,7 +143,7 @@ int radeon_gem_init(struct radeon_device *rdev) | |||
144 | 143 | ||
145 | void radeon_gem_fini(struct radeon_device *rdev) | 144 | void radeon_gem_fini(struct radeon_device *rdev) |
146 | { | 145 | { |
147 | radeon_object_force_delete(rdev); | 146 | radeon_bo_force_delete(rdev); |
148 | } | 147 | } |
149 | 148 | ||
150 | 149 | ||
@@ -160,9 +159,9 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data, | |||
160 | args->vram_size = rdev->mc.real_vram_size; | 159 | args->vram_size = rdev->mc.real_vram_size; |
161 | args->vram_visible = rdev->mc.real_vram_size; | 160 | args->vram_visible = rdev->mc.real_vram_size; |
162 | if (rdev->stollen_vga_memory) | 161 | if (rdev->stollen_vga_memory) |
163 | args->vram_visible -= radeon_object_size(rdev->stollen_vga_memory); | 162 | args->vram_visible -= radeon_bo_size(rdev->stollen_vga_memory); |
164 | if (rdev->fbdev_robj) | 163 | if (rdev->fbdev_rbo) |
165 | args->vram_visible -= radeon_object_size(rdev->fbdev_robj); | 164 | args->vram_visible -= radeon_bo_size(rdev->fbdev_rbo); |
166 | args->gart_size = rdev->mc.gtt_size - rdev->cp.ring_size - 4096 - | 165 | args->gart_size = rdev->mc.gtt_size - rdev->cp.ring_size - 4096 - |
167 | RADEON_IB_POOL_SIZE*64*1024; | 166 | RADEON_IB_POOL_SIZE*64*1024; |
168 | return 0; | 167 | return 0; |
@@ -196,8 +195,8 @@ int radeon_gem_create_ioctl(struct drm_device *dev, void *data, | |||
196 | /* create a gem object to contain this object in */ | 195 | /* create a gem object to contain this object in */ |
197 | args->size = roundup(args->size, PAGE_SIZE); | 196 | args->size = roundup(args->size, PAGE_SIZE); |
198 | r = radeon_gem_object_create(rdev, args->size, args->alignment, | 197 | r = radeon_gem_object_create(rdev, args->size, args->alignment, |
199 | args->initial_domain, false, | 198 | args->initial_domain, false, |
200 | false, true, &gobj); | 199 | false, &gobj); |
201 | if (r) { | 200 | if (r) { |
202 | return r; | 201 | return r; |
203 | } | 202 | } |
@@ -222,7 +221,7 @@ int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, | |||
222 | * just validate the BO into a certain domain */ | 221 | * just validate the BO into a certain domain */ |
223 | struct drm_radeon_gem_set_domain *args = data; | 222 | struct drm_radeon_gem_set_domain *args = data; |
224 | struct drm_gem_object *gobj; | 223 | struct drm_gem_object *gobj; |
225 | struct radeon_object *robj; | 224 | struct radeon_bo *robj; |
226 | int r; | 225 | int r; |
227 | 226 | ||
228 | /* for now if someone requests domain CPU - | 227 | /* for now if someone requests domain CPU - |
@@ -248,19 +247,18 @@ int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, | |||
248 | { | 247 | { |
249 | struct drm_radeon_gem_mmap *args = data; | 248 | struct drm_radeon_gem_mmap *args = data; |
250 | struct drm_gem_object *gobj; | 249 | struct drm_gem_object *gobj; |
251 | struct radeon_object *robj; | 250 | struct radeon_bo *robj; |
252 | int r; | ||
253 | 251 | ||
254 | gobj = drm_gem_object_lookup(dev, filp, args->handle); | 252 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
255 | if (gobj == NULL) { | 253 | if (gobj == NULL) { |
256 | return -EINVAL; | 254 | return -EINVAL; |
257 | } | 255 | } |
258 | robj = gobj->driver_private; | 256 | robj = gobj->driver_private; |
259 | r = radeon_object_mmap(robj, &args->addr_ptr); | 257 | args->addr_ptr = radeon_bo_mmap_offset(robj); |
260 | mutex_lock(&dev->struct_mutex); | 258 | mutex_lock(&dev->struct_mutex); |
261 | drm_gem_object_unreference(gobj); | 259 | drm_gem_object_unreference(gobj); |
262 | mutex_unlock(&dev->struct_mutex); | 260 | mutex_unlock(&dev->struct_mutex); |
263 | return r; | 261 | return 0; |
264 | } | 262 | } |
265 | 263 | ||
266 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, | 264 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, |
@@ -268,7 +266,7 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, | |||
268 | { | 266 | { |
269 | struct drm_radeon_gem_busy *args = data; | 267 | struct drm_radeon_gem_busy *args = data; |
270 | struct drm_gem_object *gobj; | 268 | struct drm_gem_object *gobj; |
271 | struct radeon_object *robj; | 269 | struct radeon_bo *robj; |
272 | int r; | 270 | int r; |
273 | uint32_t cur_placement; | 271 | uint32_t cur_placement; |
274 | 272 | ||
@@ -277,7 +275,7 @@ int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, | |||
277 | return -EINVAL; | 275 | return -EINVAL; |
278 | } | 276 | } |
279 | robj = gobj->driver_private; | 277 | robj = gobj->driver_private; |
280 | r = radeon_object_busy_domain(robj, &cur_placement); | 278 | r = radeon_bo_wait(robj, &cur_placement, true); |
281 | switch (cur_placement) { | 279 | switch (cur_placement) { |
282 | case TTM_PL_VRAM: | 280 | case TTM_PL_VRAM: |
283 | args->domain = RADEON_GEM_DOMAIN_VRAM; | 281 | args->domain = RADEON_GEM_DOMAIN_VRAM; |
@@ -301,7 +299,7 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, | |||
301 | { | 299 | { |
302 | struct drm_radeon_gem_wait_idle *args = data; | 300 | struct drm_radeon_gem_wait_idle *args = data; |
303 | struct drm_gem_object *gobj; | 301 | struct drm_gem_object *gobj; |
304 | struct radeon_object *robj; | 302 | struct radeon_bo *robj; |
305 | int r; | 303 | int r; |
306 | 304 | ||
307 | gobj = drm_gem_object_lookup(dev, filp, args->handle); | 305 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
@@ -309,10 +307,11 @@ int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, | |||
309 | return -EINVAL; | 307 | return -EINVAL; |
310 | } | 308 | } |
311 | robj = gobj->driver_private; | 309 | robj = gobj->driver_private; |
312 | r = radeon_object_wait(robj); | 310 | r = radeon_bo_wait(robj, NULL, false); |
313 | mutex_lock(&dev->struct_mutex); | 311 | mutex_lock(&dev->struct_mutex); |
314 | drm_gem_object_unreference(gobj); | 312 | drm_gem_object_unreference(gobj); |
315 | mutex_unlock(&dev->struct_mutex); | 313 | mutex_unlock(&dev->struct_mutex); |
314 | radeon_hdp_flush(robj->rdev); | ||
316 | return r; | 315 | return r; |
317 | } | 316 | } |
318 | 317 | ||
@@ -321,7 +320,7 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, | |||
321 | { | 320 | { |
322 | struct drm_radeon_gem_set_tiling *args = data; | 321 | struct drm_radeon_gem_set_tiling *args = data; |
323 | struct drm_gem_object *gobj; | 322 | struct drm_gem_object *gobj; |
324 | struct radeon_object *robj; | 323 | struct radeon_bo *robj; |
325 | int r = 0; | 324 | int r = 0; |
326 | 325 | ||
327 | DRM_DEBUG("%d \n", args->handle); | 326 | DRM_DEBUG("%d \n", args->handle); |
@@ -329,7 +328,7 @@ int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, | |||
329 | if (gobj == NULL) | 328 | if (gobj == NULL) |
330 | return -EINVAL; | 329 | return -EINVAL; |
331 | robj = gobj->driver_private; | 330 | robj = gobj->driver_private; |
332 | radeon_object_set_tiling_flags(robj, args->tiling_flags, args->pitch); | 331 | r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch); |
333 | mutex_lock(&dev->struct_mutex); | 332 | mutex_lock(&dev->struct_mutex); |
334 | drm_gem_object_unreference(gobj); | 333 | drm_gem_object_unreference(gobj); |
335 | mutex_unlock(&dev->struct_mutex); | 334 | mutex_unlock(&dev->struct_mutex); |
@@ -341,16 +340,19 @@ int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, | |||
341 | { | 340 | { |
342 | struct drm_radeon_gem_get_tiling *args = data; | 341 | struct drm_radeon_gem_get_tiling *args = data; |
343 | struct drm_gem_object *gobj; | 342 | struct drm_gem_object *gobj; |
344 | struct radeon_object *robj; | 343 | struct radeon_bo *rbo; |
345 | int r = 0; | 344 | int r = 0; |
346 | 345 | ||
347 | DRM_DEBUG("\n"); | 346 | DRM_DEBUG("\n"); |
348 | gobj = drm_gem_object_lookup(dev, filp, args->handle); | 347 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
349 | if (gobj == NULL) | 348 | if (gobj == NULL) |
350 | return -EINVAL; | 349 | return -EINVAL; |
351 | robj = gobj->driver_private; | 350 | rbo = gobj->driver_private; |
352 | radeon_object_get_tiling_flags(robj, &args->tiling_flags, | 351 | r = radeon_bo_reserve(rbo, false); |
353 | &args->pitch); | 352 | if (unlikely(r != 0)) |
353 | return r; | ||
354 | radeon_bo_get_tiling_flags(rbo, &args->tiling_flags, &args->pitch); | ||
355 | radeon_bo_unreserve(rbo); | ||
354 | mutex_lock(&dev->struct_mutex); | 356 | mutex_lock(&dev->struct_mutex); |
355 | drm_gem_object_unreference(gobj); | 357 | drm_gem_object_unreference(gobj); |
356 | mutex_unlock(&dev->struct_mutex); | 358 | mutex_unlock(&dev->struct_mutex); |