diff --git a/drivers/misc/nvscic2c-pcie/epf/module.c b/drivers/misc/nvscic2c-pcie/epf/module.c index 24613d64..03148206 100644 --- a/drivers/misc/nvscic2c-pcie/epf/module.c +++ b/drivers/misc/nvscic2c-pcie/epf/module.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. #include @@ -171,7 +171,8 @@ allocate_outbound_area(struct pci_epf *epf, size_t win_size, return ret; } -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) || \ + defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Linux v6.11 || Nvidia Internal */ static void clear_inbound_translation(struct pci_epf *epf) { @@ -494,7 +495,8 @@ deinit_work(struct work_struct *work) * @DRV_MODE_EPC would have already gone then by the time * struct pci_epc_event_ops.core_deinit is called. */ -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) || \ + defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Linux v6.11 || Nvidia Internal */ static int nvscic2c_pcie_epf_core_deinit(struct pci_epf *epf) { @@ -522,6 +524,13 @@ nvscic2c_pcie_epf_core_deinit(struct pci_epf *epf) return 0; } + +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) +static void nvscic2c_pcie_epf_epc_deinit(struct pci_epf *epf) +{ + WARN_ON(nvscic2c_pcie_epf_core_deinit(epf)); +} +#endif #endif /* Handle link message from @DRV_MODE_EPC. */ @@ -734,8 +743,14 @@ get_driverdata(const struct pci_epf_device_id *id, } static const struct pci_epc_event_ops nvscic2c_event_ops = { +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_INIT) /* Linux v6.11 */ + .epc_init = nvscic2c_pcie_epf_core_init, +#else .core_init = nvscic2c_pcie_epf_core_init, -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ +#endif +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) /* Linux v6.11 */ + .epc_deinit = nvscic2c_pcie_epf_epc_deinit, +#elif defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ .core_deinit = nvscic2c_pcie_epf_core_deinit, #endif }; diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index 8915545f..4930df44 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -241,7 +241,8 @@ static int pcie_dma_epf_core_init(struct pci_epf *epf) return 0; } -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) || \ + defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Linux v6.11 || Nvidia Internal */ static int pcie_dma_epf_core_deinit(struct pci_epf *epf) { struct pcie_epf_dma *epfnv = epf_get_drvdata(epf); @@ -262,6 +263,13 @@ static int pcie_dma_epf_core_deinit(struct pci_epf *epf) lpci_epc_clear_bar(epc, epf->func_no, epf_bar); return 0; } + +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) +static void pcie_dma_epf_epc_deinit(struct pci_epf *epf) +{ + pcie_dma_epf_core_deinit(epf); +} +#endif #endif static void pcie_dma_epf_unbind(struct pci_epf *epf) @@ -490,8 +498,14 @@ static const struct pci_epf_device_id pcie_dma_epf_ids[] = { }; static const struct pci_epc_event_ops pci_epf_dma_test_event_ops = { +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_INIT) /* Linux v6.11 */ + .epc_init = pcie_dma_epf_core_init, +#else .core_init = pcie_dma_epf_core_init, -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ +#endif +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) /* Linux v6.11 */ + .epc_deinit = pcie_dma_epf_epc_deinit, +#elif defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ .core_deinit = pcie_dma_epf_core_deinit, #endif }; diff --git a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c index 52119311..ceb12d85 100644 --- a/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c +++ b/drivers/pci/endpoint/functions/pci-epf-tegra-vnet.c @@ -1631,7 +1631,8 @@ static void tvnet_ep_pci_epf_linkup(struct pci_epf *epf) #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)) -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) || \ + defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Linux v6.11 || Nvidia Internal */ static int tvnet_ep_pci_epf_core_deinit(struct pci_epf *epf) { struct pci_epf_bar *epf_bar = &epf->bar[BAR_0]; @@ -1647,11 +1648,24 @@ static int tvnet_ep_pci_epf_core_deinit(struct pci_epf *epf) return 0; } + +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) +static void tvnet_ep_pci_epf_epc_deinit(struct pci_epf *epf) +{ + WARN_ON(tvnet_ep_pci_epf_core_deinit(epf)); +} +#endif #endif static const struct pci_epc_event_ops tvnet_event_ops = { +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_INIT) /* Linux v6.11 */ + .epc_init = tvnet_ep_pci_epf_core_init, +#else .core_init = tvnet_ep_pci_epf_core_init, -#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) +#endif +#if defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT) /* Linux v6.11 */ + .epc_deinit = tvnet_ep_pci_epf_epc_deinit, +#elif defined(NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT) /* Nvidia Internal */ .core_deinit = tvnet_ep_pci_epf_core_deinit, #endif .link_up = tvnet_ep_pci_epf_linkup, diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 5aa8520b..44630ca4 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -156,6 +156,8 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_chip_struct_has_struct_device NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner 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_epc_event_ops_struct_has_epc_deinit +NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_event_ops_struct_has_epc_init NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_features_struct_has_bar NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_features_struct_has_core_init_notifier NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_write_header_has_vfn_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 442c6917..3e54c89e 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7578,6 +7578,39 @@ compile_test() { compile_check_conftest "$CODE" "NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_CORE_DEINIT" "" "types" ;; + pci_epc_event_ops_struct_has_epc_deinit) + # + # Determine if the pci_epc_event_ops struct has the epc_deinit function. + # + # Commit 473b2cf9c4d1 ("PCI: endpoint: Introduce 'epc_deinit' event and + # notify the EPF drivers) added 'epc_deinit' callback in Linux v6.11. + # + CODE=" + #include + int conftest_pci_epc_event_ops_struct_has_epc_deinit(void) { + return offsetof(struct pci_epc_event_ops, epc_deinit); + }" + + compile_check_conftest "$CODE" "NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_DEINIT" "" "types" + ;; + + pci_epc_event_ops_struct_has_epc_init) + # + # Determine if the pci_epc_event_ops struct has the epc_init function. + # + # Commit 4edd7dc82bd6 ("PCI: endpoint: Rename core_init() callback in + # 'struct pci_epc_event_ops' to epc_init()") renamed core_init() + # in Linux v6.11. + # + CODE=" + #include + int conftest_pci_epc_event_ops_struct_has_epc_init(void) { + return offsetof(struct pci_epc_event_ops, epc_init); + }" + + compile_check_conftest "$CODE" "NV_PCI_EPC_EVENT_OPS_STRUCT_HAS_EPC_INIT" "" "types" + ;; + pci_epc_features_struct_has_bar) # # Determine if the pci_epc_features struct has a member 'bar'.