aboutsummaryrefslogtreecommitdiff
path: root/linux-core/drm_ttm.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2007-12-16 01:47:51 -0800
committerKeith Packard <keithp@keithp.com>2007-12-21 12:16:29 -0800
commit37fb2ac4071f62bad2c36cc9ca84f9c8feee6bf5 (patch)
tree75b313d56bd7df93dbc0191492b28995a4dd4b99 /linux-core/drm_ttm.c
parent881ee70ab7bab5d6f6140dc9bf1e19c7b5844084 (diff)
Use dummy_read_page for unpopulated kernel-allocated ttm pages.
Previously, dummy_read_page was used only for read-only user allocations; it filled in pages that were not present in the user address map (presumably, these were allocated but never written to pages). This patch allows them to be used for read-only ttms allocated from the kernel, so that applications can over-allocate buffers without forcing every page to be allocated.
Diffstat (limited to 'linux-core/drm_ttm.c')
-rw-r--r--linux-core/drm_ttm.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c
index c1fc13fc..a9d87338 100644
--- a/linux-core/drm_ttm.c
+++ b/linux-core/drm_ttm.c
@@ -262,7 +262,6 @@ int drm_ttm_set_user(struct drm_ttm *ttm,
{
struct mm_struct *mm = tsk->mm;
int ret;
- int i;
int write = (ttm->page_flags & DRM_TTM_PAGE_WRITE) != 0;
BUG_ON(num_pages != ttm->num_pages);
@@ -278,11 +277,6 @@ int drm_ttm_set_user(struct drm_ttm *ttm,
return -ENOMEM;
}
- for (i = 0; i < num_pages; ++i) {
- if (ttm->pages[i] == NULL)
- ttm->pages[i] = ttm->dummy_read_page;
- }
-
return 0;
}
@@ -304,12 +298,14 @@ int drm_ttm_populate(struct drm_ttm *ttm)
return 0;
be = ttm->be;
- for (i = 0; i < ttm->num_pages; ++i) {
- page = drm_ttm_get_page(ttm, i);
- if (!page)
- return -ENOMEM;
+ if (ttm->page_flags & DRM_TTM_PAGE_WRITE) {
+ for (i = 0; i < ttm->num_pages; ++i) {
+ page = drm_ttm_get_page(ttm, i);
+ if (!page)
+ return -ENOMEM;
+ }
}
- be->func->populate(be, ttm->num_pages, ttm->pages);
+ be->func->populate(be, ttm->num_pages, ttm->pages, ttm->dummy_read_page);
ttm->state = ttm_unbound;
return 0;
}