Пример #1
0
static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
{
	int page_count, i;
	struct page *page;
	struct inode *inode;
	struct address_space *mapping;

	if (obj->pages)
		return 0;

	page_count = obj->base.size / PAGE_SIZE;
	BUG_ON(obj->pages != NULL);
	obj->pages = drm_malloc_ab(page_count, sizeof(struct page *));
	if (obj->pages == NULL)
		return -ENOMEM;

	inode = obj->base.filp->f_path.dentry->d_inode;
	mapping = inode->i_mapping;
	gfpmask |= mapping_gfp_mask(mapping);

	for (i = 0; i < page_count; i++) {
		page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
		if (IS_ERR(page))
			goto err_pages;
		obj->pages[i] = page;
	}

	return 0;
err_pages:
	while (i--)
		page_cache_release(obj->pages[i]);
	drm_free_large(obj->pages);
	obj->pages = NULL;
	return PTR_ERR(page);
}
Пример #2
0
int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
{
	struct address_space *swap_space;
	struct file *swap_storage;
	struct page *from_page;
	struct page *to_page;
	int i;
	int ret = -ENOMEM;

	BUG_ON(ttm->state != tt_unbound && ttm->state != tt_unpopulated);
	BUG_ON(ttm->caching_state != tt_cached);

	if (!persistent_swap_storage) {
		swap_storage = shmem_file_setup("ttm swap",
						ttm->num_pages << PAGE_SHIFT,
						0);
		if (IS_ERR(swap_storage)) {
			pr_err("Failed allocating swap storage\n");
			return PTR_ERR(swap_storage);
		}
	} else {
		swap_storage = persistent_swap_storage;
	}

	swap_space = swap_storage->f_mapping;

	for (i = 0; i < ttm->num_pages; ++i) {
		gfp_t gfp_mask = mapping_gfp_mask(swap_space);

		gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);

		from_page = ttm->pages[i];
		if (unlikely(from_page == NULL))
			continue;

		to_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask);
		if (IS_ERR(to_page)) {
			ret = PTR_ERR(to_page);
			goto out_err;
		}
		copy_highpage(to_page, from_page);
		set_page_dirty(to_page);
		mark_page_accessed(to_page);
		put_page(to_page);
	}

	ttm_tt_unpopulate(ttm);
	ttm->swap_storage = swap_storage;
	ttm->page_flags |= TTM_PAGE_FLAG_SWAPPED;
	if (persistent_swap_storage)
		ttm->page_flags |= TTM_PAGE_FLAG_PERSISTENT_SWAP;

	return 0;
out_err:
	if (!persistent_swap_storage)
		fput(swap_storage);

	return ret;
}
Пример #3
0
int ttm_tt_swapin(struct ttm_tt *ttm)
{
	struct address_space *swap_space;
	struct file *swap_storage;
	struct page *from_page;
	struct page *to_page;
	int i;
	int ret = -ENOMEM;

	swap_storage = ttm->swap_storage;
	BUG_ON(swap_storage == NULL);

	swap_space = swap_storage->f_mapping;

	for (i = 0; i < ttm->num_pages; ++i) {
		gfp_t gfp_mask = mapping_gfp_mask(swap_space);

		gfp_mask |= (ttm->page_flags & TTM_PAGE_FLAG_NO_RETRY ? __GFP_RETRY_MAYFAIL : 0);
		from_page = shmem_read_mapping_page_gfp(swap_space, i, gfp_mask);

		if (IS_ERR(from_page)) {
			ret = PTR_ERR(from_page);
			goto out_err;
		}
		to_page = ttm->pages[i];
		if (unlikely(to_page == NULL))
			goto out_err;

		copy_highpage(to_page, from_page);
		put_page(from_page);
	}

	if (!(ttm->page_flags & TTM_PAGE_FLAG_PERSISTENT_SWAP))
		fput(swap_storage);
	ttm->swap_storage = NULL;
	ttm->page_flags &= ~TTM_PAGE_FLAG_SWAPPED;

	return 0;
out_err:
	return ret;
}
Vim�UnDo��h?k����jF�Km��\޲n��A9�:���P��G	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask);,ET�X~_�,E����T�V��+-�G	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask);5�_�,E����T�X|�+-�R	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask|__GFP_ZERO);5�_�,E����T�X|�+-�Q	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask__GFP_ZERO);5�_�,E����T�X|�+-�P	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask_GFP_ZERO);5�_�,E����T�X|�+-�O	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskGFP_ZERO);5�_�,E����T�X|�+-�N	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskFP_ZERO);5�_�,E����T�X}�+-�M	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskP_ZERO);5�_�	,E����T�X}�+-�L	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmask_ZERO);5�_�
	,E����T�X}�+-�K	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskZERO);5�_�	
,E����T�X}�+-�J	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskERO);5�_�
,E����T�X}�+-�I	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskRO);5�_�,E����T�X}�+-�H	backing = shmem_read_mapping_page_gfp(mapping, entry->index, gfpmaskO);5��