From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760630AbcBYKD1 (ORCPT ); Thu, 25 Feb 2016 05:03:27 -0500 Received: from torg.zytor.com ([198.137.202.12]:34648 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759853AbcBYKDX (ORCPT ); Thu, 25 Feb 2016 05:03:23 -0500 Date: Thu, 25 Feb 2016 02:02:57 -0800 From: tip-bot for Qais Yousef Message-ID: Cc: lisa.parratt@imgtec.com, qsyousef@gmail.com, mingo@kernel.org, tglx@linutronix.de, linux-mips@linux-mips.org, jason@lakedaemon.net, linux-kernel@vger.kernel.org, hpa@zytor.com, marc.zyngier@arm.com, jiang.liu@linux.intel.com, qais.yousef@imgtec.com, ralf@linux-mips.org Reply-To: lisa.parratt@imgtec.com, qsyousef@gmail.com, mingo@kernel.org, tglx@linutronix.de, jason@lakedaemon.net, linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, hpa@zytor.com, marc.zyngier@arm.com, jiang.liu@linux.intel.com, qais.yousef@imgtec.com, ralf@linux-mips.org In-Reply-To: <1449580830-23652-10-git-send-email-qais.yousef@imgtec.com> References: <1449580830-23652-10-git-send-email-qais.yousef@imgtec.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:irq/core] genirq: Add a new function to get IPI reverse mapping Git-Commit-ID: f9bce791ae2a1a10a965b30427f5507c1a77669f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f9bce791ae2a1a10a965b30427f5507c1a77669f Gitweb: http://git.kernel.org/tip/f9bce791ae2a1a10a965b30427f5507c1a77669f Author: Qais Yousef AuthorDate: Tue, 8 Dec 2015 13:20:20 +0000 Committer: Thomas Gleixner CommitDate: Thu, 25 Feb 2016 10:56:56 +0100 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 receive IPIs from and send IPIs to Linux cpus. [ tglx: Fixed the single hwirq IPI case. The hardware irq number does not change due to the cpu number ] Signed-off-by: Qais Yousef Cc: Cc: Cc: Cc: Cc: Cc: Cc: Qais Yousef Link: http://lkml.kernel.org/r/1449580830-23652-10-git-send-email-qais.yousef@imgtec.com Signed-off-by: Thomas Gleixner --- include/linux/irq.h | 1 + kernel/irq/ipi.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 95f4f66..10273dc 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -942,5 +942,6 @@ static inline u32 irq_reg_readl(struct irq_chip_generic *gc, /* Contrary to Linux irqs, for hardware irqs the irq number 0 is valid */ #define INVALID_HWIRQ (~0UL) +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 340af27..6f34f29 100644 --- a/kernel/irq/ipi.c +++ b/kernel/irq/ipi.c @@ -135,3 +135,37 @@ 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 target cpu + * + * When dealing with coprocessors IPI, we need to inform the coprocessor of + * the hwirq it needs to use to receive and send IPIs. + * + * 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; + + if (!data || !ipimask || cpu > nr_cpu_ids) + return INVALID_HWIRQ; + + if (!cpumask_test_cpu(cpu, ipimask)) + return INVALID_HWIRQ; + + /* + * Get the real hardware irq number if the underlying implementation + * uses a seperate irq per cpu. If the underlying implementation uses + * a single hardware irq for all cpus then the IPI send mechanism + * needs to take care of this. + */ + if (irq_domain_is_ipi_per_cpu(data->domain)) + data = irq_get_irq_data(irq + cpu - data->common->ipi_offset); + + return data ? irqd_to_hwirq(data) : INVALID_HWIRQ; +} +EXPORT_SYMBOL_GPL(ipi_get_hwirq);