From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753067AbbJMNbs (ORCPT ); Tue, 13 Oct 2015 09:31:48 -0400 Received: from www.linutronix.de ([62.245.132.108]:50000 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752772AbbJMNbq (ORCPT ); Tue, 13 Oct 2015 09:31:46 -0400 Date: Tue, 13 Oct 2015 15:31:09 +0200 (CEST) From: Thomas Gleixner To: Qais Yousef cc: linux-kernel@vger.kernel.org, jason@lakedaemon.net, marc.zyngier@arm.com, jiang.liu@linux.intel.com, ralf@linux-mips.org, linux-mips@linux-mips.org Subject: Re: [RFC v2 PATCH 06/14] irq: add struct ipi_mapping and its helper functions In-Reply-To: <1444731382-19313-7-git-send-email-qais.yousef@imgtec.com> Message-ID: References: <1444731382-19313-1-git-send-email-qais.yousef@imgtec.com> <1444731382-19313-7-git-send-email-qais.yousef@imgtec.com> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Oct 2015, Qais Yousef wrote: > struct ipi_mapping will provide a mechanism for irqdomain/architure > code to fill out the mapping for the generic code later to implement > generic IPI reserve and send functions. > > Signed-off-by: Qais Yousef > --- > include/linux/irq.h | 21 +++++++++++++++++++ > kernel/irq/manage.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 80 insertions(+) > > diff --git a/include/linux/irq.h b/include/linux/irq.h > index b000b217ea24..c3d0f26c3eff 100644 > --- a/include/linux/irq.h > +++ b/include/linux/irq.h > @@ -964,4 +964,25 @@ static inline u32 irq_reg_readl(struct irq_chip_generic *gc, > return readl(gc->reg_base + reg_offset); > } > > +#define INVALID_HWIRQ -1 > + > +/** > + * struct ipi_mapping - IPI mapping information object > + * @nr_hwirqs: number of hwirqs mapped > + * @nr_cpus: number of cpus the controller can talk to > + * @cpumap: per cpu hwirq mapping table > + */ > +struct ipi_mapping { > + unsigned int nr_hwirqs; > + unsigned int nr_cpus; > + unsigned int *cpumap; > +}; Again, you can avoid seperate allocations and pointer indirections by s/*cpumap/cpumap[]/ > +struct ipi_mapping *irq_alloc_ipi_mapping(unsigned int nr_cpus) > +{ > + struct ipi_mapping *map; > + int i; > + > + map = kzalloc(sizeof(struct ipi_mapping), GFP_KERNEL); > + if (!map) > + return NULL; > + > + map->nr_cpus = nr_cpus; > + > + map->cpumap = kmalloc(sizeof(irq_hw_number_t) * nr_cpus, GFP_KERNEL); > + if (!map->cpumap) { > + kfree(map); > + return NULL; > + } > + for (i = 0; i < nr_cpus; i++) > + map->cpumap[i] = INVALID_HWIRQ; memset please > + > + return map; > +} > + > +void irq_free_ipi_mapping(struct ipi_mapping *map) > +{ > + kfree(map->cpumap); > + kfree(map); > +} > + > +int irq_map_ipi(struct ipi_mapping *map, > + unsigned int cpu, irq_hw_number_t hwirq) > +{ > + if (cpu >= map->nr_cpus) > + return -EINVAL; > + > + map->cpumap[cpu] = hwirq; > + map->nr_hwirqs++; > + > + return 0; > +} > + > +int irq_unmap_ipi(struct ipi_mapping *map, > + unsigned int cpu, irq_hw_number_t *hwirq) > +{ > + if (cpu >= map->nr_cpus) > + return -EINVAL; > + > + if (map->cpumap[cpu] == INVALID_HWIRQ) > + return -EINVAL; > + > + if (hwirq) > + *hwirq = map->cpumap[cpu]; Why do we store hwirq in unmap? All these new functions lack kerneldoc comments. Thanks, tglx