Subversion Repositories Kolibri OS

Rev

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

Rev 4112 Rev 4569
Line 185... Line 185...
185
		list_del_init(&bo->io_reserve_lru);
185
		list_del_init(&bo->io_reserve_lru);
186
		ttm_mem_io_free(bo->bdev, mem);
186
		ttm_mem_io_free(bo->bdev, mem);
187
	}
187
	}
188
}
188
}
Line 189... Line 189...
189
 
189
 
190
int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
190
static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
191
			void **virtual)
191
			void **virtual)
192
{
192
{
193
	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
193
	struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];
194
	int ret;
194
	int ret;
Line 217... Line 217...
217
	}
217
	}
218
	*virtual = addr;
218
	*virtual = addr;
219
	return 0;
219
	return 0;
220
}
220
}
Line 221... Line 221...
221
 
221
 
222
void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
222
static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem,
223
			 void *virtual)
223
			 void *virtual)
224
{
224
{
Line 225... Line 225...
225
	struct ttm_mem_type_manager *man;
225
	struct ttm_mem_type_manager *man;
Line 341... Line 341...
341
		return ret;
341
		return ret;
342
	ret = ttm_mem_reg_ioremap(bdev, new_mem, &new_iomap);
342
	ret = ttm_mem_reg_ioremap(bdev, new_mem, &new_iomap);
343
	if (ret)
343
	if (ret)
344
		goto out;
344
		goto out;
Line -... Line 345...
-
 
345
 
-
 
346
	/*
-
 
347
	 * Single TTM move. NOP.
345
 
348
	 */
346
	if (old_iomap == NULL && new_iomap == NULL)
349
	if (old_iomap == NULL && new_iomap == NULL)
-
 
350
		goto out2;
-
 
351
 
-
 
352
	/*
-
 
353
	 * Don't move nonexistent data. Clear destination instead.
347
		goto out2;
354
	 */
348
	if (old_iomap == NULL && ttm == NULL)
355
	if (old_iomap == NULL && ttm == NULL)
Line -... Line 356...
-
 
356
		goto out2;
-
 
357
 
-
 
358
	/*
349
		goto out2;
359
	 * TTM might be null for moves within the same region.
350
 
360
	 */
351
	if (ttm->state == tt_unpopulated) {
361
	if (ttm && ttm->state == tt_unpopulated) {
352
		ret = ttm->bdev->driver->ttm_tt_populate(ttm);
-
 
353
		if (ret) {
-
 
354
			/* if we fail here don't nuke the mm node
-
 
355
			 * as the bo still owns it */
362
		ret = ttm->bdev->driver->ttm_tt_populate(ttm);
356
			old_copy.mm_node = NULL;
363
		if (ret)
357
			goto out1;
-
 
Line 358... Line 364...
358
		}
364
			goto out1;
359
	}
365
		}
Line 360... Line 366...
360
 
366
 
Line 379... Line 385...
379
						    PAGE_KERNEL);
385
						    PAGE_KERNEL);
380
			ret = ttm_copy_io_ttm_page(ttm, old_iomap, page,
386
			ret = ttm_copy_io_ttm_page(ttm, old_iomap, page,
381
						   prot);
387
						   prot);
382
		} else
388
		} else
383
			ret = ttm_copy_io_page(new_iomap, old_iomap, page);
389
			ret = ttm_copy_io_page(new_iomap, old_iomap, page);
384
		if (ret) {
390
		if (ret)
385
			/* failing here, means keep old copy as-is */
-
 
386
			old_copy.mm_node = NULL;
-
 
387
			goto out1;
391
			goto out1;
388
		}
392
		}
389
	}
-
 
390
	mb();
393
	mb();
391
out2:
394
out2:
392
	old_copy = *old_mem;
395
	old_copy = *old_mem;
393
	*old_mem = *new_mem;
396
	*old_mem = *new_mem;
394
	new_mem->mm_node = NULL;
397
	new_mem->mm_node = NULL;
Line 401... Line 404...
401
 
404
 
402
out1:
405
out1:
403
	ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
406
	ttm_mem_reg_iounmap(bdev, old_mem, new_iomap);
404
out:
407
out:
-
 
408
	ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
-
 
409
 
-
 
410
	/*
-
 
411
	 * On error, keep the mm node!
-
 
412
	 */
405
	ttm_mem_reg_iounmap(bdev, &old_copy, old_iomap);
413
	if (!ret)
406
	ttm_bo_mem_put(bo, &old_copy);
414
	ttm_bo_mem_put(bo, &old_copy);
407
	return ret;
415
	return ret;
408
}
416
}
Line 580... Line 588...
580
	if (num_pages > bo->num_pages)
588
	if (num_pages > bo->num_pages)
581
		return -EINVAL;
589
		return -EINVAL;
582
	if (start_page > bo->num_pages)
590
	if (start_page > bo->num_pages)
583
		return -EINVAL;
591
		return -EINVAL;
584
#if 0
592
#if 0
585
	if (num_pages > 1 && !DRM_SUSER(DRM_CURPROC))
593
	if (num_pages > 1 && !capable(CAP_SYS_ADMIN))
586
		return -EPERM;
594
		return -EPERM;
587
#endif
595
#endif
588
	(void) ttm_mem_io_lock(man, false);
596
	(void) ttm_mem_io_lock(man, false);
589
	ret = ttm_mem_io_reserve(bo->bdev, &bo->mem);
597
	ret = ttm_mem_io_reserve(bo->bdev, &bo->mem);
590
	ttm_mem_io_unlock(man);
598
	ttm_mem_io_unlock(man);