Subversion Repositories Kolibri OS

Rev

Rev 4075 | Rev 5271 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4075 Rev 5078
Line 22... Line 22...
22
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
24
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 *
25
 *
26
 **************************************************************************/
26
 **************************************************************************/
27
struct ww_acquire_ctx{};
-
 
Line 28... Line 27...
28
 
27
 
29
#include 
28
#include 
30
#include 
29
#include 
31
#include 
30
#include 
32
#include 
31
#include 
33
#include 
32
#include 
Line -... Line 33...
-
 
33
#include 
-
 
34
 
34
#include 
35
DEFINE_WW_CLASS(reservation_ww_class);
35
 
-
 
36
static void ttm_eu_backoff_reservation_locked(struct list_head *list,
36
 
37
					      struct ww_acquire_ctx *ticket)
37
static void ttm_eu_backoff_reservation_locked(struct list_head *list)
Line 38... Line 38...
38
{
38
{
39
	struct ttm_validate_buffer *entry;
39
	struct ttm_validate_buffer *entry;
Line 46... Line 46...
46
		entry->reserved = false;
46
		entry->reserved = false;
47
		if (entry->removed) {
47
		if (entry->removed) {
48
			ttm_bo_add_to_lru(bo);
48
			ttm_bo_add_to_lru(bo);
49
			entry->removed = false;
49
			entry->removed = false;
50
		}
50
		}
51
//       ww_mutex_unlock(&bo->resv->lock);
51
		__ttm_bo_unreserve(bo);
52
	}
52
	}
53
}
53
}
Line 54... Line 54...
54
 
54
 
55
static void ttm_eu_del_from_lru_locked(struct list_head *list)
55
static void ttm_eu_del_from_lru_locked(struct list_head *list)
Line 92... Line 92...
92
		return;
92
		return;
Line 93... Line 93...
93
 
93
 
94
	entry = list_first_entry(list, struct ttm_validate_buffer, head);
94
	entry = list_first_entry(list, struct ttm_validate_buffer, head);
95
	glob = entry->bo->glob;
95
	glob = entry->bo->glob;
96
	spin_lock(&glob->lru_lock);
96
	spin_lock(&glob->lru_lock);
-
 
97
	ttm_eu_backoff_reservation_locked(list);
97
	ttm_eu_backoff_reservation_locked(list, ticket);
98
	if (ticket)
98
//   ww_acquire_fini(ticket);
99
		ww_acquire_fini(ticket);
99
	spin_unlock(&glob->lru_lock);
100
	spin_unlock(&glob->lru_lock);
100
}
101
}
Line 101... Line 102...
101
EXPORT_SYMBOL(ttm_eu_backoff_reservation);
102
EXPORT_SYMBOL(ttm_eu_backoff_reservation);
Line 129... Line 130...
129
	}
130
	}
Line 130... Line 131...
130
 
131
 
131
	entry = list_first_entry(list, struct ttm_validate_buffer, head);
132
	entry = list_first_entry(list, struct ttm_validate_buffer, head);
Line -... Line 133...
-
 
133
	glob = entry->bo->glob;
132
	glob = entry->bo->glob;
134
 
133
 
135
	if (ticket)
134
//   ww_acquire_init(ticket, &reservation_ww_class);
136
		ww_acquire_init(ticket, &reservation_ww_class);
