gpu: nvgpu: use nvmap exported APIs for dma_alloc|free_attrs on kstable

To support nvmap as OOT module in kstable it implemented the APIs
nvmap_dma_alloc_attrs and nvmap_dma_free_attrs to replace usage
of kernel dma_alloc_attrs and dma_free_attrs. nvmap APIs have
special handling for VPR carveout.

Use those exported APIs in nvgpu when CONFIG_NVGPU_NVMAP_NEXT is
defined. This config will be defined only for kstable builds.

JIRA LS-458
Bug 200754700

Change-Id: I717aa579d29ee10c006b044f6b0fafbedc57dba8
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2647951
(cherry picked from commit 4e227b3e80)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2650378
Tested-by: Omprakash Shewale <oshewale@nvidia.com>
Reviewed-by: Omprakash Shewale <oshewale@nvidia.com>
This commit is contained in:
Sagar Kamble
2021-12-30 16:43:41 +05:30
committed by Omprakash Shewale
parent 6b72b2a4e7
commit 4bf47b32fc
3 changed files with 30 additions and 0 deletions

View File

@@ -42,6 +42,13 @@ ifeq ($(CONFIG_TEGRA_GK20A_NVHOST_HOST1X),y)
ccflags-y += -I$(srctree.host1x)/include
endif
# When using the upstream nvmap driver, the Makefile must define the
# srctree.nvmap path in order to find the necessary header files for
# the upstream nvmap driver.
ifeq ($(CONFIG_NVGPU_NVMAP_NEXT),y)
ccflags-y += -I$(srctree.nvmap)/include
endif
ifeq ($(CONFIG_NVGPU_DEBUGGER),y)
ccflags-y += -DCONFIG_NVGPU_DEBUGGER
ccflags-y += -DCONFIG_NVGPU_ENGINE_RESET

View File

@@ -94,6 +94,10 @@ CONFIG_TEGRA_GK20A_NVHOST := y
CONFIG_TEGRA_GK20A_NVHOST_HOST1X := y
endif
ifdef CONFIG_TEGRA_NVMAP_NEXT
CONFIG_NVGPU_NVMAP_NEXT := y
endif
# Enable support for GPUs on PCIe bus.
ifeq ($(CONFIG_PCI),y)
# Support for NVGPU DGPU
@@ -216,6 +220,9 @@ endif
ifeq ($(CONFIG_TEGRA_GK20A_NVHOST_HOST1X),y)
ccflags-y += -DCONFIG_TEGRA_GK20A_NVHOST_HOST1X
endif
ifeq ($(CONFIG_NVGPU_NVMAP_NEXT),y)
ccflags-y += -DCONFIG_NVGPU_NVMAP_NEXT
endif
ifeq ($(CONFIG_NVGPU_DGPU),y)
ccflags-y += -DCONFIG_NVGPU_DGPU
endif

View File

@@ -30,6 +30,10 @@
#include <linux/platform/tegra/common.h>
#endif
#if defined(CONFIG_NVGPU_NVMAP_NEXT)
#include <linux/nvmap_exports.h>
#endif
#ifdef CONFIG_NV_TEGRA_MC
#include <linux/platform/tegra/mc.h>
#endif /* CONFIG_NV_TEGRA_MC */
@@ -111,9 +115,15 @@ struct gk20a_emc_params {
static void gk20a_tegra_secure_page_destroy(struct gk20a *g,
struct secure_page_buffer *secure_buffer)
{
#if defined(CONFIG_NVGPU_NVMAP_NEXT)
nvmap_dma_free_attrs(&tegra_vpr_dev, secure_buffer->size,
(void *)(uintptr_t)secure_buffer->phys,
secure_buffer->phys, DMA_ATTR_NO_KERNEL_MAPPING);
#else
dma_free_attrs(&tegra_vpr_dev, secure_buffer->size,
(void *)(uintptr_t)secure_buffer->phys,
secure_buffer->phys, DMA_ATTR_NO_KERNEL_MAPPING);
#endif
secure_buffer->destroy = NULL;
}
@@ -699,8 +709,14 @@ int gk20a_tegra_init_secure_alloc(struct gk20a_platform *platform)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
tegra_vpr_dev.coherent_dma_mask = DMA_BIT_MASK(32);
#endif
#if defined(CONFIG_NVGPU_NVMAP_NEXT)
(void)nvmap_dma_alloc_attrs(&tegra_vpr_dev,
platform->secure_buffer_size, &iova,
GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING);
#else
(void)dma_alloc_attrs(&tegra_vpr_dev, platform->secure_buffer_size, &iova,
GFP_KERNEL, DMA_ATTR_NO_KERNEL_MAPPING);
#endif
/* Some platforms disable VPR. In that case VPR allocations always
* fail. Just disable VPR usage in nvgpu in that case. */
if (dma_mapping_error(&tegra_vpr_dev, iova)) {