[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1449580830-23652-10-git-send-email-qais.yousef@imgtec.com>
Date: Tue, 8 Dec 2015 13:20:20 +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>,
<lisa.parratt@...tec.com>, Qais Yousef <qais.yousef@...tec.com>
Subject: [PATCH v4 09/19] genirq: Add a new function to get IPI reverse mapping
When dealing with coprocessors we need to find out the actual hwirqs values to
pass on to the firmware so that it knows what it needs to use to received and
send IPIs from and to us.
Signed-off-by: Qais Yousef <qais.yousef@...tec.com>
---
include/linux/irq.h | 2 ++
kernel/irq/ipi.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 7f6dd4eec207..1808ee4d42ec 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -981,4 +981,6 @@ int irq_unmap_ipi(struct ipi_mapping *map, unsigned int cpu);
irq_hw_number_t irq_ipi_mapping_get_hwirq(struct ipi_mapping *map,
unsigned int cpu);
+irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu);
+
#endif /* _LINUX_IRQ_H */
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c
index f98a190b2620..a389d7e6d593 100644
--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -233,3 +233,40 @@ void irq_destroy_ipi(unsigned int irq)
irq_domain_free_irqs(irq, nr_irqs);
}
+
+/**
+ * ipi_get_hwirq - get the hwirq associated with an IPI to a cpu
+ * @irq: linux irq number
+ * @cpu: the cpu to find the revmap for
+ *
+ * When dealing with coprocessors IPI, we need to inform it of the hwirq it
+ * needs to use to receive and send IPIs. This function provides the revmap
+ * to get this info to pass on to coprocessor firmware.
+ *
+ * Returns hwirq value on success and INVALID_HWIRQ on failure.
+ */
+irq_hw_number_t ipi_get_hwirq(unsigned int irq, unsigned int cpu)
+{
+ struct irq_data *data = irq_get_irq_data(irq);
+ struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
+ irq_hw_number_t hwirq;
+
+ if (!data || !ipimask)
+ return INVALID_HWIRQ;
+
+ if (cpu > nr_cpu_ids)
+ return INVALID_HWIRQ;
+
+ if (!cpumask_test_cpu(cpu, ipimask))
+ return INVALID_HWIRQ;
+
+ if (irq_domain_is_ipi_per_cpu(data->domain)) {
+ data = irq_get_irq_data(irq + cpu - data->common->ipi_offset);
+ hwirq = data ? irqd_to_hwirq(data) : INVALID_HWIRQ;
+ } else {
+ hwirq = irqd_to_hwirq(data) + cpu - data->common->ipi_offset;
+ }
+
+ return hwirq;
+}
+EXPORT_SYMBOL_GPL(ipi_get_hwirq);
--
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