Patchwork [SDK1.2,2/3] powerpc/fsl-pci: Only scan PCI bus if configured as a host

login
register
mail settings
Submitter Hongtao Jia
Date Dec. 21, 2011, 7:10 a.m.
Message ID <1324451458-4644-3-git-send-email-B38951@freescale.com>
Download mbox | patch
Permalink /patch/132595/
State Deferred
Delegated to: Kumar Gala
Headers show

Comments

Hongtao Jia - Dec. 21, 2011, 7:10 a.m.
If we're an agent/end-point or fsl_add_bridge doesn't succeed due to some
resource failure we should not scan the PCI bus. We change fsl_add_bridge()
to return -ENODEV in the case we're an agent/end-point.

Signed-off-by: Jia Hongtao <B38951@freescale.com>
Signed-off-by: Li Yang <leoli@freescale.com>
---
 arch/powerpc/sysdev/fsl_pci.c |   34 +++++++++++++++++++---------------
 1 files changed, 19 insertions(+), 15 deletions(-)

Patch

diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index a0f305d..e318e9d 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -370,7 +370,7 @@  int __init fsl_add_bridge(struct device_node *dev, int is_primary)
 			iounmap(hose->cfg_data);
 		iounmap(hose->cfg_addr);
 		pcibios_free_controller(hose);
-		return 0;
+		return -ENODEV;
 	}
 
 	setup_pci_cmd(hose);
@@ -723,29 +723,33 @@  static const struct of_device_id pci_ids[] = {
 static int __devinit fsl_pci_probe(struct platform_device *pdev)
 {
 	struct pci_controller *hose;
+	int ret;
 
 	if (of_match_node(pci_ids, pdev->dev.of_node)) {
 		struct resource rsrc;
 		of_address_to_resource(pdev->dev.of_node, 0, &rsrc);
 		if ((rsrc.start & 0xfffff) == 8000)
-			fsl_add_bridge(pdev->dev.of_node, 1);
+			ret = fsl_add_bridge(pdev->dev.of_node, 1);
 		else
-			fsl_add_bridge(pdev->dev.of_node, 0);
+			ret = fsl_add_bridge(pdev->dev.of_node, 0);
 
+		if (ret == 0) {
 #ifdef CONFIG_SWIOTLB
-		hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
-		/*
-		 * if we couldn't map all of DRAM via the dma windows
-		 * we need SWIOTLB to handle buffers located outside of
-		 * dma capable memory region
-		 */
-		if (memblock_end_of_DRAM() > hose->dma_window_base_cur
-				+ hose->dma_window_size) {
-			ppc_swiotlb_enable = 1;
-			set_pci_dma_ops(&swiotlb_dma_ops);
-			ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
-		}
+			hose = pci_find_hose_for_OF_device(pdev->dev.of_node);
+			/*
+			 * if we couldn't map all of DRAM via the dma windows
+			 * we need SWIOTLB to handle buffers located outside of
+			 * dma capable memory region
+			 */
+			if (memblock_end_of_DRAM() > hose->dma_window_base_cur
+					+ hose->dma_window_size) {
+				ppc_swiotlb_enable = 1;
+				set_pci_dma_ops(&swiotlb_dma_ops);
+				ppc_md.pci_dma_dev_setup =
+					pci_dma_dev_setup_swiotlb;
+			}
 #endif
+		}
 
 	}