Module Name: src
Committed By: riastradh
Date: Fri Apr 3 01:06:05 UTC 2015
Modified Files:
src/sys/external/bsd/drm2/dist/drm/i915: i915_dma.c i915_gem.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
cvs rdiff -u -r1.28 -r1.29 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.15 src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.16
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c:1.15 Sat Feb 28 18:25:39 2015
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_dma.c Fri Apr 3 01:06:05 2015
@@ -1734,6 +1734,8 @@ int i915_driver_load(struct drm_device *
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 @@ out_gem_unload:
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);
Index: src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c
diff -u src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.28 src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.29
--- src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c:1.28 Fri Mar 6 22:24:05 2015
+++ src/sys/external/bsd/drm2/dist/drm/i915/i915_gem.c Fri Apr 3 01:06:05 2015
@@ -2121,32 +2121,19 @@ i915_gem_release_mmap(struct drm_i915_ge
#ifdef __NetBSD__ /* XXX gem gtt fault */
{
- struct vm_page *page;
+ 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;
- 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);
+ 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,