From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753424AbbKYMIG (ORCPT ); Wed, 25 Nov 2015 07:08:06 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:24922 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753388AbbKYMIC (ORCPT ); Wed, 25 Nov 2015 07:08:02 -0500 From: Qais Yousef To: CC: , , , , , , Qais Yousef Subject: [PATCH v2 09/19] genirq: Add a new function to get IPI reverse mapping Date: Wed, 25 Nov 2015 12:06:47 +0000 Message-ID: <1448453217-3874-10-git-send-email-qais.yousef@imgtec.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1448453217-3874-1-git-send-email-qais.yousef@imgtec.com> References: <1448453217-3874-1-git-send-email-qais.yousef@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.168.154.94] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 2fb5d255313e..9a5d1e11a08f 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -1070,4 +1070,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 f2dc8c73965c..d6faa0e768b8 100644 --- a/kernel/irq/ipi.c +++ b/kernel/irq/ipi.c @@ -247,3 +247,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 ipi_mask *ipimask = data ? irq_data_get_ipi_mask(data) : NULL; + irq_hw_number_t hwirq; + + if (!data || !ipimask) + return INVALID_HWIRQ; + + if (cpu > ipimask->nbits) + return INVALID_HWIRQ; + + if (!test_bit(cpu, ipimask->cpu_bitmap)) + return INVALID_HWIRQ; + + if (irq_domain_is_ipi_per_cpu(data->domain)) { + data = irq_get_irq_data(irq + cpu - ipimask->offset); + hwirq = data ? irqd_to_hwirq(data) : INVALID_HWIRQ; + } else { + hwirq = irqd_to_hwirq(data) + cpu - ipimask->offset; + } + + return hwirq; +} +EXPORT_SYMBOL_GPL(ipi_get_hwirq); -- 2.1.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:8917 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012760AbbKYMIGicfgf (ORCPT ); Wed, 25 Nov 2015 13:08:06 +0100 From: Qais Yousef Subject: [PATCH v2 09/19] genirq: Add a new function to get IPI reverse mapping Date: Wed, 25 Nov 2015 12:06:47 +0000 Message-ID: <1448453217-3874-10-git-send-email-qais.yousef@imgtec.com> In-Reply-To: <1448453217-3874-1-git-send-email-qais.yousef@imgtec.com> References: <1448453217-3874-1-git-send-email-qais.yousef@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain Return-Path: Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-subscribe: List-owner: List-post: List-archive: To: linux-kernel@vger.kernel.org Cc: tglx@linutronix.de, jason@lakedaemon.net, marc.zyngier@arm.com, jiang.liu@linux.intel.com, ralf@linux-mips.org, linux-mips@linux-mips.org, Qais Yousef Message-ID: <20151125120647.ypZE49uY1xtNCtUDn08et2imUlrBg6j98sbqbh_qZ3Q@z> 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 --- 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 2fb5d255313e..9a5d1e11a08f 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -1070,4 +1070,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 f2dc8c73965c..d6faa0e768b8 100644 --- a/kernel/irq/ipi.c +++ b/kernel/irq/ipi.c @@ -247,3 +247,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 ipi_mask *ipimask = data ? irq_data_get_ipi_mask(data) : NULL; + irq_hw_number_t hwirq; + + if (!data || !ipimask) + return INVALID_HWIRQ; + + if (cpu > ipimask->nbits) + return INVALID_HWIRQ; + + if (!test_bit(cpu, ipimask->cpu_bitmap)) + return INVALID_HWIRQ; + + if (irq_domain_is_ipi_per_cpu(data->domain)) { + data = irq_get_irq_data(irq + cpu - ipimask->offset); + hwirq = data ? irqd_to_hwirq(data) : INVALID_HWIRQ; + } else { + hwirq = irqd_to_hwirq(data) + cpu - ipimask->offset; + } + + return hwirq; +} +EXPORT_SYMBOL_GPL(ipi_get_hwirq); -- 2.1.0