aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlexandre Courbot <acourbot@nvidia.com>2015-02-20 04:23:02 -0500
committerBen Skeggs <bskeggs@redhat.com>2015-04-14 03:00:44 -0400
commit5dc240bcfe9a8d30b151be58b174261ba388cb01 (patch)
tree61637f05cba373da5ae3d14674fb33179984eabf /drivers/gpu
parent14520876751e1022704b58ce08e0dadc8c736656 (diff)
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>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
index 9a1fc8404ace..175ac187d382 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c
@@ -24,6 +24,10 @@
24#include <core/mm.h> 24#include <core/mm.h>
25#include <core/device.h> 25#include <core/device.h>
26 26
27#ifdef __KERNEL__
28#include <linux/dma-attrs.h>
29#endif
30
27#include "priv.h" 31#include "priv.h"
28 32
29struct gk20a_instobj_priv { 33struct gk20a_instobj_priv {
@@ -41,6 +45,7 @@ struct gk20a_instmem_priv {
41 struct nvkm_instmem base; 45 struct nvkm_instmem base;
42 spinlock_t lock; 46 spinlock_t lock;
43 u64 addr; 47 u64 addr;
48 struct dma_attrs attrs;
44}; 49};
45 50
46static u32 51static u32
@@ -91,8 +96,8 @@ gk20a_instobj_dtor(struct nvkm_object *object)
91 if (unlikely(!node->handle)) 96 if (unlikely(!node->handle))
92 return; 97 return;
93 98
94 dma_free_coherent(dev, node->mem->size << PAGE_SHIFT, node->cpuaddr, 99 dma_free_attrs(dev, node->mem->size << PAGE_SHIFT, node->cpuaddr,
95 node->handle); 100 node->handle, &priv->attrs);
96 101
97 nvkm_instobj_destroy(&node->base); 102 nvkm_instobj_destroy(&node->base);
98} 103}
@@ -126,8 +131,9 @@ gk20a_instobj_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
126 131
127 node->mem = &node->_mem; 132 node->mem = &node->_mem;
128 133
129 node->cpuaddr = dma_alloc_coherent(dev, npages << PAGE_SHIFT, 134 node->cpuaddr = dma_alloc_attrs(dev, npages << PAGE_SHIFT,
130 &node->handle, GFP_KERNEL); 135 &node->handle, GFP_KERNEL,
136 &priv->attrs);
131 if (!node->cpuaddr) { 137 if (!node->cpuaddr) {
132 nv_error(priv, "cannot allocate DMA memory\n"); 138 nv_error(priv, "cannot allocate DMA memory\n");
133 return -ENOMEM; 139 return -ENOMEM;
@@ -195,6 +201,16 @@ gk20a_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
195 201
196 spin_lock_init(&priv->lock); 202 spin_lock_init(&priv->lock);
197 203
204 init_dma_attrs(&priv->attrs);
205 /*
206 * We will access instmem through PRAMIN and thus do not need a
207 * consistent CPU pointer or kernel mapping
208 */
209 dma_set_attr(DMA_ATTR_NON_CONSISTENT, &priv->attrs);
210 dma_set_attr(DMA_ATTR_WEAK_ORDERING, &priv->attrs);
211 dma_set_attr(DMA_ATTR_WRITE_COMBINE, &priv->attrs);
212 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &priv->attrs);
213
198 return 0; 214 return 0;
199} 215}
200 216