summaryrefslogtreecommitdiff
path: root/arch/powerpc/platforms
diff options
context:
space:
mode:
authorNicholas Piggin <npiggin@gmail.com>2018-04-30 17:55:51 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2018-07-24 15:09:57 +0300
commit17cc1dd4924391b54fb179d0868b89dc96f2ee80 (patch)
tree18aada7559529c711897037d94b316a6d26cfa63 /arch/powerpc/platforms
parentac4ac788fdadc6b703ff3322de07dee442e08e1c (diff)
downloadlinux-17cc1dd4924391b54fb179d0868b89dc96f2ee80.tar.xz
powerpc/powernv: implement opal_put_chars_atomic
The RAW console does not need writes to be atomic, so relax opal_put_chars to be able to do partial writes, and implement an _atomic variant which does not take a spinlock. This API is used in xmon, so the less locking that is used, the better chance there is that a crash can be debugged. Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms')
-rw-r--r--arch/powerpc/platforms/powernv/opal.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index cf02e602237a..6405b6f20193 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -344,9 +344,9 @@ int opal_get_chars(uint32_t vtermno, char *buf, int count)
return 0;
}
-int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
+static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, bool atomic)
{
- unsigned long flags;
+ unsigned long flags = 0 /* shut up gcc */;
int written;
__be64 olen;
s64 rc;
@@ -354,11 +354,8 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
if (!opal.entry)
return -ENODEV;
- /* We want put_chars to be atomic to avoid mangling of hvsi
- * packets. To do that, we first test for room and return
- * -EAGAIN if there isn't enough.
- */
- spin_lock_irqsave(&opal_write_lock, flags);
+ if (atomic)
+ spin_lock_irqsave(&opal_write_lock, flags);
rc = opal_console_write_buffer_space(vtermno, &olen);
if (rc || be64_to_cpu(olen) < total_len) {
/* Closed -> drop characters */
@@ -391,14 +388,18 @@ int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
written = be64_to_cpu(olen);
if (written < total_len) {
- /* Should not happen */
- pr_warn("atomic console write returned partial len=%d written=%d\n", total_len, written);
+ if (atomic) {
+ /* Should not happen */
+ pr_warn("atomic console write returned partial "
+ "len=%d written=%d\n", total_len, written);
+ }
if (!written)
written = -EAGAIN;
}
out:
- spin_unlock_irqrestore(&opal_write_lock, flags);
+ if (atomic)
+ spin_unlock_irqrestore(&opal_write_lock, flags);
/* In the -EAGAIN case, callers loop, so we have to flush the console
* here in case they have interrupts off (and we don't want to wait
@@ -412,6 +413,22 @@ out:
return written;
}
+int opal_put_chars(uint32_t vtermno, const char *data, int total_len)
+{
+ return __opal_put_chars(vtermno, data, total_len, false);
+}
+
+/*
+ * opal_put_chars_atomic will not perform partial-writes. Data will be
+ * atomically written to the terminal or not at all. This is not strictly
+ * true at the moment because console space can race with OPAL's console
+ * writes.
+ */
+int opal_put_chars_atomic(uint32_t vtermno, const char *data, int total_len)
+{
+ return __opal_put_chars(vtermno, data, total_len, true);
+}
+
int opal_flush_console(uint32_t vtermno)
{
s64 rc;