diff options
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_fb.c')
-rw-r--r-- | drivers/gpu/drm/radeon/radeon_fb.c | 63 |
1 files changed, 39 insertions, 24 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c index cb2f16a0b8ff..66055b3d8668 100644 --- a/drivers/gpu/drm/radeon/radeon_fb.c +++ b/drivers/gpu/drm/radeon/radeon_fb.c | |||
@@ -140,7 +140,7 @@ int radeonfb_create(struct drm_device *dev, | |||
140 | struct radeon_framebuffer *rfb; | 140 | struct radeon_framebuffer *rfb; |
141 | struct drm_mode_fb_cmd mode_cmd; | 141 | struct drm_mode_fb_cmd mode_cmd; |
142 | struct drm_gem_object *gobj = NULL; | 142 | struct drm_gem_object *gobj = NULL; |
143 | struct radeon_object *robj = NULL; | 143 | struct radeon_bo *rbo = NULL; |
144 | struct device *device = &rdev->pdev->dev; | 144 | struct device *device = &rdev->pdev->dev; |
145 | int size, aligned_size, ret; | 145 | int size, aligned_size, ret; |
146 | u64 fb_gpuaddr; | 146 | u64 fb_gpuaddr; |
@@ -168,14 +168,14 @@ int radeonfb_create(struct drm_device *dev, | |||
168 | ret = radeon_gem_object_create(rdev, aligned_size, 0, | 168 | ret = radeon_gem_object_create(rdev, aligned_size, 0, |
169 | RADEON_GEM_DOMAIN_VRAM, | 169 | RADEON_GEM_DOMAIN_VRAM, |
170 | false, ttm_bo_type_kernel, | 170 | false, ttm_bo_type_kernel, |
171 | false, &gobj); | 171 | &gobj); |
172 | if (ret) { | 172 | if (ret) { |
173 | printk(KERN_ERR "failed to allocate framebuffer (%d %d)\n", | 173 | printk(KERN_ERR "failed to allocate framebuffer (%d %d)\n", |
174 | surface_width, surface_height); | 174 | surface_width, surface_height); |
175 | ret = -ENOMEM; | 175 | ret = -ENOMEM; |
176 | goto out; | 176 | goto out; |
177 | } | 177 | } |
178 | robj = gobj->driver_private; | 178 | rbo = gobj->driver_private; |
179 | 179 | ||
180 | if (fb_tiled) | 180 | if (fb_tiled) |
181 | tiling_flags = RADEON_TILING_MACRO; | 181 | tiling_flags = RADEON_TILING_MACRO; |
@@ -192,8 +192,13 @@ int radeonfb_create(struct drm_device *dev, | |||
192 | } | 192 | } |
193 | #endif | 193 | #endif |
194 | 194 | ||
195 | if (tiling_flags) | 195 | if (tiling_flags) { |
196 | radeon_object_set_tiling_flags(robj, tiling_flags | RADEON_TILING_SURFACE, mode_cmd.pitch); | 196 | ret = radeon_bo_set_tiling_flags(rbo, |
197 | tiling_flags | RADEON_TILING_SURFACE, | ||
198 | mode_cmd.pitch); | ||
199 | if (ret) | ||
200 | dev_err(rdev->dev, "FB failed to set tiling flags\n"); | ||
201 | } | ||
197 | mutex_lock(&rdev->ddev->struct_mutex); | 202 | mutex_lock(&rdev->ddev->struct_mutex); |
198 | fb = radeon_framebuffer_create(rdev->ddev, &mode_cmd, gobj); | 203 | fb = radeon_framebuffer_create(rdev->ddev, &mode_cmd, gobj); |
199 | if (fb == NULL) { | 204 | if (fb == NULL) { |
@@ -201,10 +206,19 @@ int radeonfb_create(struct drm_device *dev, | |||
201 | ret = -ENOMEM; | 206 | ret = -ENOMEM; |
202 | goto out_unref; | 207 | goto out_unref; |
203 | } | 208 | } |
204 | ret = radeon_object_pin(robj, RADEON_GEM_DOMAIN_VRAM, &fb_gpuaddr); | 209 | ret = radeon_bo_reserve(rbo, false); |
210 | if (unlikely(ret != 0)) | ||
211 | goto out_unref; | ||
212 | ret = radeon_bo_pin(rbo, RADEON_GEM_DOMAIN_VRAM, &fb_gpuaddr); | ||
213 | if (ret) { | ||
214 | radeon_bo_unreserve(rbo); | ||
215 | goto out_unref; | ||
216 | } | ||
217 | if (fb_tiled) | ||
218 | radeon_bo_check_tiling(rbo, 0, 0); | ||
219 | ret = radeon_bo_kmap(rbo, &fbptr); | ||
220 | radeon_bo_unreserve(rbo); | ||
205 | if (ret) { | 221 | if (ret) { |
206 | printk(KERN_ERR "failed to pin framebuffer\n"); | ||
207 | ret = -ENOMEM; | ||
208 | goto out_unref; | 222 | goto out_unref; |
209 | } | 223 | } |
210 | 224 | ||
@@ -213,7 +227,7 @@ int radeonfb_create(struct drm_device *dev, | |||
213 | *fb_p = fb; | 227 | *fb_p = fb; |
214 | rfb = to_radeon_framebuffer(fb); | 228 | rfb = to_radeon_framebuffer(fb); |
215 | rdev->fbdev_rfb = rfb; | 229 | rdev->fbdev_rfb = rfb; |
216 | rdev->fbdev_robj = robj; | 230 | rdev->fbdev_rbo = rbo; |
217 | 231 | ||
218 | info = framebuffer_alloc(sizeof(struct radeon_fb_device), device); | 232 | info = framebuffer_alloc(sizeof(struct radeon_fb_device), device); |
219 | if (info == NULL) { | 233 | if (info == NULL) { |
@@ -234,15 +248,7 @@ int radeonfb_create(struct drm_device *dev, | |||
234 | if (ret) | 248 | if (ret) |
235 | goto out_unref; | 249 | goto out_unref; |
236 | 250 | ||
237 | if (fb_tiled) | 251 | memset_io(fbptr, 0xff, aligned_size); |
238 | radeon_object_check_tiling(robj, 0, 0); | ||
239 | |||
240 | ret = radeon_object_kmap(robj, &fbptr); | ||
241 | if (ret) { | ||
242 | goto out_unref; | ||
243 | } | ||
244 | |||
245 | memset_io(fbptr, 0, aligned_size); | ||
246 | 252 | ||
247 | strcpy(info->fix.id, "radeondrmfb"); | 253 | strcpy(info->fix.id, "radeondrmfb"); |
248 | 254 | ||
@@ -288,8 +294,12 @@ int radeonfb_create(struct drm_device *dev, | |||
288 | return 0; | 294 | return 0; |
289 | 295 | ||
290 | out_unref: | 296 | out_unref: |
291 | if (robj) { | 297 | if (rbo) { |
292 | radeon_object_kunmap(robj); | 298 | ret = radeon_bo_reserve(rbo, false); |
299 | if (likely(ret == 0)) { | ||
300 | radeon_bo_kunmap(rbo); | ||
301 | radeon_bo_unreserve(rbo); | ||
302 | } | ||
293 | } | 303 | } |
294 | if (fb && ret) { | 304 | if (fb && ret) { |
295 | list_del(&fb->filp_head); | 305 | list_del(&fb->filp_head); |
@@ -335,7 +345,8 @@ int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb) | |||
335 | { | 345 | { |
336 | struct fb_info *info; | 346 | struct fb_info *info; |
337 | struct radeon_framebuffer *rfb = to_radeon_framebuffer(fb); | 347 | struct radeon_framebuffer *rfb = to_radeon_framebuffer(fb); |
338 | struct radeon_object *robj; | 348 | struct radeon_bo *rbo; |
349 | int r; | ||
339 | 350 | ||
340 | if (!fb) { | 351 | if (!fb) { |
341 | return -EINVAL; | 352 | return -EINVAL; |
@@ -343,10 +354,14 @@ int radeonfb_remove(struct drm_device *dev, struct drm_framebuffer *fb) | |||
343 | info = fb->fbdev; | 354 | info = fb->fbdev; |
344 | if (info) { | 355 | if (info) { |
345 | struct radeon_fb_device *rfbdev = info->par; | 356 | struct radeon_fb_device *rfbdev = info->par; |
346 | robj = rfb->obj->driver_private; | 357 | rbo = rfb->obj->driver_private; |
347 | unregister_framebuffer(info); | 358 | unregister_framebuffer(info); |
348 | radeon_object_kunmap(robj); | 359 | r = radeon_bo_reserve(rbo, false); |
349 | radeon_object_unpin(robj); | 360 | if (likely(r == 0)) { |
361 | radeon_bo_kunmap(rbo); | ||
362 | radeon_bo_unpin(rbo); | ||
363 | radeon_bo_unreserve(rbo); | ||
364 | } | ||
350 | drm_fb_helper_free(&rfbdev->helper); | 365 | drm_fb_helper_free(&rfbdev->helper); |
351 | framebuffer_release(info); | 366 | framebuffer_release(info); |
352 | } | 367 | } |