Skip to content

Commit

Permalink
uml: DEBUG_SHIRQ fixes
Browse files Browse the repository at this point in the history
DEBUG_SHIRQ generates spurious interrupts, triggering handlers such as
mconsole_interrupt() or line_interrupt().  They expect data to be available to
be read from their sockets/pipes, but in the case of spurious interrupts, the
host didn't actually send anything, so UML hangs in read() and friends.
Setting those fd's as O_NONBLOCK makes DEBUG_SHIRQ-enabled UML kernels boot
and run correctly.

Signed-off-by: Eduard-Gabriel Munteanu <[email protected]>
Signed-off-by: Jeff Dike <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Eduard-Gabriel Munteanu authored and Linus Torvalds committed Jul 16, 2007
1 parent e18eecb commit 89df6bf
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
8 changes: 7 additions & 1 deletion arch/um/drivers/chan_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,13 @@ static int winch_tramp(int fd, struct tty_struct *tty, int *fd_out)
err = -EINVAL;
goto out_close;
}
return err ;

if (os_set_fd_block(*fd_out, 0)) {
printk("winch_tramp: failed to set thread_fd non-blocking.\n");
goto out_close;
}

return err;

out_close:
os_close_file(fds[1]);
Expand Down
5 changes: 3 additions & 2 deletions arch/um/drivers/mconsole_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ int mconsole_get_request(int fd, struct mc_request *req)
int len;

req->originlen = sizeof(req->origin);
req->len = recvfrom(fd, &req->request, sizeof(req->request), 0,
(struct sockaddr *) req->origin, &req->originlen);
req->len = recvfrom(fd, &req->request, sizeof(req->request),
MSG_DONTWAIT, (struct sockaddr *) req->origin,
&req->originlen);
if (req->len < 0)
return 0;

Expand Down
6 changes: 6 additions & 0 deletions arch/um/drivers/ubd_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ int start_io_thread(unsigned long sp, int *fd_out)
kernel_fd = fds[0];
*fd_out = fds[1];

err = os_set_fd_block(*fd_out, 0);
if (err) {
printk("start_io_thread - failed to set nonblocking I/O.\n");
goto out_close;
}

pid = clone(io_thread, (void *) sp, CLONE_FILES | CLONE_VM | SIGCHLD,
NULL);
if(pid < 0){
Expand Down
7 changes: 7 additions & 0 deletions arch/um/drivers/xterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ int xterm_open(int input, int output, int primary, void *d,
goto out;
}

err = os_set_fd_block(new, 0);
if (err) {
printk("xterm_open : failed to set xterm descriptor "
"non-blocking, err = %d\n", -err);
goto out;
}

CATCH_EINTR(err = tcgetattr(new, &data->tt));
if(err){
new = err;
Expand Down

0 comments on commit 89df6bf

Please sign in to comment.