summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/nvgpu/gk20a/platform_gk20a.h15
-rw-r--r--drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c38
2 files changed, 49 insertions, 4 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
index 49f386d8..4e454140 100644
--- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
+++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h
@@ -20,12 +20,20 @@
20 20
21#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/pm_domain.h> 22#include <linux/pm_domain.h>
23#include <linux/dma-attrs.h>
23 24
24struct gk20a; 25struct gk20a;
25struct channel_gk20a; 26struct channel_gk20a;
26struct gr_ctx_buffer_desc; 27struct gr_ctx_buffer_desc;
27struct gk20a_scale_profile; 28struct gk20a_scale_profile;
28 29
30struct secure_page_buffer {
31 void (*destroy)(struct platform_device *, struct secure_page_buffer *);
32 size_t size;
33 u64 iova;
34 struct dma_attrs attrs;
35};
36
29struct gk20a_platform { 37struct gk20a_platform {
30#ifdef CONFIG_TEGRA_GK20A 38#ifdef CONFIG_TEGRA_GK20A
31 u32 syncpt_base; 39 u32 syncpt_base;
@@ -79,6 +87,13 @@ struct gk20a_platform {
79 struct gr_ctx_buffer_desc *desc, 87 struct gr_ctx_buffer_desc *desc,
80 size_t size); 88 size_t size);
81 89
90 /* Function to allocate a secure buffer of PAGE_SIZE at probe time.
91 * This is also helpful to trigger secure memory resizing
92 * while GPU is off
93 */
94 int (*secure_page_alloc)(struct platform_device *dev);
95 struct secure_page_buffer secure_buffer;
96
82 /* Device is going to be suspended */ 97 /* Device is going to be suspended */
83 int (*suspend)(struct device *); 98 int (*suspend)(struct device *);
84 99
diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c b/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c
index 813053e0..9f2a7971 100644
--- a/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c
+++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c
@@ -93,12 +93,41 @@ int FXDIV(int x, int y)
93 return (x << pos) / y; 93 return (x << pos) / y;
94} 94}
95 95
96static void gk20a_tegra_secure_page_destroy(struct platform_device *pdev,
97 struct secure_page_buffer *secure_buffer)
98{
99 dma_free_attrs(&tegra_vpr_dev, secure_buffer->size,
100 (void *)(uintptr_t)secure_buffer->iova,
101 secure_buffer->iova, &secure_buffer->attrs);
102}
103
104static int gk20a_tegra_secure_page_alloc(struct platform_device *pdev)
105{
106 struct gk20a_platform *platform = platform_get_drvdata(pdev);
107 struct secure_page_buffer *secure_buffer = &platform->secure_buffer;
108 DEFINE_DMA_ATTRS(attrs);
109 dma_addr_t iova;
110 size_t size = PAGE_SIZE;
111
112 (void)dma_alloc_attrs(&tegra_vpr_dev, size, &iova,
113 DMA_MEMORY_NOMAP, &attrs);
114 if (dma_mapping_error(&tegra_vpr_dev, iova))
115 return -ENOMEM;
116
117 secure_buffer->size = size;
118 secure_buffer->iova = iova;
119 secure_buffer->attrs = attrs;
120 secure_buffer->destroy = gk20a_tegra_secure_page_destroy;
121
122 return 0;
123}
124
96static void gk20a_tegra_secure_destroy(struct platform_device *pdev, 125static void gk20a_tegra_secure_destroy(struct platform_device *pdev,
97 struct gr_ctx_buffer_desc *desc) 126 struct gr_ctx_buffer_desc *desc)
98{ 127{
99 gk20a_free_sgtable(&desc->sgt); 128 gk20a_free_sgtable(&desc->sgt);
100 dma_free_attrs(&tegra_vpr_dev, desc->size, 129 dma_free_attrs(&tegra_vpr_dev, desc->size,
101 (void *)(uintptr_t)&desc->iova, 130 (void *)(uintptr_t)desc->iova,
102 desc->iova, &desc->attrs); 131 desc->iova, &desc->attrs);
103} 132}
104 133
@@ -113,10 +142,8 @@ static int gk20a_tegra_secure_alloc(struct platform_device *pdev,
113 struct page *page; 142 struct page *page;
114 int err = 0; 143 int err = 0;
115 144
116 dma_set_attr(DMA_ATTR_NO_KERNEL_MAPPING, &attrs);
117
118 (void)dma_alloc_attrs(&tegra_vpr_dev, size, &iova, 145 (void)dma_alloc_attrs(&tegra_vpr_dev, size, &iova,
119 GFP_KERNEL, &attrs); 146 DMA_MEMORY_NOMAP, &attrs);
120 if (dma_mapping_error(&tegra_vpr_dev, iova)) 147 if (dma_mapping_error(&tegra_vpr_dev, iova))
121 return -ENOMEM; 148 return -ENOMEM;
122 149
@@ -524,6 +551,7 @@ struct gk20a_platform t132_gk20a_tegra_platform = {
524 .qos_id = PM_QOS_GPU_FREQ_MIN, 551 .qos_id = PM_QOS_GPU_FREQ_MIN,
525 552
526 .secure_alloc = gk20a_tegra_secure_alloc, 553 .secure_alloc = gk20a_tegra_secure_alloc,
554 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
527 .dump_platform_dependencies = gk20a_tegra_debug_dump, 555 .dump_platform_dependencies = gk20a_tegra_debug_dump,
528}; 556};
529 557
@@ -551,6 +579,7 @@ struct gk20a_platform gk20a_tegra_platform = {
551 .qos_id = PM_QOS_GPU_FREQ_MIN, 579 .qos_id = PM_QOS_GPU_FREQ_MIN,
552 580
553 .secure_alloc = gk20a_tegra_secure_alloc, 581 .secure_alloc = gk20a_tegra_secure_alloc,
582 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
554 .dump_platform_dependencies = gk20a_tegra_debug_dump, 583 .dump_platform_dependencies = gk20a_tegra_debug_dump,
555}; 584};
556 585
@@ -574,6 +603,7 @@ struct gk20a_platform gm20b_tegra_platform = {
574 .qos_id = PM_QOS_GPU_FREQ_MIN, 603 .qos_id = PM_QOS_GPU_FREQ_MIN,
575 604
576 .secure_alloc = gk20a_tegra_secure_alloc, 605 .secure_alloc = gk20a_tegra_secure_alloc,
606 .secure_page_alloc = gk20a_tegra_secure_page_alloc,
577 .dump_platform_dependencies = gk20a_tegra_debug_dump, 607 .dump_platform_dependencies = gk20a_tegra_debug_dump,
578}; 608};
579 609