From 0d6655f480956a69d7aba114fabc56b380d8bc4f 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 Reviewed-by: svc-mobile-coverity Tested-by: mobile promotions GVS: buildbot_gerritrpt Reviewed-by: Ketan Patil Reviewed-by: mobile promotions --- drivers/video/tegra/nvmap/nvmap_cache.c | 6 +++++- drivers/video/tegra/nvmap/nvmap_core.c | 7 ++++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/video/tegra/nvmap/nvmap_cache.c b/drivers/video/tegra/nvmap/nvmap_cache.c index 1a64ae14..b703b77b 100644 --- a/drivers/video/tegra/nvmap/nvmap_cache.c +++ b/drivers/video/tegra/nvmap/nvmap_cache.c @@ -268,10 +268,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 a24ae13a..e9c27419 100644 --- a/drivers/video/tegra/nvmap/nvmap_core.c +++ b/drivers/video/tegra/nvmap/nvmap_core.c @@ -120,12 +120,17 @@ 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 = (__force void *)ioremap_prot(nvmap_get_heap_block_base(h->carveout), + adj_size, prot); +#else vaddr = (__force void *)ioremap_prot(nvmap_get_heap_block_base(h->carveout), adj_size, pgprot_val(prot)); +#endif /* NV_IOREMAP_PROT_HAS_PGPROT_T_ARG */ #else vaddr = (__force void *)__ioremap(nvmap_get_heap_block_base(h->carveout), adj_size, prot); -#endif +#endif /* CONFIG_GENERIC_IOREMAP */ } if (vaddr == NULL) goto out; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index d051b31d..f29a0063 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -157,6 +157,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 += mii_bus_struct_has_read_c45 diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 7ddf2ca0..d3ba6bab 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7702,6 +7702,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.