Merge branch 'master_next_patch' of https://github.com/ploetzma/op-build into master
diff --git a/README b/README
index 9f61021..d611f04 100644
--- a/README
+++ b/README
@@ -10,8 +10,8 @@
 
 1. Install Ubuntu 14.04 or Debian 7.5 64-bit.
 2. Install the packages necessary for the build:
-> sudo apt-get install cscope ctags libz-dev libexpat-dev libc6-dev-i386 \
-  build-essential g++ git bison flex gcc-multilib g++-multilib unzip \
+> sudo apt-get install cscope ctags libz-dev libexpat-dev \
+  build-essential g++ git bison flex unzip \
   libxml-simple-perl libxml-sax-perl libxml2-dev libxml2-utils xsltproc
 3. Continue with the clone, environment setup, and build as noted above.
 
diff --git a/openpower/package/hostboot/hostboot-0007-Fix-handling-of-ECC-protected-partitions-at-runtime.patch b/openpower/package/hostboot/hostboot-0007-Fix-handling-of-ECC-protected-partitions-at-runtime.patch
new file mode 100644
index 0000000..c9385d2
--- /dev/null
+++ b/openpower/package/hostboot/hostboot-0007-Fix-handling-of-ECC-protected-partitions-at-runtime.patch
@@ -0,0 +1,34 @@
+From 69e22b2f8c8425b4f2ec8f7adcf164afed7f2ff8 Mon Sep 17 00:00:00 2001
+From: Dan Crowell <dcrowell@us.ibm.com>
+Date: Mon, 27 Apr 2015 13:48:57 -0500
+Subject: [PATCH] Fix handling of ECC protected partitions at runtime
+
+Modify the code to only check ECC on the logical size of the data
+that is read, rather than on the full physical size.
+
+Change-Id: Ia45989e64ef70e63542274ef59df2cc755f8082e
+---
+ src/usr/pnor/runtime/rt_pnor.C | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/src/usr/pnor/runtime/rt_pnor.C b/src/usr/pnor/runtime/rt_pnor.C
+index d434f26..6e52999 100644
+--- a/src/usr/pnor/runtime/rt_pnor.C
++++ b/src/usr/pnor/runtime/rt_pnor.C
+@@ -405,10 +405,12 @@ errlHndl_t RtPnor::readFromDevice (uint64_t i_procId,
+         {
+             TRACFCOMP(g_trac_pnor, "RtPnor::readFromDevice: removing ECC...");
+             // remove the ECC and fix the original data if it is broken
++            size_t l_eccSize = (l_rc/9)*8;
++            l_eccSize = std::min( l_eccSize, i_size );
+             PNOR::ECC::eccStatus ecc_stat =
+                  PNOR::ECC::removeECC(reinterpret_cast<uint8_t*>(l_dataToRead),
+                                       reinterpret_cast<uint8_t*>(o_data),
+-                                      l_rc); //actual size of read data
++                                      l_eccSize); //logical size of read data
+ 
+             // create an error if we couldn't correct things
+             if( ecc_stat == PNOR::ECC::UNCORRECTABLE )
+-- 
+1.8.2.2
+
diff --git a/openpower/package/openpower-ffs/openpower-ffs.mk b/openpower/package/openpower-ffs/openpower-ffs.mk
index 1e6b9bf..ff82950 100644
--- a/openpower/package/openpower-ffs/openpower-ffs.mk
+++ b/openpower/package/openpower-ffs/openpower-ffs.mk
@@ -1,4 +1,4 @@
-OPENPOWER_FFS_VERSION ?= bf4630076762d9c20c16c80c1c791f352b046dd1
+OPENPOWER_FFS_VERSION ?= 2e790b8409071ca15767d822dabfa8e60f12c6e2
 OPENPOWER_FFS_SITE ?= $(call github,open-power,ffs,$(OPENPOWER_FFS_VERSION))
 OPENPOWER_FFS_LICENSE = GPLv2+
 
diff --git a/openpower/package/skiboot/skiboot-0003-xscom-remove-recursive-locking.patch b/openpower/package/skiboot/skiboot-0003-xscom-remove-recursive-locking.patch
new file mode 100644
index 0000000..e71e17e
--- /dev/null
+++ b/openpower/package/skiboot/skiboot-0003-xscom-remove-recursive-locking.patch
@@ -0,0 +1,70 @@
+diff --git a/hw/xscom.c b/hw/xscom.c
+index 6bd71a3..a3533be 100644
+--- a/hw/xscom.c
++++ b/hw/xscom.c
+@@ -342,7 +342,6 @@  static uint32_t xscom_decode_chiplet(uint32_t partid, uint64_t *pcb_addr)
+  */
+ int xscom_read(uint32_t partid, uint64_t pcb_addr, uint64_t *val)
+ {
+-	bool need_unlock;
+ 	uint32_t gcid;
+ 	int rc;
+ 
+@@ -360,12 +359,8 @@  int xscom_read(uint32_t partid, uint64_t pcb_addr, uint64_t *val)
+ 		return OPAL_PARAMETER;
+ 	}
+ 
+-	/*
+-	 * HW822317 requires locking. We use a recursive lock as error
+-	 * conditions might cause printf's which might then try to take
+-	 * the lock again
+-	 */
+-	need_unlock = lock_recursive(&xscom_lock);
++	/* HW822317 requires us to do global locking */
++	lock(&xscom_lock);
+ 
+ 	/* Direct vs indirect access */
+ 	if (pcb_addr & XSCOM_ADDR_IND_FLAG)
+@@ -374,8 +369,7 @@  int xscom_read(uint32_t partid, uint64_t pcb_addr, uint64_t *val)
+ 		rc = __xscom_read(gcid, pcb_addr & 0x7fffffff, val);
+ 
+ 	/* Unlock it */
+-	if (need_unlock)
+-		unlock(&xscom_lock);
++	unlock(&xscom_lock);
+ 	return rc;
+ }
+ 
+@@ -383,7 +377,6 @@  opal_call(OPAL_XSCOM_READ, xscom_read, 3);
+ 
+ int xscom_write(uint32_t partid, uint64_t pcb_addr, uint64_t val)
+ {
+-	bool need_unlock;
+ 	uint32_t gcid;
+ 	int rc;
+ 
+@@ -401,12 +394,8 @@  int xscom_write(uint32_t partid, uint64_t pcb_addr, uint64_t val)
+ 		return OPAL_PARAMETER;
+ 	}
+ 
+-	/*
+-	 * HW822317 requires locking. We use a recursive lock as error
+-	 * conditions might cause printf's which might then try to take
+-	 * the lock again
+-	 */
+-	need_unlock = lock_recursive(&xscom_lock);
++	/* HW822317 requires us to do global locking */
++	lock(&xscom_lock);
+ 
+ 	/* Direct vs indirect access */
+ 	if (pcb_addr & XSCOM_ADDR_IND_FLAG)
+@@ -415,8 +404,7 @@  int xscom_write(uint32_t partid, uint64_t pcb_addr, uint64_t val)
+ 		rc = __xscom_write(gcid, pcb_addr & 0x7fffffff, val);
+ 
+ 	/* Unlock it */
+-	if (need_unlock)
+-		unlock(&xscom_lock);
++	unlock(&xscom_lock);
+ 	return rc;
+ }
+ opal_call(OPAL_XSCOM_WRITE, xscom_write, 3);
diff --git a/openpower/package/skiboot/skiboot-0004-Add-xscom_ok-and-lpc_ok-to-check-XSCOM-and-LPC-usability.patch b/openpower/package/skiboot/skiboot-0004-Add-xscom_ok-and-lpc_ok-to-check-XSCOM-and-LPC-usability.patch
new file mode 100644
index 0000000..f19f6aa
--- /dev/null
+++ b/openpower/package/skiboot/skiboot-0004-Add-xscom_ok-and-lpc_ok-to-check-XSCOM-and-LPC-usability.patch
@@ -0,0 +1,117 @@
+diff --git a/hw/bt.c b/hw/bt.c
+index 7bf1b2f..8bb44cd 100644
+--- a/hw/bt.c
++++ b/hw/bt.c
+@@ -350,7 +350,8 @@  static void print_debug_queue_info(void) {}
+ 
+ static void bt_send_and_unlock(void)
+ {
+-	if (bt.state == BT_STATE_IDLE && !list_empty(&bt.msgq))
++	if (lpc_ok() &&
++	    bt.state == BT_STATE_IDLE && !list_empty(&bt.msgq))
+ 		bt_send_msg();
+ 
+ 	unlock(&bt.lock);
+@@ -361,6 +362,10 @@  static void bt_poll(struct timer *t __unused, void *data __unused)
+ {
+ 	uint8_t bt_ctrl;
+ 
++	/* Don't do anything if the LPC bus is offline */
++	if (!lpc_ok())
++		return;
++
+ 	/* If we can't get the lock assume someone else will notice
+ 	 * the new message and process it. */
+ 	lock(&bt.lock);
+@@ -440,7 +445,9 @@  static int bt_add_ipmi_msg(struct ipmi_msg *ipmi_msg)
+ 
+ void bt_irq(void)
+ {
+-	uint8_t ireg = bt_inb(BT_INTMASK);
++	uint8_t ireg;
++
++	ireg = bt_inb(BT_INTMASK);
+ 
+ 	bt.irq_ok = true;
+ 	if (ireg & BT_INTMASK_B2H_IRQ) {
+diff --git a/hw/lpc-uart.c b/hw/lpc-uart.c
+index 2e6114a..7c3190e 100644
+--- a/hw/lpc-uart.c
++++ b/hw/lpc-uart.c
+@@ -135,6 +135,10 @@  static size_t uart_con_write(const char *buf, size_t len)
+ {
+ 	size_t written = 0;
+ 
++	/* If LPC bus is bad, we just swallow data */
++	if (!lpc_ok())
++		return written;
++
+ 	lock(&uart_lock);
+ 	while(written < len) {
+ 		if (tx_room == 0) {
+diff --git a/hw/lpc.c b/hw/lpc.c
+index 0db674f..b287020 100644
+--- a/hw/lpc.c
++++ b/hw/lpc.c
+@@ -500,3 +500,15 @@  void lpc_used_by_console(void)
+ 		unlock(&chip->lpc_lock);
+ 	}
+ }
++
++bool lpc_ok(void)
++{
++	struct proc_chip *chip;
++
++	if (lpc_default_chip_id < 0)
++		return false;
++	if (!xscom_ok())
++		return false;
++	chip = get_chip(lpc_default_chip_id);
++	return !lock_held_by_me(&chip->lpc_lock);
++}
+diff --git a/hw/xscom.c b/hw/xscom.c
+index a3533be..07b9b94 100644
+--- a/hw/xscom.c
++++ b/hw/xscom.c
+@@ -531,3 +531,8 @@  void xscom_used_by_console(void)
+ 	lock(&xscom_lock);
+ 	unlock(&xscom_lock);
+ }
++
++bool xscom_ok(void)
++{
++	return !lock_held_by_me(&xscom_lock);
++}
+diff --git a/include/lpc.h b/include/lpc.h
+index 5611c54..a0990fd 100644
+--- a/include/lpc.h
++++ b/include/lpc.h
+@@ -27,6 +27,12 @@  extern void lpc_init(void);
+ /* Check for a default bus */
+ extern bool lpc_present(void);
+ 
++/* Return of LPC is currently usable. This can be false if the caller
++ * currently holds a lock that would make it unsafe, or the LPC bus
++ * is known to be in some error condition (TBI).
++ */
++extern bool lpc_ok(void);
++
+ /* Handle the interrupt from LPC source */
+ extern void __attrconst lpc_interrupt(uint32_t chip_id);
+ 
+diff --git a/include/xscom.h b/include/xscom.h
+index b1ecaf5..a841261 100644
+--- a/include/xscom.h
++++ b/include/xscom.h
+@@ -173,6 +173,11 @@  extern void xscom_init(void);
+ /* Mark XSCOM lock as being in console path */
+ extern void xscom_used_by_console(void);
+ 
++/* Returns true if XSCOM can be used. Typically this returns false if
++ * the current CPU holds the XSCOM lock (to avoid re-entrancy from error path).
++ */
++extern bool xscom_ok(void);
++
+ extern int64_t xscom_read_cfam_chipid(uint32_t partid, uint32_t *chip_id);
+ 
+ #endif /* __XSCOM_H */