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 <ldewangan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3131464
GVS: buildbot_gerritrpt <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Laxman Dewangan
2024-05-05 04:54:25 +00:00
committed by mobile promotions
parent 74c60d6681
commit a1d5f342d5
3 changed files with 43 additions and 0 deletions

View File

@@ -248,7 +248,10 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf)
tegra_pcie_dma_deinit(&cookie); tegra_pcie_dma_deinit(&cookie);
if (epfnv->chip_id == TEGRA264) { if (epfnv->chip_id == TEGRA264) {
#if defined(NV_PLATFORM_MSI_DOMAIN_FREE_IRQS_PRESENT) /* Linux v6.9 */
platform_msi_domain_free_irqs(&pdev->dev); platform_msi_domain_free_irqs(&pdev->dev);
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
irq = msi_get_virq(&pdev->dev, 0); irq = msi_get_virq(&pdev->dev, 0);
#else #else
@@ -267,6 +270,7 @@ static void pcie_dma_epf_unbind(struct pci_epf *epf)
lpci_epf_free_space(epf, epfnv->bar_virt, bar); 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) static void pcie_dma_epf_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg)
{ {
if (gepfnv->edma.msi_addr == 0) { 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; gepfnv->edma.msi_data = msg->data + 1;
} }
} }
#endif
static irqreturn_t pcie_dma_epf_irq(int irq, void *arg) 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; 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); ret = platform_msi_domain_alloc_irqs(&pdev->dev, 2, pcie_dma_epf_write_msi_msg);
if (ret < 0) { if (ret < 0) {
dev_err(fdev, "failed to allocate MSIs: %d\n", ret); dev_err(fdev, "failed to allocate MSIs: %d\n", ret);
goto fail_kasnprintf; goto fail_kasnprintf;
} }
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 16, 0)
epfnv->edma.msi_irq = msi_get_virq(&pdev->dev, 1); epfnv->edma.msi_irq = msi_get_virq(&pdev->dev, 1);
irq = msi_get_virq(&pdev->dev, 0); irq = msi_get_virq(&pdev->dev, 0);
@@ -406,8 +413,10 @@ fail_get_features:
if (epfnv->chip_id == TEGRA264) if (epfnv->chip_id == TEGRA264)
free_irq(irq, epfnv); free_irq(irq, epfnv);
fail_msi_alloc: fail_msi_alloc:
#if defined(NV_PLATFORM_MSI_DOMAIN_FREE_IRQS_PRESENT) /* Linux v6.9 */
if (epfnv->chip_id == TEGRA264) if (epfnv->chip_id == TEGRA264)
platform_msi_domain_free_irqs(&pdev->dev); platform_msi_domain_free_irqs(&pdev->dev);
#endif
fail_kasnprintf: fail_kasnprintf:
devm_kfree(fdev, name); devm_kfree(fdev, name);
fail_atu_dma: fail_atu_dma:

View File

@@ -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_find
NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_get_chip NV_CONFTEST_FUNCTION_COMPILE_TESTS += gpio_device_get_chip
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data 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_chip_struct_has_base_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += pwm_ops_struct_has_owner 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 += pwm_ops_struct_has_config

View File

@@ -7287,6 +7287,38 @@ compile_test() {
compile_check_conftest "$CODE" "NV_MII_BUS_STRUCT_HAS_WRITE_C45" "" "types" 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 <linux/msi.h>
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 <linux/msi.h>
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) pwm_chip_struct_has_base_arg)
# #
# Determine if 'struct pwm_chip' has the 'base' field. # Determine if 'struct pwm_chip' has the 'base' field.