diff --git a/drivers/scsi/ufs/ufs-tegra-common.c b/drivers/scsi/ufs/ufs-tegra-common.c index ebd2ad3b..ea6cb750 100644 --- a/drivers/scsi/ufs/ufs-tegra-common.c +++ b/drivers/scsi/ufs/ufs-tegra-common.c @@ -1,10 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-only -// SPDX-FileCopyrightText: Copyright (c) 2015-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2015-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include #include #include +#include #include #include #include @@ -1948,6 +1949,7 @@ static int ufs_tegra_config_soc_data(struct ufs_tegra_host *ufs_tegra) ufs_tegra->enable_auto_hibern8 = of_property_read_bool(np, "nvidia,enable-auto-hibern8"); +#if !defined(NV_UFS_HBA_VARIANT_OPS_HAS_SET_DMA_MASK) /* Linux v6.13 */ if (ufs_tegra->soc->chip_id >= TEGRA234) { #if defined(NV_UFSHCD_QUIRKS_ENUM_HAS_UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS) /* Linux 6.0 */ ufs_tegra->hba->quirks |= UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS; @@ -1956,6 +1958,7 @@ static int ufs_tegra_config_soc_data(struct ufs_tegra_host *ufs_tegra) return -ENOTSUPP; #endif } +#endif return 0; } @@ -2461,6 +2464,18 @@ static void ufs_tegra_exit(struct ufs_hba *hba) #endif } +#if defined(NV_UFS_HBA_VARIANT_OPS_HAS_SET_DMA_MASK) /* Linux v6.13 */ +static int ufs_tegra_set_dma_mask(struct ufs_hba *hba) +{ + struct ufs_tegra_host *ufs_tegra = hba->priv; + + if (ufs_tegra->soc->chip_id >= TEGRA234) + return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32)); + + return 0; +} +#endif + /** * struct ufs_hba_tegra_vops - UFS TEGRA specific variant operations * @@ -2476,6 +2491,9 @@ struct ufs_hba_variant_ops ufs_hba_tegra_vops = { .hce_enable_notify = ufs_tegra_hce_enable_notify, .link_startup_notify = ufs_tegra_link_startup_notify, .pwr_change_notify = ufs_tegra_pwr_change_notify, +#if defined(NV_UFS_HBA_VARIANT_OPS_HAS_SET_DMA_MASK) /* Linux v6.13 */ + .set_dma_mask = ufs_tegra_set_dma_mask, +#endif }; static int ufs_tegra_probe(struct platform_device *pdev) diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index f4d658c6..1009d4f3 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -1,6 +1,6 @@ ########################################################################### # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # # Makefile file for NVIDIA Linux conftest ########################################################################### @@ -206,6 +206,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_for_each_trip NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_send_xchar_has_u8_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_write_has_u8_ptr_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += ufs_hba_variant_ops_has_set_dma_mask NV_CONFTEST_FUNCTION_COMPILE_TESTS += ufs_hba_variant_ops_suspend_has_status_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += ufshcd_quirks_enum_has_ufshcd_quirk_broken_64bit_address NV_CONFTEST_FUNCTION_COMPILE_TESTS += ufshcd_quirks_enum_has_ufshcd_quirk_broken_power_seqeunce diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 4ab2c3c0..009aea0e 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -1,6 +1,6 @@ #!/bin/sh # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. PATH="${PATH}:/bin:/sbin:/usr/bin" @@ -8497,6 +8497,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_TTY_OPERATIONS_STRUCT_SET_TERMIOS_HAS_CONST_KTERMIOS_ARG" "" "types" ;; + ufs_hba_variant_ops_has_set_dma_mask) + # + # Determine if the 'struct ufs_hba_variant_ops' has a 'set_dma_mask' + # function pointer. + # + # In Linux v6.13, commit 78bc671bd150 ("scsi: ufs: core: Make DMA + # mask configuration more flexible)" add a 'set_dma_mask' function + # pointer to the 'ufs_hba_variant_ops' structure. + # + CODE=" + #include + int conftest_ufs_hba_variant_ops_has_set_dma_mask(void) { + return offsetof(struct ufs_hba_variant_ops, set_dma_mask); + }" + + compile_check_conftest "$CODE" "NV_UFS_HBA_VARIANT_OPS_HAS_SET_DMA_MASK" "" "types" + ;; + ufs_hba_variant_ops_suspend_has_status_arg) # # Determine if the 'suspend' function for the