diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index 977d2bf4..232879aa 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * PCIe DMA EPF test framework for Tegra PCIe. - * - * Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include @@ -207,6 +206,7 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf) static int pcie_dma_epf_bind(struct pci_epf *epf) { + const struct pci_epc_features *epc_features; struct pci_epc *epc = epf->epc; struct pcie_epf_dma *epfnv = epf_get_drvdata(epf); struct device *fdev = &epf->dev; @@ -222,7 +222,19 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) epfnv->epf = epf; epfnv->epc = epc; - epfnv->bar0_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, BAR_0, SZ_64K); + epc_features = pci_epc_get_features(epc, epf->func_no, epf->vfunc_no); + if (!epc_features) { + dev_err(fdev, "Failed to get endpoint features!\n"); + return -EINVAL; + } + +#if defined(NV_PCI_EPF_ALLOC_SPACE_HAS_EPC_FEATURES_ARG) /* Linux v6.9 */ + epfnv->bar0_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, BAR_0, + epc_features); +#else + epfnv->bar0_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, BAR_0, + epc_features->align); +#endif if (!epfnv->bar0_virt) { dev_err(fdev, "Failed to allocate memory for BAR0\n"); return -ENOMEM; diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index f8371487..2b8d9a11 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -146,6 +146,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_config NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_event_ops_struct_has_core_deinit 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_alloc_space_has_epc_features_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epf_driver_struct_probe_has_id_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_irq_type_enum_present NV_CONFTEST_FUNCTION_COMPILE_TESTS += register_shrinker_has_fmt_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 168bf752..39de6acb 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7386,6 +7386,28 @@ compile_test() { compile_check_conftest "$CODE" "NV_PCI_ENABLE_PCIE_ERROR_REPORTING_PRESENT" "" "functions" ;; + pci_epf_alloc_space_has_epc_features_arg) + # + # Determine if the function pci_epf_alloc_space() has a + # 'epc_features' argument. + # + # Commit e891becdccaa ("PCI: endpoint: Refactor + # pci_epf_alloc_space() API") updated the pci_epf_alloc_space() + # function to accept 'epc_features' as a parameter in Linux v6.9. + # + CODE=" + #include + #include + void conftest_pci_epf_alloc_space_has_epc_features_arg( + struct pci_epf *epf, size_t size, enum pci_barno bar, + const struct pci_epc_features *epc_features, + enum pci_epc_interface_type type) { + pci_epf_alloc_space(epf, size, bar, epc_features, type); + }" + + compile_check_conftest "$CODE" "NV_PCI_EPF_ALLOC_SPACE_HAS_EPC_FEATURES_ARG" "" "types" + ;; + pci_epf_driver_struct_probe_has_id_arg) # # Determine if the struct pci_epf_driver probe API has ID argument or not.