From cbac517483cc54b73baa561f149b6f763424af75 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Sun, 12 Nov 2023 19:17:24 +0000 Subject: [PATCH] pcie: Enable core_deinit only when core has implemented it The core_deinit callback is the Nvidia internal feature which is not upstreamed yet. Enable the call back from OOT modules only when core have implemented this callback. Bug 4374520 Change-Id: Iee2b92b7d70326ea3ce99ce6f6600d27f1e2896b Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3014989 (cherry picked from commit dc69c0b58a055e2990fa00dfea93aa052cb4079d) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3128429 Reviewed-by: Jon Hunter Reviewed-by: Brad Griffis GVS: Gerrit_Virtual_Submit Tested-by: Brad Griffis --- Makefile | 3 +++ drivers/misc/nvscic2c-pcie/epf/module.c | 8 +++++++- drivers/pci/endpoint/functions/pci-epf-dma-test.c | 4 ++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index de4f6b10..3905a5e5 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,9 @@ LINUXINCLUDE += -I$(srctree.nvidia-oot)/include subdir-ccflags-y += -Werror subdir-ccflags-y += -Wmissing-prototypes +# PCIE DMA EPF core deinit not implemented in core kernel +subdir-ccflags-y += -DNV_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE + ifeq ($(CONFIG_TEGRA_VIRTUALIZATION),y) subdir-ccflags-y += -DCONFIG_TEGRA_VIRTUALIZATION endif diff --git a/drivers/misc/nvscic2c-pcie/epf/module.c b/drivers/misc/nvscic2c-pcie/epf/module.c index 5e4c7125..ca3e4cd0 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. #define pr_fmt(fmt) "nvscic2c-pcie: epf: " fmt @@ -169,6 +169,7 @@ allocate_outbound_area(struct pci_epf *epf, size_t win_size, return ret; } +#if !defined(NV_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE) static void clear_inbound_translation(struct pci_epf *epf) { @@ -178,6 +179,7 @@ clear_inbound_translation(struct pci_epf *epf) /* no api to clear epf header.*/ } +#endif static int set_inbound_translation(struct pci_epf *epf) @@ -490,6 +492,7 @@ 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_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE) static int nvscic2c_pcie_epf_core_deinit(struct pci_epf *epf) { @@ -517,6 +520,7 @@ nvscic2c_pcie_epf_core_deinit(struct pci_epf *epf) return 0; } +#endif /* Handle link message from @DRV_MODE_EPC. */ static void @@ -729,7 +733,9 @@ get_driverdata(const struct pci_epf_device_id *id, static const struct pci_epc_event_ops nvscic2c_event_ops = { .core_init = nvscic2c_pcie_epf_core_init, +#if !defined(NV_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE) .core_deinit = nvscic2c_pcie_epf_core_deinit, +#endif }; static int diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index 5360ba26..8a7bb58a 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -168,6 +168,7 @@ static int pcie_dma_epf_core_init(struct pci_epf *epf) return 0; } +#if !defined(NV_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE) static int pcie_dma_epf_core_deinit(struct pci_epf *epf) { struct pcie_epf_dma *epfnv = epf_get_drvdata(epf); @@ -183,6 +184,7 @@ static int pcie_dma_epf_core_deinit(struct pci_epf *epf) return 0; } +#endif static void pcie_dma_epf_unbind(struct pci_epf *epf) { @@ -267,7 +269,9 @@ static const struct pci_epf_device_id pcie_dma_epf_ids[] = { static const struct pci_epc_event_ops pci_epf_dma_test_event_ops = { .core_init = pcie_dma_epf_core_init, +#if !defined(NV_PCIE_DMA_EPF_CORE_DEINIT_NOT_AVAILABLE) .core_deinit = pcie_dma_epf_core_deinit, +#endif }; #if defined(NV_PCI_EPF_DRIVER_STRUCT_PROBE_HAS_ID_ARG) /* Linux 6.4 */