Commit c5bb3b4e authored by Max Filippov's avatar Max Filippov Committed by Ben Hutchings

xtensa: ISS: don't hang if stdin EOF is reached

commit 362014c8 upstream.

Simulator stdin may be connected to a file, when its end is reached
kernel hangs in infinite loop inside rs_poll, because simc_poll always
signals that descriptor 0 is readable and simc_read always returns 0.
Check simc_read return value and exit loop if it's not positive. Also
don't rewind polling timer if it's zero.
Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 96a8c31b
...@@ -100,20 +100,22 @@ static void rs_poll(unsigned long priv) ...@@ -100,20 +100,22 @@ static void rs_poll(unsigned long priv)
{ {
struct tty_port *port = (struct tty_port *)priv; struct tty_port *port = (struct tty_port *)priv;
int i = 0; int i = 0;
int rd = 1;
unsigned char c; unsigned char c;
spin_lock(&timer_lock); spin_lock(&timer_lock);
while (simc_poll(0)) { while (simc_poll(0)) {
simc_read(0, &c, 1); rd = simc_read(0, &c, 1);
if (rd <= 0)
break;
tty_insert_flip_char(port, c, TTY_NORMAL); tty_insert_flip_char(port, c, TTY_NORMAL);
i++; i++;
} }
if (i) if (i)
tty_flip_buffer_push(port); tty_flip_buffer_push(port);
if (rd)
mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
spin_unlock(&timer_lock); spin_unlock(&timer_lock);
} }
......
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