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 Use pmap_pv(9) to remove mapp...



details:   https://anonhg.NetBSD.org/src/rev/21404e057adf
branches:  trunk
changeset: 337112:21404e057adf
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 03 01:09:42 2015 +0000

description:
Use pmap_pv(9) to remove mappings of device pages in TTM.

Adapt nouveau and radeon to do pmap_pv_track for their device pages.

Proposed on tech-kern with no objections:

https://mail-index.netbsd.org/tech-kern/2015/03/26/msg018561.html

Further background at:

https://mail-index.netbsd.org/tech-kern/2014/07/23/msg017392.html

diffstat:

 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c  |  13 ++++++++++---
 sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c  |  14 ++++++++++++--
 sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c    |   7 +++++++
 sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c |   8 ++++++++
 sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c           |  15 ++++++++++-----
 5 files changed, 47 insertions(+), 10 deletions(-)

diffs (150 lines):

diff -r 6b944cbb8286 -r 21404e057adf sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c      Fri Apr 03 01:06:05 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_agp.c      Fri Apr 03 01:09:42 2015 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: nouveau_agp.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $        */
+/*     $NetBSD: nouveau_agp.c,v 1.3 2015/04/03 01:09:42 riastradh Exp $        */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_agp.c,v 1.2 2014/08/06 13:35:13 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_agp.c,v 1.3 2015/04/03 01:09:42 riastradh Exp $");
 
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -190,6 +190,9 @@
        drm->agp.stat = ENABLED;
        drm->agp.base = info.aperture_base;
        drm->agp.size = info.aperture_size;
+#ifdef __NetBSD__
+       pmap_pv_track(drm->agp.base, drm->agp.size);
+#endif
 #endif
 }
 
@@ -198,7 +201,11 @@
 {
 #if __OS_HAS_AGP
        struct drm_device *dev = drm->dev;
-       if (dev->agp && dev->agp->acquired)
+       if (dev->agp && dev->agp->acquired) {
+#ifdef __NetBSD__
+               pmap_pv_untrack(drm->agp.base, drm->agp.size);
+#endif
                drm_agp_release(dev);
+       }
 #endif
 }
diff -r 6b944cbb8286 -r 21404e057adf sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c
--- a/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c      Fri Apr 03 01:06:05 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/nouveau/nouveau_ttm.c      Fri Apr 03 01:09:42 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nouveau_ttm.c,v 1.3 2015/02/25 22:12:00 riastradh Exp $        */
+/*     $NetBSD: nouveau_ttm.c,v 1.4 2015/04/03 01:09:42 riastradh Exp $        */
 
 /*
  * Copyright (c) 2007-2008 Tungsten Graphics, Inc., Cedar Park, TX., USA,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nouveau_ttm.c,v 1.3 2015/02/25 22:12:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nouveau_ttm.c,v 1.4 2015/04/03 01:09:42 riastradh Exp $");
 
 #include <subdev/fb.h>
 #include <subdev/vm.h>
@@ -443,6 +443,11 @@
        drm->ttm.mtrr = arch_phys_wc_add(nv_device_resource_start(device, 1),
                                         nv_device_resource_len(device, 1));
 
+#ifdef __NetBSD__
+       pmap_pv_track(nv_device_resource_start(device, 1),
+           nv_device_resource_len(device, 1));
+#endif
+
        /* GART init */
        if (drm->agp.stat != ENABLED) {
                drm->gem.gart_available = nouveau_vmmgr(drm->device)->limit;
@@ -476,4 +481,9 @@
 
        arch_phys_wc_del(drm->ttm.mtrr);
        drm->ttm.mtrr = 0;
+
+#ifdef __NetBSD__
+       pmap_pv_untrack(nv_device_resource_start(nv_device(drm->device), 1),
+           nv_device_resource_len(nv_device(drm->device), 1));
+#endif
 }
diff -r 6b944cbb8286 -r 21404e057adf sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c        Fri Apr 03 01:06:05 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_agp.c        Fri Apr 03 01:09:42 2015 +0000
@@ -248,6 +248,10 @@
        dev_info(rdev->dev, "GTT: %"PRIu64"M 0x%08"PRIX64" - 0x%08"PRIX64"\n",
                rdev->mc.gtt_size >> 20, rdev->mc.gtt_start, rdev->mc.gtt_end);
 
+#ifdef __NetBSD__
+       pmap_pv_track(rdev->mc.agp_base, rdev->mc.gtt_size);
+#endif
+
        /* workaround some hw issues */
        if (rdev->family < CHIP_R200) {
                WREG32(RADEON_AGP_CNTL, RREG32(RADEON_AGP_CNTL) | 0x000e0000);
@@ -274,6 +278,9 @@
 {
 #if __OS_HAS_AGP
        if (rdev->ddev->agp && rdev->ddev->agp->acquired) {
+#ifdef __NetBSD__
+               pmap_pv_untrack(rdev->mc.agp_base, rdev->mc.gtt_size);
+#endif
                drm_agp_release(rdev->ddev);
        }
 #endif
diff -r 6b944cbb8286 -r 21404e057adf sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c
--- a/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c     Fri Apr 03 01:06:05 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/radeon/radeon_object.c     Fri Apr 03 01:09:42 2015 +0000
@@ -366,6 +366,10 @@
                rdev->mc.vram_mtrr = arch_phys_wc_add(rdev->mc.aper_base,
                                                      rdev->mc.aper_size);
        }
+#ifdef __NetBSD__
+       if (rdev->mc.aper_base)
+               pmap_pv_track(rdev->mc.aper_base, rdev->mc.aper_size);
+#endif
        DRM_INFO("Detected VRAM RAM=%"PRIx64"M, BAR=%lluM\n",
                rdev->mc.mc_vram_size >> 20,
                (unsigned long long)rdev->mc.aper_size >> 20);
@@ -377,6 +381,10 @@
 void radeon_bo_fini(struct radeon_device *rdev)
 {
        radeon_ttm_fini(rdev);
+#ifdef __NetBSD__
+       if (rdev->mc.aper_base)
+               pmap_pv_untrack(rdev->mc.aper_base, rdev->mc.aper_size);
+#endif
        arch_phys_wc_del(rdev->mc.vram_mtrr);
 }
 
diff -r 6b944cbb8286 -r 21404e057adf sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c
--- a/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c       Fri Apr 03 01:06:05 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/ttm/ttm_bo.c       Fri Apr 03 01:09:42 2015 +0000
@@ -1611,11 +1611,16 @@
 
 #ifdef __NetBSD__
        if (bo->mem.bus.is_iomem) {
-               /*
-                * XXX OOPS!  NetBSD doesn't have a way to enumerate
-                * and remove the virtual mappings for device addresses
-                * or of a uvm object.
-                */
+               paddr_t start, end, pa;
+
+               KASSERT((bo->mem.bus.base & (PAGE_SIZE - 1)) == 0);
+               KASSERT((bo->mem.bus.offset & (PAGE_SIZE - 1)) == 0);
+               start = bo->mem.bus.base + bo->mem.bus.offset;
+               KASSERT((bo->mem.bus.size & (PAGE_SIZE - 1)) == 0);
+               end = start + bo->mem.bus.size;
+
+               for (pa = start; pa < end; pa += PAGE_SIZE)
+                       pmap_pv_protect(pa, VM_PROT_NONE);
        } else if (bo->ttm != NULL) {
                unsigned i;
 



Home | Main Index | Thread Index | Old Index