From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753766AbbKCLNk (ORCPT ); Tue, 3 Nov 2015 06:13:40 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:23692 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753541AbbKCLNh (ORCPT ); Tue, 3 Nov 2015 06:13:37 -0500 From: Qais Yousef To: CC: , , , , , , Qais Yousef Subject: [PATCH 04/14] genirq: Add new struct ipi_mask and helper functions Date: Tue, 3 Nov 2015 11:12:51 +0000 Message-ID: <1446549181-31788-5-git-send-email-qais.yousef@imgtec.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446549181-31788-1-git-send-email-qais.yousef@imgtec.com> References: <1446549181-31788-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 cpumask is limited to NR_CPUS. Introduce ipi_mask which allows us to address cpu range that is higher than NR_CPUS which is required for drivers to send IPIs for coprocessor that are outside Linux CPU range. Signed-off-by: Qais Yousef --- include/linux/irq.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 3c1c96786248..77ed4c53ef64 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -128,6 +129,25 @@ struct msi_desc; struct irq_domain; /** + * struct ipi_mask - IPI mask information + * @nbits: number of bits in cpumask + * @global: whether the mask is SMP IPI ie: subset of cpu_possible_mask or not + * @cpumask: cpumask to be used when the ipi_mask is global + * @cpu_bitmap: the cpu bitmap to use when the ipi_mask is not global + * + * ipi_mask is similar to cpumask, but it provides nbits that's configurable + * rather than fixed to NR_CPUS. + */ +struct ipi_mask { + unsigned int nbits; + bool global; + union { + struct cpumask cpumask; + unsigned long cpu_bitmap[0]; + }; +}; + +/** * struct irq_common_data - per irq data shared by all irqchips * @state_use_accessors: status information for irq chip functions. * Use accessor functions to deal with it @@ -934,4 +954,52 @@ static inline u32 irq_reg_readl(struct irq_chip_generic *gc, return readl(gc->reg_base + reg_offset); } +static inline const unsigned long *ipi_mask_bits(const struct ipi_mask *ipimask) +{ + if (ipimask->global) + return cpumask_bits(&ipimask->cpumask); + else + return ipimask->cpu_bitmap; +} + +static inline unsigned int ipi_mask_weight(const struct ipi_mask *ipimask) +{ + if (ipimask->global) + return cpumask_weight(&ipimask->cpumask); + else + return bitmap_weight(ipimask->cpu_bitmap, ipimask->nbits); +} + +static inline void ipi_mask_copy(struct ipi_mask *dst, + const struct ipi_mask *src) +{ + dst->nbits = src->nbits; + dst->global = src->global; + + if (src->global) + return cpumask_copy(&dst->cpumask, &src->cpumask); + else + return bitmap_copy(dst->cpu_bitmap, + src->cpu_bitmap, src->nbits); +} + +static inline struct ipi_mask *ipi_mask_alloc(unsigned int nbits) +{ + size_t size = sizeof(struct ipi_mask) + BITS_TO_LONGS(nbits); + return kzalloc(size, GFP_KERNEL); +} + +static inline void ipi_mask_free(struct ipi_mask *ipimask) +{ + kfree(ipimask); +} + +static inline void ipi_mask_set_cpumask(struct ipi_mask *ipimask, + const struct cpumask *cpumask) +{ + ipimask->nbits = NR_CPUS; + ipimask->global = true; + cpumask_copy(&ipimask->cpumask, cpumask); +} + #endif /* _LINUX_IRQ_H */ -- 2.1.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailapp01.imgtec.com ([195.59.15.196]:34095 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S27012397AbbKCLNlZtlb1 (ORCPT ); Tue, 3 Nov 2015 12:13:41 +0100 From: Qais Yousef Subject: [PATCH 04/14] genirq: Add new struct ipi_mask and helper functions Date: Tue, 3 Nov 2015 11:12:51 +0000 Message-ID: <1446549181-31788-5-git-send-email-qais.yousef@imgtec.com> In-Reply-To: <1446549181-31788-1-git-send-email-qais.yousef@imgtec.com> References: <1446549181-31788-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: <20151103111251.snCzsu0kDm8pFyE9HFYOHdQrG0o9z5vUWaMJrOr_31Q@z> cpumask is limited to NR_CPUS. Introduce ipi_mask which allows us to address cpu range that is higher than NR_CPUS which is required for drivers to send IPIs for coprocessor that are outside Linux CPU range. Signed-off-by: Qais Yousef --- include/linux/irq.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/linux/irq.h b/include/linux/irq.h index 3c1c96786248..77ed4c53ef64 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -128,6 +129,25 @@ struct msi_desc; struct irq_domain; /** + * struct ipi_mask - IPI mask information + * @nbits: number of bits in cpumask + * @global: whether the mask is SMP IPI ie: subset of cpu_possible_mask or not + * @cpumask: cpumask to be used when the ipi_mask is global + * @cpu_bitmap: the cpu bitmap to use when the ipi_mask is not global + * + * ipi_mask is similar to cpumask, but it provides nbits that's configurable + * rather than fixed to NR_CPUS. + */ +struct ipi_mask { + unsigned int nbits; + bool global; + union { + struct cpumask cpumask; + unsigned long cpu_bitmap[0]; + }; +}; + +/** * struct irq_common_data - per irq data shared by all irqchips * @state_use_accessors: status information for irq chip functions. * Use accessor functions to deal with it @@ -934,4 +954,52 @@ static inline u32 irq_reg_readl(struct irq_chip_generic *gc, return readl(gc->reg_base + reg_offset); } +static inline const unsigned long *ipi_mask_bits(const struct ipi_mask *ipimask) +{ + if (ipimask->global) + return cpumask_bits(&ipimask->cpumask); + else + return ipimask->cpu_bitmap; +} + +static inline unsigned int ipi_mask_weight(const struct ipi_mask *ipimask) +{ + if (ipimask->global) + return cpumask_weight(&ipimask->cpumask); + else + return bitmap_weight(ipimask->cpu_bitmap, ipimask->nbits); +} + +static inline void ipi_mask_copy(struct ipi_mask *dst, + const struct ipi_mask *src) +{ + dst->nbits = src->nbits; + dst->global = src->global; + + if (src->global) + return cpumask_copy(&dst->cpumask, &src->cpumask); + else + return bitmap_copy(dst->cpu_bitmap, + src->cpu_bitmap, src->nbits); +} + +static inline struct ipi_mask *ipi_mask_alloc(unsigned int nbits) +{ + size_t size = sizeof(struct ipi_mask) + BITS_TO_LONGS(nbits); + return kzalloc(size, GFP_KERNEL); +} + +static inline void ipi_mask_free(struct ipi_mask *ipimask) +{ + kfree(ipimask); +} + +static inline void ipi_mask_set_cpumask(struct ipi_mask *ipimask, + const struct cpumask *cpumask) +{ + ipimask->nbits = NR_CPUS; + ipimask->global = true; + cpumask_copy(&ipimask->cpumask, cpumask); +} + #endif /* _LINUX_IRQ_H */ -- 2.1.0