Commit 76c31f23 authored by Vitaly Mayatskikh's avatar Vitaly Mayatskikh Committed by Benjamin Herrenschmidt

powerpc: Honor O_NONBLOCK flag when reading RTAS log

rtas_log_read() doesn't check file flags for O_NONBLOCK and blocks
non-blocking readers of /proc/ppc64/rtas/error_log when there is
no data available. This fixes it.

Also rtas_log_read() returns now with ENODATA to prevent suspending of
process in wait_event_interruptible() when logging facility was
switched off and log is already empty.
Signed-off-by: default avatarVitaly Mayatskikh <v.mayatskih@gmail.com>
Acked-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 3396c72b
...@@ -295,19 +295,29 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf, ...@@ -295,19 +295,29 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
if (!tmp) if (!tmp)
return -ENOMEM; return -ENOMEM;
spin_lock_irqsave(&rtasd_log_lock, s); spin_lock_irqsave(&rtasd_log_lock, s);
/* if it's 0, then we know we got the last one (the one in NVRAM) */ /* if it's 0, then we know we got the last one (the one in NVRAM) */
if (rtas_log_size == 0 && logging_enabled) while (rtas_log_size == 0) {
nvram_clear_error_log(); if (file->f_flags & O_NONBLOCK) {
spin_unlock_irqrestore(&rtasd_log_lock, s); spin_unlock_irqrestore(&rtasd_log_lock, s);
error = -EAGAIN;
goto out;
}
if (!logging_enabled) {
spin_unlock_irqrestore(&rtasd_log_lock, s);
error = -ENODATA;
goto out;
}
nvram_clear_error_log();
error = wait_event_interruptible(rtas_log_wait, rtas_log_size); spin_unlock_irqrestore(&rtasd_log_lock, s);
if (error) error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
goto out; if (error)
goto out;
spin_lock_irqsave(&rtasd_log_lock, s);
}
spin_lock_irqsave(&rtasd_log_lock, s);
offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK); offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
memcpy(tmp, &rtas_log_buf[offset], count); memcpy(tmp, &rtas_log_buf[offset], count);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment