]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - kernel/irq/chip.c
Merge branch 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[karo-tx-linux.git] / kernel / irq / chip.c
index 6e40a9539763f48efc695c2b780a29f61b760f9f..15206453b12aab09cf96dd09cc3fa2da92fd9c14 100644 (file)
 
 #include "internals.h"
 
+static irqreturn_t bad_chained_irq(int irq, void *dev_id)
+{
+       WARN_ONCE(1, "Chained irq %d should not call an action\n", irq);
+       return IRQ_NONE;
+}
+
+/*
+ * Chained handlers should never call action on their IRQ. This default
+ * action will emit warning if such thing happens.
+ */
+struct irqaction chained_action = {
+       .handler = bad_chained_irq,
+};
+
 /**
  *     irq_set_chip - set the irq chip for an irq
  *     @irq:   irq number
@@ -83,7 +97,7 @@ int irq_set_handler_data(unsigned int irq, void *data)
 
        if (!desc)
                return -EINVAL;
-       desc->irq_data.handler_data = data;
+       desc->irq_common_data.handler_data = data;
        irq_put_desc_unlock(desc, flags);
        return 0;
 }
@@ -105,7 +119,7 @@ int irq_set_msi_desc_off(unsigned int irq_base, unsigned int irq_offset,
 
        if (!desc)
                return -EINVAL;
-       desc->irq_data.msi_desc = entry;
+       desc->irq_common_data.msi_desc = entry;
        if (entry && !irq_offset)
                entry->irq = irq_base;
        irq_put_desc_unlock(desc, flags);
@@ -227,6 +241,13 @@ void irq_enable(struct irq_desc *desc)
  * disabled. If an interrupt happens, then the interrupt flow
  * handler masks the line at the hardware level and marks it
  * pending.
+ *
+ * If the interrupt chip does not implement the irq_disable callback,
+ * a driver can disable the lazy approach for a particular irq line by
+ * calling 'irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY)'. This can
+ * be used for devices which cannot disable the interrupt at the
+ * device level under certain circumstances and have to use
+ * disable_irq[_nosync] instead.
  */
 void irq_disable(struct irq_desc *desc)
 {
@@ -234,6 +255,8 @@ void irq_disable(struct irq_desc *desc)
        if (desc->irq_data.chip->irq_disable) {
                desc->irq_data.chip->irq_disable(&desc->irq_data);
                irq_state_set_masked(desc);
+       } else if (irq_settings_disable_unlazy(desc)) {
+               mask_irq(desc);
        }
 }
 
@@ -372,7 +395,6 @@ static bool irq_may_run(struct irq_desc *desc)
 
 /**
  *     handle_simple_irq - Simple and software-decoded IRQs.
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  *     Simple interrupts are either sent from a demultiplexing interrupt
@@ -382,8 +404,7 @@ static bool irq_may_run(struct irq_desc *desc)
  *     Note: The caller is expected to handle the ack, clear, mask and
  *     unmask issues if necessary.
  */
