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/drm/nouveau/core Don't assume tha...



details:   https://anonhg.NetBSD.org/src/rev/ac04e6406630
branches:  trunk
changeset: 811312:ac04e6406630
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Oct 22 22:39:46 2015 +0000

description:
Don't assume that PAGE_SIZE is the same as the GPU page size (4K).
LGTM riastradh@

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/vm.h                |   5 +
 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c |  28 +++++----
 2 files changed, 21 insertions(+), 12 deletions(-)

diffs (71 lines):

diff -r fc2910ee51bf -r ac04e6406630 sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/vm.h
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/vm.h   Thu Oct 22 19:36:04 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/include/subdev/vm.h   Thu Oct 22 22:39:46 2015 +0000
@@ -30,6 +30,11 @@
 #include <core/device.h>
 #include <core/mm.h>
 
+#define NOUVEAU_GPU_PAGE_SIZE          4096
+#define NOUVEAU_GPU_PAGE_MASK          (NOUVEAU_GPU_PAGE_SIZE - 1)
+#define NOUVEAU_GPU_PAGE_SHIFT         12
+#define NOUVEAU_GPU_PAGE_ALIGN(a)      (((a) + NOUVEAU_GPU_PAGE_MASK) & ~NOUVEAU_GPU_PAGE_MASK)
+
 struct nouveau_vm_pgt {
        struct nouveau_gpuobj *obj[2];
        u32 refcount[2];
diff -r fc2910ee51bf -r ac04e6406630 sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c    Thu Oct 22 19:36:04 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/core/subdev/vm/nouveau_subdev_vm_base.c    Thu Oct 22 22:39:46 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_subdev_vm_base.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $     */
+/*     $NetBSD: nouveau_subdev_vm_base.c,v 1.3 2015/10/22 22:39:46 jmcneill Exp $      */
 
 /*
  * Copyright 2010 Red Hat Inc.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_base.c,v 1.2 2015/02/25 22:12:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_vm_base.c,v 1.3 2015/10/22 22:39:46 jmcneill Exp $");
 
 #include <core/gpuobj.h>
 #include <core/mm.h>
@@ -92,23 +92,27 @@
        u32 pde  = (offset >> vmm->pgt_bits) - vm->fpde;
        u32 pte  = (offset & ((1 << vmm->pgt_bits) - 1)) >> bits;
        u32 max  = 1 << (vmm->pgt_bits - bits);
-       unsigned seg;
+       unsigned seg, pgoff;
 
        for (seg = 0; seg < mem->pages->dm_nsegs; seg++) {
                struct nouveau_gpuobj *pgt = vm->pgt[pde].obj[big];
                dma_addr_t addr = mem->pages->dm_segs[seg].ds_addr;
 
-               KASSERT(mem->pages->dm_segs[seg].ds_len == PAGE_SIZE);
-               vmm->map_sg(vma, pgt, mem, pte, 1, &addr);
-               num--;
-               pte++;
+               KASSERT((mem->pages->dm_segs[seg].ds_len & NOUVEAU_GPU_PAGE_MASK) == 0);
+               for (pgoff = 0; pgoff < mem->pages->dm_segs[seg].ds_len;
+                    pgoff += NOUVEAU_GPU_PAGE_SIZE, addr += NOUVEAU_GPU_PAGE_SIZE) {
+                       
+                       vmm->map_sg(vma, pgt, mem, pte, 1, &addr);
+                       num--;
+                       pte++;
 
-               if (num == 0)
-                       goto finish;
+                       if (num == 0)
+                               goto finish;
 
-               if (__predict_false(pte >= max)) {
-                       pde++;
-                       pte = 0;
+                       if (__predict_false(pte >= max)) {
+                               pde++;
+                               pte = 0;
+                       }
                }
        }
 



Home | Main Index | Thread Index | Old Index