genirq: Introduce irq_chip.irq_compose_msi_msg() to support stacked irqchip
authorJiang Liu <jiang.liu@linux.intel.com>
Thu, 6 Nov 2014 14:20:17 +0000 (22:20 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Sun, 23 Nov 2014 12:01:46 +0000 (13:01 +0100)
Add callback irq_compose_msi_msg to struct irq_chip, which will be used
to support stacked irqchip.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Yingjoe Chen <yingjoe.chen@mediatek.com>
Cc: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/linux/irq.h
kernel/irq/chip.c

index fad4bf6..d58e589 100644 (file)
@@ -29,6 +29,7 @@ struct seq_file;
 struct module;
 struct irq_desc;
 struct irq_data;
+struct msi_msg;
 typedef        void (*irq_flow_handler_t)(unsigned int irq,
                                            struct irq_desc *desc);
 typedef        void (*irq_preflow_handler_t)(struct irq_data *data);
@@ -320,6 +321,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
  *                             any other callback related to this irq
  * @irq_release_resources:     optional to release resources acquired with
  *                             irq_request_resources
+ * @irq_compose_msi_msg:       optional to compose message content for MSI
  * @flags:             chip specific flags
  */
 struct irq_chip {
@@ -356,6 +358,8 @@ struct irq_chip {
        int             (*irq_request_resources)(struct irq_data *data);
        void            (*irq_release_resources)(struct irq_data *data);
 
+       void            (*irq_compose_msi_msg)(struct irq_data *data, struct msi_msg *msg);
+
        unsigned long   flags;
 };
 
@@ -443,6 +447,7 @@ extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc *desc);
 extern void handle_bad_irq(unsigned int irq, struct irq_desc *desc);
 extern void handle_nested_irq(unsigned int irq);
 
+extern int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg);
 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
 extern void irq_chip_ack_parent(struct irq_data *data);
 extern int irq_chip_retrigger_hierarchy(struct irq_data *data);
index 47f4c64..63c16d1 100644 (file)
@@ -926,3 +926,29 @@ int irq_chip_retrigger_hierarchy(struct irq_data *data)
        return -ENOSYS;
 }
 #endif
+
+/**
+ * irq_chip_compose_msi_msg - Componse msi message for a irq chip
+ * @data:      Pointer to interrupt specific data
+ * @msg:       Pointer to the MSI message
+ *
+ * For hierarchical domains we find the first chip in the hierarchy
+ * which implements the irq_compose_msi_msg callback. For non
+ * hierarchical we use the top level chip.
+ */
+int irq_chip_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
+{
+       struct irq_data *pos = NULL;
+
+#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
+       for (; data; data = data->parent_data)
+#endif
+               if (data->chip && data->chip->irq_compose_msi_msg)
+                       pos = data;
+       if (!pos)
+               return -ENOSYS;
+
+       pos->chip->irq_compose_msi_msg(pos, msg);
+
+       return 0;
+}