summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Nieto <dmartineznie@nvidia.com>2018-01-04 14:09:57 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2018-01-08 17:38:06 -0500
commit6dde9e67d91419d1e671a520571a2be9bde93999 (patch)
tree0471b3f8ef26bed5b3adf4c8ddc6c949e8651bf4
parent82f253b7c14d7811a54f8187ff82f8d8befae529 (diff)
gpu: nvgpu: allocate from coherent pool
Maps memory coherently on devices that are connected to a coherent bus. (1) Add code to be able to get the platform device node. (2) Create a new flag to mark if the device is connected to a coherent bus (3) Map memory coherently on coherent devices. bug 2040331 Change-Id: Ide83a9261acdbbc6e9fef4fc5f38d6f9d0e5ab5b Signed-off-by: David Nieto <dmartineznie@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1633985 Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com> Reviewed-by: Alex Waterman <alexw@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.c21
-rw-r--r--drivers/gpu/nvgpu/common/linux/module.h1
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvgpu_mem.c4
-rw-r--r--drivers/gpu/nvgpu/common/linux/nvhost.c3
-rw-r--r--drivers/gpu/nvgpu/common/linux/pci.c8
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c2
-rw-r--r--drivers/gpu/nvgpu/include/nvgpu/enabled.h3
7 files changed, 38 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c
index 4fe38588..5d91da8f 100644
--- a/drivers/gpu/nvgpu/common/linux/module.c
+++ b/drivers/gpu/nvgpu/common/linux/module.c
@@ -24,6 +24,8 @@
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/reset.h> 25#include <linux/reset.h>
26#include <linux/platform/tegra/common.h> 26#include <linux/platform/tegra/common.h>
27#include <linux/pci.h>
28
27#include <uapi/linux/nvgpu.h> 29#include <uapi/linux/nvgpu.h>
28#include <dt-bindings/soc/gm20b-fuse.h> 30#include <dt-bindings/soc/gm20b-fuse.h>
29#include <dt-bindings/soc/gp10b-fuse.h> 31#include <dt-bindings/soc/gp10b-fuse.h>
@@ -70,6 +72,23 @@
70#define CREATE_TRACE_POINTS 72#define CREATE_TRACE_POINTS
71#include <trace/events/gk20a.h> 73#include <trace/events/gk20a.h>
72 74
75
76struct device_node *nvgpu_get_node(struct gk20a *g)
77{
78 struct device *dev = dev_from_gk20a(g);
79
80 if (dev_is_pci(dev)) {
81 struct pci_bus *bus = to_pci_dev(dev)->bus;
82
83 while (!pci_is_root_bus(bus))
84 bus = bus->parent;
85
86 return bus->bridge->parent->of_node;
87 }
88
89 return dev->of_node;
90}
91
73void gk20a_busy_noresume(struct gk20a *g) 92void gk20a_busy_noresume(struct gk20a *g)
74{ 93{
75 pm_runtime_get_noresume(dev_from_gk20a(g)); 94 pm_runtime_get_noresume(dev_from_gk20a(g));
@@ -1042,7 +1061,7 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a)
1042 1061
1043static int nvgpu_read_fuse_overrides(struct gk20a *g) 1062static int nvgpu_read_fuse_overrides(struct gk20a *g)
1044{ 1063{
1045 struct device_node *np = dev_from_gk20a(g)->of_node; 1064 struct device_node *np = nvgpu_get_node(g);
1046 u32 *fuses; 1065 u32 *fuses;
1047 int count, i; 1066 int count, i;
1048 1067
diff --git a/drivers/gpu/nvgpu/common/linux/module.h b/drivers/gpu/nvgpu/common/linux/module.h
index 90dba804..934c895d 100644
--- a/drivers/gpu/nvgpu/common/linux/module.h
+++ b/drivers/gpu/nvgpu/common/linux/module.h
@@ -28,6 +28,7 @@ void gk20a_driver_start_unload(struct gk20a *g);
28int nvgpu_quiesce(struct gk20a *g); 28int nvgpu_quiesce(struct gk20a *g);
29int nvgpu_remove(struct device *dev, struct class *class); 29int nvgpu_remove(struct device *dev, struct class *class);
30void nvgpu_free_irq(struct gk20a *g); 30void nvgpu_free_irq(struct gk20a *g);
31struct device_node *nvgpu_get_node(struct gk20a *g);
31 32
32extern struct class nvgpu_class; 33extern struct class nvgpu_class;
33 34
diff --git a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
index 79098eca..e4b4be06 100644
--- a/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
+++ b/drivers/gpu/nvgpu/common/linux/nvgpu_mem.c
@@ -61,6 +61,8 @@ u32 nvgpu_aperture_mask(struct gk20a *g, struct nvgpu_mem *mem,
61int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem) 61int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem)
62{ 62{
63 void *cpu_va; 63 void *cpu_va;
64 pgprot_t prot = nvgpu_is_enabled(g, NVGPU_DMA_COHERENT) ? PAGE_KERNEL :
65 pgprot_writecombine(PAGE_KERNEL);
64 66
65 if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin) 67 if (mem->aperture != APERTURE_SYSMEM || g->mm.force_pramin)
66 return 0; 68 return 0;
@@ -80,7 +82,7 @@ int nvgpu_mem_begin(struct gk20a *g, struct nvgpu_mem *mem)
80 82
81 cpu_va = vmap(mem->priv.pages, 83 cpu_va = vmap(mem->priv.pages,
82 PAGE_ALIGN(mem->size) >> PAGE_SHIFT, 84 PAGE_ALIGN(mem->size) >> PAGE_SHIFT,
83 0, pgprot_writecombine(PAGE_KERNEL)); 85 0, prot);
84 86
85 if (WARN_ON(!cpu_va)) 87 if (WARN_ON(!cpu_va))
86 return -ENOMEM; 88 return -ENOMEM;
diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c
index b8e51aac..511cffc4 100644
--- a/drivers/gpu/nvgpu/common/linux/nvhost.c
+++ b/drivers/gpu/nvgpu/common/linux/nvhost.c
@@ -24,10 +24,11 @@
24 24
25#include "gk20a/gk20a.h" 25#include "gk20a/gk20a.h"
26#include "os_linux.h" 26#include "os_linux.h"
27#include "module.h"
27 28
28int nvgpu_get_nvhost_dev(struct gk20a *g) 29int nvgpu_get_nvhost_dev(struct gk20a *g)
29{ 30{
30 struct device_node *np = dev_from_gk20a(g)->of_node; 31 struct device_node *np = nvgpu_get_node(g);
31 struct platform_device *host1x_pdev = NULL; 32 struct platform_device *host1x_pdev = NULL;
32 const __be32 *host1x_ptr; 33 const __be32 *host1x_ptr;
33 34
diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c
index 23604633..7c853b14 100644
--- a/drivers/gpu/nvgpu/common/linux/pci.c
+++ b/drivers/gpu/nvgpu/common/linux/pci.c
@@ -21,6 +21,8 @@
21#include <nvgpu/nvgpu_common.h> 21#include <nvgpu/nvgpu_common.h>
22#include <nvgpu/kmem.h> 22#include <nvgpu/kmem.h>
23#include <nvgpu/enabled.h> 23#include <nvgpu/enabled.h>
24#include <linux/of_platform.h>
25#include <linux/of_address.h>
24 26
25#include "gk20a/gk20a.h" 27#include "gk20a/gk20a.h"
26#include "clk/clk.h" 28#include "clk/clk.h"
@@ -525,6 +527,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
525 struct gk20a *g; 527 struct gk20a *g;
526 int err; 528 int err;
527 char nodefmt[64]; 529 char nodefmt[64];
530 struct device_node *np;
528 531
529 /* make sure driver_data is a sane index */ 532 /* make sure driver_data is a sane index */
530 if (pent->driver_data >= sizeof(nvgpu_pci_device) / 533 if (pent->driver_data >= sizeof(nvgpu_pci_device) /
@@ -632,6 +635,11 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
632 635
633 g->mm.has_physical_mode = false; 636 g->mm.has_physical_mode = false;
634 637
638 np = nvgpu_get_node(g);
639
640 if (of_dma_is_coherent(np))
641 __nvgpu_set_enabled(g, NVGPU_DMA_COHERENT, true);
642
635 return 0; 643 return 0;
636} 644}
637 645
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index a03ae03e..9c847a55 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -540,7 +540,7 @@ static const struct gpu_ops gv100_ops = {
540 .vm_bind_channel = gk20a_vm_bind_channel, 540 .vm_bind_channel = gk20a_vm_bind_channel,
541 .fb_flush = gk20a_mm_fb_flush, 541 .fb_flush = gk20a_mm_fb_flush,
542 .l2_invalidate = gk20a_mm_l2_invalidate, 542 .l2_invalidate = gk20a_mm_l2_invalidate,
543 .l2_flush = gk20a_mm_l2_flush, 543 .l2_flush = gv11b_mm_l2_flush,
544 .cbc_clean = gk20a_mm_cbc_clean, 544 .cbc_clean = gk20a_mm_cbc_clean,
545 .set_big_page_size = gm20b_mm_set_big_page_size, 545 .set_big_page_size = gm20b_mm_set_big_page_size,
546 .get_big_page_sizes = gm20b_mm_get_big_page_sizes, 546 .get_big_page_sizes = gm20b_mm_get_big_page_sizes,
diff --git a/drivers/gpu/nvgpu/include/nvgpu/enabled.h b/drivers/gpu/nvgpu/include/nvgpu/enabled.h
index 3a5caf0c..e7dd61d2 100644
--- a/drivers/gpu/nvgpu/include/nvgpu/enabled.h
+++ b/drivers/gpu/nvgpu/include/nvgpu/enabled.h
@@ -75,6 +75,9 @@ struct gk20a;
75#define NVGPU_SUPPORT_MAP_DIRECT_KIND_CTRL 24 75#define NVGPU_SUPPORT_MAP_DIRECT_KIND_CTRL 24
76/* Support batch mapping */ 76/* Support batch mapping */
77#define NVGPU_SUPPORT_MAP_BUFFER_BATCH 25 77#define NVGPU_SUPPORT_MAP_BUFFER_BATCH 25
78/* Support DMA coherence */
79#define NVGPU_DMA_COHERENT 26
80
78 81
79/* 82/*
80 * Host flags 83 * Host flags