135
retry:
137
retry:
Line 136... Line 138...
136
	list_for_each_entry(entry, list, head) {
138
	list_for_each_entry(entry, list, head) {
137
		struct ttm_buffer_object *bo = entry->bo;
139
		struct ttm_buffer_object *bo = entry->bo;
138
 
140
 
Line 139... Line -...
139
		/* already slowpath reserved? */
-
 
140
		if (entry->reserved)
141
		/* already slowpath reserved? */
-
 
142
		if (entry->reserved)
Line 141... Line 143...
141
			continue;
143
			continue;
142
 
144
 
143
 
145
		ret = __ttm_bo_reserve(bo, true, (ticket == NULL), true,
144
		ret = ttm_bo_reserve_nolru(bo, true, false, true, ticket);
146
				       ticket);
145
 
147
 
-
 
148
		if (ret == -EDEADLK) {
146
		if (ret == -EDEADLK) {
149
			/* uh oh, we lost out, drop every reservation and try
147
			/* uh oh, we lost out, drop every reservation and try
150
			 * to only reserve this buffer, then start over if
148
			 * to only reserve this buffer, then start over if
151
			 * this succeeds.
149
			 * this succeeds.
152
			 */
150
			 */
153
			BUG_ON(ticket == NULL);
151
			spin_lock(&glob->lru_lock);
154
			spin_lock(&glob->lru_lock);
152
			ttm_eu_backoff_reservation_locked(list, ticket);
155
			ttm_eu_backoff_reservation_locked(list);
153
			spin_unlock(&glob->lru_lock);
156
			spin_unlock(&glob->lru_lock);
154
			ttm_eu_list_ref_sub(list);
157
			ttm_eu_list_ref_sub(list);
155
  //         ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
158
			ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
156
  //                                ticket);
159
							       ticket);
Line 174... Line 177...
174
			ret = -EBUSY;
177
			ret = -EBUSY;
175
			goto err;
178
			goto err;
176
		}
179
		}
177
	}
180
	}
Line -... Line 181...
-
 
181
 
178
 
182
	if (ticket)
179
//   ww_acquire_done(ticket);
183
		ww_acquire_done(ticket);
180
	spin_lock(&glob->lru_lock);
184
	spin_lock(&glob->lru_lock);
181
	ttm_eu_del_from_lru_locked(list);
185
	ttm_eu_del_from_lru_locked(list);
182
	spin_unlock(&glob->lru_lock);
186
	spin_unlock(&glob->lru_lock);
183
	ttm_eu_list_ref_sub(list);
187
	ttm_eu_list_ref_sub(list);
Line 184... Line 188...
184
	return 0;
188
	return 0;
185
 
189
 
186
err:
190
err:
187
	spin_lock(&glob->lru_lock);
191
	spin_lock(&glob->lru_lock);
188
	ttm_eu_backoff_reservation_locked(list, ticket);
192
	ttm_eu_backoff_reservation_locked(list);
189
	spin_unlock(&glob->lru_lock);
193
	spin_unlock(&glob->lru_lock);
-
 
194
	ttm_eu_list_ref_sub(list);
190
	ttm_eu_list_ref_sub(list);
195
err_fini:
191
err_fini:
196
	if (ticket) {
-
 
197
		ww_acquire_done(ticket);
192
//   ww_acquire_done(ticket);
198
		ww_acquire_fini(ticket);
193
//   ww_acquire_fini(ticket);
199
	}
194
	return ret;
200
	return ret;
Line 195... Line 201...
195
}
201
}
Line 218... Line 224...
218
	list_for_each_entry(entry, list, head) {
224
	list_for_each_entry(entry, list, head) {
219
		bo = entry->bo;
225
		bo = entry->bo;
220
		entry->old_sync_obj = bo->sync_obj;
226
		entry->old_sync_obj = bo->sync_obj;
221
		bo->sync_obj = driver->sync_obj_ref(sync_obj);
227
		bo->sync_obj = driver->sync_obj_ref(sync_obj);
222
		ttm_bo_add_to_lru(bo);
228
		ttm_bo_add_to_lru(bo);
223
//       ww_mutex_unlock(&bo->resv->lock);
229
		__ttm_bo_unreserve(bo);
224
		entry->reserved = false;
230
		entry->reserved = false;
225
	}
231
	}
226
	spin_unlock(&bdev->fence_lock);
232
	spin_unlock(&bdev->fence_lock);
227
	spin_unlock(&glob->lru_lock);
233
	spin_unlock(&glob->lru_lock);
-
 
234
	if (ticket)
228
//   ww_acquire_fini(ticket);
235
		ww_acquire_fini(ticket);
Line 229... Line 236...
229
 
236
 
230
	list_for_each_entry(entry, list, head) {
237
	list_for_each_entry(entry, list, head) {
231
		if (entry->old_sync_obj)
238
		if (entry->old_sync_obj)
232
			driver->sync_obj_unref(&entry->old_sync_obj);
239
			driver->sync_obj_unref(&entry->old_sync_obj);