Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/external/bsd/drm2/dist Reduce some logic duplication and...



details:   https://anonhg.NetBSD.org/src/rev/c241c0dc13c8
branches:  trunk
changeset: 992774:c241c0dc13c8
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 27 07:45:33 2018 +0000

description:
Reduce some logic duplication and just use vmap/kmap here.

diffstat:

 sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c        |  48 ++++------------
 sys/external/bsd/drm2/dist/include/drm/ttm/ttm_bo_api.h |   7 +-
 2 files changed, 17 insertions(+), 38 deletions(-)

diffs (128 lines):

diff -r 342b3f0d1890 -r c241c0dc13c8 sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c  Mon Aug 27 07:45:23 2018 +0000
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo_util.c  Mon Aug 27 07:45:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttm_bo_util.c,v 1.10 2018/08/27 07:45:23 riastradh Exp $       */
+/*     $NetBSD: ttm_bo_util.c,v 1.11 2018/08/27 07:45:33 riastradh Exp $       */
 
 /**************************************************************************
  *
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ttm_bo_util.c,v 1.10 2018/08/27 07:45:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ttm_bo_util.c,v 1.11 2018/08/27 07:45:33 riastradh Exp $");
 
 #include <drm/ttm/ttm_bo_driver.h>
 #include <drm/ttm/ttm_placement.h>
@@ -647,10 +647,6 @@
        struct ttm_mem_reg *mem = &bo->mem;
        pgprot_t prot;
        struct ttm_tt *ttm = bo->ttm;
-#ifdef __NetBSD__
-       unsigned i;
-       vaddr_t vaddr;
-#endif
        int ret;
 
        BUG_ON(!ttm);
@@ -661,30 +657,6 @@
                        return ret;
        }
 
-#ifdef __NetBSD__
-       /*
-        * Can't use uvm_map here because it provides no way to pass
-        * along the cacheability flags.  So we'll uvm_km_alloc
-        * ourselves some KVA and then pmap_kenter_pa directly.
-        */
-
-       KASSERT(num_pages <= ttm->num_pages);
-       KASSERT(start_page <= (ttm->num_pages - num_pages));
-       prot = ttm_io_prot(mem->placement, (VM_PROT_READ | VM_PROT_WRITE));
-       vaddr = uvm_km_alloc(kernel_map, (num_pages << PAGE_SHIFT), PAGE_SIZE,
-           UVM_KMF_VAONLY | UVM_KMF_CANFAIL | UVM_KMF_WAITVA);
-       if (vaddr == 0)
-               return -ENOMEM;
-       for (i = 0; i < num_pages; i++)
-               pmap_kenter_pa(vaddr + i*PAGE_SIZE,
-                   page_to_phys(ttm->pages[start_page + i]),
-                   (VM_PROT_READ | VM_PROT_WRITE), prot);
-       pmap_update(pmap_kernel());
-       map->bo_kmap_type = ttm_bo_map_vmap;
-       map->u.uvm.vsize = (num_pages << PAGE_SHIFT);
-       map->virtual = (void *)vaddr;
-       return 0;
-#else
        if (num_pages == 1 && (mem->placement & TTM_PL_FLAG_CACHED)) {
                /*
                 * We're mapping a single page, and the desired
@@ -692,8 +664,13 @@
                 */
 
                map->bo_kmap_type = ttm_bo_map_kmap;
+#ifdef __NetBSD__
+               map->u.kmapped.page = ttm->pages[start_page];
+               map->virtual = kmap(map->u.kmapped.page);
+#else
                map->page = ttm->pages[start_page];
                map->virtual = kmap(map->page);
+#endif
        } else {
                /*
                 * We need to use vmap to get the desired page protection
@@ -703,9 +680,11 @@
                map->bo_kmap_type = ttm_bo_map_vmap;
                map->virtual = vmap(ttm->pages + start_page, num_pages,
                                    0, prot);
+#ifdef __NetBSD__
+               map->u.vmapped.vsize = (vsize_t)num_pages << PAGE_SHIFT;
+#endif
        }
        return (!map->virtual) ? -ENOMEM : 0;
-#endif
 }
 
 int ttm_bo_kmap(struct ttm_buffer_object *bo,
@@ -764,17 +743,14 @@
                break;
        case ttm_bo_map_vmap:
 #ifdef __NetBSD__
-               pmap_kremove((vaddr_t)map->virtual, map->u.uvm.vsize);
-               pmap_update(pmap_kernel());
-               uvm_km_free(kernel_map, (vaddr_t)map->virtual,
-                   map->u.uvm.vsize, UVM_KMF_VAONLY);
+               vunmap(map->virtual, map->u.vmapped.vsize >> PAGE_SHIFT);
 #else
                vunmap(map->virtual);
 #endif
                break;
        case ttm_bo_map_kmap:
 #ifdef __NetBSD__
-               panic("ttm_bo_map_kmap does not exist in NetBSD");
+               kunmap(map->u.kmapped.page);
 #else
                kunmap(map->page);
 #endif
diff -r 342b3f0d1890 -r c241c0dc13c8 sys/external/bsd/drm2/dist/include/drm/ttm/ttm_bo_api.h
--- a/sys/external/bsd/drm2/dist/include/drm/ttm/ttm_bo_api.h   Mon Aug 27 07:45:23 2018 +0000
+++ b/sys/external/bsd/drm2/dist/include/drm/ttm/ttm_bo_api.h   Mon Aug 27 07:45:33 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ttm_bo_api.h,v 1.3 2018/08/27 04:58:38 riastradh Exp $ */
+/*     $NetBSD: ttm_bo_api.h,v 1.4 2018/08/27 07:45:33 riastradh Exp $ */
 
 /**************************************************************************
  *
@@ -301,7 +301,10 @@
                } io;
                struct {
                        vsize_t                 vsize;
-               } uvm;
+               } vmapped;
+               struct {
+                       struct page             *page;
+               } kmapped;
        } u;
 #else
        struct page *page;



Home | Main Index | Thread Index | Old Index