From a1d5f342d5d16a6a662ca8838a05e7e132260388 Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Sun, 5 May 2024 04:54:25 +0000 Subject: [PATCH] pcie: endpoint: Add support to build with k6.9 Few of the APIs from msi are deprecated in the kernel 6.9. These APIs are: platform_msi_domain_alloc_irqs platform_msi_domain_free_irqs The change is with commit commit 1a4671ff7a903e87 ("platform-msi: Remove unused interfaces") Add support to not use these APIs via conftest. Bug 4471899 Change-Id: I3b07236eeb69900b06c4e17b7675f6419b8321e4 Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3131464 GVS: buildbot_gerritrpt --- .../pci/endpoint/functions/pci-epf-dma-test.c | 9 ++++++ scripts/conftest/Makefile | 2 ++ scripts/conftest/conftest.sh | 32 +++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index a0b453ac..d73a257c 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -248,7 +248,10 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf) tegra_pcie_dma_deinit(&cookie); if (epfnv->chip_id == TEGRA264) { + +#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) irq = msi_get_virq(&pdev->dev, 0); #else @@ -267,6 +270,7 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf) lpci_epf_free_space(epf, epfnv->bar_virt, bar); } +#if defined(NV_PLATFORM_MSI_DOMAIN_ALLOC_IRQS_PRESENT) /* Linux 6.9 */ static void pcie_dma_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) { if (gepfnv->edma.msi_addr == 0) { @@ -276,6 +280,7 @@ static void pcie_dma_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *ms gepfnv->edma.msi_data = msg->data + 1; } } +#endif static irqreturn_t pcie_dma_epf_irq(int irq, void *arg) { @@ -356,11 +361,13 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) goto fail_kasnprintf; } +#if defined(NV_PLATFORM_MSI_DOMAIN_ALLOC_IRQS_PRESENT) /* Linux 6.9 */ ret = platform_msi_domain_alloc_irqs(&pdev->dev, 2, pcie_dma_epf_write_msi_msg); if (ret < 0) { dev_err(fdev, "failed to allocate MSIs: %d\n", ret); goto fail_kasnprintf; } +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) epfnv->edma.msi_irq = msi_get_virq(&pdev->dev, 1); irq = msi_get_virq(&pdev->dev, 0); @@ -406,8 +413,10 @@ fail_get_features: if (epfnv->chip_id == TEGRA264) free_irq(irq, epfnv); fail_msi_alloc: +#if defined(NV_PLATFORM_MSI_DOMAIN_FREE_IRQS_PRESENT) /* Linux v6.9 */ if (epfnv->chip_id == TEGRA264) platform_msi_domain_free_irqs(&pdev->dev); +#endif fail_kasnprintf: devm_kfree(fdev, name); fail_atu_dma: diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index cf6dd203..492c30d8 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -140,6 +140,8 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_chip_struct_has_of_node_present NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_find NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_get_chip NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data +NV_CONFTEST_FUNCTION_COMPILE_TESTS += platform_msi_domain_alloc_irqs +NV_CONFTEST_FUNCTION_COMPILE_TESTS += platform_msi_domain_free_irqs NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_chip_struct_has_base_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_config diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 58966d39..d39f6e85 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7287,6 +7287,38 @@ compile_test() { compile_check_conftest "$CODE" "NV_MII_BUS_STRUCT_HAS_WRITE_C45" "" "types" ;; + platform_msi_domain_alloc_irqs) + # + # Determine if the platform_msi_domain_alloc_irqs() API available or not. + # + # API platform_msi_domain_free_irqs() is dropped from Linux 6.9 + # with commit 1a4671ff7a903e87 ("platform-msi: Remove unused interfaces") + # + CODE=" + #include + void conftest_platform_msi_domain_alloc_irqs(void) { + platform_msi_domain_alloc_irqs(); + }" + + compile_check_conftest "$CODE" "NV_PLATFORM_MSI_DOMAIN_ALLOC_IRQS_PRESENT" "" "functions" + ;; + + platform_msi_domain_free_irqs) + # + # Determine if the platform_msi_domain_free_irqs() API available or not. + # + # API platform_msi_domain_free_irqs() is dropped from Linux 6.9 + # with commit 1a4671ff7a903e87 ("platform-msi: Remove unused interfaces") + # + CODE=" + #include + void conftest_platform_msi_domain_free_irqs(void) { + platform_msi_domain_free_irqs(); + }" + + compile_check_conftest "$CODE" "NV_PLATFORM_MSI_DOMAIN_FREE_IRQS_PRESENT" "" "functions" + ;; + pwm_chip_struct_has_base_arg) # # Determine if 'struct pwm_chip' has the 'base' field.