linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Subject: [PATCH 5/8] ppc/pnv: skip check on PE if necessary
Date: Mon, 25 Jun 2012 23:43:18 +0800	[thread overview]
Message-ID: <1340639001-28152-6-git-send-email-shangw@linux.vnet.ibm.com> (raw)
In-Reply-To: <1340639001-28152-1-git-send-email-shangw@linux.vnet.ibm.com>

While the device driver or PCI core tries to enable PCI device, the
platform dependent callback "ppc_md.pcibios_enable_device_hook" will
be called to check if there has one associated PE for the PCI device.
If we don't have the associated PE for the PCI device, it's not allowed
to enable the PCI device. Unfortunately, there might have some cases
we have to enable the PCI device (e.g. P2P bridge), but the PEs have
not been created yet.

The patch handles the unfortunate cases. Each PHB (struct pnv_phb)
has one field "initialized" to trace if the PEs have been created
and configured or not. When the PEs are not available, we won't check
the associated PE for the PCI device to be enabled.

Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
Reviewed-by: Ram Pai <linuxram@us.ibm.com>
Reviewed-by: Richard Yang <weiyang@linux.vnet.ibm.com>
---
 arch/powerpc/platforms/powernv/pci-ioda.c |   19 ++++++++++++++++++-
 arch/powerpc/platforms/powernv/pci.h      |    1 +
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
index f0ae647..052a50f 100644
--- a/arch/powerpc/platforms/powernv/pci-ioda.c
+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1246,9 +1246,14 @@ static void __devinit pnv_pci_ioda_setup_seg(void)
 static void __devinit pnv_pci_ioda_setup_DMA(void)
 {
 	struct pci_controller *hose, *tmp;
+	struct pnv_phb *phb;
 
 	list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {
 		pnv_ioda_setup_dma(hose->private_data);
+
+		/* Mark the PHB initialization done */
+		phb = hose->private_data;
+		phb->initialized = 1;
 	}
 }
 
@@ -1264,10 +1269,22 @@ static void __devinit pnv_pci_ioda_fixup(void)
  */
 static int __devinit pnv_pci_enable_device_hook(struct pci_dev *dev)
 {
-	struct pci_dn *pdn = pnv_ioda_get_pdn(dev);
+	struct pci_controller *hose = pci_bus_to_host(dev->bus);
+	struct pnv_phb *phb = hose->private_data;
+	struct pci_dn *pdn;
 
+	/* The function is probably called while the PEs have
+	 * not be created yet. For example, resource reassignment
+	 * during PCI probe period. We just skip the check if
+	 * PEs isn't ready.
+	 */
+	if (!phb->initialized)
+		return 0;
+
+	pdn = pnv_ioda_get_pdn(dev);
 	if (!pdn || pdn->pe_number == IODA_INVALID_PE)
 		return -EINVAL;
+
 	return 0;
 }
 
diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index b70720b..7cfb7c8 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -69,6 +69,7 @@ struct pnv_phb {
 	enum pnv_phb_model	model;
 	u64			opal_id;
 	void __iomem		*regs;
+	int			initialized;
 	spinlock_t		lock;
 
 #ifdef CONFIG_PCI_MSI
-- 
1.7.9.5

  parent reply	other threads:[~2012-06-25 16:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 15:43 [PATCH V3 0/8] ppc/pnv: Rework on pnv P7IOC initialization Gavin Shan
2012-06-25 15:43 ` [PATCH 1/8] ppc/pnv: create bus sensitive PEs Gavin Shan
2012-08-01  7:49   ` Richard Yang
2012-08-01  8:26     ` Gavin Shan
2012-08-01  9:04       ` Richard Yang
2012-08-01  9:18         ` Gavin Shan
2012-06-25 15:43 ` [PATCH 2/8] ppc/pnv: PE list based on creation order Gavin Shan
2012-06-25 15:43 ` [PATCH 3/8] ppc/pnv: I/O and MMIO resource assignment for PEs Gavin Shan
2012-06-25 15:43 ` [PATCH 4/8] ppc/pnv: initialize DMA " Gavin Shan
2012-06-25 15:43 ` Gavin Shan [this message]
2012-06-25 15:43 ` [PATCH 6/8] ppc/pnv: fix overrunning segment tracing array Gavin Shan
2012-06-25 15:43 ` [PATCH 7/8] ppc/pnv: using PCI core to do resource assignment Gavin Shan
2012-06-25 15:43 ` [PATCH 8/8] ppc/pnv: remove unused functions Gavin Shan
  -- strict thread matches above, loose matches on Subject: below --
2012-08-20 13:49 [PATCH V4 0/8] Rework on PowerNV P7IOC initialization Gavin Shan
2012-08-20 13:49 ` [PATCH 5/8] ppc/pnv: skip check on PE if necessary Gavin Shan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1340639001-28152-6-git-send-email-shangw@linux.vnet.ibm.com \
    --to=shangw@linux.vnet.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).