[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1446549181-31788-10-git-send-email-qais.yousef@imgtec.com>
Date: Tue, 3 Nov 2015 11:12:56 +0000
From: Qais Yousef <qais.yousef@...tec.com>
To: <linux-kernel@...r.kernel.org>
CC: <tglx@...utronix.de>, <jason@...edaemon.net>,
<marc.zyngier@....com>, <jiang.liu@...ux.intel.com>,
<ralf@...ux-mips.org>, <linux-mips@...ux-mips.org>,
Qais Yousef <qais.yousef@...tec.com>
Subject: [PATCH 09/14] genirq: Implement irq_send_ipi() to be used by drivers
There are 2 variants. __irq_desc_send_ipi() is meant to be used by arch code to
save the desc lookup when doing SMP IPIs.
irq_send_ipi() is meant for drivers that want to send IPIs to coprocessors they
interact with.
Signed-off-by: Qais Yousef <qais.yousef@...tec.com>
---
include/linux/irq.h | 3 +++
kernel/irq/manage.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 69 insertions(+), 1 deletion(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 3b2f448b7ac3..680bee078879 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -1032,4 +1032,7 @@ int irq_map_ipi(struct ipi_mapping *map,
int irq_unmap_ipi(struct ipi_mapping *map,
unsigned int cpu, irq_hw_number_t *hwirq);
+int __irq_desc_send_ipi(struct irq_desc *desc, const struct ipi_mask *dest);
+int irq_send_ipi(unsigned int virq, const struct ipi_mask *dest);
+
#endif /* _LINUX_IRQ_H */
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 67a71667a359..4bdf6df95b45 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -2013,7 +2013,6 @@ EXPORT_SYMBOL_GPL(irq_set_irqchip_state);
struct ipi_mapping *irq_alloc_ipi_mapping(unsigned int nr_cpus)
{
struct ipi_mapping *map;
- int i;
map = kzalloc(sizeof(struct ipi_mapping) +
BITS_TO_LONGS(nr_cpus), GFP_KERNEL);
@@ -2087,3 +2086,69 @@ int irq_unmap_ipi(struct ipi_mapping *map,
return 0;
}
+
+/**
+ * __irq_desc_send_ipi - send an IPI to target CPU(s)
+ * @irq_desc: pointer to irq_desc of the IRQ
+ * @dest: dest CPU(s), must be the same or a subset of the mask passed to
+ * irq_reserve_ipi()
+ *
+ * Sends an IPI to all cpus in dest mask.
+ * This function is meant to be used from arch code to save the need to do
+ * desc lookup that happens in the generic irq_send_ipi().
+ *
+ * Returns zero on success and negative error number on failure.
+ */
+int __irq_desc_send_ipi(struct irq_desc *desc, const struct ipi_mask *dest)
+{
+ struct irq_data *data = irq_desc_get_irq_data(desc);
+ struct irq_chip *chip = irq_data_get_irq_chip(data);
+
+ if (!chip || !chip->irq_send_ipi)
+ return -EINVAL;
+
+ if (dest->nbits > data->common->ipi_mask->nbits)
+ return -EINVAL;
+
+ /*
+ * Do not validate the mask for IPIs marked global. These are
+ * regular IPIs so we can avoid the operation as their target
+ * mask is the cpu_possible_mask.
+ */
+ if (!data->common->ipi_mask->global) {
+ if (dest->global)
+ return -EINVAL;
+
+ if (!bitmap_subset(dest->cpu_bitmap,
+ data->common->ipi_mask->cpu_bitmap,
+ dest->nbits))
+ return -EINVAL;
+ } else {
+ if (!dest->global)
+ return -EINVAL;
+ }
+
+ chip->irq_send_ipi(data, dest);
+ return 0;
+}
+
+/**
+ * irq_send_ipi - send an IPI to target CPU(s)
+ * @irq: linux irq number from irq_reserve_ipi()
+ * @dest: dest CPU(s), must be the same or a subset of the mask passed to
+ * irq_reserve_ipi()
+ *
+ * Sends an IPI to all cpus in dest mask.
+ *
+ * Returns zero on success and negative error number on failure.
+ */
+int irq_send_ipi(unsigned int virq, const struct ipi_mask *dest)
+{
+ struct irq_desc *desc = irq_to_desc(virq);
+
+ if (!desc)
+ return -EINVAL;
+
+ return __irq_desc_send_ipi(desc, dest);
+}
+EXPORT_SYMBOL_GPL(irq_send_ipi);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists