From a77ffaf1d026c5b2f66efcf9158b24223bb864d7 Mon Sep 17 00:00:00 2001 From: Manikanta Maddireddy Date: Mon, 6 May 2024 16:51:20 +0530 Subject: [PATCH] PCI: EPF: dma-test: Fix BAR and MSI allocations Fix BAR-1 and BAR-2 allocations for T264. Platform MSI is supported in T264 only, fix the chip_id comparision check so that MSI is allocated only for T264. Bug 4549851 Signed-off-by: Manikanta Maddireddy Change-Id: I13dad41375e607d78c6a99924ed6fef0c9113208 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3131939 Reviewed-by: Nagarjuna Kristam GVS: buildbot_gerritrpt Reviewed-by: Bibek Basu --- .../pci/endpoint/functions/pci-epf-dma-test.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-dma-test.c b/drivers/pci/endpoint/functions/pci-epf-dma-test.c index d73a257c..f3b5bc51 100644 --- a/drivers/pci/endpoint/functions/pci-epf-dma-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-dma-test.c @@ -186,12 +186,13 @@ static int pcie_dma_epf_core_init(struct pci_epf *epf) return 0; /* Expose MSI address as BAR2 to allow RP to send MSI to EP. */ - epf_bar = &epf->bar[BAR_2]; - epf_bar[bar].phys_addr = gepfnv->edma.msi_addr & ~(SZ_32M - 1); - epf_bar[bar].addr = NULL; - epf_bar[bar].size = SZ_32M; - epf_bar[bar].barno = BAR_2; - epf_bar[bar].flags |= PCI_BASE_ADDRESS_MEM_TYPE_64; + bar = BAR_2; + epf_bar = &epf->bar[bar]; + epf_bar->phys_addr = gepfnv->edma.msi_addr & ~(SZ_32M - 1); + epf_bar->addr = NULL; + epf_bar->size = SZ_32M; + epf_bar->barno = bar; + epf_bar->flags |= PCI_BASE_ADDRESS_MEM_TYPE_64 | PCI_BASE_ADDRESS_MEM_PREFETCH; ret = lpci_epc_set_bar(epc, epf->func_no, epf_bar); if (ret < 0) { dev_err(fdev, "PCIe set BAR2 failed: %d\n", ret); @@ -327,9 +328,9 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) } #if defined(NV_PCI_EPF_ALLOC_SPACE_HAS_EPC_FEATURES_ARG) /* Linux v6.9 */ - epfnv->bar_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, BAR_0, epc_features); + epfnv->bar_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, bar, epc_features); #else - epfnv->bar_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, BAR_0, epc_features->align); + epfnv->bar_virt = lpci_epf_alloc_space(epf, BAR0_SIZE, bar, epc_features->align); #endif if (!epfnv->bar_virt) { dev_err(fdev, "Failed to allocate memory for BAR0\n"); @@ -353,7 +354,7 @@ static int pcie_dma_epf_bind(struct pci_epf *epf) for (i = 0; i < TEGRA_PCIE_DMA_WRITE; i++) init_waitqueue_head(&epfnv->edma.wr_wq[i]); - if (epfnv->chip_id == TEGRA234) { + if (epfnv->chip_id == TEGRA264) { domain = dev_get_msi_domain(&pdev->dev); if (!domain) { dev_err(fdev, "failed to get MSI domain\n");