summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@openbsd.org>2013-06-20 01:09:11 +0200
committerJonathan Gray <jsg@jsg.id.au>2013-08-12 10:42:56 +1000
commit9b57e4ef2882aab4561fe3e23ed0bb10632e6291 (patch)
tree16735173bcecac1235fb661e0f5bce2806dcaa91
parentcce1a848e1175c343f244cce864dd37544c3511d (diff)
actually unmap buffers; fixes pixmap corruption issues
-rw-r--r--sys/dev/pci/drm/ttm/ttm_bo.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/sys/dev/pci/drm/ttm/ttm_bo.c b/sys/dev/pci/drm/ttm/ttm_bo.c
index 50e2ae4cde4..8144b4a0b11 100644
--- a/sys/dev/pci/drm/ttm/ttm_bo.c
+++ b/sys/dev/pci/drm/ttm/ttm_bo.c
@@ -1699,17 +1699,27 @@ ttm_mem_reg_is_pci(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem)
void
ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)
{
- struct ttm_bo_device *bdev = bo->bdev;
-#ifdef notyet
- off_t offset = (off_t) bo->addr_space_offset;
- off_t holelen = ((off_t) bo->mem.num_pages) << PAGE_SHIFT;
-#endif
+ struct ttm_tt *ttm = bo->ttm;
+ struct vm_page *page;
+ paddr_t paddr;
+ int i;
- if (!bdev->dev_mapping)
- return;
-#ifdef notyet
- unmap_mapping_range(bdev->dev_mapping, offset, holelen, 1);
-#endif
+ if (bo->mem.bus.is_iomem) {
+ for (i = 0; i < bo->mem.num_pages; ++i) {
+ paddr = (bo->mem.bus.base + bo->mem.bus.offset) + (i << PAGE_SHIFT);
+ page = PHYS_TO_VM_PAGE(paddr);
+ if (unlikely(page == NULL))
+ continue;
+ pmap_page_protect(page, VM_PROT_NONE);
+ }
+ } else if (ttm) {
+ for (i = 0; i < ttm->num_pages; ++i) {
+ page = ttm->pages[i];
+ if (unlikely(page == NULL))
+ continue;
+ pmap_page_protect(page, VM_PROT_NONE);
+ }
+ }
ttm_mem_io_free_vm(bo);
}