mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-26 19:36:41 +00:00
dbce706e25
With Chris Wedgwood <cw@f00f.org> Currently UML must explicitly call the UML-specific free_irq_by_irq_and_dev() for each free_irq call it's done. This is needed because ->shutdown and/or ->disable are only called when the last "action" for that irq is removed. Instead, for UML shared IRQs (UML IRQs are very often, if not always, shared), for each dev_id some setup is done, which must be cleared on the release of that fd. For instance, for each open console a new instance (i.e. new dev_id) of the same IRQ is requested(). Exactly, a fd is stored in an array (pollfds), which is after read by a host thread and passed to poll(). Each event registered by poll() triggers an interrupt. So, for each free_irq() we must remove the corresponding host fd from the table, which we do via this -release() method. In this patch we add an appropriate hook for this, and remove all uses of it by pointing the hook to the said procedure; this is safe to do since the said procedure. Also some cosmetic improvements are included. This is heavily based on some work by Chris Wedgwood, which however didn't get the patch merged for something I'd call a "misunderstanding" (the need for this patch wasn't cleanly explained, thus adding the generic hook was felt as undesirable). Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> CC: Ingo Molnar <mingo@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
92 lines
2.0 KiB
C
92 lines
2.0 KiB
C
/*
|
|
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
|
|
* Licensed under the GPL
|
|
*/
|
|
|
|
#include "linux/errno.h"
|
|
#include "linux/slab.h"
|
|
#include "linux/signal.h"
|
|
#include "linux/interrupt.h"
|
|
#include "asm/irq.h"
|
|
#include "irq_user.h"
|
|
#include "irq_kern.h"
|
|
#include "kern_util.h"
|
|
#include "os.h"
|
|
#include "xterm.h"
|
|
|
|
struct xterm_wait {
|
|
struct completion ready;
|
|
int fd;
|
|
int pid;
|
|
int new_fd;
|
|
};
|
|
|
|
static irqreturn_t xterm_interrupt(int irq, void *data, struct pt_regs *regs)
|
|
{
|
|
struct xterm_wait *xterm = data;
|
|
int fd;
|
|
|
|
fd = os_rcv_fd(xterm->fd, &xterm->pid);
|
|
if(fd == -EAGAIN)
|
|
return(IRQ_NONE);
|
|
|
|
xterm->new_fd = fd;
|
|
complete(&xterm->ready);
|
|
return(IRQ_HANDLED);
|
|
}
|
|
|
|
int xterm_fd(int socket, int *pid_out)
|
|
{
|
|
struct xterm_wait *data;
|
|
int err, ret;
|
|
|
|
data = kmalloc(sizeof(*data), GFP_KERNEL);
|
|
if(data == NULL){
|
|
printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
|
|
return(-ENOMEM);
|
|
}
|
|
|
|
/* This is a locked semaphore... */
|
|
*data = ((struct xterm_wait)
|
|
{ .fd = socket,
|
|
.pid = -1,
|
|
.new_fd = -1 });
|
|
init_completion(&data->ready);
|
|
|
|
err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
|
|
SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
|
|
"xterm", data);
|
|
if (err){
|
|
printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
|
|
"err = %d\n", err);
|
|
ret = err;
|
|
goto out;
|
|
}
|
|
|
|
/* ... so here we wait for an xterm interrupt.
|
|
*
|
|
* XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
|
|
* isn't set) this will hang... */
|
|
wait_for_completion(&data->ready);
|
|
|
|
free_irq(XTERM_IRQ, data);
|
|
|
|
ret = data->new_fd;
|
|
*pid_out = data->pid;
|
|
out:
|
|
kfree(data);
|
|
|
|
return(ret);
|
|
}
|
|
|
|
/*
|
|
* Overrides for Emacs so that we follow Linus's tabbing style.
|
|
* Emacs will notice this stuff at the end of the file and automatically
|
|
* adjust the settings for this buffer only. This must remain at the end
|
|
* of the file.
|
|
* ---------------------------------------------------------------------------
|
|
* Local variables:
|
|
* c-file-style: "linux"
|
|
* End:
|
|
*/
|