irq: Add irq_set_chained_handler_and_data()
Driver authors seem to get the ordering of irq_set_chained_handler() and irq_set_handler_data() wrong - ordering the former before the latter. This opens a race window where, if there is an interrupt pending, the handler will be called between these two calls, potentially resulting in an oops. Provide a single interface to set both of these together, especially as that's commonly what is required. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Alexandre Courbot <gnurou@gmail.com> Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com> Cc: Jason Cooper <jason@lakedaemon.net> Cc: Lee Jones <lee.jones@linaro.org> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/E1Z4yzs-0002Rw-4B@rmk-PC.arm.linux.org.uk Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
6fd4899a54
commit
3b0f95be14
2 changed files with 43 additions and 11 deletions
|
@ -525,6 +525,15 @@ irq_set_chained_handler(unsigned int irq, irq_flow_handler_t handle)
|
||||||
__irq_set_handler(irq, handle, 1, NULL);
|
__irq_set_handler(irq, handle, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set a highlevel chained flow handler and its data for a given IRQ.
|
||||||
|
* (a chained handler is automatically enabled and set to
|
||||||
|
* IRQ_NOREQUEST, IRQ_NOPROBE, and IRQ_NOTHREAD)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
|
||||||
|
void *data);
|
||||||
|
|
||||||
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set);
|
void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set);
|
||||||
|
|
||||||
static inline void irq_set_status_flags(unsigned int irq, unsigned long set)
|
static inline void irq_set_status_flags(unsigned int irq, unsigned long set)
|
||||||
|
|
|
@ -719,15 +719,9 @@ void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
|
__irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
|
||||||
const char *name)
|
int is_chained, const char *name)
|
||||||
{
|
{
|
||||||
unsigned long flags;
|
|
||||||
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
|
|
||||||
|
|
||||||
if (!desc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
handle = handle_bad_irq;
|
handle = handle_bad_irq;
|
||||||
} else {
|
} else {
|
||||||
|
@ -749,13 +743,13 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
|
||||||
* right away.
|
* right away.
|
||||||
*/
|
*/
|
||||||
if (WARN_ON(is_chained))
|
if (WARN_ON(is_chained))
|
||||||
goto out;
|
return;
|
||||||
/* Try the parent */
|
/* Try the parent */
|
||||||
irq_data = irq_data->parent_data;
|
irq_data = irq_data->parent_data;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
|
if (WARN_ON(!irq_data || irq_data->chip == &no_irq_chip))
|
||||||
goto out;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Uninstall? */
|
/* Uninstall? */
|
||||||
|
@ -774,11 +768,40 @@ __irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
|
||||||
irq_settings_set_nothread(desc);
|
irq_settings_set_nothread(desc);
|
||||||
irq_startup(desc, true);
|
irq_startup(desc, true);
|
||||||
}
|
}
|
||||||
out:
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__irq_do_set_handler(desc, handle, is_chained, name);
|
||||||
irq_put_desc_busunlock(desc, flags);
|
irq_put_desc_busunlock(desc, flags);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__irq_set_handler);
|
EXPORT_SYMBOL_GPL(__irq_set_handler);
|
||||||
|
|
||||||
|
void
|
||||||
|
irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
|
||||||
|
void *data)
|
||||||
|
{
|
||||||
|
unsigned long flags;
|
||||||
|
struct irq_desc *desc = irq_get_desc_buslock(irq, &flags, 0);
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
__irq_do_set_handler(desc, handle, 1, NULL);
|
||||||
|
desc->irq_data.handler_data = data;
|
||||||
|
|
||||||
|
irq_put_desc_busunlock(desc, flags);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(irq_set_chained_handler_and_data);
|
||||||
|
|
||||||
void
|
void
|
||||||
irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
|
irq_set_chip_and_handler_name(unsigned int irq, struct irq_chip *chip,
|
||||||
irq_flow_handler_t handle, const char *name)
|
irq_flow_handler_t handle, const char *name)
|
||||||
|
|
Loading…
Reference in a new issue