[PATCH 3/3] powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops

2018-04-10 Thread Nicholas Piggin
The OPAL NVRAM driver does not sleep in case it gets OPAL_BUSY or
OPAL_BUSY_EVENT from firmware, which causes large scheduling
latencies, and various lockup errors to trigger (again, BMC reboot
can cause it).

Fix this by converting it to the standard form OPAL_BUSY loop that
sleeps.

Fixes: 628daa8d5abfd ("powerpc/powernv: Add RTC and NVRAM support plus RTAS 
fallbacks")
Cc: Benjamin Herrenschmidt 
Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/platforms/powernv/opal-nvram.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/opal-nvram.c 
b/arch/powerpc/platforms/powernv/opal-nvram.c
index ba2ff06a2c98..1bceb95f422d 100644
--- a/arch/powerpc/platforms/powernv/opal-nvram.c
+++ b/arch/powerpc/platforms/powernv/opal-nvram.c
@@ -11,6 +11,7 @@
 
 #define DEBUG
 
+#include 
 #include 
 #include 
 #include 
@@ -56,8 +57,12 @@ static ssize_t opal_nvram_write(char *buf, size_t count, 
loff_t *index)
 
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
rc = opal_write_nvram(__pa(buf), count, off);
-   if (rc == OPAL_BUSY_EVENT)
+   if (rc == OPAL_BUSY_EVENT) {
+   msleep(OPAL_BUSY_DELAY_MS);
opal_poll_events(NULL);
+   } else if (rc == OPAL_BUSY) {
+   msleep(OPAL_BUSY_DELAY_MS);
+   }
}
 
if (rc)
-- 
2.17.0



Re: [3/3] powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops

2018-04-11 Thread Michael Ellerman
On Tue, 2018-04-10 at 11:49:33 UTC, Nicholas Piggin wrote:
> The OPAL NVRAM driver does not sleep in case it gets OPAL_BUSY or
> OPAL_BUSY_EVENT from firmware, which causes large scheduling
> latencies, and various lockup errors to trigger (again, BMC reboot
> can cause it).
> 
> Fix this by converting it to the standard form OPAL_BUSY loop that
> sleeps.
> 
> Fixes: 628daa8d5abfd ("powerpc/powernv: Add RTC and NVRAM support plus RTAS 
> fallbacks")
> Cc: Benjamin Herrenschmidt 
> Signed-off-by: Nicholas Piggin 

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/3b8070335f751aac9f1526ae2e012e

cheers