Skip to content

Commit c1d2a31

Browse files
npigginmpe
authored andcommitted
powerpc/powernv: Fix NVRAM sleep in invalid context when crashing
Similarly to opal_event_shutdown, opal_nvram_write can be called in the crash path with irqs disabled. Special case the delay to avoid sleeping in invalid context. Fixes: 3b80703 ("powerpc/powernv: Fix OPAL NVRAM driver OPAL_BUSY loops") Cc: stable@vger.kernel.org # v3.2 Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 497a079 commit c1d2a31

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

arch/powerpc/platforms/powernv/opal-nvram.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ static ssize_t opal_nvram_read(char *buf, size_t count, loff_t *index)
4444
return count;
4545
}
4646

47+
/*
48+
* This can be called in the panic path with interrupts off, so use
49+
* mdelay in that case.
50+
*/
4751
static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
4852
{
4953
s64 rc = OPAL_BUSY;
@@ -58,10 +62,16 @@ static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
5862
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
5963
rc = opal_write_nvram(__pa(buf), count, off);
6064
if (rc == OPAL_BUSY_EVENT) {
61-
msleep(OPAL_BUSY_DELAY_MS);
65+
if (in_interrupt() || irqs_disabled())
66+
mdelay(OPAL_BUSY_DELAY_MS);
67+
else
68+
msleep(OPAL_BUSY_DELAY_MS);
6269
opal_poll_events(NULL);
6370
} else if (rc == OPAL_BUSY) {
64-
msleep(OPAL_BUSY_DELAY_MS);
71+
if (in_interrupt() || irqs_disabled())
72+
mdelay(OPAL_BUSY_DELAY_MS);
73+
else
74+
msleep(OPAL_BUSY_DELAY_MS);
6575
}
6676
}
6777

0 commit comments

Comments
 (0)