From 6dde9e67d91419d1e671a520571a2be9bde93999 Mon Sep 17 00:00:00 2001 From: David Nieto Date: Thu, 4 Jan 2018 11:09:57 -0800 Subject: 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 Reviewed-on: https://git-master.nvidia.com/r/1633985 Reviewed-by: svc-mobile-coverity Reviewed-by: Alex Waterman GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/module.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/common/linux/module.c') 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 @@ #include #include #include +#include + #include #include #include @@ -70,6 +72,23 @@ #define CREATE_TRACE_POINTS #include + +struct device_node *nvgpu_get_node(struct gk20a *g) +{ + struct device *dev = dev_from_gk20a(g); + + if (dev_is_pci(dev)) { + struct pci_bus *bus = to_pci_dev(dev)->bus; + + while (!pci_is_root_bus(bus)) + bus = bus->parent; + + return bus->bridge->parent->of_node; + } + + return dev->of_node; +} + void gk20a_busy_noresume(struct gk20a *g) { pm_runtime_get_noresume(dev_from_gk20a(g)); @@ -1042,7 +1061,7 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a) static int nvgpu_read_fuse_overrides(struct gk20a *g) { - struct device_node *np = dev_from_gk20a(g)->of_node; + struct device_node *np = nvgpu_get_node(g); u32 *fuses; int count, i; -- cgit v1.2.2