2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
|
|
|
|
* Licensed under the GPL
|
|
|
|
* Derived (i.e. mostly copied) from arch/i386/kernel/irq.c:
|
|
|
|
* Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "linux/kernel.h"
|
|
|
|
#include "linux/module.h"
|
|
|
|
#include "linux/smp.h"
|
|
|
|
#include "linux/kernel_stat.h"
|
|
|
|
#include "linux/interrupt.h"
|
|
|
|
#include "linux/random.h"
|
|
|
|
#include "linux/slab.h"
|
|
|
|
#include "linux/file.h"
|
|
|
|
#include "linux/proc_fs.h"
|
|
|
|
#include "linux/init.h"
|
|
|
|
#include "linux/seq_file.h"
|
|
|
|
#include "linux/profile.h"
|
|
|
|
#include "linux/hardirq.h"
|
|
|
|
#include "asm/irq.h"
|
|
|
|
#include "asm/hw_irq.h"
|
|
|
|
#include "asm/atomic.h"
|
|
|
|
#include "asm/signal.h"
|
|
|
|
#include "asm/system.h"
|
|
|
|
#include "asm/errno.h"
|
|
|
|
#include "asm/uaccess.h"
|
|
|
|
#include "user_util.h"
|
|
|
|
#include "kern_util.h"
|
|
|
|
#include "irq_user.h"
|
|
|
|
#include "irq_kern.h"
|
2005-09-03 18:57:45 -04:00
|
|
|
#include "os.h"
|
2006-03-27 04:14:31 -05:00
|
|
|
#include "sigio.h"
|
2006-10-20 02:28:20 -04:00
|
|
|
#include "um_malloc.h"
|
2006-03-27 04:14:31 -05:00
|
|
|
#include "misc_constants.h"
|
2005-04-16 18:20:36 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic, controller-independent functions:
|
|
|
|
*/
|
|
|
|
|
|
|
|
int show_interrupts(struct seq_file *p, void *v)
|
|
|
|
{
|
|
|
|
int i = *(loff_t *) v, j;
|
|
|
|
struct irqaction * action;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
seq_printf(p, " ");
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "CPU%d ",j);
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i < NR_IRQS) {
|
|
|
|
spin_lock_irqsave(&irq_desc[i].lock, flags);
|
|
|
|
action = irq_desc[i].action;
|
|
|
|
if (!action)
|
|
|
|
goto skip;
|
|
|
|
seq_printf(p, "%3d: ",i);
|
|
|
|
#ifndef CONFIG_SMP
|
|
|
|
seq_printf(p, "%10u ", kstat_irqs(i));
|
|
|
|
#else
|
|
|
|
for_each_online_cpu(j)
|
|
|
|
seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
|
|
|
|
#endif
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 05:24:36 -04:00
|
|
|
seq_printf(p, " %14s", irq_desc[i].chip->typename);
|
2005-04-16 18:20:36 -04:00
|
|
|
seq_printf(p, " %s", action->name);
|
|
|
|
|
|
|
|
for (action=action->next; action; action = action->next)
|
|
|
|
seq_printf(p, ", %s", action->name);
|
|
|
|
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
skip:
|
|
|
|
spin_unlock_irqrestore(&irq_desc[i].lock, flags);
|
|
|
|
} else if (i == NR_IRQS) {
|
|
|
|
seq_putc(p, '\n');
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-27 04:14:31 -05:00
|
|
|
struct irq_fd *active_fds = NULL;
|
|
|
|
static struct irq_fd **last_irq_ptr = &active_fds;
|
|
|
|
|
|
|
|
extern void free_irqs(void);
|
|
|
|
|
|
|
|
void sigio_handler(int sig, union uml_pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq_fd;
|
|
|
|
int n;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
if (smp_sigio_handler())
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (1) {
|
2006-03-27 04:14:31 -05:00
|
|
|
n = os_waiting_for_events(active_fds);
|
|
|
|
if (n <= 0) {
|
|
|
|
if(n == -EINTR) continue;
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
|
|
|
|
if (irq_fd->current_events != 0) {
|
2006-03-27 04:14:31 -05:00
|
|
|
irq_fd->current_events = 0;
|
|
|
|
do_IRQ(irq_fd->irq, regs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
free_irqs();
|
|
|
|
}
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
static DEFINE_SPINLOCK(irq_lock);
|
|
|
|
|
2006-03-27 04:14:31 -05:00
|
|
|
int activate_fd(int irq, int fd, int type, void *dev_id)
|
|
|
|
{
|
|
|
|
struct pollfd *tmp_pfd;
|
|
|
|
struct irq_fd *new_fd, *irq_fd;
|
|
|
|
unsigned long flags;
|
|
|
|
int pid, events, err, n;
|
|
|
|
|
|
|
|
pid = os_getpid();
|
|
|
|
err = os_set_fd_async(fd, pid);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err < 0)
|
2006-03-27 04:14:31 -05:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
new_fd = um_kmalloc(sizeof(*new_fd));
|
|
|
|
err = -ENOMEM;
|
2006-05-01 15:15:57 -04:00
|
|
|
if (new_fd == NULL)
|
2006-03-27 04:14:31 -05:00
|
|
|
goto out;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
if (type == IRQ_READ)
|
|
|
|
events = UM_POLLIN | UM_POLLPRI;
|
|
|
|
else
|
|
|
|
events = UM_POLLOUT;
|
2006-03-27 04:14:31 -05:00
|
|
|
*new_fd = ((struct irq_fd) { .next = NULL,
|
|
|
|
.id = dev_id,
|
|
|
|
.fd = fd,
|
|
|
|
.type = type,
|
|
|
|
.irq = irq,
|
|
|
|
.pid = pid,
|
|
|
|
.events = events,
|
|
|
|
.current_events = 0 } );
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-05-01 15:15:57 -04:00
|
|
|
for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
|
|
|
|
if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
|
2006-03-27 04:14:31 -05:00
|
|
|
printk("Registering fd %d twice\n", fd);
|
|
|
|
printk("Irqs : %d, %d\n", irq_fd->irq, irq);
|
|
|
|
printk("Ids : 0x%p, 0x%p\n", irq_fd->id, dev_id);
|
|
|
|
goto out_unlock;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
if (type == IRQ_WRITE)
|
2006-03-27 04:14:31 -05:00
|
|
|
fd = -1;
|
|
|
|
|
|
|
|
tmp_pfd = NULL;
|
|
|
|
n = 0;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
while (1) {
|
2006-03-27 04:14:31 -05:00
|
|
|
n = os_create_pollfd(fd, events, tmp_pfd, n);
|
|
|
|
if (n == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* n > 0
|
|
|
|
* It means we couldn't put new pollfd to current pollfds
|
|
|
|
* and tmp_fds is NULL or too small for new pollfds array.
|
|
|
|
* Needed size is equal to n as minimum.
|
|
|
|
*
|
|
|
|
* Here we have to drop the lock in order to call
|
|
|
|
* kmalloc, which might sleep.
|
|
|
|
* If something else came in and changed the pollfds array
|
|
|
|
* so we will not be able to put new pollfd struct to pollfds
|
|
|
|
* then we free the buffer tmp_fds and try again.
|
|
|
|
*/
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-05-01 15:15:57 -04:00
|
|
|
kfree(tmp_pfd);
|
|
|
|
tmp_pfd = NULL;
|
2006-03-27 04:14:31 -05:00
|
|
|
|
|
|
|
tmp_pfd = um_kmalloc(n);
|
|
|
|
if (tmp_pfd == NULL)
|
|
|
|
goto out_kfree;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
*last_irq_ptr = new_fd;
|
|
|
|
last_irq_ptr = &new_fd->next;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
|
|
|
|
/* This calls activate_fd, so it has to be outside the critical
|
|
|
|
* section.
|
|
|
|
*/
|
2006-07-10 07:45:11 -04:00
|
|
|
maybe_sigio_broken(fd, (type == IRQ_READ));
|
2006-03-27 04:14:31 -05:00
|
|
|
|
[PATCH] uml: SIGIO cleanups
- Various cleanups in the sigio code.
- Removed explicit zero-initializations of a few structures.
- Improved some error messages.
- An API change - there was an asymmetry between reactivate_fd calling
maybe_sigio_broken, which goes through all the machinery of figuring out if
a file descriptor supports SIGIO and applying the workaround to it if not,
and deactivate_fd, which just turns off the descriptor.
This is changed so that only activate_fd calls maybe_sigio_broken, when
the descriptor is first seen. reactivate_fd now calls add_sigio_fd, which
is symmetric with ignore_sigio_fd.
This removes a recursion which makes a critical section look more critical
than it really was, obsoleting a big comment to that effect. This requires
keeping track of all descriptors which are getting the SIGIO treatment, not
just the ones being polled at any given moment, so that reactivate_fd,
through add_sigio_fd, doesn't try to tell the SIGIO thread about descriptors
it doesn't care about.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 02:33:04 -04:00
|
|
|
return 0;
|
2006-03-27 04:14:31 -05:00
|
|
|
|
|
|
|
out_unlock:
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
out_kfree:
|
|
|
|
kfree(new_fd);
|
|
|
|
out:
|
[PATCH] uml: SIGIO cleanups
- Various cleanups in the sigio code.
- Removed explicit zero-initializations of a few structures.
- Improved some error messages.
- An API change - there was an asymmetry between reactivate_fd calling
maybe_sigio_broken, which goes through all the machinery of figuring out if
a file descriptor supports SIGIO and applying the workaround to it if not,
and deactivate_fd, which just turns off the descriptor.
This is changed so that only activate_fd calls maybe_sigio_broken, when
the descriptor is first seen. reactivate_fd now calls add_sigio_fd, which
is symmetric with ignore_sigio_fd.
This removes a recursion which makes a critical section look more critical
than it really was, obsoleting a big comment to that effect. This requires
keeping track of all descriptors which are getting the SIGIO treatment, not
just the ones being polled at any given moment, so that reactivate_fd,
through add_sigio_fd, doesn't try to tell the SIGIO thread about descriptors
it doesn't care about.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 02:33:04 -04:00
|
|
|
return err;
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct irq_and_dev {
|
|
|
|
int irq;
|
|
|
|
void *dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int same_irq_and_dev(struct irq_fd *irq, void *d)
|
|
|
|
{
|
|
|
|
struct irq_and_dev *data = d;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
return ((irq->irq == data->irq) && (irq->id == data->dev));
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void free_irq_by_irq_and_dev(unsigned int irq, void *dev)
|
|
|
|
{
|
|
|
|
struct irq_and_dev data = ((struct irq_and_dev) { .irq = irq,
|
|
|
|
.dev = dev });
|
|
|
|
|
|
|
|
free_irq_by_cb(same_irq_and_dev, &data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int same_fd(struct irq_fd *irq, void *fd)
|
|
|
|
{
|
2006-05-01 15:15:57 -04:00
|
|
|
return (irq->fd == *((int *)fd));
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void free_irq_by_fd(int fd)
|
|
|
|
{
|
|
|
|
free_irq_by_cb(same_fd, &fd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq;
|
|
|
|
int i = 0;
|
|
|
|
int fdi;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
|
|
|
if ((irq->fd == fd) && (irq->irq == irqnum))
|
|
|
|
break;
|
2006-03-27 04:14:31 -05:00
|
|
|
i++;
|
|
|
|
}
|
2006-05-01 15:15:57 -04:00
|
|
|
if (irq == NULL) {
|
2006-03-27 04:14:31 -05:00
|
|
|
printk("find_irq_by_fd doesn't have descriptor %d\n", fd);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
fdi = os_get_pollfd(i);
|
2006-05-01 15:15:57 -04:00
|
|
|
if ((fdi != -1) && (fdi != fd)) {
|
2006-03-27 04:14:31 -05:00
|
|
|
printk("find_irq_by_fd - mismatch between active_fds and "
|
|
|
|
"pollfds, fd %d vs %d, need %d\n", irq->fd,
|
|
|
|
fdi, fd);
|
|
|
|
irq = NULL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
*index_out = i;
|
|
|
|
out:
|
2006-05-01 15:15:57 -04:00
|
|
|
return irq;
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void reactivate_fd(int fd, int irqnum)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq;
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
irq = find_irq_by_fd(fd, irqnum, &i);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (irq == NULL) {
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
os_set_pollfd(i, irq->fd);
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
|
[PATCH] uml: SIGIO cleanups
- Various cleanups in the sigio code.
- Removed explicit zero-initializations of a few structures.
- Improved some error messages.
- An API change - there was an asymmetry between reactivate_fd calling
maybe_sigio_broken, which goes through all the machinery of figuring out if
a file descriptor supports SIGIO and applying the workaround to it if not,
and deactivate_fd, which just turns off the descriptor.
This is changed so that only activate_fd calls maybe_sigio_broken, when
the descriptor is first seen. reactivate_fd now calls add_sigio_fd, which
is symmetric with ignore_sigio_fd.
This removes a recursion which makes a critical section look more critical
than it really was, obsoleting a big comment to that effect. This requires
keeping track of all descriptors which are getting the SIGIO treatment, not
just the ones being polled at any given moment, so that reactivate_fd,
through add_sigio_fd, doesn't try to tell the SIGIO thread about descriptors
it doesn't care about.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 02:33:04 -04:00
|
|
|
add_sigio_fd(fd);
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void deactivate_fd(int fd, int irqnum)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq;
|
|
|
|
unsigned long flags;
|
|
|
|
int i;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
irq = find_irq_by_fd(fd, irqnum, &i);
|
[PATCH] uml: SIGIO cleanups
- Various cleanups in the sigio code.
- Removed explicit zero-initializations of a few structures.
- Improved some error messages.
- An API change - there was an asymmetry between reactivate_fd calling
maybe_sigio_broken, which goes through all the machinery of figuring out if
a file descriptor supports SIGIO and applying the workaround to it if not,
and deactivate_fd, which just turns off the descriptor.
This is changed so that only activate_fd calls maybe_sigio_broken, when
the descriptor is first seen. reactivate_fd now calls add_sigio_fd, which
is symmetric with ignore_sigio_fd.
This removes a recursion which makes a critical section look more critical
than it really was, obsoleting a big comment to that effect. This requires
keeping track of all descriptors which are getting the SIGIO treatment, not
just the ones being polled at any given moment, so that reactivate_fd,
through add_sigio_fd, doesn't try to tell the SIGIO thread about descriptors
it doesn't care about.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 02:33:04 -04:00
|
|
|
if(irq == NULL){
|
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-27 04:14:31 -05:00
|
|
|
os_set_pollfd(i, -1);
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
[PATCH] uml: SIGIO cleanups
- Various cleanups in the sigio code.
- Removed explicit zero-initializations of a few structures.
- Improved some error messages.
- An API change - there was an asymmetry between reactivate_fd calling
maybe_sigio_broken, which goes through all the machinery of figuring out if
a file descriptor supports SIGIO and applying the workaround to it if not,
and deactivate_fd, which just turns off the descriptor.
This is changed so that only activate_fd calls maybe_sigio_broken, when
the descriptor is first seen. reactivate_fd now calls add_sigio_fd, which
is symmetric with ignore_sigio_fd.
This removes a recursion which makes a critical section look more critical
than it really was, obsoleting a big comment to that effect. This requires
keeping track of all descriptors which are getting the SIGIO treatment, not
just the ones being polled at any given moment, so that reactivate_fd,
through add_sigio_fd, doesn't try to tell the SIGIO thread about descriptors
it doesn't care about.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-09-26 02:33:04 -04:00
|
|
|
|
|
|
|
ignore_sigio_fd(fd);
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int deactivate_all_fds(void)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq;
|
|
|
|
int err;
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
2006-03-27 04:14:31 -05:00
|
|
|
err = os_clear_fd_async(irq->fd);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err)
|
|
|
|
return err;
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
/* If there is a signal already queued, after unblocking ignore it */
|
|
|
|
os_set_ioignore();
|
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
return 0;
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
|
|
|
|
2006-07-10 07:45:09 -04:00
|
|
|
#ifdef CONFIG_MODE_TT
|
2006-03-27 04:14:31 -05:00
|
|
|
void forward_interrupts(int pid)
|
|
|
|
{
|
|
|
|
struct irq_fd *irq;
|
|
|
|
unsigned long flags;
|
|
|
|
int err;
|
|
|
|
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_lock_irqsave(&irq_lock, flags);
|
2006-05-01 15:15:57 -04:00
|
|
|
for (irq = active_fds; irq != NULL; irq = irq->next) {
|
2006-03-27 04:14:31 -05:00
|
|
|
err = os_set_owner(irq->fd, pid);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err < 0) {
|
2006-03-27 04:14:31 -05:00
|
|
|
/* XXX Just remove the irq rather than
|
|
|
|
* print out an infinite stream of these
|
|
|
|
*/
|
|
|
|
printk("Failed to forward %d to pid %d, err = %d\n",
|
|
|
|
irq->fd, pid, -err);
|
|
|
|
}
|
|
|
|
|
|
|
|
irq->pid = pid;
|
|
|
|
}
|
2006-07-10 07:45:10 -04:00
|
|
|
spin_unlock_irqrestore(&irq_lock, flags);
|
2006-03-27 04:14:31 -05:00
|
|
|
}
|
2006-07-10 07:45:09 -04:00
|
|
|
#endif
|
2006-03-27 04:14:31 -05:00
|
|
|
|
2005-04-16 18:20:36 -04:00
|
|
|
/*
|
|
|
|
* do_IRQ handles all normal device IRQ's (the special
|
|
|
|
* SMP cross-CPU interrupts have their own specific
|
|
|
|
* handlers).
|
|
|
|
*/
|
|
|
|
unsigned int do_IRQ(int irq, union uml_pt_regs *regs)
|
|
|
|
{
|
2006-10-08 17:49:34 -04:00
|
|
|
struct pt_regs *old_regs = set_irq_regs((struct pt_regs *)regs);
|
|
|
|
irq_enter();
|
|
|
|
__do_IRQ(irq);
|
|
|
|
irq_exit();
|
|
|
|
set_irq_regs(old_regs);
|
|
|
|
return 1;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int um_request_irq(unsigned int irq, int fd, int type,
|
2006-10-09 07:19:47 -04:00
|
|
|
irq_handler_t handler,
|
2005-04-16 18:20:36 -04:00
|
|
|
unsigned long irqflags, const char * devname,
|
|
|
|
void *dev_id)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = request_irq(irq, handler, irqflags, devname, dev_id);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err)
|
|
|
|
return err;
|
2005-04-16 18:20:36 -04:00
|
|
|
|
2006-05-01 15:15:57 -04:00
|
|
|
if (fd != -1)
|
2005-04-16 18:20:36 -04:00
|
|
|
err = activate_fd(irq, fd, type, dev_id);
|
2006-05-01 15:15:57 -04:00
|
|
|
return err;
|
2005-04-16 18:20:36 -04:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(um_request_irq);
|
|
|
|
EXPORT_SYMBOL(reactivate_fd);
|
|
|
|
|
[PATCH] uml: add and use generic hw_controller_type->release
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>
2005-06-21 20:16:19 -04:00
|
|
|
/* hw_interrupt_type must define (startup || enable) &&
|
|
|
|
* (shutdown || disable) && end */
|
2005-04-16 18:20:36 -04:00
|
|
|
static void dummy(unsigned int irq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
[PATCH] uml: add and use generic hw_controller_type->release
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>
2005-06-21 20:16:19 -04:00
|
|
|
/* This is used for everything else than the timer. */
|
|
|
|
static struct hw_interrupt_type normal_irq_type = {
|
2005-04-16 18:20:36 -04:00
|
|
|
.typename = "SIGIO",
|
[PATCH] uml: add and use generic hw_controller_type->release
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>
2005-06-21 20:16:19 -04:00
|
|
|
.release = free_irq_by_irq_and_dev,
|
2005-04-16 18:20:36 -04:00
|
|
|
.disable = dummy,
|
|
|
|
.enable = dummy,
|
|
|
|
.ack = dummy,
|
|
|
|
.end = dummy
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct hw_interrupt_type SIGVTALRM_irq_type = {
|
|
|
|
.typename = "SIGVTALRM",
|
[PATCH] uml: add and use generic hw_controller_type->release
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>
2005-06-21 20:16:19 -04:00
|
|
|
.release = free_irq_by_irq_and_dev,
|
2005-04-16 18:20:36 -04:00
|
|
|
.shutdown = dummy, /* never called */
|
|
|
|
.disable = dummy,
|
|
|
|
.enable = dummy,
|
|
|
|
.ack = dummy,
|
|
|
|
.end = dummy
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init init_IRQ(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
irq_desc[TIMER_IRQ].status = IRQ_DISABLED;
|
|
|
|
irq_desc[TIMER_IRQ].action = NULL;
|
|
|
|
irq_desc[TIMER_IRQ].depth = 1;
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 05:24:36 -04:00
|
|
|
irq_desc[TIMER_IRQ].chip = &SIGVTALRM_irq_type;
|
2005-04-16 18:20:36 -04:00
|
|
|
enable_irq(TIMER_IRQ);
|
2006-05-01 15:15:57 -04:00
|
|
|
for (i = 1; i < NR_IRQS; i++) {
|
2005-04-16 18:20:36 -04:00
|
|
|
irq_desc[i].status = IRQ_DISABLED;
|
|
|
|
irq_desc[i].action = NULL;
|
|
|
|
irq_desc[i].depth = 1;
|
[PATCH] genirq: rename desc->handler to desc->chip
This patch-queue improves the generic IRQ layer to be truly generic, by adding
various abstractions and features to it, without impacting existing
functionality.
While the queue can be best described as "fix and improve everything in the
generic IRQ layer that we could think of", and thus it consists of many
smaller features and lots of cleanups, the one feature that stands out most is
the new 'irq chip' abstraction.
The irq-chip abstraction is about describing and coding and IRQ controller
driver by mapping its raw hardware capabilities [and quirks, if needed] in a
straightforward way, without having to think about "IRQ flow"
(level/edge/etc.) type of details.
This stands in contrast with the current 'irq-type' model of genirq
architectures, which 'mixes' raw hardware capabilities with 'flow' details.
The patchset supports both types of irq controller designs at once, and
converts i386 and x86_64 to the new irq-chip design.
As a bonus side-effect of the irq-chip approach, chained interrupt controllers
(master/slave PIC constructs, etc.) are now supported by design as well.
The end result of this patchset intends to be simpler architecture-level code
and more consolidation between architectures.
We reused many bits of code and many concepts from Russell King's ARM IRQ
layer, the merging of which was one of the motivations for this patchset.
This patch:
rename desc->handler to desc->chip.
Originally i did not want to do this, because it's a big patch. But having
both "desc->handler", "desc->handle_irq" and "action->handler" caused a
large degree of confusion and made the code appear alot less clean than it
truly is.
I have also attempted a dual approach as well by introducing a
desc->chip alias - but that just wasnt robust enough and broke
frequently.
So lets get over with this quickly. The conversion was done automatically
via scripts and converts all the code in the kernel.
This renaming patch is the first one amongst the patches, so that the
remaining patches can stay flexible and can be merged and split up
without having some big monolithic patch act as a merge barrier.
[akpm@osdl.org: build fix]
[akpm@osdl.org: another build fix]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-06-29 05:24:36 -04:00
|
|
|
irq_desc[i].chip = &normal_irq_type;
|
2005-04-16 18:20:36 -04:00
|
|
|
enable_irq(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-09 07:19:47 -04:00
|
|
|
int init_aio_irq(int irq, char *name, irq_handler_t handler)
|
2005-09-03 18:57:45 -04:00
|
|
|
{
|
|
|
|
int fds[2], err;
|
|
|
|
|
|
|
|
err = os_pipe(fds, 1, 1);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err) {
|
2005-09-03 18:57:45 -04:00
|
|
|
printk("init_aio_irq - os_pipe failed, err = %d\n", -err);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = um_request_irq(irq, fds[0], IRQ_READ, handler,
|
2006-07-01 22:29:27 -04:00
|
|
|
IRQF_DISABLED | IRQF_SAMPLE_RANDOM, name,
|
2005-09-03 18:57:45 -04:00
|
|
|
(void *) (long) fds[0]);
|
2006-05-01 15:15:57 -04:00
|
|
|
if (err) {
|
2005-09-03 18:57:45 -04:00
|
|
|
printk("init_aio_irq - : um_request_irq failed, err = %d\n",
|
|
|
|
err);
|
|
|
|
goto out_close;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = fds[1];
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
out_close:
|
|
|
|
os_close_file(fds[0]);
|
|
|
|
os_close_file(fds[1]);
|
|
|
|
out:
|
2006-05-01 15:15:57 -04:00
|
|
|
return err;
|
2005-09-03 18:57:45 -04:00
|
|
|
}
|