瀏覽代碼

drm/nouveau/instmem/gk20a: use DMA attributes

instmem for GK20A is allocated using dma_alloc_coherent(), which
provides us with a coherent CPU mapping that we never use because
instmem objects are accessed through PRAMIN. Switch to
dma_alloc_attrs() which gives us the option to dismiss that CPU mapping
and free up some CPU virtual space.

Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Alexandre Courbot 10 年之前
父節點
當前提交
5dc240bcfe
共有 1 個文件被更改,包括 20 次插入4 次删除
  1. 20 4
      drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c

+ 20 - 4
drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c

@@ -24,6 +24,10 @@
 #include <core/mm.h>
 #include <core/mm.h>
 #include <core/device.h>
 #include <core/device.h>
 
 
+#ifdef __KERNEL__
+#include <linux/dma-attrs.h>
+#endif
+
 #include "priv.h"
 #include "priv.h"
 
 
 struct gk20a_instobj_priv {
 struct gk20a_instobj_priv {
@@ -41,6 +45,7 @@ struct gk20a_instmem_priv {
 	struct nvkm_instmem base;
 	struct nvkm_instmem base;
 	spinlock_t lock;
 	spinlock_t lock;
 	u64 addr;
 	u64 addr;
+	struct dma_attrs attrs;
 };
 };
 
 
 static u32
 static u32
@@ -91,8 +96,8 @@ gk20a_instobj_dtor(struct nvkm_object *object)
 	if (unlikely(!node->handle))
 	if (unlikely(!node->handle))
 		return;
 		return;
 
 
-	dma_free_coherent(dev, node->mem->size << PAGE_SHIFT, node->cpuaddr,
-			  node->handle);
+	dma_free_attrs(dev, node->mem->size << PAGE_SHIFT, node->cpuaddr,
+		       node->handle, &priv->attrs);
 
 
 	nvkm_instobj_destroy(&node->base);
 	nvkm_instobj_destroy(&node->base);
 }
 }
@@ -126,8 +131,9 @@ gk20a_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
 
 	node->mem = &node->_mem;
 	node->mem = &node->_mem;
 
 
-	node->cpuaddr = dma_alloc_coherent(dev, npages << PAGE_SHIFT,
-					   &node->handle, GFP_KERNEL);
+	node->cpuaddr = dma_alloc_attrs(dev, npages << PAGE_SHIFT,
+					&node->handle, GFP_KERNEL,
+					&priv->attrs);
 	if (!node->cpuaddr) {
 	if (!node->cpuaddr) {
 		nv_error(priv, "cannot allocate DMA memory\n");
 		nv_error(priv, "cannot allocate DMA memory\n");
 		return -ENOMEM;
 		return -ENOMEM;
@@ -195,6 +201,16 @@ gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
 
 
 	spin_lock_init(&priv->lock);
 	spin_lock_init(&priv->lock);
 
 
+	init_dma_attrs(&priv->attrs);
+	/*
+	 * We will access instmem through PRAMIN and thus do not need a
+	 * consistent CPU pointer or kernel mapping
+	 */
+	dma_set_attr(DMA_ATTR_NON_CONSISTENT, &priv->attrs);
+	dma_set_attr(DMA_ATTR_WEAK_ORDERING, &priv->attrs);
+	dma_set_attr(DMA_ATTR_WRITE_COMBINE, &priv->attrs);
+	dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &priv->attrs);
+
 	return 0;
 	return 0;
 }
 }