From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH 21/21] powerpc/powernv: Handle PCI-X/PCIe reset delay
Date: Sat, 10 Sep 2011 11:20:08 -0300 [thread overview]
Message-ID: <1315664408-16797-21-git-send-email-benh@kernel.crashing.org> (raw)
In-Reply-To: <1315664408-16797-1-git-send-email-benh@kernel.crashing.org>
The firmware doesn't wait after lifting the PCI reset. However it does
timestamp it in the device tree. We use that to ensure we wait long
enough (3s is our current arbitrary setting) from that timestamp to
actually probing the bus.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/platforms/powernv/pci.c | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c
index f85fb13..1835db5 100644
--- a/arch/powerpc/platforms/powernv/pci.c
+++ b/arch/powerpc/platforms/powernv/pci.c
@@ -35,6 +35,8 @@
#include "powernv.h"
#include "pci.h"
+/* Delay in usec */
+#define PCI_RESET_DELAY_US 3000000
#define cfg_dbg(fmt...) do { } while(0)
//#define cfg_dbg(fmt...) printk(fmt)
@@ -353,6 +355,35 @@ static void __devinit pnv_pci_dma_dev_setup(struct pci_dev *pdev)
pnv_pci_dma_fallback_setup(hose, pdev);
}
+static int pnv_pci_probe_mode(struct pci_bus *bus)
+{
+ struct pci_controller *hose = pci_bus_to_host(bus);
+ const __be64 *tstamp;
+ u64 now, target;
+
+
+ /* We hijack this as a way to ensure we have waited long
+ * enough since the reset was lifted on the PCI bus
+ */
+ if (bus != hose->bus)
+ return PCI_PROBE_NORMAL;
+ tstamp = of_get_property(hose->dn, "reset-clear-timestamp", NULL);
+ if (!tstamp || !*tstamp)
+ return PCI_PROBE_NORMAL;
+
+ now = mftb() / tb_ticks_per_usec;
+ target = (be64_to_cpup(tstamp) / tb_ticks_per_usec)
+ + PCI_RESET_DELAY_US;
+
+ pr_devel("pci %04d: Reset target: 0x%llx now: 0x%llx\n",
+ hose->global_number, target, now);
+
+ if (now < target)
+ msleep((target - now + 999) / 1000);
+
+ return PCI_PROBE_NORMAL;
+}
+
void __init pnv_pci_init(void)
{
struct device_node *np;
@@ -383,6 +414,7 @@ void __init pnv_pci_init(void)
ppc_md.pci_dma_dev_setup = pnv_pci_dma_dev_setup;
ppc_md.tce_build = pnv_tce_build;
ppc_md.tce_free = pnv_tce_free;
+ ppc_md.pci_probe_mode = pnv_pci_probe_mode;
set_pci_dma_ops(&dma_iommu_ops);
/* Configure MSIs */
--
1.7.4.1
prev parent reply other threads:[~2011-09-10 14:21 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-10 14:19 [PATCH 01/21] powerpc/udbg: Fix Kconfig entry for avoiding 44x early debug with KVM Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 02/21] powerpc/smp: More generic support for "soft hotplug" Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 03/21] powerpc/pci: Call pcie_bus_configure_settings() Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 04/21] tty/hvc/hvsi_lib: Updates for running under OPAL v2 Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 05/21] powerpc/powernv: Don't clobber r9 in relative_toc() Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 06/21] powerpc: Add skeleton PowerNV platform Benjamin Herrenschmidt
2011-09-12 1:17 ` Michael Neuling
2011-09-12 6:02 ` Geert Uytterhoeven
2011-09-10 14:19 ` [PATCH 07/21] of: Change logic to overwrite cmd_line with CONFIG_CMDLINE Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 08/21] powerpc/powernv: Add CPU hotplug support Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 09/21] powerpc/powernv: Add OPAL takeover from PowerVM Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 10/21] powerpc/powernv: Get kernel command line accross OPAL takeover Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 11/21] powerpc/powernv: Basic support for OPAL Benjamin Herrenschmidt
2011-09-10 14:19 ` [PATCH 12/21] powerpc/powernv: Add support for instanciating OPAL v2 from Open Firmware Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 13/21] powerpc/powernv: Support for OPAL console Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 14/21] powerpc/powernv: Hookup reboot and poweroff functions Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 15/21] powerpc/powernv: Add RTC and NVRAM support plus RTAS fallbacks Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 16/21] powerpc/powernv: Add OPAL ICS backend Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 17/21] powerpc/powernv: Register and handle OPAL interrupts Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 18/21] powerpc/powernv: Machine check and other system interrupts Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 19/21] powerpc/powernv: Add support for p5ioc2 PCI-X and PCIe Benjamin Herrenschmidt
2011-09-10 14:20 ` [PATCH 20/21] powerpc/powernv: Implement MSI support for p5ioc2 PCIe Benjamin Herrenschmidt
2011-09-10 14:20 ` Benjamin Herrenschmidt [this message]
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=1315664408-16797-21-git-send-email-benh@kernel.crashing.org \
--to=benh@kernel.crashing.org \
--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).