-void
-handle_simple_irq(unsigned int irq, struct irq_desc *desc)
+void handle_simple_irq(struct irq_desc *desc)
 {
        raw_spin_lock(&desc->lock);
 
@@ -425,7 +446,6 @@ static void cond_unmask_irq(struct irq_desc *desc)
 
 /**
  *     handle_level_irq - Level type irq handler
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  *     Level type interrupts are active as long as the hardware line has
@@ -433,8 +453,7 @@ static void cond_unmask_irq(struct irq_desc *desc)
  *     it after the associated handler has acknowledged the device, so the
  *     interrupt line is back to inactive.
  */
-void
-handle_level_irq(unsigned int irq, struct irq_desc *desc)
+void handle_level_irq(struct irq_desc *desc)
 {
        raw_spin_lock(&desc->lock);
        mask_ack_irq(desc);
@@ -496,7 +515,6 @@ static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip)
 
 /**
  *     handle_fasteoi_irq - irq handler for transparent controllers
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  *     Only a single callback will be issued to the chip: an ->eoi()
@@ -504,8 +522,7 @@ static void cond_unmask_eoi_irq(struct irq_desc *desc, struct irq_chip *chip)
  *     for modern forms of interrupt handlers, which handle the flow
  *     details in hardware, transparently.
  */
-void
-handle_fasteoi_irq(unsigned int irq, struct irq_desc *desc)
+void handle_fasteoi_irq(struct irq_desc *desc)
 {
        struct irq_chip *chip = desc->irq_data.chip;
 
@@ -546,7 +563,6 @@ EXPORT_SYMBOL_GPL(handle_fasteoi_irq);
 
 /**
  *     handle_edge_irq - edge type IRQ handler
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  *     Interrupt occures on the falling and/or rising edge of a hardware
@@ -560,8 +576,7 @@ EXPORT_SYMBOL_GPL(handle_fasteoi_irq);
  *     the handler was running. If all pending interrupts are handled, the
  *     loop is left.
  */
-void
-handle_edge_irq(unsigned int irq, struct irq_desc *desc)
+void handle_edge_irq(struct irq_desc *desc)
 {
        raw_spin_lock(&desc->lock);
 
@@ -618,13 +633,12 @@ EXPORT_SYMBOL(handle_edge_irq);
 #ifdef CONFIG_IRQ_EDGE_EOI_HANDLER
 /**
  *     handle_edge_eoi_irq - edge eoi type IRQ handler
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  * Similar as the above handle_edge_irq, but using eoi and w/o the
  * mask/unmask logic.
  */
-void handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc)
+void handle_edge_eoi_irq(struct irq_desc *desc)
 {
        struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -665,13 +679,11 @@ out_eoi:
 
 /**
  *     handle_percpu_irq - Per CPU local irq handler
- *     @irq:   the interrupt number
  *     @desc:  the interrupt description structure for this irq
  *
  *     Per CPU interrupts on SMP machines without locking requirements
  */
-void
-handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
+void handle_percpu_irq(struct irq_desc *desc)
 {
        struct irq_chip *chip = irq_desc_get_chip(desc);
 
@@ -680,7 +692,7 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
        if (chip->irq_ack)
                chip->irq_ack(&desc->irq_data);
 
-       handle_irq_event_percpu(desc, desc->action);
+       handle_irq_event_percpu(desc);
 
        if (chip->irq_eoi)
                chip->irq_eoi(&desc->irq_data);
@@ -688,7 +700,6 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
 
 /**
  * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids
- * @irq:       the interrupt number
  * @desc:      the interrupt description structure for this irq
  *
  * Per CPU interrupts on SMP machines without locking requirements. Same as
@@ -698,11 +709,12 @@ handle_percpu_irq(unsigned int irq, struct irq_desc *desc)
  * contain the real device id for the cpu on which this handler is
  * called
  */
-void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc)
+void handle_percpu_devid_irq(struct irq_desc *desc)
 {
        struct irq_chip *chip = irq_desc_get_chip(desc);
        struct irqaction *action = desc->action;
        void *dev_id = raw_cpu_ptr(action->percpu_dev_id);
+       unsigned int irq = irq_desc_get_irq(desc);
        irqreturn_t res;
 
        kstat_incr_irqs_this_cpu(desc);
@@ -757,6 +769,8 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
                if (desc->irq_data.chip != &no_irq_chip)
                        mask_ack_irq(desc);
                irq_state_set_disabled(desc);
+               if (is_chained)
+                       desc->action = NULL;
                desc->depth = 1;
        }
        desc->handle_irq = handle;
@@ -766,6 +780,7 @@ __irq_do_set_handler(struct irq_desc *desc, irq_flow_handler_t handle,
                irq_settings_set_noprobe(desc);
                irq_settings_set_norequest(desc);
                irq_settings_set_nothread(desc);
+               desc->action = &chained_action;
                irq_startup(desc, true);
        }
 }
@@ -796,7 +811,7 @@ irq_set_chained_handler_and_data(unsigned int irq, irq_flow_handler_t handle,
                return;
 
        __irq_do_set_handler(desc, handle, 1, NULL);
-       desc->irq_data.handler_data = data;
+       desc->irq_common_data.handler_data = data;
 
        irq_put_desc_busunlock(desc, flags);
 }