Deleted Added
full compact
ttm_bo.c (254862) ttm_bo.c (254863)
1/**************************************************************************
2 *
3 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including

--- 15 unchanged lines hidden (view full) ---

24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27/*
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */
30
31#include <sys/cdefs.h>
1/**************************************************************************
2 *
3 * Copyright (c) 2006-2009 VMware, Inc., Palo Alto, CA., USA
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including

--- 15 unchanged lines hidden (view full) ---

24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27/*
28 * Authors: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/dev/drm2/ttm/ttm_bo.c 254862 2013-08-25 14:41:22Z dumbbell $");
32__FBSDID("$FreeBSD: head/sys/dev/drm2/ttm/ttm_bo.c 254863 2013-08-25 14:47:22Z dumbbell $");
33
34#include <dev/drm2/drmP.h>
35#include <dev/drm2/ttm/ttm_module.h>
36#include <dev/drm2/ttm/ttm_bo_driver.h>
37#include <dev/drm2/ttm/ttm_placement.h>
38
39#define TTM_ASSERT_LOCKED(param)
40#define TTM_DEBUG(fmt, arg...)

--- 247 unchanged lines hidden (view full) ---

288 put_count = ttm_bo_del_from_lru(bo);
289 mtx_unlock(&glob->lru_lock);
290 ttm_bo_list_ref_sub(bo, put_count, true);
291 }
292
293 return ret;
294}
295
33
34#include <dev/drm2/drmP.h>
35#include <dev/drm2/ttm/ttm_module.h>
36#include <dev/drm2/ttm/ttm_bo_driver.h>
37#include <dev/drm2/ttm/ttm_placement.h>
38
39#define TTM_ASSERT_LOCKED(param)
40#define TTM_DEBUG(fmt, arg...)

--- 247 unchanged lines hidden (view full) ---

288 put_count = ttm_bo_del_from_lru(bo);
289 mtx_unlock(&glob->lru_lock);
290 ttm_bo_list_ref_sub(bo, put_count, true);
291 }
292
293 return ret;
294}
295
296int ttm_bo_reserve_slowpath_nolru(struct ttm_buffer_object *bo,
297 bool interruptible, uint32_t sequence)
298{
299 bool wake_up = false;
300 int ret;
301
302 while (unlikely(atomic_xchg(&bo->reserved, 1) != 0)) {
303 if (bo->seq_valid && sequence == bo->val_seq) {
304 DRM_ERROR(
305 "%s: bo->seq_valid && sequence == bo->val_seq",
306 __func__);
307 }
308
309 ret = ttm_bo_wait_unreserved_locked(bo, interruptible);
310
311 if (unlikely(ret))
312 return ret;
313 }
314
315 if ((bo->val_seq - sequence < (1 << 31)) || !bo->seq_valid)
316 wake_up = true;
317
318 /**
319 * Wake up waiters that may need to recheck for deadlock,
320 * if we decreased the sequence number.
321 */
322 bo->val_seq = sequence;
323 bo->seq_valid = true;
324 if (wake_up)
325 wakeup(bo);
326
327 return 0;
328}
329
330int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo,
331 bool interruptible, uint32_t sequence)
332{
333 struct ttm_bo_global *glob = bo->glob;
334 int put_count, ret;
335
336 ret = ttm_bo_reserve_slowpath_nolru(bo, interruptible, sequence);
337 if (likely(!ret)) {
338 mtx_lock(&glob->lru_lock);
339 put_count = ttm_bo_del_from_lru(bo);
340 mtx_unlock(&glob->lru_lock);
341 ttm_bo_list_ref_sub(bo, put_count, true);
342 }
343 return ret;
344}
345
296void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo)
297{
298 ttm_bo_add_to_lru(bo);
299 atomic_set(&bo->reserved, 0);
300 wakeup(bo);
301}
302
303void ttm_bo_unreserve(struct ttm_buffer_object *bo)

--- 1534 unchanged lines hidden ---
346void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo)
347{
348 ttm_bo_add_to_lru(bo);
349 atomic_set(&bo->reserved, 0);
350 wakeup(bo);
351}
352
353void ttm_bo_unreserve(struct ttm_buffer_object *bo)

--- 1534 unchanged lines hidden ---