diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2014-03-08 02:59:58 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2014-03-12 11:00:24 -0400 |
commit | c1bacbae8192dd2a9ebadd22d793b68054f6c6e5 (patch) | |
tree | a2d402e83d75c77a390e47c0150078230bc0101a | |
parent | fa389e220254c69ffae0d403eac4146171062d08 (diff) |
genirq: Provide irq_request/release_resources chip callbacks
For certain irq types, e.g. gpios, it's necessary to request resources
before starting up the irq.
This might fail so we cannot use the irq_startup() callback because we
might call the irq_set_type() callback before that which does not make
sense when the resource is not available. Calling irq_startup() before
irq_set_type() can lead to spurious interrupts which is not desired
either.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: linux-arm-kernel@lists.infradead.org
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: http://lkml.kernel.org/r/alpine.DEB.2.02.1403080857160.18573@ionos.tec.linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | include/linux/irq.h | 6 | ||||
-rw-r--r-- | kernel/irq/manage.c | 28 |
2 files changed, 33 insertions, 1 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h index 7dc10036eff5..e675971bdc3f 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h | |||
@@ -303,6 +303,10 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d) | |||
303 | * @irq_pm_shutdown: function called from core code on shutdown once per chip | 303 | * @irq_pm_shutdown: function called from core code on shutdown once per chip |
304 | * @irq_calc_mask: Optional function to set irq_data.mask for special cases | 304 | * @irq_calc_mask: Optional function to set irq_data.mask for special cases |
305 | * @irq_print_chip: optional to print special chip info in show_interrupts | 305 | * @irq_print_chip: optional to print special chip info in show_interrupts |
306 | * @irq_request_resources: optional to request resources before calling | ||
307 | * any other callback related to this irq | ||
308 | * @irq_release_resources: optional to release resources acquired with | ||
309 | * irq_request_resources | ||
306 | * @flags: chip specific flags | 310 | * @flags: chip specific flags |
307 | */ | 311 | */ |
308 | struct irq_chip { | 312 | struct irq_chip { |
@@ -336,6 +340,8 @@ struct irq_chip { | |||
336 | void (*irq_calc_mask)(struct irq_data *data); | 340 | void (*irq_calc_mask)(struct irq_data *data); |
337 | 341 | ||
338 | void (*irq_print_chip)(struct irq_data *data, struct seq_file *p); | 342 | void (*irq_print_chip)(struct irq_data *data, struct seq_file *p); |
343 | int (*irq_request_resources)(struct irq_data *data); | ||
344 | void (*irq_release_resources)(struct irq_data *data); | ||
339 | 345 | ||
340 | unsigned long flags; | 346 | unsigned long flags; |
341 | }; | 347 | }; |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index d3bf660cb57f..5d35cbe22896 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -896,6 +896,23 @@ static void irq_setup_forced_threading(struct irqaction *new) | |||
896 | } | 896 | } |
897 | } | 897 | } |
898 | 898 | ||
899 | static int irq_request_resources(struct irq_desc *desc) | ||
900 | { | ||
901 | struct irq_data *d = &desc->irq_data; | ||
902 | struct irq_chip *c = d->chip; | ||
903 | |||
904 | return c->irq_request_resources ? c->irq_request_resources(d) : 0; | ||
905 | } | ||
906 | |||
907 | static void irq_release_resources(struct irq_desc *desc) | ||
908 | { | ||
909 | struct irq_data *d = &desc->irq_data; | ||
910 | struct irq_chip *c = d->chip; | ||
911 | |||
912 | if (c->irq_release_resources) | ||
913 | c->irq_release_resources(d); | ||
914 | } | ||
915 | |||
899 | /* | 916 | /* |
900 | * Internal function to register an irqaction - typically used to | 917 | * Internal function to register an irqaction - typically used to |
901 | * allocate special interrupts that are part of the architecture. | 918 | * allocate special interrupts that are part of the architecture. |
@@ -1091,6 +1108,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
1091 | } | 1108 | } |
1092 | 1109 | ||
1093 | if (!shared) { | 1110 | if (!shared) { |
1111 | ret = irq_request_resources(desc); | ||
1112 | if (ret) { | ||
1113 | pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", | ||
1114 | new->name, irq, desc->irq_data.chip->name); | ||
1115 | goto out_mask; | ||
1116 | } | ||
1117 | |||
1094 | init_waitqueue_head(&desc->wait_for_threads); | 1118 | init_waitqueue_head(&desc->wait_for_threads); |
1095 | 1119 | ||
1096 | /* Setup the type (level, edge polarity) if configured: */ | 1120 | /* Setup the type (level, edge polarity) if configured: */ |
@@ -1261,8 +1285,10 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1261 | *action_ptr = action->next; | 1285 | *action_ptr = action->next; |
1262 | 1286 | ||
1263 | /* If this was the last handler, shut down the IRQ line: */ | 1287 | /* If this was the last handler, shut down the IRQ line: */ |
1264 | if (!desc->action) | 1288 | if (!desc->action) { |
1265 | irq_shutdown(desc); | 1289 | irq_shutdown(desc); |
1290 | irq_release_resources(desc); | ||
1291 | } | ||
1266 | 1292 | ||
1267 | #ifdef CONFIG_SMP | 1293 | #ifdef CONFIG_SMP |
1268 | /* make sure affinity_hint is cleaned up */ | 1294 | /* make sure affinity_hint is cleaned up */ |