linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
To: Jiang Liu <jiang.liu@linux.intel.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Yinghai Lu <yinghai@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Grant Likely <grant.likely@linaro.org>,
	Marc Zyngier <marc.zyngier@arm.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Tony Luck <tony.luck@intel.com>, Joerg Roedel <joro@8bytes.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	x86@kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [RFC Part2 v1 01/21] irqdomain: Introduce new interfaces to support hierarchy irqdomains
Date: Wed, 24 Sep 2014 15:55:29 +0900	[thread overview]
Message-ID: <54226AE1.4000603@jp.fujitsu.com> (raw)
In-Reply-To: <1410444228-3134-2-git-send-email-jiang.liu@linux.intel.com>

(2014/09/11 23:03), Jiang Liu wrote:
> We plan to use hierarchy irqdomain to suppport CPU vector assignment,
> interrupt remapping controller, IO-APIC controller, MSI interrupt
> and hypertransport interrupt etc on x86 platforms. So extend irqdomain
> interfaces to support hierarchy irqdomain.
> 
> There are already many clients of current irqdomain interfaces.
> To minimize the changes, we choose to introduce new version 2 interfaces
> to support hierarchy instead of extending existing irqdomain interfaces.
> 
> According to Thomas's suggestion, the most important design decision is
> to build hierarchy struct irq_data to support hierarchy irqdomain, so
> hierarchy irqdomain related data could be saved in struct irq_data.
> With support of hierarchy irq_data, we could also support stacked
> irq_chips. This is most useful in case of set_affinity().
> 
> The new hierarchy irqdomain introduces following interfaces:
> 1) irq_domain_alloc_irqs()/irq_domain_free_irqs(): allocate/release IRQ
>     and related resources.
> 2) __irq_domain_alloc_irqs(): a special version to support legacy IRQs.
> 3) irq_domain_activate_irq()/irq_domain_deactivate_irq(): program
>     interrupt controllers to activate/deactivate interrupt.
> 
> There are also several help functions to ease irqdomain implemenations:
> 1) irq_domain_get_irq_data(): get irq_data associated with a specific
>     irqdomain.
> 2) irq_domain_set_hwirq_and_chip(): save irqdomain specific data into
>     irq_data.
> 3) irq_domain_alloc_irqs_parent()/irq_domain_free_irqs_parent(): invoke
>     parent irqdomain's alloc/free callbacks.
> 
> We also changed irq_startup()/irq_shutdown() to invoke
> irq_domain_activate_irq()/irq_domain_deactivate_irq() to program
> interrupt controller when start/stop interrupts.
> 
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
>   include/linux/irq.h       |    3 +
>   include/linux/irqdomain.h |   60 ++++++++
>   kernel/irq/Kconfig        |    3 +
>   kernel/irq/chip.c         |    3 +
>   kernel/irq/irqdomain.c    |  349 +++++++++++++++++++++++++++++++++++++++++++--
>   5 files changed, 404 insertions(+), 14 deletions(-)
> 
> diff --git a/include/linux/irq.h b/include/linux/irq.h
> index 62af59242ddc..4b74565690ce 100644
> --- a/include/linux/irq.h
> +++ b/include/linux/irq.h
> @@ -151,6 +151,9 @@ struct irq_data {
>   	unsigned int		state_use_accessors;
>   	struct irq_chip		*chip;
>   	struct irq_domain	*domain;
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +	struct irq_data		*parent_data;
> +#endif
>   	void			*handler_data;
>   	void			*chip_data;
>   	struct msi_desc		*msi_desc;
> diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
> index b0f9d16e48f6..a9ddc8534c63 100644
> --- a/include/linux/irqdomain.h
> +++ b/include/linux/irqdomain.h
> @@ -38,6 +38,7 @@
>   struct device_node;
>   struct irq_domain;
>   struct of_device_id;
> +struct irq_chip;
>   
>   /* Number of irqs reserved for a legacy isa controller */
>   #define NUM_ISA_INTERRUPTS	16
> @@ -64,6 +65,16 @@ struct irq_domain_ops {
>   	int (*xlate)(struct irq_domain *d, struct device_node *node,
>   		     const u32 *intspec, unsigned int intsize,
>   		     unsigned long *out_hwirq, unsigned int *out_type);
> +
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +	/* extended V2 interfaces to support hierarchy irqdomains */
> +	int (*alloc)(struct irq_domain *d, unsigned int virq,
> +		     unsigned int nr_irqs, void *arg);
> +	void (*free)(struct irq_domain *d, unsigned int virq,
> +		     unsigned int nr_irqs);
> +	int (*activate)(struct irq_domain *d, struct irq_data *irq_data);
> +	int (*deactivate)(struct irq_domain *d, struct irq_data *irq_data);
> +#endif
>   };
>   
>   extern struct irq_domain_ops irq_generic_chip_ops;
> @@ -101,6 +112,9 @@ struct irq_domain {
>   	/* Optional data */
>   	struct device_node *of_node;
>   	struct irq_domain_chip_generic *gc;
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +	struct irq_domain *parent;
> +#endif
>   
>   	/* reverse map data. The linear map gets appended to the irq_domain */
>   	irq_hw_number_t hwirq_max;
> @@ -220,8 +234,54 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
>   			const u32 *intspec, unsigned int intsize,
>   			irq_hw_number_t *out_hwirq, unsigned int *out_type);
>   
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +/* V2 interfaces to support hierarchy IRQ domains. */
> +extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
> +						unsigned int virq);
> +extern int irq_domain_set_hwirq_and_chip(struct irq_domain *domain,
> +					 unsigned int virq,
> +					 irq_hw_number_t hwirq,
> +					 struct irq_chip *chip,
> +					 void *chip_data);
> +extern void irq_domain_reset_irq_data(struct irq_data *irq_data);
> +extern int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
> +				   unsigned int nr_irqs, int node, void *arg,
> +				   bool realloc);
> +extern void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs);
> +extern int irq_domain_activate_irq(struct irq_data *irq_data);
> +extern int irq_domain_deactivate_irq(struct irq_data *irq_data);
> +
> +static inline int irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
> +				unsigned int nr_irqs, int node, void *arg)
> +{
> +	return __irq_domain_alloc_irqs(domain, irq_base, nr_irqs, node,
> +				       arg, false);
> +}
> +
> +static inline int irq_domain_alloc_irqs_parent(struct irq_domain *domain,
> +				int irq_base, unsigned int nr_irqs, void *arg)
> +{
> +	if (domain->parent && domain->parent->ops->alloc)
> +		return domain->parent->ops->alloc(domain->parent, irq_base,
> +						  nr_irqs, arg);
> +	return -ENOSYS;
> +}
> +
> +static inline void irq_domain_free_irqs_parent(struct irq_domain *domain,
> +					int irq_base, unsigned int nr_irqs)
> +{
> +	if (domain->parent && domain->parent->ops->free)
> +		domain->parent->ops->free(domain->parent, irq_base, nr_irqs);
> +}
> +#else	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
> +static inline int irq_domain_activate_irq(struct irq_data *data) { return 0; }
> +static inline int irq_domain_deactivate_irq(struct irq_data *data) { return 0; }
> +#endif	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
> +
>   #else /* CONFIG_IRQ_DOMAIN */
>   static inline void irq_dispose_mapping(unsigned int virq) { }
> +static inline int irq_domain_activate_irq(struct irq_data *data) { return 0; }
> +static inline int irq_domain_deactivate_irq(struct irq_data *data) { return 0; }
>   #endif /* !CONFIG_IRQ_DOMAIN */
>   
>   #endif /* _LINUX_IRQDOMAIN_H */
> diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
> index d269cecdfbf0..dc1f3d08892e 100644
> --- a/kernel/irq/Kconfig
> +++ b/kernel/irq/Kconfig
> @@ -55,6 +55,9 @@ config GENERIC_IRQ_CHIP
>   config IRQ_DOMAIN
>   	bool
>   
> +config IRQ_DOMAIN_HIERARCHY
> +	bool
> +
>   config IRQ_DOMAIN_DEBUG
>   	bool "Expose hardware/virtual IRQ mapping via debugfs"
>   	depends on IRQ_DOMAIN && DEBUG_FS
> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
> index 6223fab9a9d2..46bd5e2190c3 100644
> --- a/kernel/irq/chip.c
> +++ b/kernel/irq/chip.c
> @@ -15,6 +15,7 @@
>   #include <linux/module.h>
>   #include <linux/interrupt.h>
>   #include <linux/kernel_stat.h>
> +#include <linux/irqdomain.h>
>   
>   #include <trace/events/irq.h>
>   
> @@ -178,6 +179,7 @@ int irq_startup(struct irq_desc *desc, bool resend)
>   	irq_state_clr_disabled(desc);
>   	desc->depth = 0;
>   
> +	irq_domain_activate_irq(&desc->irq_data);
>   	if (desc->irq_data.chip->irq_startup) {
>   		ret = desc->irq_data.chip->irq_startup(&desc->irq_data);
>   		irq_state_clr_masked(desc);
> @@ -199,6 +201,7 @@ void irq_shutdown(struct irq_desc *desc)
>   		desc->irq_data.chip->irq_disable(&desc->irq_data);
>   	else
>   		desc->irq_data.chip->irq_mask(&desc->irq_data);
> +	irq_domain_deactivate_irq(&desc->irq_data);
>   	irq_state_set_masked(desc);
>   }
>   
> diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
> index 6534ff6ce02e..e285f3abc595 100644
> --- a/kernel/irq/irqdomain.c
> +++ b/kernel/irq/irqdomain.c
> @@ -23,6 +23,9 @@ static DEFINE_MUTEX(irq_domain_mutex);
>   static DEFINE_MUTEX(revmap_trees_mutex);
>   static struct irq_domain *irq_default_domain;
>   
> +static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
> +				  irq_hw_number_t hwirq, int node);
> +
>   /**
>    * __irq_domain_add() - Allocate a new irq_domain data structure
>    * @of_node: optional device-tree node of the interrupt controller
> @@ -30,7 +33,7 @@ static struct irq_domain *irq_default_domain;
>    * @hwirq_max: Maximum number of interrupts supported by controller
>    * @direct_max: Maximum value of direct maps; Use ~0 for no limit; 0 for no
>    *              direct mapping
> - * @ops: map/unmap domain callbacks
> + * @ops: domain callbacks
>    * @host_data: Controller private data pointer
>    *
>    * Allocates and initialize and irq_domain structure.
> @@ -109,7 +112,7 @@ EXPORT_SYMBOL_GPL(irq_domain_remove);
>    * @first_irq: first number of irq block assigned to the domain,
>    *	pass zero to assign irqs on-the-fly. If first_irq is non-zero, then
>    *	pre-map all of the irqs in the domain to virqs starting at first_irq.
> - * @ops: map/unmap domain callbacks
> + * @ops: domain callbacks
>    * @host_data: Controller private data pointer
>    *
>    * Allocates an irq_domain, and optionally if first_irq is positive then also
> @@ -174,10 +177,8 @@ struct irq_domain *irq_domain_add_legacy(struct device_node *of_node,
>   
>   	domain = __irq_domain_add(of_node, first_hwirq + size,
>   				  first_hwirq + size, 0, ops, host_data);
> -	if (!domain)
> -		return NULL;
> -
> -	irq_domain_associate_many(domain, first_irq, first_hwirq, size);
> +	if (domain)
> +		irq_domain_associate_many(domain, first_irq, first_hwirq, size);
>   
>   	return domain;
>   }
> @@ -388,7 +389,6 @@ EXPORT_SYMBOL_GPL(irq_create_direct_mapping);
>   unsigned int irq_create_mapping(struct irq_domain *domain,
>   				irq_hw_number_t hwirq)
>   {
> -	unsigned int hint;
>   	int virq;
>   
>   	pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
> @@ -410,12 +410,8 @@ unsigned int irq_create_mapping(struct irq_domain *domain,
>   	}
>   
>   	/* Allocate a virtual interrupt number */
> -	hint = hwirq % nr_irqs;
> -	if (hint == 0)
> -		hint++;
> -	virq = irq_alloc_desc_from(hint, of_node_to_nid(domain->of_node));
> -	if (virq <= 0)
> -		virq = irq_alloc_desc_from(1, of_node_to_nid(domain->of_node));
> +	virq = irq_domain_alloc_descs(-1, 1, hwirq,
> +				      of_node_to_nid(domain->of_node));
>   	if (virq <= 0) {
>   		pr_debug("-> virq allocation failed\n");
>   		return 0;
> @@ -490,7 +486,13 @@ unsigned int irq_create_of_mapping(struct of_phandle_args *irq_data)
>   	}
>   
>   	/* Create mapping */
> -	virq = irq_create_mapping(domain, hwirq);
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +	if (domain->ops->alloc)
> +		virq = irq_domain_alloc_irqs(domain, -1, 1, NUMA_NO_NODE,
> +					     irq_data);
> +	else
> +#endif
> +		virq = irq_create_mapping(domain, hwirq);
>   	if (!virq)
>   		return virq;
>   
> @@ -540,7 +542,11 @@ unsigned int irq_find_mapping(struct irq_domain *domain,
>   		return 0;
>   
>   	if (hwirq < domain->revmap_direct_max_irq) {
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +		data = irq_domain_get_irq_data(domain, hwirq);
> +#else
>   		data = irq_get_irq_data(hwirq);
> +#endif
>   		if (data && (data->domain == domain) && (data->hwirq == hwirq))
>   			return hwirq;
>   	}
> @@ -709,3 +715,318 @@ const struct irq_domain_ops irq_domain_simple_ops = {
>   	.xlate = irq_domain_xlate_onetwocell,
>   };
>   EXPORT_SYMBOL_GPL(irq_domain_simple_ops);
> +
> +static int irq_domain_alloc_descs(int virq, unsigned int nr_irqs,
> +				  irq_hw_number_t hwirq, int node)
> +{
> +	unsigned int hint;
> +
> +	if (virq >= 0) {
> +		virq = irq_alloc_descs(virq, virq, nr_irqs, node);
> +	} else {
> +		hint = hwirq % nr_irqs;
> +		if (hint == 0)
> +			hint++;
> +		virq = irq_alloc_descs_from(hint, nr_irqs, node);
> +		if (virq <= 0 && hint > 1)
> +			virq = irq_alloc_descs_from(1, nr_irqs, node);
> +	}
> +
> +	return virq;
> +}
> +
> +#ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
> +static void irq_domain_free_descs(unsigned int virq, unsigned int nr_irqs)
> +{
> +	unsigned int i;
> +
> +	for (i = 0; i < nr_irqs; i++)
> +		irq_free_desc(virq + i);
> +}
> +
> +static void irq_domain_insert_irq(int virq)
> +{
> +	struct irq_data *data;
> +
> +	for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
> +		struct irq_domain *domain = data->domain;
> +		irq_hw_number_t hwirq = data->hwirq;
> +
> +		if (hwirq < domain->revmap_size) {
> +			domain->linear_revmap[hwirq] = virq;
> +		} else {
> +			mutex_lock(&revmap_trees_mutex);
> +			radix_tree_insert(&domain->revmap_tree, hwirq, data);
> +			mutex_unlock(&revmap_trees_mutex);
> +		}
> +
> +		/* If not already assigned, give the domain the chip's name */
> +		if (!domain->name && data->chip)
> +			domain->name = data->chip->name;
> +	}
> +
> +	irq_clear_status_flags(virq, IRQ_NOREQUEST);
> +}
> +
> +static void irq_domain_remove_irq(int virq)
> +{
> +	struct irq_data *data;
> +
> +	irq_set_status_flags(virq, IRQ_NOREQUEST);
> +	irq_set_chip_and_handler(virq, NULL, NULL);
> +	synchronize_irq(virq);
> +	smp_mb();
> +
> +	for (data = irq_get_irq_data(virq); data; data = data->parent_data) {
> +		struct irq_domain *domain = data->domain;
> +		irq_hw_number_t hwirq = data->hwirq;
> +
> +		if (hwirq < domain->revmap_size) {
> +			domain->linear_revmap[hwirq] = 0;
> +		} else {
> +			mutex_lock(&revmap_trees_mutex);
> +			radix_tree_delete(&domain->revmap_tree, hwirq);
> +			mutex_unlock(&revmap_trees_mutex);
> +		}
> +	}
> +}
> +
> +static struct irq_data *irq_domain_insert_irq_data(struct irq_domain *domain,
> +						   struct irq_data *child)
> +{
> +	struct irq_data *irq_data;
> +
> +	irq_data = kzalloc_node(sizeof(*irq_data), GFP_KERNEL, child->node);
> +	if (irq_data) {
> +		child->parent_data = irq_data;
> +		irq_data->irq = child->irq;
> +		irq_data->node = child->node;
> +		irq_data->domain = domain;
> +	}
> +
> +	return irq_data;
> +}
> +
> +static void irq_domain_free_irq_data(unsigned int virq, unsigned int nr_irqs)
> +{
> +	int i;
> +	struct irq_data *irq_data, *tmp;
> +
> +	for (i = 0; i < nr_irqs; i++) {

> +		irq_data = irq_get_irq_data(virq + i);
> +		tmp = irq_data->parent_data;

Why don't you care NULL condition?

> +		irq_data->parent_data = NULL;
> +		irq_data->domain = NULL;
> +
> +		while (tmp) {
> +			irq_data = tmp;
> +			tmp = tmp->parent_data;
> +			kfree(irq_data);
> +		}
> +	}
> +}
> +
> +static int irq_domain_alloc_irq_data(struct irq_domain *domain,
> +				     unsigned int virq, unsigned int nr_irqs)
> +{
> +	int i;
> +	struct irq_data *irq_data;
> +	struct irq_domain *parent;
> +
> +	/* The outmost irq_data is embedded in struct irq_desc */
> +	for (i = 0; i < nr_irqs; i++) {


> +		irq_data = irq_get_irq_data(virq + i);
> +		irq_data->domain = domain;

ditto.

Thanks,
Yasuaki Ishimatsu

> +
> +		for (parent = domain->parent; parent; parent = parent->parent) {
> +			irq_data = irq_domain_insert_irq_data(parent, irq_data);
> +			if (!irq_data) {
> +				irq_domain_free_irq_data(virq, i + 1);
> +				return -ENOMEM;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +/**
> + * irq_domain_get_irq_data - Get irq_data assoicated with @virq and  @domain
> + * @domain: domain to match
> + * @virq: IRQ number to get irq_data
> + */
> +struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
> +					 unsigned int virq)
> +{
> +	struct irq_data *irq_data;
> +
> +	for (irq_data = irq_get_irq_data(virq); irq_data;
> +	     irq_data = irq_data->parent_data)
> +		if (irq_data->domain == domain)
> +			return irq_data;
> +
> +	return NULL;
> +}
> +
> +int irq_domain_set_hwirq_and_chip(struct irq_domain *domain, unsigned int virq,
> +				  irq_hw_number_t hwirq, struct irq_chip *chip,
> +				  void *chip_data)
> +{
> +	struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq);
> +
> +	if (!irq_data)
> +		return -ENOENT;
> +
> +	irq_data->hwirq = hwirq;
> +	irq_data->chip = chip;
> +	irq_data->chip_data = chip_data;
> +
> +	return 0;
> +}
> +
> +void irq_domain_reset_irq_data(struct irq_data *irq_data)
> +{
> +	irq_data->hwirq = 0;
> +	irq_data->chip = NULL;
> +	irq_data->chip_data = NULL;
> +}
> +
> +/**
> + * irq_domain_alloc_irqs - Allocate IRQs from domain
> + * @domain: domain to allocate from
> + * @irq_base: allocate specified IRQ nubmer if irq_base >= 0
> + * @nr_irqs: number of IRQs to allocate
> + * @node: NUMA node id for memory allocation
> + * @arg: domain specific argument
> + * @realloc: IRQ descriptors have already been allocated if true
> + *
> + * Allocate IRQ numbers and initialized all data structures to support
> + * hiearchy IRQ domains.
> + * Parameter @realloc is mainly to support legacy IRQs.
> + * Returns error code or allocated IRQ number
> + */
> +int __irq_domain_alloc_irqs(struct irq_domain *domain, int irq_base,
> +			    unsigned int nr_irqs, int node, void *arg,
> +			    bool realloc)
> +{
> +	int i, ret, virq;
> +
> +	if (domain == NULL) {
> +		domain = irq_default_domain;
> +		if (WARN(!domain, "domain is NULL; cannot allocate IRQ\n"))
> +			return -EINVAL;
> +	}
> +
> +	if (!domain->ops->alloc) {
> +		pr_debug("domain->ops->alloc() is NULL\n");
> +		return -ENOSYS;
> +	}
> +
> +	if (realloc && irq_base >= 0) {
> +		virq =  irq_base;
> +	} else {
> +		virq = irq_domain_alloc_descs(irq_base, nr_irqs, 0, node);
> +		if (virq < 0) {
> +			pr_debug("cannot allocate IRQ(base %d, count %d)\n",
> +				 irq_base, nr_irqs);
> +			return virq;
> +		}
> +	}
> +
> +	if (irq_domain_alloc_irq_data(domain, virq, nr_irqs)) {
> +		pr_debug("cannot allocate memory for IRQ%d\n", virq);
> +		ret = -ENOMEM;
> +		goto out_free_desc;
> +	}
> +
> +	mutex_lock(&irq_domain_mutex);
> +	ret = domain->ops->alloc(domain, virq, nr_irqs, arg);
> +	if (ret < 0) {
> +		mutex_unlock(&irq_domain_mutex);
> +		goto out_free_irq_data;
> +	}
> +	for (i = 0; i < nr_irqs; i++)
> +		irq_domain_insert_irq(virq + i);
> +	mutex_unlock(&irq_domain_mutex);
> +
> +	return virq;
> +
> +out_free_irq_data:
> +	irq_domain_free_irq_data(virq, nr_irqs);
> +out_free_desc:
> +	irq_domain_free_descs(virq, nr_irqs);
> +	return ret;
> +}
> +
> +/**
> + * irq_domain_free_irqs - Free IRQ number and assoicated data structures
> + * @virq: base IRQ number
> + * @nr_irqs: number of IRQs to free
> + */
> +void irq_domain_free_irqs(unsigned int virq, unsigned int nr_irqs)
> +{
> +	int i;
> +	struct irq_data *data = irq_get_irq_data(virq);
> +
> +	if (WARN(!data || !data->domain || !data->domain->ops->free,
> +		 "NULL pointer, cannot free irq\n"))
> +		return;
> +
> +	mutex_lock(&irq_domain_mutex);
> +	for (i = 0; i < nr_irqs; i++)
> +		irq_domain_remove_irq(virq + i);
> +	data->domain->ops->free(data->domain, virq, nr_irqs);
> +	mutex_unlock(&irq_domain_mutex);
> +
> +	irq_domain_free_irq_data(virq, nr_irqs);
> +	irq_domain_free_descs(virq, nr_irqs);
> +}
> +
> +/**
> + * irq_domain_activate_irq - Call domain_ops->activate recursively to activate
> + *			     interrupt
> + * @irq_data: out most irq_data associated with interrupt
> + *
> + * It calls domain_ops->activate to program interrupt controllers, so the
> + * interrupt could actually delivered.
> + */
> +int irq_domain_activate_irq(struct irq_data *irq_data)
> +{
> +	int ret = 0;
> +
> +	if (irq_data && irq_data->domain) {
> +		struct irq_domain *domain = irq_data->domain;
> +
> +		if (irq_data->parent_data)
> +			ret = irq_domain_activate_irq(irq_data->parent_data);
> +		if (ret == 0 && domain->ops->activate)
> +			ret = domain->ops->activate(domain, irq_data);
> +	}
> +
> +	return ret;
> +}
> +
> +/**
> + * irq_domain_deactivate_irq - Call domain_ops->deactivate recursively to
> + *			       deactivate interrupt
> + * @irq_data: out most irq_data associated with interrupt
> + *
> + * It calls domain_ops->deactivate to program interrupt controllers to disable
> + * interrupt delivery.
> + */
> +int irq_domain_deactivate_irq(struct irq_data *irq_data)
> +{
> +	int ret = 0;
> +
> +	if (irq_data && irq_data->domain) {
> +		struct irq_domain *domain = irq_data->domain;
> +
> +		if (domain->ops->deactivate)
> +			ret = domain->ops->deactivate(domain, irq_data);
> +		if (ret == 0 && irq_data->parent_data)
> +			ret = irq_domain_deactivate_irq(irq_data->parent_data);
> +	}
> +
> +	return ret;
> +}
> +#endif	/* CONFIG_IRQ_DOMAIN_HIERARCHY */
> 



  parent reply	other threads:[~2014-09-24  6:56 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-11 14:03 [RFC Part2 v1 00/21] Enable hierarchy irqdomian on x86 platforms Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 01/21] irqdomain: Introduce new interfaces to support hierarchy irqdomains Jiang Liu
2014-09-16 17:43   ` Thomas Gleixner
2014-09-18  7:28     ` Jiang Liu
2014-09-22  8:17     ` [Patch] " Jiang Liu
2014-09-22 17:30       ` Randy Dunlap
2014-09-24  5:26         ` Jiang Liu
2014-09-23  9:43       ` Joe.C
2014-09-24  5:55         ` Jiang Liu
2014-09-18  8:48   ` [RFC Part2 v1 01/21] " Joe.C
2014-09-18  8:58     ` Jiang Liu
2014-09-24  6:55   ` Yasuaki Ishimatsu [this message]
2014-09-24  7:23     ` Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 02/21] genirq: Introduce helper functions to support stacked irq_chip Jiang Liu
2014-09-16 17:45   ` Thomas Gleixner
2014-09-17  3:07     ` Jiang Liu
2014-09-17 20:58       ` Thomas Gleixner
2014-09-18  6:14         ` Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 03/21] x86, irq: Save destination CPU ID in irq_cfg Jiang Liu
2014-09-16 17:47   ` Thomas Gleixner
2014-09-17  2:24     ` Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 04/21] x86, irq: Use hierarchy irqdomain to manage CPU interrupt vectors Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 05/21] x86, hpet: Use new irqdomain interfaces to allocate/free IRQ Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 06/21] x86, MSI: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 07/21] x86, uv: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 08/21] x86, htirq: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 09/21] x86, dmar: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 10/21] x86: irq_remapping: Introduce new interfaces to support hierarchy irqdomain Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 11/21] iommu/vt-d: Change prototypes to prepare for enabling " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 12/21] iommu/vt-d: Enhance Intel IR driver to suppport " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 13/21] iommu/amd: Enhance AMD " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 14/21] x86, hpet: Enhance HPET IRQ to support " Jiang Liu
2014-09-16 18:31   ` Thomas Gleixner
2014-09-17  5:16     ` Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 15/21] x86, MSI: Use hierarchy irqdomain to manage MSI interrupts Jiang Liu
2014-09-11 14:17   ` Ni, Xun
2014-09-11 14:29     ` Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 16/21] x86, irq: Directly call native_compose_msi_msg() for DMAR IRQ Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 17/21] x86, htirq: Use hierarchy irqdomain to manage Hypertransport interrupts Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 18/21] iommu/vt-d: Clean up unused MSI related code Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 19/21] iommu/amd: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 20/21] x86: irq_remapping: " Jiang Liu
2014-09-11 14:03 ` [RFC Part2 v1 21/21] x86, irq: Clean up unused MSI related code and interfaces Jiang Liu
2014-09-24  7:59 ` [RFC Part2 v1 00/21] Enable hierarchy irqdomian on x86 platforms Yasuaki Ishimatsu
2014-09-24  8:10   ` Jiang Liu
2014-09-24  8:12     ` Yasuaki Ishimatsu
2014-09-24 19:25   ` Thomas Gleixner
2014-09-25  8:15     ` Yasuaki Ishimatsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54226AE1.4000603@jp.fujitsu.com \
    --to=isimatu.yasuaki@jp.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=grant.likely@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jiang.liu@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mingo@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=rjw@rjwysocki.net \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).