pci: Use conf test to determine API change of pci_epc_write_header()

Add conftest to determine if the pci_epc_write_header() has the vfn
argument or not.

Commit 53fd3cbe5e9d791("PCI: endpoint: Add virtual function number
in pci_epc ops") added virtual function number as argument in the
APIs in Linux 5.14.

Jira HOSTX-5375

Change-Id: Ib0b1fbc2a33f9159f3497374d253e264a90f7b4d
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3166765
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Laxman Dewangan
2024-07-02 10:52:21 +00:00
committed by mobile promotions
parent b02764ce1c
commit b260a8f442
3 changed files with 19 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
#ifndef PCI_EPF_WRAPPER_H
#define PCI_EPF_WRAPPER_H
#include <nvidia/conftest.h>
#include <linux/version.h>
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
@@ -31,7 +32,7 @@
#define lpci_epf_alloc_space(A, B, C, D) pci_epf_alloc_space(A, B, C, D)
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(5, 14, 0))
#if defined(NV_PCI_EPC_WRITE_HEADER_HAS_VFN_ARG)
#define lpci_epc_write_header(A, B, C) pci_epc_write_header(A, B, 0, C)
#define lpci_epc_raise_irq(A, B, C, D) pci_epc_raise_irq(A, B, 0, C, D)
#define lpci_epc_clear_bar(A, B, C) pci_epc_clear_bar(A, B, 0, C)

View File

@@ -151,6 +151,7 @@ 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_features_struct_has_bar
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pci_epc_write_header_has_vfn_arg
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

View File

@@ -7470,6 +7470,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_PCI_EPC_FEATURES_STRUCT_HAS_BAR" "" "types"
;;
pci_epc_write_header_has_vfn_arg)
#
# Determine if the pci_epc_write_header() has the vfn argument or not.
#
# Commit 53fd3cbe5e9d791("PCI: endpoint: Add virtual function number in pci_epc ops"
# added virtual function number as argument in the APIs in Linux 5.14.
#
CODE="
#include <linux/pci-epc.h>
int conftest_pci_epc_write_header_has_vfn_arg(void) {
return pci_epc_write_header(NULL, 0, 0, NULL);
}"
compile_check_conftest "$CODE" "NV_PCI_EPC_WRITE_HEADER_HAS_VFN_ARG" "" "types"
;;
pci_disable_pcie_error_reporting)
#
# Determine if the pci_disable_pcie_error_reporting() API available or not.