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



details:   https://anonhg.NetBSD.org/src/rev/6b944cbb8286
branches:  trunk
changeset: 337111:6b944cbb8286
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 03 01:06:05 2015 +0000

description:
Use pmap_pv(9) to remove mappings of Intel graphics aperture 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/i915/i915_dma.c |   7 ++++
 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c |  39 ++++++++-----------------
 2 files changed, 20 insertions(+), 26 deletions(-)

diffs (73 lines):

diff -r 58ab0768226f -r 6b944cbb8286 sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c    Fri Apr 03 01:04:23 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c    Fri Apr 03 01:06:05 2015 +0000
@@ -1734,6 +1734,8 @@
        dev_priv->gtt.mappable =
            drm_io_mapping_create_wc(dev, dev_priv->gtt.mappable_base,
                aperture_size);
+       /* Note: mappable_end is the size, not end paddr, of the aperture.  */
+       pmap_pv_track(dev_priv->gtt.mappable_base, dev_priv->gtt.mappable_end);
 #else
        dev_priv->gtt.mappable =
                io_mapping_create_wc(dev_priv->gtt.mappable_base,
@@ -1851,6 +1853,11 @@
        destroy_workqueue(dev_priv->wq);
 out_mtrrfree:
        arch_phys_wc_del(dev_priv->gtt.mtrr);
+#ifdef __NetBSD__
+       /* Note: mappable_end is the size, not end paddr, of the aperture.  */
+       pmap_pv_untrack(dev_priv->gtt.mappable_base,
+           dev_priv->gtt.mappable_end);
+#endif
        io_mapping_free(dev_priv->gtt.mappable);
 out_gtt:
        list_del(&dev_priv->gtt.base.global_link);
diff -r 58ab0768226f -r 6b944cbb8286 sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
--- a/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Fri Apr 03 01:04:23 2015 +0000
+++ b/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c    Fri Apr 03 01:06:05 2015 +0000
@@ -2121,32 +2121,19 @@
 
 #ifdef __NetBSD__              /* XXX gem gtt fault */
        {
-               struct vm_page *page;
-
-               mutex_enter(obj->base.gemo_shm_uao->vmobjlock);
-               KASSERT(obj->pages != NULL);
-               /* Force a fresh fault for each page.  */
-               /*
-                * XXX OOPS!  This doesn't actually do what we want.
-                * This causes a fresh fault for access to the backing
-                * pages -- but nothing accesses the backing pages
-                * directly!  What is actually entered into CPU page
-                * table entries is aperture addresses which have been
-                * programmed by the GTT to refer to those backing
-                * pages.
-                *
-                * We need to clear those page table entries, but
-                * there's no good way to do that at the moment: nobody
-                * records for us a map from either uvm objects or
-                * physical device addresses to a list of all virtual
-                * pages where they have been mapped.  pmap(9) records
-                * a map only from physical RAM addresses to virtual
-                * pages; it does nothing for physical device
-                * addresses.
-                */
-               TAILQ_FOREACH(page, &obj->igo_pageq, pageq.queue)
-                       pmap_page_protect(page, VM_PROT_NONE);
-               mutex_exit(obj->base.gemo_shm_uao->vmobjlock);
+               struct drm_device *const dev = obj->base.dev;
+               struct drm_i915_private *const dev_priv = dev->dev_private;
+               const paddr_t start = dev_priv->gtt.mappable_base +
+                   i915_gem_obj_ggtt_offset(obj);
+               const size_t size = obj->base.size;
+               const paddr_t end = start + size;
+               paddr_t pa;
+
+               KASSERT((start & (PAGE_SIZE - 1)) == 0);
+               KASSERT((size & (PAGE_SIZE - 1)) == 0);
+
+               for (pa = start; pa < end; pa += PAGE_SIZE)
+                       pmap_pv_protect(pa, VM_PROT_NONE);
        }
 #else
        drm_vma_node_unmap(&obj->base.vma_node,



Home | Main Index | Thread Index | Old Index