diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/platform_gk20a_tegra.c | 38 |
1 files changed, 34 insertions, 4 deletions
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 | ||
96 | static 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 | |||
104 | static 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 | |||
96 | static void gk20a_tegra_secure_destroy(struct platform_device *pdev, | 125 | static 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 | ||