From 48373c24ad8d21897867fa457ea2e6416e2a2982 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 24 Feb 2025 13:23:48 +0000 Subject: [PATCH] video: tegra: nvmap: Fix build for Linux v6.15 In Linux v6.15, the function ioremap_prot() was updated to pass a variable of type pgprot_t instead of an unsigned long. Add a conftest test to check for this and update the NVMAP driver accordlingly to fix the build for Linux v6.15. JIRA LINQPJ14-47 Change-Id: Icff9f63bf5c914997b69076435dd9e2432f343a3 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3332454 (cherry picked from commit b464d75b06c7976ae73e5d7a8660b49e29e1df77) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3499759 Reviewed-by: Brad Griffis Tested-by: Brad Griffis GVS: buildbot_gerritrpt --- drivers/video/tegra/nvmap/nvmap_cache.c | 6 +++++- drivers/video/tegra/nvmap/nvmap_core.c | 6 +++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_cache.c b/drivers/video/tegra/nvmap/nvmap_cache.c index db50936a..511b16a9 100644 --- a/drivers/video/tegra/nvmap/nvmap_cache.c +++ b/drivers/video/tegra/nvmap/nvmap_cache.c @@ -148,10 +148,14 @@ int nvmap_cache_maint_phys_range(unsigned int op, phys_addr_t pstart, void *base; next = min(next, pend); #if defined(CONFIG_GENERIC_IOREMAP) +#if defined(NV_IOREMAP_PROT_HAS_PGPROT_T_ARG) /* Linux v6.15 */ + io_addr = ioremap_prot(loop, PAGE_SIZE, PAGE_KERNEL); +#else io_addr = ioremap_prot(loop, PAGE_SIZE, pgprot_val(PAGE_KERNEL)); +#endif /* NV_IOREMAP_PROT_HAS_PGPROT_T_ARG */ #else io_addr = __ioremap(loop, PAGE_SIZE, PG_PROT_KERNEL); -#endif +#endif /* CONFIG_GENERIC_IOREMAP */ if (io_addr == NULL) return -ENOMEM; base = (__force void *)io_addr + (loop & ~PAGE_MASK); diff --git a/drivers/video/tegra/nvmap/nvmap_core.c b/drivers/video/tegra/nvmap/nvmap_core.c index c91d26a6..8433e3b7 100644 --- a/drivers/video/tegra/nvmap/nvmap_core.c +++ b/drivers/video/tegra/nvmap/nvmap_core.c @@ -201,11 +201,15 @@ void *__nvmap_mmap(struct nvmap_handle *h) vaddr = vmap(pages, nr_pages, VM_MAP, prot); } else { #if defined(CONFIG_GENERIC_IOREMAP) +#if defined(NV_IOREMAP_PROT_HAS_PGPROT_T_ARG) /* Linux v6.15 */ + vaddr = ioremap_prot(h->carveout->base, adj_size, prot); +#else vaddr = ioremap_prot(h->carveout->base, adj_size, pgprot_val(prot)); +#endif /* NV_IOREMAP_PROT_HAS_PGPROT_T_ARG */ #else vaddr = (__force void *)__ioremap(h->carveout->base, adj_size, prot); -#endif +#endif /* CONFIG_GENERIC_IOREMAP */ } if (vaddr == NULL) goto out; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index be689ced..a714e4ec 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -146,6 +146,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += i2c_mux_add_adapter_has_no_class_argument NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_paging_domain_alloc +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_prot_has_pgprot_t_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += irq_get_nr_irqs NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit NV_CONFTEST_FUNCTION_COMPILE_TESTS += media_entity_remote_pad diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index d094f203..607f2d6b 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7570,6 +7570,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_IOMMU_MAP_HAS_GFP_ARG" "" "types" ;; + ioremap_prot_has_pgprot_t_arg) + # + # Determine if pgprot_t is passed to ioremap_prot() + # + # In Linux v6.15, commit 86758b504864 ("mm/ioremap: pass pgprot_t to + # ioremap_prot() instead of unsigned long") updated ioremap_prot() to + # pass pgprot_t. + # + CODE=" + #include + void conftest_ioremap_prot_has_pgprot_t_arg(phys_addr_t phys_addr, + size_t size, pgprot_t prot) { + ioremap_prot(phys_addr, size, prot); + }" + + compile_check_conftest "$CODE" "NV_IOREMAP_PROT_HAS_PGPROT_T_ARG" "" "types" $1 + ;; + iio_dev_opaque_has_mlock) # # Determine if the 'iio_dev_opaque' structure has 'mlock' field.