mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
36d46a5907
It's cumbersome and error-prone to keep adding fixed IRQ numbers, and for proper device wakeup support for the virtio/vhost-user support we need to have different IRQs for each device. Even if in theory two IRQs (with and without wake) might be sufficient, it's much easier to reason about it when we have dynamic number assignment. It also makes it easier to add new devices that may dynamically exist or depending on the configuration, etc. Add support for this, up to 64 IRQs (the same limit as epoll FDs we have right now). Since it's not easy to port all the existing places to dynamic allocation (some data is statically initialized) keep the low numbers are reserved for the existing hard-coded IRQ numbers. Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-By: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at>
49 lines
961 B
C
49 lines
961 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
|
|
*/
|
|
|
|
#include <linux/interrupt.h>
|
|
#include <irq_kern.h>
|
|
#include <os.h>
|
|
#include <sigio.h>
|
|
|
|
/* Protected by sigio_lock() called from write_sigio_workaround */
|
|
static int sigio_irq_fd = -1;
|
|
|
|
static irqreturn_t sigio_interrupt(int irq, void *data)
|
|
{
|
|
char c;
|
|
|
|
os_read_file(sigio_irq_fd, &c, sizeof(c));
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
int write_sigio_irq(int fd)
|
|
{
|
|
int err;
|
|
|
|
err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
|
|
0, "write sigio", NULL);
|
|
if (err < 0) {
|
|
printk(KERN_ERR "write_sigio_irq : um_request_irq failed, "
|
|
"err = %d\n", err);
|
|
return -1;
|
|
}
|
|
sigio_irq_fd = fd;
|
|
return 0;
|
|
}
|
|
|
|
/* These are called from os-Linux/sigio.c to protect its pollfds arrays. */
|
|
static DEFINE_MUTEX(sigio_mutex);
|
|
|
|
void sigio_lock(void)
|
|
{
|
|
mutex_lock(&sigio_mutex);
|
|
}
|
|
|
|
void sigio_unlock(void)
|
|
{
|
|
mutex_unlock(&sigio_mutex);
|
|
}
|