Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 156021
b: refs/heads/master
c: 542c6f6
h: refs/heads/master
i:
  156019: ae94422
v: v3
  • Loading branch information
Thomas Hellstrom authored and Dave Airlie committed Jul 29, 2009
1 parent cfe820a commit 7504968
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4677f15c60421d48566c48c3149474e64977f071
refs/heads/master: 542c6f6df51327dbb180cf4d9b34827e147efe17
63 changes: 52 additions & 11 deletions trunk/drivers/gpu/drm/ttm/ttm_bo_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ static int ttm_copy_io_page(void *dst, void *src, unsigned long page)
}

static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
unsigned long page)
unsigned long page,
pgprot_t prot)
{
struct page *d = ttm_tt_get_page(ttm, page);
void *dst;
Expand All @@ -145,17 +146,35 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
return -ENOMEM;

src = (void *)((unsigned long)src + (page << PAGE_SHIFT));
dst = kmap(d);

#ifdef CONFIG_X86
dst = kmap_atomic_prot(d, KM_USER0, prot);
#else
if (prot != PAGE_KERNEL)
dst = vmap(&d, 1, 0, prot);
else
dst = kmap(d);
#endif
if (!dst)
return -ENOMEM;

memcpy_fromio(dst, src, PAGE_SIZE);
kunmap(d);

#ifdef CONFIG_X86
kunmap_atomic(dst, KM_USER0);
#else
if (prot != PAGE_KERNEL)
vunmap(dst);
else
kunmap(d);
#endif

return 0;
}

static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
unsigned long page)
unsigned long page,
pgprot_t prot)
{
struct page *s = ttm_tt_get_page(ttm, page);
void *src;
Expand All @@ -164,12 +183,28 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
return -ENOMEM;

dst = (void *)((unsigned long)dst + (page << PAGE_SHIFT));
src = kmap(s);
#ifdef CONFIG_X86
src = kmap_atomic_prot(s, KM_USER0, prot);
#else
if (prot != PAGE_KERNEL)
src = vmap(&s, 1, 0, prot);
else
src = kmap(s);
#endif
if (!src)
return -ENOMEM;

memcpy_toio(dst, src, PAGE_SIZE);
kunmap(s);

#ifdef CONFIG_X86
kunmap_atomic(src, KM_USER0);
#else
if (prot != PAGE_KERNEL)
vunmap(src);
else
kunmap(s);
#endif

return 0;
}

Expand Down Expand Up @@ -214,11 +249,17 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,

for (i = 0; i < new_mem->num_pages; ++i) {
page = i * dir + add;
if (old_iomap == NULL)
ret = ttm_copy_ttm_io_page(ttm, new_iomap, page);
else if (new_iomap == NULL)
ret = ttm_copy_io_ttm_page(ttm, old_iomap, page);
else
if (old_iomap == NULL) {
pgprot_t prot = ttm_io_prot(old_mem->placement,
PAGE_KERNEL);
ret = ttm_copy_ttm_io_page(ttm, new_iomap, page,
prot);
} else if (new_iomap == NULL) {
pgprot_t prot = ttm_io_prot(new_mem->placement,
PAGE_KERNEL);
ret = ttm_copy_io_ttm_page(ttm, old_iomap, page,
prot);
} else
ret = ttm_copy_io_page(new_iomap, old_iomap, page);
if (ret)
goto out1;
Expand Down

0 comments on commit 7504968

Please sign in to comment.