From: linas <linas@austin.ibm.com>
To: paulus@samba.org
Cc: linuxppc64-dev@ozlabs.org, linux-kernel@vger.kernel.org,
linux-pci@atrey.karlin.mff.cuni.cz
Subject: [PATCH 4/22] ppc64: EEH Recovery support routines
Date: Thu, 6 Oct 2005 18:28:31 -0500 [thread overview]
Message-ID: <20051006232831.GE29826@austin.ibm.com> (raw)
In-Reply-To: <20051006232032.GA29826@austin.ibm.com>
04-eeh-recovery-support-routines.patch
EEH Recovery support routines
This patch adds routines required to help drive the recovery of
EEH-frozen slots. The main function is to drive the PCI #RST
signal line high for a qurter of a second, and then allow for
a second & a half of settle time.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
Index: linux-2.6.14-rc2-git6/arch/ppc64/kernel/pci.h
===================================================================
--- linux-2.6.14-rc2-git6.orig/arch/ppc64/kernel/pci.h 2005-10-06 17:50:31.847694674 -0500
+++ linux-2.6.14-rc2-git6/arch/ppc64/kernel/pci.h 2005-10-06 17:51:58.844488173 -0500
@@ -51,4 +51,18 @@
extern unsigned long pci_assign_all_buses;
extern int pci_read_irq_line(struct pci_dev *pci_dev);
+/* ---- EEH internal-use-only related routines ---- */
+#ifdef CONFIG_EEH
+/**
+ * rtas_set_slot_reset -- unfreeze a frozen slot
+ *
+ * Clear the EEH-frozen condition on a slot. This routine
+ * does this by asserting the PCI #RST line for 1/8th of
+ * a second; this routine will sleep while the adapter is
+ * being reset.
+ */
+void rtas_set_slot_reset (struct pci_dn *);
+
+#endif
+
#endif /* __PPC_KERNEL_PCI_H__ */
Index: linux-2.6.14-rc2-git6/arch/ppc64/kernel/eeh.c
===================================================================
--- linux-2.6.14-rc2-git6.orig/arch/ppc64/kernel/eeh.c 2005-10-06 17:50:31.847694674 -0500
+++ linux-2.6.14-rc2-git6/arch/ppc64/kernel/eeh.c 2005-10-06 17:52:27.908410223 -0500
@@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <linux/delay.h>
#include <linux/init.h>
#include <linux/list.h>
#include <linux/pci.h>
@@ -678,6 +679,104 @@
EXPORT_SYMBOL(eeh_check_failure);
/* ------------------------------------------------------------- */
+/* The code below deals with error recovery */
+
+/** Return negative value if a permanent error, else return
+ * a number of milliseconds to wait until the PCI slot is
+ * ready to be used.
+ */
+static int
+eeh_slot_availability(struct pci_dn *pdn)
+{
+ int rc;
+ int rets[3];
+
+ rc = read_slot_reset_state(pdn, rets);
+
+ if (rc) return rc;
+
+ if (rets[1] == 0) return -1; /* EEH is not supported */
+ if (rets[0] == 0) return 0; /* Oll Korrect */
+ if (rets[0] == 5) {
+ if (rets[2] == 0) return -1; /* permanently unavailable */
+ return rets[2]; /* number of millisecs to wait */
+ }
+ return -1;
+}
+
+/** rtas_pci_slot_reset raises/lowers the pci #RST line
+ * state: 1/0 to raise/lower the #RST
+ *
+ * Clear the EEH-frozen condition on a slot. This routine
+ * asserts the PCI #RST line if the 'state' argument is '1',
+ * and drops the #RST line if 'state is '0'. This routine is
+ * safe to call in an interrupt context.
+ *
+ */
+
+static void
+rtas_pci_slot_reset(struct pci_dn *pdn, int state)
+{
+ int rc;
+
+ BUG_ON (pdn==NULL);
+
+ if (!pdn->phb) {
+ printk (KERN_WARNING "EEH: in slot reset, device node %s has no phb\n",
+ pdn->node->full_name);
+ return;
+ }
+
+ rc = rtas_call(ibm_set_slot_reset,4,1, NULL,
+ pdn->eeh_config_addr,
+ BUID_HI(pdn->phb->buid),
+ BUID_LO(pdn->phb->buid),
+ state);
+ if (rc) {
+ printk (KERN_WARNING "EEH: Unable to reset the failed slot, (%d) #RST=%d dn=%s\n",
+ rc, state, pdn->node->full_name);
+ return;
+ }
+
+ if (state == 0)
+ eeh_clear_slot (pdn->node->parent->child);
+}
+
+/** rtas_set_slot_reset -- assert the pci #RST line for 1/4 second
+ * dn -- device node to be reset.
+ */
+
+void
+rtas_set_slot_reset(struct pci_dn *pdn)
+{
+ int i, rc;
+
+ rtas_pci_slot_reset (pdn, 1);
+
+ /* The PCI bus requires that the reset be held high for at least
+ * a 100 milliseconds. We wait a bit longer 'just in case'. */
+
+#define PCI_BUS_RST_HOLD_TIME_MSEC 250
+ msleep (PCI_BUS_RST_HOLD_TIME_MSEC);
+ rtas_pci_slot_reset (pdn, 0);
+
+ /* After a PCI slot has been reset, the PCI Express spec requires
+ * a 1.5 second idle time for the bus to stabilize, before starting
+ * up traffic. */
+#define PCI_BUS_SETTLE_TIME_MSEC 1800
+ msleep (PCI_BUS_SETTLE_TIME_MSEC);
+
+ /* Now double check with the firmware to make sure the device is
+ * ready to be used; if not, wait for recovery. */
+ for (i=0; i<10; i++) {
+ rc = eeh_slot_availability (pdn);
+ if (rc <= 0) break;
+
+ msleep (rc+100);
+ }
+}
+
+/* ------------------------------------------------------------- */
/* The code below deals with enabling EEH for devices during the
* early boot sequence. EEH must be enabled before any PCI probing
* can be done.
next prev parent reply other threads:[~2005-10-06 23:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-10-06 23:20 [PATCH 0/22] ppc64: Full sequence of PCI Error recovery patches linas
2005-10-06 23:23 ` [PATCH 1/22] ppc64: Dynamic LPAR bugfix linas
2005-10-06 23:25 ` [PATCH 2/22] ppc64: Enable detection bugfix linas
2005-10-06 23:26 ` [PATCH 3/22] ppc64: EEH Recovery dispatcher thread linas
2005-10-06 23:28 ` linas [this message]
2005-10-06 23:29 ` [PATCH 5/22] ppc64: Device BAR save and restore linas
2005-10-06 23:31 ` [PATCH 6/22] ppc64: PCI Error Recovery: documentation patch linas
2005-10-06 23:32 ` [PATCH 7/22] PCI Error Recovery: header file patch linas
2005-10-06 23:33 ` [PATCH 8/22] ppc64: Slot Marking Bugfix linas
2005-10-06 23:35 ` [PATCH 9/22] ppc64: DLPAR slot add and remove bugfixes linas
2005-10-06 23:36 ` [PATCH 10/22] ppc64: Crash on DLPAR PHB add linas
2005-10-06 23:39 ` [PATCH 11/22] ppc64: RPA PHP and EEH common code linas
2005-10-06 23:40 ` [PATCH 12/22] ppc64: RPA PHP cleanup linas
2005-10-06 23:44 ` [PATCH 13/22] ppc64: RPAPHP duplicated code removal linas
2005-10-06 23:46 ` [PATCH 14/22] ppc64: RPA PHP to EEH code movement linas
2006-01-07 21:28 ` Olaf Hering
2006-01-09 19:58 ` [PATCH]: ppowerpc: fix compile-time failure when EEH disabled linas
2005-10-06 23:47 ` [PATCH 15/22] ppc64: PCI Error Recovery: PPC64 core recovery routines linas
2005-10-12 9:49 ` Paul Mackerras
2005-10-13 16:03 ` linas
2005-10-06 23:53 ` [PATCH 16/22] PCI Address cache lookup code linas
2005-10-06 23:54 ` [PATCH 17/22] ppc64: New Partition Endpoin support linas
2005-10-06 23:55 ` [PATCH 18/22] PCI Error Recovery: IPR SCSI device driver linas
2005-10-06 23:56 ` [PATCH 19/22] PCI Error Recovery: Symbios " linas
2005-10-06 23:57 ` [PATCH 20/22] PCI Error Recovery: e100 network " linas
2005-10-11 0:10 ` Greg KH
2005-10-11 23:04 ` linas
2005-10-11 23:41 ` Paul Mackerras
2005-10-06 23:58 ` [PATCH 21/22] PCI Error Recovery: e1000 " linas
2005-10-06 23:59 ` [PATCH 22/22] PCI Error Recovery: ixgb " linas
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=20051006232831.GE29826@austin.ibm.com \
--to=linas@austin.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
--cc=linuxppc64-dev@ozlabs.org \
--cc=paulus@samba.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