Subversion Repositories Kolibri OS

Rev

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

Rev 1179 Rev 1404
Line 167... Line 167...
167
 
167
 
168
	if (rdev->ib_pool.robj)
168
	if (rdev->ib_pool.robj)
169
		return 0;
169
		return 0;
170
	/* Allocate 1M object buffer */
170
	/* Allocate 1M object buffer */
171
	INIT_LIST_HEAD(&rdev->ib_pool.scheduled_ibs);
171
	INIT_LIST_HEAD(&rdev->ib_pool.scheduled_ibs);
172
	r = radeon_object_create(rdev, NULL,  RADEON_IB_POOL_SIZE*64*1024,
172
	r = radeon_bo_create(rdev, NULL,  RADEON_IB_POOL_SIZE*64*1024,
173
				 true, RADEON_GEM_DOMAIN_GTT,
173
				 true, RADEON_GEM_DOMAIN_GTT,
174
				 false, &rdev->ib_pool.robj);
174
				&rdev->ib_pool.robj);
175
	if (r) {
175
	if (r) {
176
		DRM_ERROR("radeon: failed to ib pool (%d).\n", r);
176
		DRM_ERROR("radeon: failed to ib pool (%d).\n", r);
177
		return r;
177
		return r;
-
 
178
	}
-
 
179
	r = radeon_bo_reserve(rdev->ib_pool.robj, false);
-
 
180
	if (unlikely(r != 0))
178
	}
181
		return r;
179
	r = radeon_object_pin(rdev->ib_pool.robj, RADEON_GEM_DOMAIN_GTT, &gpu_addr);
182
	r = radeon_bo_pin(rdev->ib_pool.robj, RADEON_GEM_DOMAIN_GTT, &gpu_addr);
-
 
183
	if (r) {
180
	if (r) {
184
		radeon_bo_unreserve(rdev->ib_pool.robj);
181
		DRM_ERROR("radeon: failed to pin ib pool (%d).\n", r);
185
		DRM_ERROR("radeon: failed to pin ib pool (%d).\n", r);
182
		return r;
186
		return r;
183
	}
187
	}
-
 
188
	r = radeon_bo_kmap(rdev->ib_pool.robj, &ptr);
184
	r = radeon_object_kmap(rdev->ib_pool.robj, &ptr);
189
	radeon_bo_unreserve(rdev->ib_pool.robj);
185
	if (r) {
190
	if (r) {
186
		DRM_ERROR("radeon: failed to map ib poll (%d).\n", r);
191
		DRM_ERROR("radeon: failed to map ib poll (%d).\n", r);
187
		return r;
192
		return r;
188
	}
193
	}
Line 205... Line 210...
205
	return r;
210
	return r;
206
}
211
}
Line 207... Line 212...
207
 
212
 
208
void radeon_ib_pool_fini(struct radeon_device *rdev)
213
void radeon_ib_pool_fini(struct radeon_device *rdev)
-
 
