ttm porting: Small changes (3/3)
authorFrançois Tigeot <ftigeot@wolfpond.org>
Wed, 7 Aug 2013 11:00:58 +0000 (13:00 +0200)
committerFrançois Tigeot <ftigeot@wolfpond.org>
Thu, 8 Aug 2013 18:27:13 +0000 (20:27 +0200)
* Fix taskqueue_start_threads() calls

* Remove VPO_UNMANAGED

* Remove VM_ALLOC_WIRED and VM_ALLOC_NOOBJ

* Remove VM_ALLOC_NOBUSY

* Replace VPO_BUSY by PG_BUSY

* Fix calls to pmap_copy_page()

* Fix calls to pmap_zero_page()

sys/dev/drm2/ttm/ttm_bo_vm.c
sys/dev/drm2/ttm/ttm_memory.c
sys/dev/drm2/ttm/ttm_page_alloc.c
sys/dev/drm2/ttm/ttm_tt.c

index 3746557..d8c45f7 100644 (file)
@@ -209,7 +209,7 @@ reserve:
        }
 
        VM_OBJECT_WLOCK(vm_obj);
-       if ((m->flags & VPO_BUSY) != 0) {
+       if ((m->flags & PG_BUSY) != 0) {
 #if 0
                vm_page_sleep(m, "ttmpbs");
 #endif
index 108ca56..28c9608 100644 (file)
@@ -254,7 +254,7 @@ int ttm_mem_global_init(struct ttm_mem_global *glob)
        spin_init(&glob->spin);
        glob->swap_queue = taskqueue_create("ttm_swap", M_WAITOK,
            taskqueue_thread_enqueue, &glob->swap_queue);
-       taskqueue_start_threads(&glob->swap_queue, 1, PVM, "ttm swap");
+       taskqueue_start_threads(&glob->swap_queue, 1, 0, -1, "ttm swap");
        TASK_INIT(&glob->work, 0, ttm_shrink_work, glob);
 
        refcount_init(&glob->kobj_ref, 1);
index 1277c57..7c0fe01 100644 (file)
@@ -139,9 +139,11 @@ ttm_vm_page_free(vm_page_t m)
        KASSERT(m->object == NULL, ("ttm page %p is owned", m));
        KASSERT(m->wire_count == 1, ("ttm lost wire %p", m));
        KASSERT((m->flags & PG_FICTITIOUS) != 0, ("ttm lost fictitious %p", m));
+#if 0
        KASSERT((m->oflags & VPO_UNMANAGED) == 0, ("ttm got unmanaged %p", m));
-       m->flags &= ~PG_FICTITIOUS;
        m->oflags |= VPO_UNMANAGED;
+#endif
+       m->flags &= ~PG_FICTITIOUS;
        vm_page_unwire(m, 0);
        vm_page_free(m);
 }
@@ -492,7 +494,7 @@ static int ttm_alloc_new_pages(struct pglist *pages, int ttm_alloc_flags,
        unsigned max_cpages = min(count,
                        (unsigned)(PAGE_SIZE/sizeof(vm_page_t)));
 
-       aflags = VM_ALLOC_NORMAL | VM_ALLOC_WIRED | VM_ALLOC_NOOBJ |
+       aflags = VM_ALLOC_NORMAL |
            ((ttm_alloc_flags & TTM_PAGE_FLAG_ZERO_ALLOC) != 0 ?
            VM_ALLOC_ZERO : 0);
        
@@ -521,7 +523,9 @@ static int ttm_alloc_new_pages(struct pglist *pages, int ttm_alloc_flags,
                        r = -ENOMEM;
                        goto out;
                }
+#if 0
                p->oflags &= ~VPO_UNMANAGED;
+#endif
                p->flags |= PG_FICTITIOUS;
 
 #ifdef CONFIG_HIGHMEM /* KIB: nop */
@@ -708,7 +712,7 @@ static int ttm_get_pages(vm_page_t *pages, unsigned npages, int flags,
        unsigned count;
        int r;
 
-       aflags = VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
+       aflags = VM_ALLOC_NORMAL |
            ((flags & TTM_PAGE_FLAG_ZERO_ALLOC) != 0 ? VM_ALLOC_ZERO : 0);
 
        /* No pool for cached pages */
@@ -722,7 +726,9 @@ static int ttm_get_pages(vm_page_t *pages, unsigned npages, int flags,
                                kprintf("[TTM] Unable to allocate page\n");
                                return -ENOMEM;
                        }
+#if 0
                        p->oflags &= ~VPO_UNMANAGED;
+#endif
                        p->flags |= PG_FICTITIOUS;
                        pages[r] = p;
                }
@@ -743,7 +749,7 @@ static int ttm_get_pages(vm_page_t *pages, unsigned npages, int flags,
        /* clear the pages coming from the pool if requested */
        if (flags & TTM_PAGE_FLAG_ZERO_ALLOC) {
                TAILQ_FOREACH(p, &plist, pageq) {
-                       pmap_zero_page(p);
+                       pmap_zero_page(VM_PAGE_TO_PHYS(p));
                }
        }
 
index 5c482e1..853d38e 100644 (file)
@@ -287,8 +287,7 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
        VM_OBJECT_WLOCK(obj);
        vm_object_pip_add(obj, 1);
        for (i = 0; i < ttm->num_pages; ++i) {
-               from_page = vm_page_grab(obj, i, VM_ALLOC_NOBUSY |
-                   VM_ALLOC_RETRY);
+               from_page = vm_page_grab(obj, i, VM_ALLOC_RETRY);
                if (from_page->valid != VM_PAGE_BITS_ALL) {
                        vm_page_busy_try(from_page, FALSE);
                        if (vm_pager_has_page(obj, i)) {
@@ -307,7 +306,8 @@ int ttm_tt_swapin(struct ttm_tt *ttm)
                        ret = -ENOMEM;
                        goto err_ret;
                }
-               pmap_copy_page(from_page, to_page);
+               pmap_copy_page(VM_PAGE_TO_PHYS(from_page),
+                                       VM_PAGE_TO_PHYS(to_page));
        }
        vm_object_pip_wakeup(obj);
        VM_OBJECT_WUNLOCK(obj);
@@ -356,7 +356,8 @@ int ttm_tt_swapout(struct ttm_tt *ttm, vm_object_t persistent_swap_storage)
                if (unlikely(from_page == NULL))
                        continue;
                to_page = vm_page_grab(obj, i, VM_ALLOC_RETRY);
-               pmap_copy_page(from_page, to_page);
+               pmap_copy_page(VM_PAGE_TO_PHYS(from_page),
+                                       VM_PAGE_TO_PHYS(to_page));
                vm_page_dirty(to_page);
                to_page->valid = VM_PAGE_BITS_ALL;
                vm_page_wakeup(to_page);