1 1.2 riastrad /* $NetBSD: qxl_release.c,v 1.3 2021/12/18 23:45:42 riastradh Exp $ */ 2 1.2 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2011 Red Hat, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * on the rights to use, copy, modify, merge, publish, distribute, sub 10 1.1 riastrad * license, and/or sell copies of the Software, and to permit persons to whom 11 1.1 riastrad * the Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice (including the next 14 1.1 riastrad * paragraph) shall be included in all copies or substantial portions of the 15 1.1 riastrad * Software. 16 1.1 riastrad * 17 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 20 1.1 riastrad * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 1.1 riastrad * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 1.1 riastrad * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad */ 24 1.3 riastrad 25 1.2 riastrad #include <sys/cdefs.h> 26 1.2 riastrad __KERNEL_RCSID(0, "$NetBSD: qxl_release.c,v 1.3 2021/12/18 23:45:42 riastradh Exp $"); 27 1.2 riastrad 28 1.3 riastrad #include <linux/delay.h> 29 1.3 riastrad 30 1.3 riastrad #include <trace/events/dma_fence.h> 31 1.3 riastrad 32 1.1 riastrad #include "qxl_drv.h" 33 1.1 riastrad #include "qxl_object.h" 34 1.1 riastrad 35 1.1 riastrad /* 36 1.1 riastrad * drawable cmd cache - allocate a bunch of VRAM pages, suballocate 37 1.1 riastrad * into 256 byte chunks for now - gives 16 cmds per page. 38 1.1 riastrad * 39 1.1 riastrad * use an ida to index into the chunks? 40 1.1 riastrad */ 41 1.1 riastrad /* manage releaseables */ 42 1.1 riastrad /* stack them 16 high for now -drawable object is 191 */ 43 1.1 riastrad #define RELEASE_SIZE 256 44 1.1 riastrad #define RELEASES_PER_BO (4096 / RELEASE_SIZE) 45 1.1 riastrad /* put an alloc/dealloc surface cmd into one bo and round up to 128 */ 46 1.1 riastrad #define SURFACE_RELEASE_SIZE 128 47 1.1 riastrad #define SURFACE_RELEASES_PER_BO (4096 / SURFACE_RELEASE_SIZE) 48 1.1 riastrad 49 1.1 riastrad static const int release_size_per_bo[] = { RELEASE_SIZE, SURFACE_RELEASE_SIZE, RELEASE_SIZE }; 50 1.1 riastrad static const int releases_per_bo[] = { RELEASES_PER_BO, SURFACE_RELEASES_PER_BO, RELEASES_PER_BO }; 51 1.1 riastrad 52 1.3 riastrad static const char *qxl_get_driver_name(struct dma_fence *fence) 53 1.2 riastrad { 54 1.2 riastrad return "qxl"; 55 1.2 riastrad } 56 1.2 riastrad 57 1.3 riastrad static const char *qxl_get_timeline_name(struct dma_fence *fence) 58 1.2 riastrad { 59 1.2 riastrad return "release"; 60 1.2 riastrad } 61 1.2 riastrad 62 1.3 riastrad static long qxl_fence_wait(struct dma_fence *fence, bool intr, 63 1.3 riastrad signed long timeout) 64 1.2 riastrad { 65 1.2 riastrad struct qxl_device *qdev; 66 1.2 riastrad struct qxl_release *release; 67 1.2 riastrad int count = 0, sc = 0; 68 1.2 riastrad bool have_drawable_releases; 69 1.2 riastrad unsigned long cur, end = jiffies + timeout; 70 1.2 riastrad 71 1.2 riastrad qdev = container_of(fence->lock, struct qxl_device, release_lock); 72 1.2 riastrad release = container_of(fence, struct qxl_release, base); 73 1.2 riastrad have_drawable_releases = release->type == QXL_RELEASE_DRAWABLE; 74 1.2 riastrad 75 1.2 riastrad retry: 76 1.2 riastrad sc++; 77 1.2 riastrad 78 1.3 riastrad if (dma_fence_is_signaled(fence)) 79 1.2 riastrad goto signaled; 80 1.2 riastrad 81 1.2 riastrad qxl_io_notify_oom(qdev); 82 1.2 riastrad 83 1.2 riastrad for (count = 0; count < 11; count++) { 84 1.2 riastrad if (!qxl_queue_garbage_collect(qdev, true)) 85 1.2 riastrad break; 86 1.2 riastrad 87 1.3 riastrad if (dma_fence_is_signaled(fence)) 88 1.2 riastrad goto signaled; 89 1.2 riastrad } 90 1.2 riastrad 91 1.3 riastrad if (dma_fence_is_signaled(fence)) 92 1.2 riastrad goto signaled; 93 1.2 riastrad 94 1.2 riastrad if (have_drawable_releases || sc < 4) { 95 1.2 riastrad if (sc > 2) 96 1.2 riastrad /* back off */ 97 1.2 riastrad usleep_range(500, 1000); 98 1.2 riastrad 99 1.2 riastrad if (time_after(jiffies, end)) 100 1.2 riastrad return 0; 101 1.2 riastrad 102 1.2 riastrad if (have_drawable_releases && sc > 300) { 103 1.3 riastrad DMA_FENCE_WARN(fence, "failed to wait on release %llu " 104 1.3 riastrad "after spincount %d\n", 105 1.3 riastrad fence->context & ~0xf0000000, sc); 106 1.2 riastrad goto signaled; 107 1.2 riastrad } 108 1.2 riastrad goto retry; 109 1.2 riastrad } 110 1.2 riastrad /* 111 1.2 riastrad * yeah, original sync_obj_wait gave up after 3 spins when 112 1.2 riastrad * have_drawable_releases is not set. 113 1.2 riastrad */ 114 1.2 riastrad 115 1.2 riastrad signaled: 116 1.2 riastrad cur = jiffies; 117 1.2 riastrad if (time_after(cur, end)) 118 1.2 riastrad return 0; 119 1.2 riastrad return end - cur; 120 1.2 riastrad } 121 1.2 riastrad 122 1.3 riastrad static const struct dma_fence_ops qxl_fence_ops = { 123 1.2 riastrad .get_driver_name = qxl_get_driver_name, 124 1.2 riastrad .get_timeline_name = qxl_get_timeline_name, 125 1.2 riastrad .wait = qxl_fence_wait, 126 1.2 riastrad }; 127 1.2 riastrad 128 1.2 riastrad static int 129 1.1 riastrad qxl_release_alloc(struct qxl_device *qdev, int type, 130 1.1 riastrad struct qxl_release **ret) 131 1.1 riastrad { 132 1.1 riastrad struct qxl_release *release; 133 1.1 riastrad int handle; 134 1.1 riastrad size_t size = sizeof(*release); 135 1.1 riastrad 136 1.1 riastrad release = kmalloc(size, GFP_KERNEL); 137 1.1 riastrad if (!release) { 138 1.1 riastrad DRM_ERROR("Out of memory\n"); 139 1.3 riastrad return -ENOMEM; 140 1.1 riastrad } 141 1.2 riastrad release->base.ops = NULL; 142 1.1 riastrad release->type = type; 143 1.1 riastrad release->release_offset = 0; 144 1.1 riastrad release->surface_release_id = 0; 145 1.1 riastrad INIT_LIST_HEAD(&release->bos); 146 1.1 riastrad 147 1.1 riastrad idr_preload(GFP_KERNEL); 148 1.1 riastrad spin_lock(&qdev->release_idr_lock); 149 1.2 riastrad handle = idr_alloc(&qdev->release_idr, release, 1, 0, GFP_NOWAIT); 150 1.2 riastrad release->base.seqno = ++qdev->release_seqno; 151 1.1 riastrad spin_unlock(&qdev->release_idr_lock); 152 1.1 riastrad idr_preload_end(); 153 1.2 riastrad if (handle < 0) { 154 1.2 riastrad kfree(release); 155 1.2 riastrad *ret = NULL; 156 1.2 riastrad return handle; 157 1.2 riastrad } 158 1.1 riastrad *ret = release; 159 1.3 riastrad DRM_DEBUG_DRIVER("allocated release %d\n", handle); 160 1.1 riastrad release->id = handle; 161 1.2 riastrad return handle; 162 1.2 riastrad } 163 1.2 riastrad 164 1.2 riastrad static void 165 1.2 riastrad qxl_release_free_list(struct qxl_release *release) 166 1.2 riastrad { 167 1.2 riastrad while (!list_empty(&release->bos)) { 168 1.2 riastrad struct qxl_bo_list *entry; 169 1.2 riastrad struct qxl_bo *bo; 170 1.1 riastrad 171 1.2 riastrad entry = container_of(release->bos.next, 172 1.2 riastrad struct qxl_bo_list, tv.head); 173 1.2 riastrad bo = to_qxl_bo(entry->tv.bo); 174 1.2 riastrad qxl_bo_unref(&bo); 175 1.2 riastrad list_del(&entry->tv.head); 176 1.2 riastrad kfree(entry); 177 1.2 riastrad } 178 1.3 riastrad release->release_bo = NULL; 179 1.1 riastrad } 180 1.1 riastrad 181 1.1 riastrad void 182 1.1 riastrad qxl_release_free(struct qxl_device *qdev, 183 1.1 riastrad struct qxl_release *release) 184 1.1 riastrad { 185 1.3 riastrad DRM_DEBUG_DRIVER("release %d, type %d\n", release->id, release->type); 186 1.1 riastrad 187 1.1 riastrad if (release->surface_release_id) 188 1.1 riastrad qxl_surface_id_dealloc(qdev, release->surface_release_id); 189 1.1 riastrad 190 1.1 riastrad spin_lock(&qdev->release_idr_lock); 191 1.1 riastrad idr_remove(&qdev->release_idr, release->id); 192 1.1 riastrad spin_unlock(&qdev->release_idr_lock); 193 1.2 riastrad 194 1.2 riastrad if (release->base.ops) { 195 1.2 riastrad WARN_ON(list_empty(&release->bos)); 196 1.2 riastrad qxl_release_free_list(release); 197 1.2 riastrad 198 1.3 riastrad dma_fence_signal(&release->base); 199 1.3 riastrad dma_fence_put(&release->base); 200 1.2 riastrad } else { 201 1.2 riastrad qxl_release_free_list(release); 202 1.2 riastrad kfree(release); 203 1.2 riastrad } 204 1.1 riastrad } 205 1.1 riastrad 206 1.1 riastrad static int qxl_release_bo_alloc(struct qxl_device *qdev, 207 1.1 riastrad struct qxl_bo **bo) 208 1.1 riastrad { 209 1.1 riastrad /* pin releases bo's they are too messy to evict */ 210 1.3 riastrad return qxl_bo_create(qdev, PAGE_SIZE, false, true, 211 1.3 riastrad QXL_GEM_DOMAIN_VRAM, NULL, bo); 212 1.1 riastrad } 213 1.1 riastrad 214 1.1 riastrad int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo) 215 1.1 riastrad { 216 1.1 riastrad struct qxl_bo_list *entry; 217 1.1 riastrad 218 1.1 riastrad list_for_each_entry(entry, &release->bos, tv.head) { 219 1.1 riastrad if (entry->tv.bo == &bo->tbo) 220 1.1 riastrad return 0; 221 1.1 riastrad } 222 1.1 riastrad 223 1.1 riastrad entry = kmalloc(sizeof(struct qxl_bo_list), GFP_KERNEL); 224 1.1 riastrad if (!entry) 225 1.1 riastrad return -ENOMEM; 226 1.1 riastrad 227 1.1 riastrad qxl_bo_ref(bo); 228 1.1 riastrad entry->tv.bo = &bo->tbo; 229 1.3 riastrad entry->tv.num_shared = 0; 230 1.1 riastrad list_add_tail(&entry->tv.head, &release->bos); 231 1.1 riastrad return 0; 232 1.1 riastrad } 233 1.1 riastrad 234 1.1 riastrad static int qxl_release_validate_bo(struct qxl_bo *bo) 235 1.1 riastrad { 236 1.3 riastrad struct ttm_operation_ctx ctx = { true, false }; 237 1.1 riastrad int ret; 238 1.1 riastrad 239 1.1 riastrad if (!bo->pin_count) { 240 1.1 riastrad qxl_ttm_placement_from_domain(bo, bo->type, false); 241 1.3 riastrad ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx); 242 1.1 riastrad if (ret) 243 1.1 riastrad return ret; 244 1.1 riastrad } 245 1.1 riastrad 246 1.3 riastrad ret = dma_resv_reserve_shared(bo->tbo.base.resv, 1); 247 1.2 riastrad if (ret) 248 1.2 riastrad return ret; 249 1.2 riastrad 250 1.1 riastrad /* allocate a surface for reserved + validated buffers */ 251 1.3 riastrad ret = qxl_bo_check_id(bo->tbo.base.dev->dev_private, bo); 252 1.1 riastrad if (ret) 253 1.1 riastrad return ret; 254 1.1 riastrad return 0; 255 1.1 riastrad } 256 1.1 riastrad 257 1.1 riastrad int qxl_release_reserve_list(struct qxl_release *release, bool no_intr) 258 1.1 riastrad { 259 1.1 riastrad int ret; 260 1.1 riastrad struct qxl_bo_list *entry; 261 1.1 riastrad 262 1.1 riastrad /* if only one object on the release its the release itself 263 1.1 riastrad since these objects are pinned no need to reserve */ 264 1.1 riastrad if (list_is_singular(&release->bos)) 265 1.1 riastrad return 0; 266 1.1 riastrad 267 1.2 riastrad ret = ttm_eu_reserve_buffers(&release->ticket, &release->bos, 268 1.2 riastrad !no_intr, NULL); 269 1.1 riastrad if (ret) 270 1.1 riastrad return ret; 271 1.1 riastrad 272 1.1 riastrad list_for_each_entry(entry, &release->bos, tv.head) { 273 1.1 riastrad struct qxl_bo *bo = to_qxl_bo(entry->tv.bo); 274 1.1 riastrad 275 1.1 riastrad ret = qxl_release_validate_bo(bo); 276 1.1 riastrad if (ret) { 277 1.1 riastrad ttm_eu_backoff_reservation(&release->ticket, &release->bos); 278 1.1 riastrad return ret; 279 1.1 riastrad } 280 1.1 riastrad } 281 1.1 riastrad return 0; 282 1.1 riastrad } 283 1.1 riastrad 284 1.1 riastrad void qxl_release_backoff_reserve_list(struct qxl_release *release) 285 1.1 riastrad { 286 1.1 riastrad /* if only one object on the release its the release itself 287 1.1 riastrad since these objects are pinned no need to reserve */ 288 1.1 riastrad if (list_is_singular(&release->bos)) 289 1.1 riastrad return; 290 1.1 riastrad 291 1.1 riastrad ttm_eu_backoff_reservation(&release->ticket, &release->bos); 292 1.1 riastrad } 293 1.1 riastrad 294 1.1 riastrad int qxl_alloc_surface_release_reserved(struct qxl_device *qdev, 295 1.1 riastrad enum qxl_surface_cmd_type surface_cmd_type, 296 1.1 riastrad struct qxl_release *create_rel, 297 1.1 riastrad struct qxl_release **release) 298 1.1 riastrad { 299 1.1 riastrad if (surface_cmd_type == QXL_SURFACE_CMD_DESTROY && create_rel) { 300 1.1 riastrad int idr_ret; 301 1.1 riastrad struct qxl_bo *bo; 302 1.1 riastrad union qxl_release_info *info; 303 1.1 riastrad 304 1.1 riastrad /* stash the release after the create command */ 305 1.1 riastrad idr_ret = qxl_release_alloc(qdev, QXL_RELEASE_SURFACE_CMD, release); 306 1.2 riastrad if (idr_ret < 0) 307 1.2 riastrad return idr_ret; 308 1.3 riastrad bo = create_rel->release_bo; 309 1.1 riastrad 310 1.3 riastrad (*release)->release_bo = bo; 311 1.1 riastrad (*release)->release_offset = create_rel->release_offset + 64; 312 1.1 riastrad 313 1.1 riastrad qxl_release_list_add(*release, bo); 314 1.1 riastrad 315 1.1 riastrad info = qxl_release_map(qdev, *release); 316 1.1 riastrad info->id = idr_ret; 317 1.1 riastrad qxl_release_unmap(qdev, *release, info); 318 1.1 riastrad return 0; 319 1.1 riastrad } 320 1.1 riastrad 321 1.1 riastrad return qxl_alloc_release_reserved(qdev, sizeof(struct qxl_surface_cmd), 322 1.1 riastrad QXL_RELEASE_SURFACE_CMD, release, NULL); 323 1.1 riastrad } 324 1.1 riastrad 325 1.1 riastrad int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size, 326 1.1 riastrad int type, struct qxl_release **release, 327 1.1 riastrad struct qxl_bo **rbo) 328 1.1 riastrad { 329 1.1 riastrad struct qxl_bo *bo; 330 1.1 riastrad int idr_ret; 331 1.1 riastrad int ret = 0; 332 1.1 riastrad union qxl_release_info *info; 333 1.1 riastrad int cur_idx; 334 1.1 riastrad 335 1.1 riastrad if (type == QXL_RELEASE_DRAWABLE) 336 1.1 riastrad cur_idx = 0; 337 1.1 riastrad else if (type == QXL_RELEASE_SURFACE_CMD) 338 1.1 riastrad cur_idx = 1; 339 1.1 riastrad else if (type == QXL_RELEASE_CURSOR_CMD) 340 1.1 riastrad cur_idx = 2; 341 1.1 riastrad else { 342 1.1 riastrad DRM_ERROR("got illegal type: %d\n", type); 343 1.1 riastrad return -EINVAL; 344 1.1 riastrad } 345 1.1 riastrad 346 1.1 riastrad idr_ret = qxl_release_alloc(qdev, type, release); 347 1.2 riastrad if (idr_ret < 0) { 348 1.2 riastrad if (rbo) 349 1.2 riastrad *rbo = NULL; 350 1.2 riastrad return idr_ret; 351 1.2 riastrad } 352 1.1 riastrad 353 1.1 riastrad mutex_lock(&qdev->release_mutex); 354 1.1 riastrad if (qdev->current_release_bo_offset[cur_idx] + 1 >= releases_per_bo[cur_idx]) { 355 1.1 riastrad qxl_bo_unref(&qdev->current_release_bo[cur_idx]); 356 1.1 riastrad qdev->current_release_bo_offset[cur_idx] = 0; 357 1.1 riastrad qdev->current_release_bo[cur_idx] = NULL; 358 1.1 riastrad } 359 1.1 riastrad if (!qdev->current_release_bo[cur_idx]) { 360 1.1 riastrad ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]); 361 1.1 riastrad if (ret) { 362 1.1 riastrad mutex_unlock(&qdev->release_mutex); 363 1.2 riastrad qxl_release_free(qdev, *release); 364 1.1 riastrad return ret; 365 1.1 riastrad } 366 1.1 riastrad } 367 1.1 riastrad 368 1.1 riastrad bo = qxl_bo_ref(qdev->current_release_bo[cur_idx]); 369 1.1 riastrad 370 1.3 riastrad (*release)->release_bo = bo; 371 1.1 riastrad (*release)->release_offset = qdev->current_release_bo_offset[cur_idx] * release_size_per_bo[cur_idx]; 372 1.1 riastrad qdev->current_release_bo_offset[cur_idx]++; 373 1.1 riastrad 374 1.1 riastrad if (rbo) 375 1.1 riastrad *rbo = bo; 376 1.1 riastrad 377 1.1 riastrad mutex_unlock(&qdev->release_mutex); 378 1.1 riastrad 379 1.2 riastrad ret = qxl_release_list_add(*release, bo); 380 1.2 riastrad qxl_bo_unref(&bo); 381 1.2 riastrad if (ret) { 382 1.2 riastrad qxl_release_free(qdev, *release); 383 1.2 riastrad return ret; 384 1.2 riastrad } 385 1.1 riastrad 386 1.1 riastrad info = qxl_release_map(qdev, *release); 387 1.1 riastrad info->id = idr_ret; 388 1.1 riastrad qxl_release_unmap(qdev, *release, info); 389 1.1 riastrad 390 1.1 riastrad return ret; 391 1.1 riastrad } 392 1.1 riastrad 393 1.1 riastrad struct qxl_release *qxl_release_from_id_locked(struct qxl_device *qdev, 394 1.1 riastrad uint64_t id) 395 1.1 riastrad { 396 1.1 riastrad struct qxl_release *release; 397 1.1 riastrad 398 1.1 riastrad spin_lock(&qdev->release_idr_lock); 399 1.1 riastrad release = idr_find(&qdev->release_idr, id); 400 1.1 riastrad spin_unlock(&qdev->release_idr_lock); 401 1.1 riastrad if (!release) { 402 1.1 riastrad DRM_ERROR("failed to find id in release_idr\n"); 403 1.1 riastrad return NULL; 404 1.1 riastrad } 405 1.1 riastrad 406 1.1 riastrad return release; 407 1.1 riastrad } 408 1.1 riastrad 409 1.1 riastrad union qxl_release_info *qxl_release_map(struct qxl_device *qdev, 410 1.1 riastrad struct qxl_release *release) 411 1.1 riastrad { 412 1.1 riastrad void *ptr; 413 1.1 riastrad union qxl_release_info *info; 414 1.3 riastrad struct qxl_bo *bo = release->release_bo; 415 1.1 riastrad 416 1.3 riastrad ptr = qxl_bo_kmap_atomic_page(qdev, bo, release->release_offset & PAGE_MASK); 417 1.1 riastrad if (!ptr) 418 1.1 riastrad return NULL; 419 1.3 riastrad info = ptr + (release->release_offset & ~PAGE_MASK); 420 1.1 riastrad return info; 421 1.1 riastrad } 422 1.1 riastrad 423 1.1 riastrad void qxl_release_unmap(struct qxl_device *qdev, 424 1.1 riastrad struct qxl_release *release, 425 1.1 riastrad union qxl_release_info *info) 426 1.1 riastrad { 427 1.3 riastrad struct qxl_bo *bo = release->release_bo; 428 1.1 riastrad void *ptr; 429 1.1 riastrad 430 1.3 riastrad ptr = ((void *)info) - (release->release_offset & ~PAGE_MASK); 431 1.1 riastrad qxl_bo_kunmap_atomic_page(qdev, bo, ptr); 432 1.1 riastrad } 433 1.1 riastrad 434 1.1 riastrad void qxl_release_fence_buffer_objects(struct qxl_release *release) 435 1.1 riastrad { 436 1.1 riastrad struct ttm_buffer_object *bo; 437 1.1 riastrad struct ttm_bo_device *bdev; 438 1.2 riastrad struct ttm_validate_buffer *entry; 439 1.2 riastrad struct qxl_device *qdev; 440 1.1 riastrad 441 1.1 riastrad /* if only one object on the release its the release itself 442 1.1 riastrad since these objects are pinned no need to reserve */ 443 1.2 riastrad if (list_is_singular(&release->bos) || list_empty(&release->bos)) 444 1.1 riastrad return; 445 1.1 riastrad 446 1.1 riastrad bo = list_first_entry(&release->bos, struct ttm_validate_buffer, head)->bo; 447 1.1 riastrad bdev = bo->bdev; 448 1.2 riastrad qdev = container_of(bdev, struct qxl_device, mman.bdev); 449 1.2 riastrad 450 1.2 riastrad /* 451 1.2 riastrad * Since we never really allocated a context and we don't want to conflict, 452 1.2 riastrad * set the highest bits. This will break if we really allow exporting of dma-bufs. 453 1.2 riastrad */ 454 1.3 riastrad dma_fence_init(&release->base, &qxl_fence_ops, &qdev->release_lock, 455 1.3 riastrad release->id | 0xf0000000, release->base.seqno); 456 1.3 riastrad trace_dma_fence_emit(&release->base); 457 1.1 riastrad 458 1.3 riastrad spin_lock(&ttm_bo_glob.lru_lock); 459 1.1 riastrad 460 1.1 riastrad list_for_each_entry(entry, &release->bos, head) { 461 1.1 riastrad bo = entry->bo; 462 1.1 riastrad 463 1.3 riastrad dma_resv_add_shared_fence(bo->base.resv, &release->base); 464 1.3 riastrad ttm_bo_move_to_lru_tail(bo, NULL); 465 1.3 riastrad dma_resv_unlock(bo->base.resv); 466 1.1 riastrad } 467 1.3 riastrad spin_unlock(&ttm_bo_glob.lru_lock); 468 1.1 riastrad ww_acquire_fini(&release->ticket); 469 1.1 riastrad } 470 1.1 riastrad 471