From 50c387ecf9bf6ccf61109e5a4af8af05d0d4d0b1 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Thu, 10 Apr 2025 13:52:53 +0100 Subject: [PATCH] nvmap: Remove dma_buf_ops flag cache_sgt_mapping The dma_buf_ops flag 'cache_sgt_mapping' has been removed in Linux v6.16. Although NVMAP has its own caching and so it should be possible to simply drop this flag, some tests are failing. For now add a test to conftest to detect if this flag is present and update the NVMAP driver accordingly. Bug 5215421 Change-Id: I382d5c62fd550254d387abd1a21e5a1c5cda3a6e Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3384177 (cherry picked from commit 326b31912bf1da7de0a5340826ec1fdaf084c11e) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3461885 Tested-by: mobile promotions Reviewed-by: Brad Griffis Reviewed-by: mobile promotions GVS: buildbot_gerritrpt --- drivers/video/tegra/nvmap/nvmap_dmabuf.c | 3 ++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/video/tegra/nvmap/nvmap_dmabuf.c b/drivers/video/tegra/nvmap/nvmap_dmabuf.c index bd0c5c11..5d8e87c4 100644 --- a/drivers/video/tegra/nvmap/nvmap_dmabuf.c +++ b/drivers/video/tegra/nvmap/nvmap_dmabuf.c @@ -489,8 +489,9 @@ static struct dma_buf_ops nvmap_dma_buf_ops = { .mmap = nvmap_dmabuf_mmap, .vmap = nvmap_dmabuf_vmap, .vunmap = nvmap_dmabuf_vunmap, +#if defined(NV_DMA_BUF_OPS_HAS_CACHE_SGT_MAPPING) .cache_sgt_mapping = true, - +#endif }; static char dmabuf_name[] = "nvmap_dmabuf"; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 1d164d7b..084f0774 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -123,6 +123,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_spi_alloc_host NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_tegra_core_dev_init_opp_table_common NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register NV_CONFTEST_FUNCTION_COMPILE_TESTS += disk_check_media_change +NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_buf_ops_has_cache_sgt_mapping NV_CONFTEST_FUNCTION_COMPILE_TESTS += dma_slave_config_struct_has_slave_id NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_connector_helper_funcs_struct_mode_valid_has_const_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 1688e9d6..61c8247b 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7131,6 +7131,22 @@ compile_test() { compile_check_conftest "$CODE" "NV_DISK_CHECK_MEDIA_CHANGE_PRESENT" "" "functions" ;; + dma_buf_ops_has_cache_sgt_mapping) + # + # Determine if the 'dma_buf_ops' structure has 'cache_sgt_mapping' member. + # + # In Linux v6.16, commit b72f66f22c0e ("dma-buf: drop caching of sg_tables") + # removed the 'cache_sgt_mapping' member from the 'dma_buf_ops' structure. + # + CODE=" + #include + int conftest_dma_buf_ops_has_cache_sgt_mapping(void) { + return offsetof(struct dma_buf_ops, cache_sgt_mapping); + }" + + compile_check_conftest "$CODE" "NV_DMA_BUF_OPS_HAS_CACHE_SGT_MAPPING" "" "types" + ;; + dma_slave_config_struct_has_slave_id) # # Determine if 'struct dma_slave_config' has the 'slave_id' member.