diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index a352d57..81ca63e 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -1,9 +1,11 @@
#include <linux/fs.h>
+#include <linux/poll.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/irqnr.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/slab.h>
/*
* /proc/interrupts
@@ -33,16 +35,73 @@ static const struct seq_operations int_seq_ops = {
.show = show_interrupts
};
-static int interrupts_open(struct inode *inode, struct file *filp)
+struct interrupts_fd_state {
+ atomic_long_t last_irq_change_count;
+};
+
+static int interrupts_open(struct inode *inode, struct file *file)
+{
+ int res;
+ struct interrupts_fd_state *privdata;
+ struct seq_file *sf;
+
+ privdata = kzalloc(sizeof(struct interrupts_fd_state), GFP_KERNEL);
+ if (!privdata) {
+ res = -ENOMEM;
+ goto exit;
+ }
+
+ res = seq_open(file, &int_seq_ops);
+ if (res) {
+ kfree(privdata);
+ goto exit;
+ }
+
+ sf = file->private_data;
+ sf->private = privdata;
+
+ atomic_long_set(&privdata->last_irq_change_count,
+ atomic_long_read(&irq_handler_change_count));
+
+exit:
+ return res;
+}
+
+static int interrupts_release(struct inode *inode, struct file *file)
+{
+ struct seq_file *sf = file->private_data;
+
+ kfree(sf->private);
+ return seq_release(inode, file);
+}
+
+static unsigned int interrupts_poll(struct file *file,
+ struct poll_table_struct *pt)
{
- return seq_open(filp, &int_seq_ops);
+ unsigned int mask = 0;
+ long newcount, oldcount;
+ struct seq_file *sf = file->private_data;
+ struct interrupts_fd_state *fds = sf->private;
+
+ /* Register for changes to IRQ handlers */
+ poll_wait(file, &irq_handler_change_wq, pt);
+
+ /* Store new change count in priv data */
+ newcount = atomic_long_read(&irq_handler_change_count);
+ oldcount = atomic_long_xchg(&fds->last_irq_change_count, newcount);
+
+ if (newcount != oldcount)
+ mask |= POLLIN | POLLRDNORM;
+
+ return mask;
}
static const struct file_operations proc_interrupts_operations = {
.open = interrupts_open,
.read = seq_read,
+ .poll = interrupts_poll,
.llseek = seq_lseek,
- .release = seq_release,
+ .release = interrupts_release,
};
static int __init proc_interrupts_init(void)diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index be7e75c..8d89eef 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -670,4 +670,7 @@ extern int early_irq_init(void);
extern int arch_probe_nr_irqs(void);
extern int arch_early_irq_init(void);
+extern atomic_long_t irq_handler_change_count;
+extern wait_queue_head_t irq_handler_change_wq;
+
#endif
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index f974485..5c7b34d 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -18,6 +18,7 @@
#include <linux/sched.h>
#include <linux/sched/rt.h>
#include <linux/task_work.h>
+#include <linux/poll.h>
#include "internals.h"
@@ -32,6 +33,17 @@ static int __init setup_forced_irqthreads(char *arg)
early_param("threadirqs", setup_forced_irqthreads);
#endif
+atomic_long_t irq_handler_change_count = ATOMIC_LONG_INIT(0);
+DECLARE_WAIT_QUEUE_HEAD(irq_handler_change_wq);
+
+/* Bump change count and wake up anything waiting on changes to
+ * IRQ handlers */
+static void __irq_handler_change_event(void)
+{
+ atomic_long_inc(&irq_handler_change_count);
+ wake_up_poll(&irq_handler_change_wq, POLLIN);
+}
+
static void __synchronize_hardirq(struct irq_desc *desc)
{
bool inprogress;@@ -1296,7 +1308,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
new->dir = NULL;
register_handler_proc(irq, new);
free_cpumask_var(mask);
-
+ __irq_handler_change_event();
return 0;
mismatch:
@@ -1431,6 +1443,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
}
module_put(desc->owner);
+ __irq_handler_change_event();
return action;
}