214
{
-
 
215
	int r;
209
{
216
 
210
	if (!rdev->ib_pool.ready) {
217
	if (!rdev->ib_pool.ready) {
211
		return;
218
		return;
212
	}
219
	}
213
	mutex_lock(&rdev->ib_pool.mutex);
220
	mutex_lock(&rdev->ib_pool.mutex);
214
	bitmap_zero(rdev->ib_pool.alloc_bm, RADEON_IB_POOL_SIZE);
221
	bitmap_zero(rdev->ib_pool.alloc_bm, RADEON_IB_POOL_SIZE);
-
 
222
	if (rdev->ib_pool.robj) {
-
 
223
		r = radeon_bo_reserve(rdev->ib_pool.robj, false);
215
	if (rdev->ib_pool.robj) {
224
		if (likely(r == 0)) {
-
 
225
			radeon_bo_kunmap(rdev->ib_pool.robj);
-
 
226
			radeon_bo_unpin(rdev->ib_pool.robj);
-
 
227
			radeon_bo_unreserve(rdev->ib_pool.robj);
216
//       radeon_object_kunmap(rdev->ib_pool.robj);
228
		}
217
//       radeon_object_unref(&rdev->ib_pool.robj);
229
		radeon_bo_unref(&rdev->ib_pool.robj);
218
		rdev->ib_pool.robj = NULL;
230
		rdev->ib_pool.robj = NULL;
219
	}
231
	}
220
	mutex_unlock(&rdev->ib_pool.mutex);
232
	mutex_unlock(&rdev->ib_pool.mutex);
Line 292... Line 304...
292
    ENTER();
304
    ENTER();
Line 293... Line 305...
293
 
305
 
294
	rdev->cp.ring_size = ring_size;
306
	rdev->cp.ring_size = ring_size;
295
    /* Allocate ring buffer */
307
    /* Allocate ring buffer */
296
	if (rdev->cp.ring_obj == NULL) {
308
	if (rdev->cp.ring_obj == NULL) {
297
		r = radeon_object_create(rdev, NULL, rdev->cp.ring_size,
-
 
298
					 true,
309
		r = radeon_bo_create(rdev, NULL, rdev->cp.ring_size, true,
299
					 RADEON_GEM_DOMAIN_GTT,
-
 
300
					 false,
310
					 RADEON_GEM_DOMAIN_GTT,
301
					 &rdev->cp.ring_obj);
311
					 &rdev->cp.ring_obj);
302
		if (r) {
312
		if (r) {
303
			DRM_ERROR("radeon: failed to create ring buffer (%d).\n", r);
-
 
304
			mutex_unlock(&rdev->cp.mutex);
313
			dev_err(rdev->dev, "(%d) ring create failed\n", r);
305
			return r;
314
			return r;
306
		}
315
		}
-
 
316
		r = radeon_bo_reserve(rdev->cp.ring_obj, false);
-
 
317
		if (unlikely(r != 0))
307
		r = radeon_object_pin(rdev->cp.ring_obj,
318
			return r;
308
				      RADEON_GEM_DOMAIN_GTT,
319
		r = radeon_bo_pin(rdev->cp.ring_obj, RADEON_GEM_DOMAIN_GTT,
309
				      &rdev->cp.gpu_addr);
320
				      &rdev->cp.gpu_addr);
310
		if (r) {
321
		if (r) {
311
			DRM_ERROR("radeon: failed to pin ring buffer (%d).\n", r);
322
			radeon_bo_unreserve(rdev->cp.ring_obj);
312
			mutex_unlock(&rdev->cp.mutex);
323
			dev_err(rdev->dev, "(%d) ring pin failed\n", r);
313
			return r;
324
			return r;
314
		}
325
		}
315
		r = radeon_object_kmap(rdev->cp.ring_obj,
326
		r = radeon_bo_kmap(rdev->cp.ring_obj,
-
 
327
				       (void **)&rdev->cp.ring);
316
				       (void **)&rdev->cp.ring);
328
		radeon_bo_unreserve(rdev->cp.ring_obj);
317
		if (r) {
329
		if (r) {
318
			DRM_ERROR("radeon: failed to map ring buffer (%d).\n", r);
-
 
319
			mutex_unlock(&rdev->cp.mutex);
330
			dev_err(rdev->dev, "(%d) ring map failed\n", r);
320
			return r;
331
			return r;
321
		}
332
		}
322
	}
-
 
323
 
-
 
324
 
-
 
325
//    rdev->cp.ring  = CreateRingBuffer( ring_size, PG_SW );
-
 
326
 
-
 
327
    dbgprintf("ring buffer %x\n", rdev->cp.ring );
-
 
328
 
-
 
329
//    rdev->cp.gpu_addr = rdev->mc.gtt_location;
-
 
330
 
-
 
331
 //   u32_t *pagelist =  &((u32_t*)page_tabs)[(u32_t)rdev->cp.ring >> 12];
-
 
332
 
-
 
333
 //   dbgprintf("pagelist %x\n", pagelist);
-
 
334
 
-
 
335
 //   radeon_gart_bind(rdev, 0, ring_size / 4096, pagelist);
-
 
336
 
333
	}
337
	rdev->cp.ptr_mask = (rdev->cp.ring_size / 4) - 1;
334
	rdev->cp.ptr_mask = (rdev->cp.ring_size / 4) - 1;
Line 338... Line 335...
338
	rdev->cp.ring_free_dw = rdev->cp.ring_size / 4;
335
	rdev->cp.ring_free_dw = rdev->cp.ring_size / 4;
Line 339... Line 336...
339
 
336
 
340
    LEAVE();
337
    LEAVE();
Line 341... Line 338...
341
 
338
 
342
	return 0;
339
	return 0;
-
 
340
}
-
 
341
 
343
}
342
void radeon_ring_fini(struct radeon_device *rdev)
344
 
343
{
-
 
344
	int r;
-
 
345
 
345
void radeon_ring_fini(struct radeon_device *rdev)
346
	mutex_lock(&rdev->cp.mutex);
346
{
347
   if (rdev->cp.ring_obj) {
-
 
348
		r = radeon_bo_reserve(rdev->cp.ring_obj, false);
-
 
349
		if (likely(r == 0)) {
347
	mutex_lock(&rdev->cp.mutex);
350
			radeon_bo_kunmap(rdev->cp.ring_obj);
348
   if (rdev->cp.ring_obj) {
351
			radeon_bo_unpin(rdev->cp.ring_obj);
349
 //      radeon_object_kunmap(rdev->cp.ring_obj);
352
			radeon_bo_unreserve(rdev->cp.ring_obj);
350
 //      radeon_object_unpin(rdev->cp.ring_obj);
353
		}
351
 //      radeon_object_unref(&rdev->cp.ring_obj);
354
		radeon_bo_unref(&rdev->cp.ring_obj);
352
       rdev->cp.ring = NULL;
355
       rdev->cp.ring = NULL;