From f255a170a7d1603400812a301bb88f2ec3043b36 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 5 Dec 2023 10:07:13 +0000 Subject: [PATCH] nvmap: Use conftest to finding shrinker_alloc() presence Use conftest to find whether shrinker_alloc() is present or not. In Linux v6.7, commit c42d50aefd17 ("mm: shrinker: add infrastructure for dynamically allocating shrinker") added this API. Bug 4346767 Change-Id: Ida724bb31d3c4db650b3a5742c5972f984cb9152 Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3028574 (cherry picked from commit 3b457a12930a362fd9bd7a1e96990ac1522d2a88) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3036795 Tested-by: mobile promotions Reviewed-by: mobile promotions --- Makefile | 6 ------ drivers/video/tegra/nvmap/nvmap_pp.c | 6 +++--- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index ee38391a..076165df 100644 --- a/Makefile +++ b/Makefile @@ -53,12 +53,6 @@ subdir-ccflags-y += -DNV_V4L2_ASYNC_NF_SUBDEVICE_INIT_RENAME export CONFIG_SKIP_CRYPTO=y endif -# Changes done in Linux 6.7 onwards -ifeq ($(shell test $(LINUX_VERSION) -ge $(LINUX_VERSION_6_7); echo $$?),0) -# Support enable to allocate shrinker dynamically -subdir-ccflags-y += -DNV_NVMAP_DYNAMIC_SHRINKER_ALLOC_SUPPORT -endif - ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION endif diff --git a/drivers/video/tegra/nvmap/nvmap_pp.c b/drivers/video/tegra/nvmap/nvmap_pp.c index 8c165125..15b3f307 100644 --- a/drivers/video/tegra/nvmap/nvmap_pp.c +++ b/drivers/video/tegra/nvmap/nvmap_pp.c @@ -581,7 +581,7 @@ static unsigned long nvmap_page_pool_scan_objects(struct shrinker *shrinker, SHRINK_STOP : (sc->nr_to_scan - remaining); } -#if defined(NV_NVMAP_DYNAMIC_SHRINKER_ALLOC_SUPPORT) +#if defined(NV_SHRINKER_ALLOC_PRESENT) /* Linux 6.7 */ static struct shrinker *nvmap_page_pool_shrinker; #else static struct shrinker nvmap_page_pool_shrinker = { @@ -775,7 +775,7 @@ int nvmap_page_pool_init(struct nvmap_device *dev) NULL, "nvmap-bz"); if (IS_ERR(background_allocator)) goto fail; -#if defined(NV_NVMAP_DYNAMIC_SHRINKER_ALLOC_SUPPORT) +#if defined(NV_SHRINKER_ALLOC_PRESENT) /* Linux 6.7 */ nvmap_page_pool_shrinker = shrinker_alloc(0, "nvmap_pp_shrinker"); if (!nvmap_page_pool_shrinker) { goto fail; @@ -810,7 +810,7 @@ int nvmap_page_pool_fini(struct nvmap_device *dev) * registered */ if (!IS_ERR_OR_NULL(background_allocator)) { -#if defined(NV_NVMAP_DYNAMIC_SHRINKER_ALLOC_SUPPORT) +#if defined(NV_SHRINKER_ALLOC_PRESENT) /* Linux 6.7 */ shrinker_free(nvmap_page_pool_shrinker); nvmap_page_pool_shrinker = NULL; #else diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index d17c4709..e106f2f7 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -130,6 +130,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_disable_pcie_error_reporting NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_enable_pcie_error_reporting NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epf_driver_struct_probe_has_id_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += register_shrinker_has_fmt_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += shrinker_alloc NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_card_jack_new_has_no_snd_soc_jack_pins NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_component_driver_struct_has_non_legacy_dai_naming NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_dai_link_struct_has_c2c_params_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 7ef60daa..dc48f232 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7108,6 +7108,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_REQUEST_STRUCT_HAS_COMPLETION_DATA_ARG" "" "types" ;; + shrinker_alloc) + # + # Determine if the shrinker alloc present or not. + # + # In Linux v6.7, commit c42d50aefd17 ("mm: shrinker: add infrastructure for + # dynamically allocating shrinker") + # + CODE=" + #include + #include + #include + void conftest_shrinker_alloc(void) { + shrinker_alloc(); + }" + + compile_check_conftest "$CODE" "NV_SHRINKER_ALLOC_PRESENT" "" "functions" + ;; + snd_soc_card_jack_new_has_no_snd_soc_jack_pins) # # Determine if the function snd_soc_card_jack_new() has 'pins' and