diff options
| -rw-r--r-- | drivers/gpu/drm/ttm/ttm_execbuf_util.c | 32 | ||||
| -rw-r--r-- | include/drm/ttm/ttm_execbuf_util.h | 3 |
2 files changed, 21 insertions, 14 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c index 6c911789ae5c..479e9418e3d7 100644 --- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c +++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c | |||
| @@ -32,8 +32,7 @@ | |||
| 32 | #include <linux/sched.h> | 32 | #include <linux/sched.h> |
| 33 | #include <linux/module.h> | 33 | #include <linux/module.h> |
| 34 | 34 | ||
| 35 | static void ttm_eu_backoff_reservation_locked(struct list_head *list, | 35 | static void ttm_eu_backoff_reservation_locked(struct list_head *list) |
| 36 | struct ww_acquire_ctx *ticket) | ||
| 37 | { | 36 | { |
| 38 | struct ttm_validate_buffer *entry; | 37 | struct ttm_validate_buffer *entry; |
| 39 | 38 | ||
| @@ -93,8 +92,9 @@ void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, | |||
| 93 | entry = list_first_entry(list, struct ttm_validate_buffer, head); | 92 | entry = list_first_entry(list, struct ttm_validate_buffer, head); |
| 94 | glob = entry->bo->glob; | 93 | glob = entry->bo->glob; |
| 95 | spin_lock(&glob->lru_lock); | 94 | spin_lock(&glob->lru_lock); |
| 96 | ttm_eu_backoff_reservation_locked(list, ticket); | 95 | ttm_eu_backoff_reservation_locked(list); |
| 97 | ww_acquire_fini(ticket); | 96 | if (ticket) |
| 97 | ww_acquire_fini(ticket); | ||
| 98 | spin_unlock(&glob->lru_lock); | 98 | spin_unlock(&glob->lru_lock); |
| 99 | } | 99 | } |
| 100 | EXPORT_SYMBOL(ttm_eu_backoff_reservation); | 100 | EXPORT_SYMBOL(ttm_eu_backoff_reservation); |
| @@ -130,7 +130,8 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, | |||
| 130 | entry = list_first_entry(list, struct ttm_validate_buffer, head); | 130 | entry = list_first_entry(list, struct ttm_validate_buffer, head); |
| 131 | glob = entry->bo->glob; | 131 | glob = entry->bo->glob; |
| 132 | 132 | ||
| 133 | ww_acquire_init(ticket, &reservation_ww_class); | 133 | if (ticket) |
| 134 | ww_acquire_init(ticket, &reservation_ww_class); | ||
| 134 | retry: | 135 | retry: |
| 135 | list_for_each_entry(entry, list, head) { | 136 | list_for_each_entry(entry, list, head) { |
| 136 | struct ttm_buffer_object *bo = entry->bo; | 137 | struct ttm_buffer_object *bo = entry->bo; |
| @@ -139,16 +140,17 @@ retry: | |||
| 139 | if (entry->reserved) | 140 | if (entry->reserved) |
| 140 | continue; | 141 | continue; |
| 141 | 142 | ||
| 142 | 143 | ret = ttm_bo_reserve_nolru(bo, true, (ticket == NULL), true, | |
| 143 | ret = ttm_bo_reserve_nolru(bo, true, false, true, ticket); | 144 | ticket); |
| 144 | 145 | ||
| 145 | if (ret == -EDEADLK) { | 146 | if (ret == -EDEADLK) { |
| 146 | /* uh oh, we lost out, drop every reservation and try | 147 | /* uh oh, we lost out, drop every reservation and try |
| 147 | * to only reserve this buffer, then start over if | 148 | * to only reserve this buffer, then start over if |
| 148 | * this succeeds. | 149 | * this succeeds. |
| 149 | */ | 150 | */ |
| 151 | BUG_ON(ticket == NULL); | ||
| 150 | spin_lock(&glob->lru_lock); | 152 | spin_lock(&glob->lru_lock); |
| 151 | ttm_eu_backoff_reservation_locked(list, ticket); | 153 | ttm_eu_backoff_reservation_locked(list); |
| 152 | spin_unlock(&glob->lru_lock); | 154 | spin_unlock(&glob->lru_lock); |
| 153 | ttm_eu_list_ref_sub(list); | 155 | ttm_eu_list_ref_sub(list); |
| 154 | ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, | 156 | ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock, |
| @@ -175,7 +177,8 @@ retry: | |||
| 175 | } | 177 | } |
| 176 | } | 178 | } |
| 177 | 179 | ||
| 178 | ww_acquire_done(ticket); | 180 | if (ticket) |
| 181 | ww_acquire_done(ticket); | ||
| 179 | spin_lock(&glob->lru_lock); | 182 | spin_lock(&glob->lru_lock); |
| 180 | ttm_eu_del_from_lru_locked(list); | 183 | ttm_eu_del_from_lru_locked(list); |
| 181 | spin_unlock(&glob->lru_lock); | 184 | spin_unlock(&glob->lru_lock); |
| @@ -184,12 +187,14 @@ retry: | |||
| 184 | 187 | ||
| 185 | err: | 188 | err: |
| 186 | spin_lock(&glob->lru_lock); | 189 | spin_lock(&glob->lru_lock); |
| 187 | ttm_eu_backoff_reservation_locked(list, ticket); | 190 | ttm_eu_backoff_reservation_locked(list); |
| 188 | spin_unlock(&glob->lru_lock); | 191 | spin_unlock(&glob->lru_lock); |
| 189 | ttm_eu_list_ref_sub(list); | 192 | ttm_eu_list_ref_sub(list); |
| 190 | err_fini: | 193 | err_fini: |
| 191 | ww_acquire_done(ticket); | 194 | if (ticket) { |
| 192 | ww_acquire_fini(ticket); | 195 | ww_acquire_done(ticket); |
| 196 | ww_acquire_fini(ticket); | ||
| 197 | } | ||
| 193 | return ret; | 198 | return ret; |
| 194 | } | 199 | } |
| 195 | EXPORT_SYMBOL(ttm_eu_reserve_buffers); | 200 | EXPORT_SYMBOL(ttm_eu_reserve_buffers); |
| @@ -224,7 +229,8 @@ void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, | |||
| 224 | } | 229 | } |
| 225 | spin_unlock(&bdev->fence_lock); | 230 | spin_unlock(&bdev->fence_lock); |
| 226 | spin_unlock(&glob->lru_lock); | 231 | spin_unlock(&glob->lru_lock); |
| 227 | ww_acquire_fini(ticket); | 232 | if (ticket) |
| 233 | ww_acquire_fini(ticket); | ||
| 228 | 234 | ||
| 229 | list_for_each_entry(entry, list, head) { | 235 | list_for_each_entry(entry, list, head) { |
| 230 | if (entry->old_sync_obj) | 236 | if (entry->old_sync_obj) |
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h index ec8a1d306510..16db7d01a336 100644 --- a/include/drm/ttm/ttm_execbuf_util.h +++ b/include/drm/ttm/ttm_execbuf_util.h | |||
| @@ -70,7 +70,8 @@ extern void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, | |||
| 70 | /** | 70 | /** |
| 71 | * function ttm_eu_reserve_buffers | 71 | * function ttm_eu_reserve_buffers |
| 72 | * | 72 | * |
| 73 | * @ticket: [out] ww_acquire_ctx returned by call. | 73 | * @ticket: [out] ww_acquire_ctx filled in by call, or NULL if only |
| 74 | * non-blocking reserves should be tried. | ||
| 74 | * @list: thread private list of ttm_validate_buffer structs. | 75 | * @list: thread private list of ttm_validate_buffer structs. |
| 75 | * | 76 | * |
| 76 | * Tries to reserve bos pointed to by the list entries for validation. | 77 | * Tries to reserve bos pointed to by the list entries for validation. |
