From 00a95facef8c3fdce9bf4c7d6f3c3384367e4a31 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Tue, 2 Jul 2024 11:38:19 +0000 Subject: [PATCH] pci: Add conftest to determine if msi_get_virq() present The API msi_get_virq() get added by commit 98043704f375 ("genirq/msi: Make msi_get_virq() device domain aware") in Linux v6.1. Use conftest to determine if this API is available or not. Jira HOSTX-5375 Change-Id: I5e4cef9622d852fc889d9652e6631a79f2d21f9b Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3166766 Tested-by: mobile promotions Reviewed-by: mobile promotions --- .../pci/endpoint/functions/pci-epf-dma-test.c | 8 ++++---- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index 3d9211d4..c4a6aa0f 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -292,7 +292,7 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf) struct pcie_epf_bar *epf_bar = (struct pcie_epf_bar *)epfnv->bar_virt; struct device *cdev = epc->dev.parent; struct platform_device *pdev = of_find_device_by_node(cdev->of_node); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(NV_MSI_GET_VIRQ_PRESENT) /* Linux v6.1 */ struct msi_desc *desc; #endif enum pci_barno bar; @@ -309,7 +309,7 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf) #if defined(NV_PLATFORM_MSI_DOMAIN_FREE_IRQS_PRESENT) /* Linux v6.9 */ platform_msi_domain_free_irqs(&pdev->dev); #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#if defined(NV_MSI_GET_VIRQ_PRESENT) /* Linux v6.1 */ irq = msi_get_virq(&pdev->dev, 0); #else for_each_msi_entry(desc, cdev) { @@ -355,7 +355,7 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) struct pcie_epf_bar *epf_bar_virt; struct pci_epf_bar *epf_bar; struct irq_domain *domain; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) +#if !defined(NV_MSI_GET_VIRQ_PRESENT) /* Linux v6.1 */ struct msi_desc *desc; #endif enum pci_barno bar; @@ -425,7 +425,7 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) goto fail_kasnprintf; } #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) +#if defined(NV_MSI_GET_VIRQ_PRESENT) /* Linux v6.1 */ epfnv->edma.msi_irq = msi_get_virq(&pdev->dev, 1); irq = msi_get_virq(&pdev->dev, 0); #else diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 1d6a0b81..87fdeb1d 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -136,6 +136,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += mii_bus_struct_has_read_c45 NV_CONFTEST_FUNCTION_COMPILE_TESTS += mii_bus_struct_has_write_c45 NV_CONFTEST_FUNCTION_COMPILE_TESTS += media_entity_remote_pad NV_CONFTEST_FUNCTION_COMPILE_TESTS += module_import_ns_macro +NV_CONFTEST_FUNCTION_COMPILE_TESTS += msi_get_virq NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight NV_CONFTEST_FUNCTION_COMPILE_TESTS += of_get_named_gpio_flags diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 5bc16638..78d21af6 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -1192,6 +1192,22 @@ compile_test() { compile_check_conftest "$CODE" "NV_MDEV_DRIVER_HAS_SUPPORTED_TYPE_GROUPS" "" "types" ;; + msi_get_virq) + # + # Determine if msi_get_virq() function is present or not + # + # Added by commit 98043704f375 ("genirq/msi: Make msi_get_virq() + # device domain aware") in Linux V6.1 + # + CODE=" + #include + void conftest_msi_get_virq() { + msi_get_virq(); + }" + + compile_check_conftest "$CODE" "NV_MSI_GET_VIRQ_PRESENT" "" "functions" + ;; + vfio_device_ops_has_dma_unmap) # # Determine if 'vfio_device_ops' struct has 'dma_unmap' field.