video: tegra: nvmap: Make ioremap_prot depend on GENERIC_IOREMAP

The function ioremap_prot() has been exported by the Linux kernel since
v5.9. However, it is only available if GENERIC_IOREMAP is enabled. Since
Linux v6.0, when the ARM64 __ioremap() function was removed, was
GENERIC_IOREMAP enabled for ARM64 by default. Rather than depend on
kernel version for selecting if ioremap_prot is used, use ioremap_prot
if GENERIC_IOREMAP is enabled.

This is a better solution for working with 3rd party Linux kernels that
may backport upstream changes to the kernel and hence are not compatible
with these existing version checks.

Bug 4119327

Change-Id: I2f5f9a691c66c5fbd83d4aa51062c749d39dd447
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2982126
Reviewed-by: Ketan Patil <ketanp@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Jon Hunter
2023-09-20 10:40:54 +01:00
committed by mobile promotions
parent e3f94bde03
commit 069925e74b
3 changed files with 8 additions and 2 deletions

View File

@@ -7,6 +7,12 @@ subdir-ccflags-y += -Werror
include $(srctree.nvidia-oot)/drivers/video/tegra/nvmap/Makefile.memory.configs include $(srctree.nvidia-oot)/drivers/video/tegra/nvmap/Makefile.memory.configs
# If the kernel enables CONFIG_GENERIC_IOREMAP,
# then pass this flag for building NVMAP.
ifdef CONFIG_GENERIC_IOREMAP
ccflags-y += -DCONFIG_GENERIC_IOREMAP
endif
ifeq ($(NVMAP_CONFIG), y) ifeq ($(NVMAP_CONFIG), y)
# Build NvMap only when NVMAP_CONFIG is set to y # Build NvMap only when NVMAP_CONFIG is set to y
nvmap-y := nvmap_core.o \ nvmap-y := nvmap_core.o \

View File

@@ -147,7 +147,7 @@ int nvmap_cache_maint_phys_range(unsigned int op, phys_addr_t pstart,
phys_addr_t next = (loop + PAGE_SIZE) & PAGE_MASK; phys_addr_t next = (loop + PAGE_SIZE) & PAGE_MASK;
void *base; void *base;
next = min(next, pend); next = min(next, pend);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) #if defined(CONFIG_GENERIC_IOREMAP)
io_addr = ioremap_prot(loop, PAGE_SIZE, pgprot_val(PAGE_KERNEL)); io_addr = ioremap_prot(loop, PAGE_SIZE, pgprot_val(PAGE_KERNEL));
#else #else
io_addr = __ioremap(loop, PAGE_SIZE, PG_PROT_KERNEL); io_addr = __ioremap(loop, PAGE_SIZE, PG_PROT_KERNEL);

View File

@@ -200,7 +200,7 @@ void *__nvmap_mmap(struct nvmap_handle *h)
vaddr = vmap(pages, nr_pages, VM_MAP, prot); vaddr = vmap(pages, nr_pages, VM_MAP, prot);
} else { } else {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0) #if defined(CONFIG_GENERIC_IOREMAP)
vaddr = ioremap_prot(h->carveout->base, adj_size, pgprot_val(prot)); vaddr = ioremap_prot(h->carveout->base, adj_size, pgprot_val(prot));
#else #else
vaddr = (__force void *)__ioremap(h->carveout->base, adj_size, vaddr = (__force void *)__ioremap(h->carveout->base, adj_size,