summaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-05-01 16:37:03 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-11 14:05:31 -0400
commitbd68f98ba76f43954e9858252a30e6c3b054c146 (patch)
treefaa4e213603b9fe91d911cf5e0f06977c4232db4 /drivers/gpu
parentc3fa78b1d9cba28547ca59154207d434931ae746 (diff)
gpu: nvgpu: Move secure_alloc to struct gk20a
Move the function pointer for VPR page allocation to struct gk20a and use it from there. At the same time remove secure_page_alloc pointer and add a direct call to it in probe. Move platform_tegra.h as tegra/linux/platform_gk20a_tegra.h, as it's only declaring functions defined in platform_gk20a_tegra.c to other files in the same directory. JIRA NVGPU-16 Change-Id: I19ac9ee0b2f6734203ae32a1f51d67fd51aced9f Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: http://git-master/r/1473706 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/nvgpu/common/linux/driver_common.c19
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.h8
-rw-r--r--drivers/gpu/nvgpu/gk20a/gr_gk20a.c16
-rw-r--r--drivers/gpu/nvgpu/gk20a/platform_gk20a.h14
-rw-r--r--drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c25
-rw-r--r--drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.h (renamed from drivers/gpu/nvgpu/platform_tegra.h)16
-rw-r--r--drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c9
7 files changed, 41 insertions, 66 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/driver_common.c b/drivers/gpu/nvgpu/common/linux/driver_common.c
index 14d4dd40..7d6acf91 100644
--- a/drivers/gpu/nvgpu/common/linux/driver_common.c
+++ b/drivers/gpu/nvgpu/common/linux/driver_common.c
@@ -134,20 +134,6 @@ static void nvgpu_init_mm_vars(struct gk20a *g)
134 nvgpu_mutex_init(&g->mm.priv_lock); 134 nvgpu_mutex_init(&g->mm.priv_lock);
135} 135}
136 136
137static int gk20a_secure_page_alloc(struct device *dev)
138{
139 struct gk20a_platform *platform = dev_get_drvdata(dev);
140 int err = 0;
141
142 if (platform->secure_page_alloc) {
143 err = platform->secure_page_alloc(dev);
144 if (!err)
145 platform->secure_alloc_ready = true;
146 }
147
148 return err;
149}
150
151int nvgpu_probe(struct gk20a *g, 137int nvgpu_probe(struct gk20a *g,
152 const char *debugfs_symlink, 138 const char *debugfs_symlink,
153 const char *interface_name, 139 const char *interface_name,
@@ -178,11 +164,6 @@ int nvgpu_probe(struct gk20a *g,
178 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ)) 164 if (IS_ENABLED(CONFIG_GK20A_DEVFREQ))
179 gk20a_scale_init(g->dev); 165 gk20a_scale_init(g->dev);
180 166
181 err = gk20a_secure_page_alloc(g->dev);
182 if (err)
183 dev_err(g->dev,
184 "failed to allocate secure buffer %d\n", err);
185
186 if (platform->late_probe) { 167 if (platform->late_probe) {
187 err = platform->late_probe(g->dev); 168 err = platform->late_probe(g->dev);
188 if (err) { 169 if (err) {
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.h b/drivers/gpu/nvgpu/gk20a/gk20a.h
index 96ca69a3..03f61c33 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.h
@@ -669,6 +669,14 @@ struct gpu_ops {
669 void (*init_inst_block)(struct nvgpu_mem *inst_block, 669 void (*init_inst_block)(struct nvgpu_mem *inst_block,
670 struct vm_gk20a *vm, u32 big_page_size); 670 struct vm_gk20a *vm, u32 big_page_size);
671 bool (*mmu_fault_pending)(struct gk20a *g); 671 bool (*mmu_fault_pending)(struct gk20a *g);
672 /* This function is called to allocate secure memory (memory
673 * that the CPU cannot see). The function should fill the
674 * context buffer descriptor (especially fields destroy, sgt,
675 * size).
676 */
677 int (*secure_alloc)(struct device *dev,
678 struct gr_ctx_buffer_desc *desc,
679 size_t size);
672 } mm; 680 } mm;
673 struct { 681 struct {
674 u32 (*enter)(struct gk20a *g, struct nvgpu_mem *mem, 682 u32 (*enter)(struct gk20a *g, struct nvgpu_mem *mem,
diff --git a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
index 2f52fdcf..2d87911d 100644
--- a/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gr_gk20a.c
@@ -2722,7 +2722,6 @@ static void gr_gk20a_free_global_ctx_buffers(struct gk20a *g)
2722 2722
2723static int gr_gk20a_alloc_global_ctx_buffers(struct gk20a *g) 2723static int gr_gk20a_alloc_global_ctx_buffers(struct gk20a *g)
2724{ 2724{
2725 struct gk20a_platform *platform = dev_get_drvdata(g->dev);
2726 struct gr_gk20a *gr = &g->gr; 2725 struct gr_gk20a *gr = &g->gr;
2727 int attr_buffer_size, err; 2726 int attr_buffer_size, err;
2728 struct device *dev = g->dev; 2727 struct device *dev = g->dev;
@@ -2744,8 +2743,8 @@ static int gr_gk20a_alloc_global_ctx_buffers(struct gk20a *g)
2744 if (err) 2743 if (err)
2745 goto clean_up; 2744 goto clean_up;
2746 2745
2747 if (platform->secure_alloc) 2746 if (g->ops.mm.secure_alloc)
2748 platform->secure_alloc(dev, 2747 g->ops.mm.secure_alloc(dev,
2749 &gr->global_ctx_buffer[CIRCULAR_VPR], 2748 &gr->global_ctx_buffer[CIRCULAR_VPR],
2750 cb_buffer_size); 2749 cb_buffer_size);
2751 2750
@@ -2756,8 +2755,8 @@ static int gr_gk20a_alloc_global_ctx_buffers(struct gk20a *g)
2756 if (err) 2755 if (err)
2757 goto clean_up; 2756 goto clean_up;
2758 2757
2759 if (platform->secure_alloc) 2758 if (g->ops.mm.secure_alloc)
2760 platform->secure_alloc(dev, 2759 g->ops.mm.secure_alloc(dev,
2761 &gr->global_ctx_buffer[PAGEPOOL_VPR], 2760 &gr->global_ctx_buffer[PAGEPOOL_VPR],
2762 pagepool_buffer_size); 2761 pagepool_buffer_size);
2763 2762
@@ -2768,14 +2767,11 @@ static int gr_gk20a_alloc_global_ctx_buffers(struct gk20a *g)
2768 if (err) 2767 if (err)
2769 goto clean_up; 2768 goto clean_up;
2770 2769
2771 if (platform->secure_alloc) 2770 if (g->ops.mm.secure_alloc)
2772 platform->secure_alloc(dev, 2771 g->ops.mm.secure_alloc(dev,
2773 &gr->global_ctx_buffer[ATTRIBUTE_VPR], 2772 &gr->global_ctx_buffer[ATTRIBUTE_VPR],
2774 attr_buffer_size); 2773 attr_buffer_size);
2775 2774
2776 if (platform->secure_buffer.destroy)
2777 platform->secure_buffer.destroy(dev, &platform->secure_buffer);
2778
2779 gk20a_dbg_info("golden_image_size : %d", 2775 gk20a_dbg_info("golden_image_size : %d",
2780 gr->ctx_vars.golden_image_size); 2776 gr->ctx_vars.golden_image_size);
2781 2777
diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
index 8c93249a..44277abf 100644
--- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
@@ -148,21 +148,7 @@ struct gk20a_platform {
148 /* Powerdown platform dependencies */ 148 /* Powerdown platform dependencies */
149 void (*idle)(struct device *dev); 149 void (*idle)(struct device *dev);
150 150
151 /* This function is called to allocate secure memory (memory that the
152 * CPU cannot see). The function should fill the context buffer
153 * descriptor (especially fields destroy, sgt, size).
154 */
155 int (*secure_alloc)(struct device *dev,
156 struct gr_ctx_buffer_desc *desc,
157 size_t size);
158
159 /* Function to allocate a secure buffer of PAGE_SIZE at probe time.
160 * This is also helpful to trigger secure memory resizing
161 * while GPU is off
162 */
163 int (*secure_page_alloc)(struct device *dev);
164 struct secure_page_buffer secure_buffer; 151 struct secure_page_buffer secure_buffer;
165 bool secure_alloc_ready;
166 152
167 /* Device is going to be suspended */ 153 /* Device is going to be suspended */
168 int (*suspend)(struct device *); 154 int (*suspend)(struct device *);
diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
index 99c7e8b3..996fd251 100644
--- a/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
+++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.c
@@ -110,6 +110,8 @@ static void gk20a_tegra_secure_page_destroy(struct device *dev,
110 dma_free_attrs(&tegra_vpr_dev, secure_buffer->size, 110 dma_free_attrs(&tegra_vpr_dev, secure_buffer->size,
111 (void *)(uintptr_t)secure_buffer->iova, 111 (void *)(uintptr_t)secure_buffer->iova,
112 secure_buffer->iova, __DMA_ATTR(attrs)); 112 secure_buffer->iova, __DMA_ATTR(attrs));
113
114 secure_buffer->destroy = NULL;
113} 115}
114 116
115int gk20a_tegra_secure_page_alloc(struct device *dev) 117int gk20a_tegra_secure_page_alloc(struct device *dev)
@@ -153,7 +155,7 @@ static void gk20a_tegra_secure_destroy(struct gk20a *g,
153 } 155 }
154} 156}
155 157
156int gk20a_tegra_secure_alloc(struct device *dev, 158static int gk20a_tegra_secure_alloc(struct device *dev,
157 struct gr_ctx_buffer_desc *desc, 159 struct gr_ctx_buffer_desc *desc,
158 size_t size) 160 size_t size)
159{ 161{
@@ -164,9 +166,6 @@ int gk20a_tegra_secure_alloc(struct device *dev,
164 struct page *page; 166 struct page *page;
165 int err = 0; 167 int err = 0;
166 168
167 if (!platform->secure_alloc_ready)
168 return -EINVAL;
169
170 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, __DMA_ATTR(attrs)); 169 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, __DMA_ATTR(attrs));
171 (void)dma_alloc_attrs(&tegra_vpr_dev, size, &iova, 170 (void)dma_alloc_attrs(&tegra_vpr_dev, size, &iova,
172 GFP_KERNEL, __DMA_ATTR(attrs)); 171 GFP_KERNEL, __DMA_ATTR(attrs));
@@ -194,6 +193,9 @@ int gk20a_tegra_secure_alloc(struct device *dev,
194 desc->mem.size = size; 193 desc->mem.size = size;
195 desc->mem.aperture = APERTURE_SYSMEM; 194 desc->mem.aperture = APERTURE_SYSMEM;
196 195
196 if (platform->secure_buffer.destroy)
197 platform->secure_buffer.destroy(dev, &platform->secure_buffer);
198
197 return err; 199 return err;
198 200
199fail_sgt: 201fail_sgt:
@@ -896,6 +898,11 @@ void gk20a_tegra_idle(struct device *dev)
896#endif 898#endif
897} 899}
898 900
901void gk20a_tegra_init_secure_alloc(struct gk20a *g)
902{
903 g->ops.mm.secure_alloc = gk20a_tegra_secure_alloc;
904}
905
899static int gk20a_tegra_probe(struct device *dev) 906static int gk20a_tegra_probe(struct device *dev)
900{ 907{
901 struct gk20a_platform *platform = dev_get_drvdata(dev); 908 struct gk20a_platform *platform = dev_get_drvdata(dev);
@@ -974,6 +981,7 @@ static int gk20a_tegra_probe(struct device *dev)
974 981
975 gk20a_tegra_get_clocks(dev); 982 gk20a_tegra_get_clocks(dev);
976 nvgpu_linux_init_clk_support(platform->g); 983 nvgpu_linux_init_clk_support(platform->g);
984 gk20a_tegra_init_secure_alloc(platform->g);
977 985
978 if (platform->clk_register) { 986 if (platform->clk_register) {
979 ret = platform->clk_register(platform->g); 987 ret = platform->clk_register(platform->g);
@@ -988,8 +996,11 @@ static int gk20a_tegra_probe(struct device *dev)
988 return 0; 996 return 0;
989} 997}
990 998
991static int gk20a_tegra_late_probe(struct device *dev) 999int gk20a_tegra_late_probe(struct device *dev)
992{ 1000{
1001 /* Cause early VPR resize */
1002 gk20a_tegra_secure_page_alloc(dev);
1003
993 /* Initialise tegra specific scaling quirks */ 1004 /* Initialise tegra specific scaling quirks */
994 gk20a_tegra_scale_init(dev); 1005 gk20a_tegra_scale_init(dev);
995 1006
@@ -1085,8 +1096,6 @@ struct gk20a_platform gk20a_tegra_platform = {
1085 .devfreq_governor = "nvhost_podgov", 1096 .devfreq_governor = "nvhost_podgov",
1086 .qos_notify = gk20a_scale_qos_notify, 1097 .qos_notify = gk20a_scale_qos_notify,
1087 1098
1088 .secure_alloc = gk20a_tegra_secure_alloc,
1089 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
1090 .dump_platform_dependencies = gk20a_tegra_debug_dump, 1099 .dump_platform_dependencies = gk20a_tegra_debug_dump,
1091 1100
1092 .soc_name = "tegra12x", 1101 .soc_name = "tegra12x",
@@ -1157,8 +1166,6 @@ struct gk20a_platform gm20b_tegra_platform = {
1157 .devfreq_governor = "nvhost_podgov", 1166 .devfreq_governor = "nvhost_podgov",
1158 .qos_notify = gk20a_scale_qos_notify, 1167 .qos_notify = gk20a_scale_qos_notify,
1159 1168
1160 .secure_alloc = gk20a_tegra_secure_alloc,
1161 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
1162 .dump_platform_dependencies = gk20a_tegra_debug_dump, 1169 .dump_platform_dependencies = gk20a_tegra_debug_dump,
1163 1170
1164 .has_cde = true, 1171 .has_cde = true,
diff --git a/drivers/gpu/nvgpu/platform_tegra.h b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.h
index 63aed5a7..1aa7c1e3 100644
--- a/drivers/gpu/nvgpu/platform_tegra.h
+++ b/drivers/gpu/nvgpu/tegra/linux/platform_gk20a_tegra.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * GK20A Platform (SoC) Interface 2 * GK20A Platform (SoC) Interface
3 * 3 *
4 * Copyright (c) 2014-2016, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify it 6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License, 7 * under the terms and conditions of the GNU General Public License,
@@ -13,17 +13,13 @@
13 * more details. 13 * more details.
14 */ 14 */
15 15
16#ifndef _NVGPU_PLATFORM_TEGRA_H_ 16#ifndef _NVGPU_PLATFORM_GK20A_TEGRA_H_
17#define _NVGPU_PLATFORM_TEGRA_H_ 17#define _NVGPU_PLATFORM_GK20A_TEGRA_H_
18 18
19#include <nvgpu/types.h> 19struct device;
20struct gk20a;
20 21
21struct platform_device; 22void gk20a_tegra_init_secure_alloc(struct gk20a *g);
22struct gr_ctx_buffer_desc;
23
24int gk20a_tegra_secure_alloc(struct device *dev,
25 struct gr_ctx_buffer_desc *desc,
26 size_t size);
27int gk20a_tegra_secure_page_alloc(struct device *dev); 23int gk20a_tegra_secure_page_alloc(struct device *dev);
28 24
29#endif 25#endif
diff --git a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c
index 77b4b536..138b8fda 100644
--- a/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c
+++ b/drivers/gpu/nvgpu/tegra/linux/platform_gp10b_tegra.c
@@ -36,7 +36,7 @@
36#include "gk20a/gk20a.h" 36#include "gk20a/gk20a.h"
37#include "gk20a/gk20a_scale.h" 37#include "gk20a/gk20a_scale.h"
38 38
39#include "platform_tegra.h" 39#include "platform_gk20a_tegra.h"
40#include "gp10b/gp10b_sysfs.h" 40#include "gp10b/gp10b_sysfs.h"
41#include "gp10b/platform_gp10b.h" 41#include "gp10b/platform_gp10b.h"
42 42
@@ -163,12 +163,16 @@ static int gp10b_tegra_probe(struct device *dev)
163 163
164 gp10b_tegra_get_clocks(dev); 164 gp10b_tegra_get_clocks(dev);
165 nvgpu_linux_init_clk_support(platform->g); 165 nvgpu_linux_init_clk_support(platform->g);
166 gk20a_tegra_init_secure_alloc(platform->g);
166 167
167 return 0; 168 return 0;
168} 169}
169 170
170static int gp10b_tegra_late_probe(struct device *dev) 171static int gp10b_tegra_late_probe(struct device *dev)
171{ 172{
173 /* Cause early VPR resize */
174 gk20a_tegra_secure_page_alloc(dev);
175
172 /*Create GP10B specific sysfs*/ 176 /*Create GP10B specific sysfs*/
173 gp10b_create_sysfs(dev); 177 gp10b_create_sysfs(dev);
174 178
@@ -423,9 +427,6 @@ struct gk20a_platform gp10b_tegra_platform = {
423 427
424 .qos_notify = gk20a_scale_qos_notify, 428 .qos_notify = gk20a_scale_qos_notify,
425 429
426 .secure_alloc = gk20a_tegra_secure_alloc,
427 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
428
429 .reset_assert = gp10b_tegra_reset_assert, 430 .reset_assert = gp10b_tegra_reset_assert,
430 .reset_deassert = gp10b_tegra_reset_deassert, 431 .reset_deassert = gp10b_tegra_reset_deassert,
431 432