diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/dma.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/dma.c b/drivers/gpu/nvgpu/common/linux/dma.c index ec9c3b5a..fe4e9bc8 100644 --- a/drivers/gpu/nvgpu/common/linux/dma.c +++ b/drivers/gpu/nvgpu/common/linux/dma.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/dma-attrs.h> | ||
18 | #include <linux/dma-mapping.h> | 17 | #include <linux/dma-mapping.h> |
19 | #include <linux/version.h> | 18 | #include <linux/version.h> |
20 | 19 | ||
@@ -35,6 +34,17 @@ | |||
35 | #include "platform_gk20a.h" | 34 | #include "platform_gk20a.h" |
36 | #include "os_linux.h" | 35 | #include "os_linux.h" |
37 | 36 | ||
37 | #ifdef __DMA_ATTRS_LONGS | ||
38 | #define NVGPU_DEFINE_DMA_ATTRS(x) \ | ||
39 | struct dma_attrs x = { \ | ||
40 | .flags = { [0 ... __DMA_ATTRS_LONGS-1] = 0 }, \ | ||
41 | } | ||
42 | #define NVGPU_DMA_ATTR(attrs) &attrs | ||
43 | #else | ||
44 | #define NVGPU_DEFINE_DMA_ATTRS(attrs) unsigned long attrs = 0 | ||
45 | #define NVGPU_DMA_ATTR(attrs) attrs | ||
46 | #endif | ||
47 | |||
38 | /* | 48 | /* |
39 | * Enough to hold all the possible flags in string form. When a new flag is | 49 | * Enough to hold all the possible flags in string form. When a new flag is |
40 | * added it must be added here as well!! | 50 | * added it must be added here as well!! |
@@ -211,7 +221,7 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, | |||
211 | struct device *d = dev_from_gk20a(g); | 221 | struct device *d = dev_from_gk20a(g); |
212 | int err; | 222 | int err; |
213 | dma_addr_t iova; | 223 | dma_addr_t iova; |
214 | DEFINE_DMA_ATTRS(dma_attrs); | 224 | NVGPU_DEFINE_DMA_ATTRS(dma_attrs); |
215 | void *alloc_ret; | 225 | void *alloc_ret; |
216 | 226 | ||
217 | /* | 227 | /* |
@@ -233,7 +243,7 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, | |||
233 | 243 | ||
234 | alloc_ret = dma_alloc_attrs(d, size, &iova, | 244 | alloc_ret = dma_alloc_attrs(d, size, &iova, |
235 | GFP_KERNEL|__GFP_ZERO, | 245 | GFP_KERNEL|__GFP_ZERO, |
236 | __DMA_ATTR(dma_attrs)); | 246 | NVGPU_DMA_ATTR(dma_attrs)); |
237 | if (!alloc_ret) | 247 | if (!alloc_ret) |
238 | return -ENOMEM; | 248 | return -ENOMEM; |
239 | 249 | ||
@@ -260,7 +270,7 @@ int nvgpu_dma_alloc_flags_sys(struct gk20a *g, unsigned long flags, | |||
260 | 270 | ||
261 | fail_free: | 271 | fail_free: |
262 | g->dma_memory_used -= mem->aligned_size; | 272 | g->dma_memory_used -= mem->aligned_size; |
263 | dma_free_attrs(d, size, alloc_ret, iova, __DMA_ATTR(dma_attrs)); | 273 | dma_free_attrs(d, size, alloc_ret, iova, NVGPU_DMA_ATTR(dma_attrs)); |
264 | mem->cpu_va = NULL; | 274 | mem->cpu_va = NULL; |
265 | mem->priv.sgt = NULL; | 275 | mem->priv.sgt = NULL; |
266 | mem->size = 0; | 276 | mem->size = 0; |
@@ -460,18 +470,18 @@ static void nvgpu_dma_free_sys(struct gk20a *g, struct nvgpu_mem *mem) | |||
460 | !(mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) && | 470 | !(mem->mem_flags & __NVGPU_MEM_FLAG_NO_DMA) && |
461 | (mem->cpu_va || mem->priv.pages)) { | 471 | (mem->cpu_va || mem->priv.pages)) { |
462 | if (mem->priv.flags) { | 472 | if (mem->priv.flags) { |
463 | DEFINE_DMA_ATTRS(dma_attrs); | 473 | NVGPU_DEFINE_DMA_ATTRS(dma_attrs); |
464 | 474 | ||
465 | nvgpu_dma_flags_to_attrs(&dma_attrs, mem->priv.flags); | 475 | nvgpu_dma_flags_to_attrs(&dma_attrs, mem->priv.flags); |
466 | 476 | ||
467 | if (mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING) { | 477 | if (mem->priv.flags & NVGPU_DMA_NO_KERNEL_MAPPING) { |
468 | dma_free_attrs(d, mem->aligned_size, mem->priv.pages, | 478 | dma_free_attrs(d, mem->aligned_size, mem->priv.pages, |
469 | sg_dma_address(mem->priv.sgt->sgl), | 479 | sg_dma_address(mem->priv.sgt->sgl), |
470 | __DMA_ATTR(dma_attrs)); | 480 | NVGPU_DMA_ATTR(dma_attrs)); |
471 | } else { | 481 | } else { |
472 | dma_free_attrs(d, mem->aligned_size, mem->cpu_va, | 482 | dma_free_attrs(d, mem->aligned_size, mem->cpu_va, |
473 | sg_dma_address(mem->priv.sgt->sgl), | 483 | sg_dma_address(mem->priv.sgt->sgl), |
474 | __DMA_ATTR(dma_attrs)); | 484 | NVGPU_DMA_ATTR(dma_attrs)); |
475 | } | 485 | } |
476 | } else { | 486 | } else { |
477 | dma_free_coherent(d, mem->aligned_size, mem->cpu_va, | 487 | dma_free_coherent(d, mem->aligned_size, mem->cpu_va, |
@@ -563,7 +573,7 @@ int nvgpu_get_sgtable_attrs(struct gk20a *g, struct sg_table **sgt, | |||
563 | { | 573 | { |
564 | int err = 0; | 574 | int err = 0; |
565 | struct sg_table *tbl; | 575 | struct sg_table *tbl; |
566 | DEFINE_DMA_ATTRS(dma_attrs); | 576 | NVGPU_DEFINE_DMA_ATTRS(dma_attrs); |
567 | 577 | ||
568 | tbl = nvgpu_kzalloc(g, sizeof(struct sg_table)); | 578 | tbl = nvgpu_kzalloc(g, sizeof(struct sg_table)); |
569 | if (!tbl) { | 579 | if (!tbl) { |
@@ -573,7 +583,7 @@ int nvgpu_get_sgtable_attrs(struct gk20a *g, struct sg_table **sgt, | |||
573 | 583 | ||
574 | nvgpu_dma_flags_to_attrs(&dma_attrs, flags); | 584 | nvgpu_dma_flags_to_attrs(&dma_attrs, flags); |
575 | err = dma_get_sgtable_attrs(dev_from_gk20a(g), tbl, cpuva, iova, | 585 | err = dma_get_sgtable_attrs(dev_from_gk20a(g), tbl, cpuva, iova, |
576 | size, __DMA_ATTR(dma_attrs)); | 586 | size, NVGPU_DMA_ATTR(dma_attrs)); |
577 | if (err) | 587 | if (err) |
578 | goto fail; | 588 | goto fail; |
579 | 589 | ||