From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752925AbbJMKQ7 (ORCPT ); Tue, 13 Oct 2015 06:16:59 -0400 Received: from mailapp01.imgtec.com ([195.59.15.196]:12609 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbbJMKQz (ORCPT ); Tue, 13 Oct 2015 06:16:55 -0400 From: Qais Yousef To: CC: , , , , , , Qais Yousef Subject: [RFC v2 PATCH 08/14] irq: implement irq_send_ipi Date: Tue, 13 Oct 2015 11:16:16 +0100 Message-ID: <1444731382-19313-9-git-send-email-qais.yousef@imgtec.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1444731382-19313-1-git-send-email-qais.yousef@imgtec.com> References: <1444731382-19313-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 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 --- include/linux/irq.h | 3 +++ kernel/irq/manage.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index c3d0f26c3eff..32c740ac95b4 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -985,4 +985,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 9a9bc0822c8f..f2425116a243 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c @@ -1983,3 +1983,47 @@ int irq_unmap_ipi(struct ipi_mapping *map, return 0; } + +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; + + /* + * 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 (!dest->global) { + if (!bitmap_subset(dest->cpumask, data->ipi_mask.cpumask, + dest->nbits)) + 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 0 on success and errno otherwise.. + */ +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(irq_send_ipi); -- 2.1.0