Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2008 Advanced Micro Devices, Inc. |
| 3 | * Copyright 2008 Red Hat Inc. |
| 4 | * Copyright 2009 Jerome Glisse. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in |
| 14 | * all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 20 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 21 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 22 | * OTHER DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: Dave Airlie |
| 25 | * Alex Deucher |
| 26 | * Jerome Glisse |
| 27 | */ |
| 28 | #include "drmP.h" |
| 29 | #include "drm.h" |
| 30 | #include "radeon_drm.h" |
| 31 | #include "radeon.h" |
| 32 | |
| 33 | int radeon_gem_object_init(struct drm_gem_object *obj) |
| 34 | { |
| 35 | /* we do nothings here */ |
| 36 | return 0; |
| 37 | } |
| 38 | |
| 39 | void radeon_gem_object_free(struct drm_gem_object *gobj) |
| 40 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 41 | struct radeon_bo *robj = gobj->driver_private; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 42 | |
| 43 | gobj->driver_private = NULL; |
| 44 | if (robj) { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 45 | radeon_bo_unref(&robj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 46 | } |
Daniel Vetter | fd632aa | 2010-04-09 19:05:05 +0000 | [diff] [blame] | 47 | |
| 48 | drm_gem_object_release(gobj); |
| 49 | kfree(gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | int radeon_gem_object_create(struct radeon_device *rdev, int size, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 53 | int alignment, int initial_domain, |
| 54 | bool discardable, bool kernel, |
| 55 | struct drm_gem_object **obj) |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 56 | { |
| 57 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 58 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 59 | int r; |
| 60 | |
| 61 | *obj = NULL; |
| 62 | gobj = drm_gem_object_alloc(rdev->ddev, size); |
| 63 | if (!gobj) { |
| 64 | return -ENOMEM; |
| 65 | } |
| 66 | /* At least align on page size */ |
| 67 | if (alignment < PAGE_SIZE) { |
| 68 | alignment = PAGE_SIZE; |
| 69 | } |
Alex Deucher | 268b251 | 2010-11-17 19:00:26 -0500 | [diff] [blame] | 70 | r = radeon_bo_create(rdev, gobj, size, alignment, kernel, initial_domain, &robj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 71 | if (r) { |
Dave Airlie | ecabd32 | 2009-12-15 10:39:48 +1000 | [diff] [blame] | 72 | if (r != -ERESTARTSYS) |
| 73 | DRM_ERROR("Failed to allocate GEM object (%d, %d, %u, %d)\n", |
| 74 | size, initial_domain, alignment, r); |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 75 | drm_gem_object_unreference_unlocked(gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 76 | return r; |
| 77 | } |
| 78 | gobj->driver_private = robj; |
| 79 | *obj = gobj; |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int radeon_gem_object_pin(struct drm_gem_object *obj, uint32_t pin_domain, |
| 84 | uint64_t *gpu_addr) |
| 85 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 86 | struct radeon_bo *robj = obj->driver_private; |
| 87 | int r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 88 | |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 89 | r = radeon_bo_reserve(robj, false); |
| 90 | if (unlikely(r != 0)) |
| 91 | return r; |
| 92 | r = radeon_bo_pin(robj, pin_domain, gpu_addr); |
| 93 | radeon_bo_unreserve(robj); |
| 94 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | void radeon_gem_object_unpin(struct drm_gem_object *obj) |
| 98 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 99 | struct radeon_bo *robj = obj->driver_private; |
| 100 | int r; |
| 101 | |
| 102 | r = radeon_bo_reserve(robj, false); |
| 103 | if (likely(r == 0)) { |
| 104 | radeon_bo_unpin(robj); |
| 105 | radeon_bo_unreserve(robj); |
| 106 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | int radeon_gem_set_domain(struct drm_gem_object *gobj, |
| 110 | uint32_t rdomain, uint32_t wdomain) |
| 111 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 112 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 113 | uint32_t domain; |
| 114 | int r; |
| 115 | |
| 116 | /* FIXME: reeimplement */ |
| 117 | robj = gobj->driver_private; |
| 118 | /* work out where to validate the buffer to */ |
| 119 | domain = wdomain; |
| 120 | if (!domain) { |
| 121 | domain = rdomain; |
| 122 | } |
| 123 | if (!domain) { |
| 124 | /* Do nothings */ |
| 125 | printk(KERN_WARNING "Set domain withou domain !\n"); |
| 126 | return 0; |
| 127 | } |
| 128 | if (domain == RADEON_GEM_DOMAIN_CPU) { |
| 129 | /* Asking for cpu access wait for object idle */ |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 130 | r = radeon_bo_wait(robj, NULL, false); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 131 | if (r) { |
| 132 | printk(KERN_ERR "Failed to wait for object !\n"); |
| 133 | return r; |
| 134 | } |
| 135 | } |
| 136 | return 0; |
| 137 | } |
| 138 | |
| 139 | int radeon_gem_init(struct radeon_device *rdev) |
| 140 | { |
| 141 | INIT_LIST_HEAD(&rdev->gem.objects); |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | void radeon_gem_fini(struct radeon_device *rdev) |
| 146 | { |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 147 | radeon_bo_force_delete(rdev); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | |
| 151 | /* |
| 152 | * GEM ioctls. |
| 153 | */ |
| 154 | int radeon_gem_info_ioctl(struct drm_device *dev, void *data, |
| 155 | struct drm_file *filp) |
| 156 | { |
| 157 | struct radeon_device *rdev = dev->dev_private; |
| 158 | struct drm_radeon_gem_info *args = data; |
Dave Airlie | 5359533 | 2011-03-14 09:47:24 +1000 | [diff] [blame^] | 159 | struct ttm_mem_type_manager *man; |
| 160 | |
| 161 | man = &rdev->mman.bdev.man[TTM_PL_VRAM]; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 162 | |
Dave Airlie | 7a50f01 | 2009-07-21 20:39:30 +1000 | [diff] [blame] | 163 | args->vram_size = rdev->mc.real_vram_size; |
Dave Airlie | 5359533 | 2011-03-14 09:47:24 +1000 | [diff] [blame^] | 164 | args->vram_visible = (u64)man->size << PAGE_SHIFT; |
Michel Dänzer | 38e1492 | 2009-08-05 00:19:51 +0200 | [diff] [blame] | 165 | if (rdev->stollen_vga_memory) |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 166 | args->vram_visible -= radeon_bo_size(rdev->stollen_vga_memory); |
Dave Airlie | 3865167 | 2010-03-30 05:34:13 +0000 | [diff] [blame] | 167 | args->vram_visible -= radeon_fbdev_total_size(rdev); |
Michel Dänzer | 38e1492 | 2009-08-05 00:19:51 +0200 | [diff] [blame] | 168 | args->gart_size = rdev->mc.gtt_size - rdev->cp.ring_size - 4096 - |
| 169 | RADEON_IB_POOL_SIZE*64*1024; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | int radeon_gem_pread_ioctl(struct drm_device *dev, void *data, |
| 174 | struct drm_file *filp) |
| 175 | { |
| 176 | /* TODO: implement */ |
| 177 | DRM_ERROR("unimplemented %s\n", __func__); |
| 178 | return -ENOSYS; |
| 179 | } |
| 180 | |
| 181 | int radeon_gem_pwrite_ioctl(struct drm_device *dev, void *data, |
| 182 | struct drm_file *filp) |
| 183 | { |
| 184 | /* TODO: implement */ |
| 185 | DRM_ERROR("unimplemented %s\n", __func__); |
| 186 | return -ENOSYS; |
| 187 | } |
| 188 | |
| 189 | int radeon_gem_create_ioctl(struct drm_device *dev, void *data, |
| 190 | struct drm_file *filp) |
| 191 | { |
| 192 | struct radeon_device *rdev = dev->dev_private; |
| 193 | struct drm_radeon_gem_create *args = data; |
| 194 | struct drm_gem_object *gobj; |
| 195 | uint32_t handle; |
| 196 | int r; |
| 197 | |
| 198 | /* create a gem object to contain this object in */ |
| 199 | args->size = roundup(args->size, PAGE_SIZE); |
| 200 | r = radeon_gem_object_create(rdev, args->size, args->alignment, |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 201 | args->initial_domain, false, |
| 202 | false, &gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 203 | if (r) { |
| 204 | return r; |
| 205 | } |
| 206 | r = drm_gem_handle_create(filp, gobj, &handle); |
Dave Airlie | 29d08b3 | 2010-09-27 16:17:17 +1000 | [diff] [blame] | 207 | /* drop reference from allocate - handle holds it now */ |
| 208 | drm_gem_object_unreference_unlocked(gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 209 | if (r) { |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 210 | return r; |
| 211 | } |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 212 | args->handle = handle; |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | int radeon_gem_set_domain_ioctl(struct drm_device *dev, void *data, |
| 217 | struct drm_file *filp) |
| 218 | { |
| 219 | /* transition the BO to a domain - |
| 220 | * just validate the BO into a certain domain */ |
| 221 | struct drm_radeon_gem_set_domain *args = data; |
| 222 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 223 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 224 | int r; |
| 225 | |
| 226 | /* for now if someone requests domain CPU - |
| 227 | * just make sure the buffer is finished with */ |
| 228 | |
| 229 | /* just do a BO wait for now */ |
| 230 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 231 | if (gobj == NULL) { |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 232 | return -ENOENT; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 233 | } |
| 234 | robj = gobj->driver_private; |
| 235 | |
| 236 | r = radeon_gem_set_domain(gobj, args->read_domains, args->write_domain); |
| 237 | |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 238 | drm_gem_object_unreference_unlocked(gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 239 | return r; |
| 240 | } |
| 241 | |
| 242 | int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data, |
| 243 | struct drm_file *filp) |
| 244 | { |
| 245 | struct drm_radeon_gem_mmap *args = data; |
| 246 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 247 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 248 | |
| 249 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 250 | if (gobj == NULL) { |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 251 | return -ENOENT; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 252 | } |
| 253 | robj = gobj->driver_private; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 254 | args->addr_ptr = radeon_bo_mmap_offset(robj); |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 255 | drm_gem_object_unreference_unlocked(gobj); |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 256 | return 0; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, |
| 260 | struct drm_file *filp) |
| 261 | { |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 262 | struct drm_radeon_gem_busy *args = data; |
| 263 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 264 | struct radeon_bo *robj; |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 265 | int r; |
Dave Airlie | 4361e52 | 2009-12-10 15:59:32 +1000 | [diff] [blame] | 266 | uint32_t cur_placement = 0; |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 267 | |
| 268 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 269 | if (gobj == NULL) { |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 270 | return -ENOENT; |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 271 | } |
| 272 | robj = gobj->driver_private; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 273 | r = radeon_bo_wait(robj, &cur_placement, true); |
Michel Dänzer | 9f844e5 | 2009-08-22 17:38:23 +0200 | [diff] [blame] | 274 | switch (cur_placement) { |
| 275 | case TTM_PL_VRAM: |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 276 | args->domain = RADEON_GEM_DOMAIN_VRAM; |
Michel Dänzer | 9f844e5 | 2009-08-22 17:38:23 +0200 | [diff] [blame] | 277 | break; |
| 278 | case TTM_PL_TT: |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 279 | args->domain = RADEON_GEM_DOMAIN_GTT; |
Michel Dänzer | 9f844e5 | 2009-08-22 17:38:23 +0200 | [diff] [blame] | 280 | break; |
| 281 | case TTM_PL_SYSTEM: |
Dave Airlie | cefb87e | 2009-08-16 21:05:45 +1000 | [diff] [blame] | 282 | args->domain = RADEON_GEM_DOMAIN_CPU; |
Michel Dänzer | 9f844e5 | 2009-08-22 17:38:23 +0200 | [diff] [blame] | 283 | default: |
| 284 | break; |
| 285 | } |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 286 | drm_gem_object_unreference_unlocked(gobj); |
Dave Airlie | e3b2415 | 2009-08-21 09:47:45 +1000 | [diff] [blame] | 287 | return r; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, |
| 291 | struct drm_file *filp) |
| 292 | { |
| 293 | struct drm_radeon_gem_wait_idle *args = data; |
| 294 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 295 | struct radeon_bo *robj; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 296 | int r; |
| 297 | |
| 298 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 299 | if (gobj == NULL) { |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 300 | return -ENOENT; |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 301 | } |
| 302 | robj = gobj->driver_private; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 303 | r = radeon_bo_wait(robj, NULL, false); |
Jerome Glisse | 062b389 | 2010-02-04 20:36:39 +0100 | [diff] [blame] | 304 | /* callback hw specific functions if any */ |
| 305 | if (robj->rdev->asic->ioctl_wait_idle) |
| 306 | robj->rdev->asic->ioctl_wait_idle(robj->rdev, robj); |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 307 | drm_gem_object_unreference_unlocked(gobj); |
Jerome Glisse | 771fe6b | 2009-06-05 14:42:42 +0200 | [diff] [blame] | 308 | return r; |
| 309 | } |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 310 | |
| 311 | int radeon_gem_set_tiling_ioctl(struct drm_device *dev, void *data, |
| 312 | struct drm_file *filp) |
| 313 | { |
| 314 | struct drm_radeon_gem_set_tiling *args = data; |
| 315 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 316 | struct radeon_bo *robj; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 317 | int r = 0; |
| 318 | |
| 319 | DRM_DEBUG("%d \n", args->handle); |
| 320 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 321 | if (gobj == NULL) |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 322 | return -ENOENT; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 323 | robj = gobj->driver_private; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 324 | r = radeon_bo_set_tiling_flags(robj, args->tiling_flags, args->pitch); |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 325 | drm_gem_object_unreference_unlocked(gobj); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 326 | return r; |
| 327 | } |
| 328 | |
| 329 | int radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data, |
| 330 | struct drm_file *filp) |
| 331 | { |
| 332 | struct drm_radeon_gem_get_tiling *args = data; |
| 333 | struct drm_gem_object *gobj; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 334 | struct radeon_bo *rbo; |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 335 | int r = 0; |
| 336 | |
| 337 | DRM_DEBUG("\n"); |
| 338 | gobj = drm_gem_object_lookup(dev, filp, args->handle); |
| 339 | if (gobj == NULL) |
Chris Wilson | bf79cb9 | 2010-08-04 14:19:46 +0100 | [diff] [blame] | 340 | return -ENOENT; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 341 | rbo = gobj->driver_private; |
| 342 | r = radeon_bo_reserve(rbo, false); |
| 343 | if (unlikely(r != 0)) |
Dave Airlie | 51f07b7 | 2009-12-16 13:10:43 +1000 | [diff] [blame] | 344 | goto out; |
Jerome Glisse | 4c78867 | 2009-11-20 14:29:23 +0100 | [diff] [blame] | 345 | radeon_bo_get_tiling_flags(rbo, &args->tiling_flags, &args->pitch); |
| 346 | radeon_bo_unreserve(rbo); |
Dave Airlie | 51f07b7 | 2009-12-16 13:10:43 +1000 | [diff] [blame] | 347 | out: |
Luca Barbieri | bc9025b | 2010-02-09 05:49:12 +0000 | [diff] [blame] | 348 | drm_gem_object_unreference_unlocked(gobj); |
Dave Airlie | e024e11 | 2009-06-24 09:48:08 +1000 | [diff] [blame] | 349 | return r; |
| 350 | } |