Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1245546 > unrolled thread

[RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

Started byQais Yousef <qais.yousef@imgtec.com>
First post2015-10-13 12:20 +0200
Last post2015-10-13 16:40 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core Qais Yousef <qais.yousef@imgtec.com> - 2015-10-13 12:20 +0200
    Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code  to irq core kbuild test robot <lkp@intel.com> - 2015-10-13 13:00 +0200
    Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code  to irq core kbuild test robot <lkp@intel.com> - 2015-10-13 13:00 +0200
    Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code  to irq core Thomas Gleixner <tglx@linutronix.de> - 2015-10-13 15:40 +0200
      Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code  to irq core Qais Yousef <qais.yousef@imgtec.com> - 2015-10-13 16:40 +0200

#1245546 — [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

FromQais Yousef <qais.yousef@imgtec.com>
Date2015-10-13 12:20 +0200
Subject[RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core
Message-ID<qj4QA-3vO-39@gated-at.bofh.it>
Add a generic mechanism to dynamically allocate an IPI.

With this change the user can call irq_reserve_ipi() to dynamically allocate an
IPI and use the associate virq to send one to 1 or more cpus.

Signed-off-by: Qais Yousef <qais.yousef@imgtec.com>
---
 include/linux/irqdomain.h |  6 ++++
 kernel/irq/irqdomain.c    | 84 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 9b3dc6c2a3cc..f5003f5fd530 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -41,6 +41,7 @@ struct irq_domain;
 struct of_device_id;
 struct irq_chip;
 struct irq_data;
+struct ipi_mask;
 
 /* Number of irqs reserved for a legacy isa controller */
 #define NUM_ISA_INTERRUPTS	16
@@ -280,6 +281,11 @@ 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);
 
+/* IPI functions */
+unsigned int irq_reserve_ipi(struct irq_domain *domain,
+			     const struct ipi_mask *dest);
+void irq_destroy_ipi(unsigned int irq);
+
 /* V2 interfaces to support hierarchy IRQ domains. */
 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
 						unsigned int virq);
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index dc9d27c0c158..781407f7d692 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -749,6 +749,90 @@ static int irq_domain_alloc_descs(int virq, unsigned int cnt,
 	return virq;
 }
 
+/**
+ * irq_reserve_ipi() - setup an IPI to destination cpumask
+ * @domain: IPI domain
+ * @dest: cpumask of cpus to receive the IPI
+ *
+ * Allocate a virq that can be used to send IPI to any CPU in dest mask.
+ *
+ * On success it'll return linux irq number and 0 on failure
+ */
+unsigned int irq_reserve_ipi(struct irq_domain *domain,
+			     const struct ipi_mask *dest)
+{
+	struct irq_data *data;
+	int virq;
+	unsigned int nr_irqs;
+
+	if (domain == NULL)
+		domain = irq_default_domain; /* need a separate ipi_default_domain? */
+
+	if (domain == NULL) {
+		pr_warn("Must provide a valid IPI domain!\n");
+		return 0;
+	}
+
+	if (!irq_domain_is_ipi(domain)) {
+		pr_warn("Not an IPI domain!\n");
+		return 0;
+	}
+
+	/* always allocate a virq per cpu */
+	nr_irqs = bitmap_weight(dest->cpumask, dest->nbits);;
+
+	virq = irq_domain_alloc_descs(-1, nr_irqs, 0, NUMA_NO_NODE);
+	if (virq <= 0) {
+		pr_warn("Can't reserve IPI, failed to alloc descs\n");
+		return 0;
+	}
+
+	/* we are reusing hierarchy alloc function, should we create another one? */
+	virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
+					(void *) dest, true);
+	if (virq <= 0) {
+		pr_warn("Can't reserve IPI, failed to alloc irqs\n");
+		goto free_descs;
+	}
+
+	data = irq_get_irq_data(virq);
+	bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
+	data->ipi_mask.nbits = dest->nbits;
+
+	return virq;
+
+free_descs:
+	irq_free_descs(virq, nr_irqs);
+	return 0;
+}
+
+/**
+ * irq_destroy_ipi() - unreserve an IPI that was previously allocated
+ * @irq: linux irq number to be destroyed
+ *
+ * Return an IPI allocated with irq_reserve_ipi() to the system.
+ */
+void irq_destroy_ipi(unsigned int irq)
+{
+	struct irq_data *data = irq_get_irq_data(irq);
+	struct irq_domain *domain;
+
+	if (!irq || !data)
+		return;
+
+	domain = data->domain;
+	if (WARN_ON(domain == NULL))
+		return;
+
+	if (!irq_domain_is_ipi(domain)) {
+		pr_warn("Not an IPI domain!\n");
+		return;
+	}
+
+	irq_domain_free_irqs(irq,
+		bitmap_weight(data->ipi_mask.cpumask, data->ipi_mask.nbits));
+}
+
 #ifdef	CONFIG_IRQ_DOMAIN_HIERARCHY
 /**
  * irq_domain_add_hierarchy - Add a irqdomain into the hierarchy
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1245582 — Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

Fromkbuild test robot <lkp@intel.com>
Date2015-10-13 13:00 +0200
SubjectRe: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core
Message-ID<qj5tg-4gD-5@gated-at.bofh.it>
In reply to#1245546

[Multipart message — attachments visible in raw view] — view raw

Hi Qais,

[auto build test ERROR on v4.3-rc5 -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Implement-generic-IPI-support-mechanism/20151013-182314
config: x86_64-allnoconfig (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   kernel/irq/irqdomain.c: In function 'irq_reserve_ipi':
>> kernel/irq/irqdomain.c:799:18: error: 'struct irq_data' has no member named 'ipi_mask'
     bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
                     ^
   kernel/irq/irqdomain.c:800:6: error: 'struct irq_data' has no member named 'ipi_mask'
     data->ipi_mask.nbits = dest->nbits;
         ^
   kernel/irq/irqdomain.c: In function 'irq_destroy_ipi':
   kernel/irq/irqdomain.c:833:21: error: 'struct irq_data' has no member named 'ipi_mask'
      bitmap_weight(data->ipi_mask.cpumask, data->ipi_mask.nbits));
                        ^
   kernel/irq/irqdomain.c:833:45: error: 'struct irq_data' has no member named 'ipi_mask'
      bitmap_weight(data->ipi_mask.cpumask, data->ipi_mask.nbits));
                                                ^

vim +799 kernel/irq/irqdomain.c

   793		if (virq <= 0) {
   794			pr_warn("Can't reserve IPI, failed to alloc irqs\n");
   795			goto free_descs;
   796		}
   797	
   798		data = irq_get_irq_data(virq);
 > 799		bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
   800		data->ipi_mask.nbits = dest->nbits;
   801	
   802		return virq;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1245587 — Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

Fromkbuild test robot <lkp@intel.com>
Date2015-10-13 13:00 +0200
SubjectRe: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core
Message-ID<qj5tg-4gD-13@gated-at.bofh.it>
In reply to#1245546

[Multipart message — attachments visible in raw view] — view raw

Hi Qais,

[auto build test ERROR on v4.3-rc5 -- if it's inappropriate base, please suggest rules for selecting the more suitable base]

url:    https://github.com/0day-ci/linux/commits/Qais-Yousef/Implement-generic-IPI-support-mechanism/20151013-182314
config: sh-titan_defconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sh 

All errors (new ones prefixed by >>):

   kernel/irq/irqdomain.c: In function 'irq_reserve_ipi':
>> kernel/irq/irqdomain.c:791:2: error: implicit declaration of function '__irq_domain_alloc_irqs' [-Werror=implicit-function-declaration]
   kernel/irq/irqdomain.c:799:18: error: 'struct irq_data' has no member named 'ipi_mask'
   kernel/irq/irqdomain.c:800:6: error: 'struct irq_data' has no member named 'ipi_mask'
   kernel/irq/irqdomain.c: In function 'irq_destroy_ipi':
>> kernel/irq/irqdomain.c:832:2: error: implicit declaration of function 'irq_domain_free_irqs' [-Werror=implicit-function-declaration]
   kernel/irq/irqdomain.c:833:21: error: 'struct irq_data' has no member named 'ipi_mask'
   kernel/irq/irqdomain.c:833:45: error: 'struct irq_data' has no member named 'ipi_mask'
   cc1: some warnings being treated as errors

vim +/__irq_domain_alloc_irqs +791 kernel/irq/irqdomain.c

   785		if (virq <= 0) {
   786			pr_warn("Can't reserve IPI, failed to alloc descs\n");
   787			return 0;
   788		}
   789	
   790		/* we are reusing hierarchy alloc function, should we create another one? */
 > 791		virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
   792						(void *) dest, true);
   793		if (virq <= 0) {
   794			pr_warn("Can't reserve IPI, failed to alloc irqs\n");
   795			goto free_descs;
   796		}
   797	
   798		data = irq_get_irq_data(virq);
   799		bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
   800		data->ipi_mask.nbits = dest->nbits;
   801	
   802		return virq;
   803	
   804	free_descs:
   805		irq_free_descs(virq, nr_irqs);
   806		return 0;
   807	}
   808	
   809	/**
   810	 * irq_destroy_ipi() - unreserve an IPI that was previously allocated
   811	 * @irq: linux irq number to be destroyed
   812	 *
   813	 * Return an IPI allocated with irq_reserve_ipi() to the system.
   814	 */
   815	void irq_destroy_ipi(unsigned int irq)
   816	{
   817		struct irq_data *data = irq_get_irq_data(irq);
   818		struct irq_domain *domain;
   819	
   820		if (!irq || !data)
   821			return;
   822	
   823		domain = data->domain;
   824		if (WARN_ON(domain == NULL))
   825			return;
   826	
   827		if (!irq_domain_is_ipi(domain)) {
   828			pr_warn("Not an IPI domain!\n");
   829			return;
   830		}
   831	
 > 832		irq_domain_free_irqs(irq,
   833			bitmap_weight(data->ipi_mask.cpumask, data->ipi_mask.nbits));
   834	}
   835	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1245714 — Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

FromThomas Gleixner <tglx@linutronix.de>
Date2015-10-13 15:40 +0200
SubjectRe: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core
Message-ID<qj7Y5-819-3@gated-at.bofh.it>
In reply to#1245546
On Tue, 13 Oct 2015, Qais Yousef wrote:
> +/**
> + * irq_reserve_ipi() - setup an IPI to destination cpumask
> + * @domain: IPI domain
> + * @dest: cpumask of cpus to receive the IPI
> + *
> + * Allocate a virq that can be used to send IPI to any CPU in dest mask.
> + *
> + * On success it'll return linux irq number and 0 on failure
> + */
> +unsigned int irq_reserve_ipi(struct irq_domain *domain,
> +			     const struct ipi_mask *dest)
> +{
> +	struct irq_data *data;
> +	int virq;
> +	unsigned int nr_irqs;

Please order them so:

+	struct irq_data *data;
+	unsigned int nr_irqs;
+	int virq;

Much simpler to read.

> +	if (domain == NULL)
> +		domain = irq_default_domain; /* need a separate ipi_default_domain? */

No tail comments please.

We should neither use irq_default_domain nor have an
ipi_default_domain.

> +
> +	if (domain == NULL) {
> +		pr_warn("Must provide a valid IPI domain!\n");
> +		return 0;
> +	}
> +
> +	if (!irq_domain_is_ipi(domain)) {
> +		pr_warn("Not an IPI domain!\n");
> +		return 0;
> +	}
> +
> +	/* always allocate a virq per cpu */
> +	nr_irqs = bitmap_weight(dest->cpumask, dest->nbits);;

Double semicolon

> +
> +	virq = irq_domain_alloc_descs(-1, nr_irqs, 0, NUMA_NO_NODE);
> +	if (virq <= 0) {
> +		pr_warn("Can't reserve IPI, failed to alloc descs\n");
> +		return 0;
> +	}
> +
> +	/* we are reusing hierarchy alloc function, should we create another one? */
> +	virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
> +					(void *) dest, true);
> +	if (virq <= 0) {
> +		pr_warn("Can't reserve IPI, failed to alloc irqs\n");
> +		goto free_descs;
> +	}
> +
> +	data = irq_get_irq_data(virq);
> +	bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
> +	data->ipi_mask.nbits = dest->nbits;

This does only initialize the first virq data. What about the others?

> +	return virq;
> +
> +free_descs:
> +	irq_free_descs(virq, nr_irqs);
> +	return 0;
> +}
> +
> +/**
> + * irq_destroy_ipi() - unreserve an IPI that was previously allocated
> + * @irq: linux irq number to be destroyed
> + *
> + * Return an IPI allocated with irq_reserve_ipi() to the system.

That wants to explain that it actually destroys a number of virqs not
just the primary one.

Thanks,

	tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1245785 — Re: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core

FromQais Yousef <qais.yousef@imgtec.com>
Date2015-10-13 16:40 +0200
SubjectRe: [RFC v2 PATCH 07/14] irq: add a new generic IPI reservation code to irq core
Message-ID<qj8Ua-Wq-5@gated-at.bofh.it>
In reply to#1245714
On 10/13/2015 02:37 PM, Thomas Gleixner wrote:
> On Tue, 13 Oct 2015, Qais Yousef wrote:
>
>> +	if (domain == NULL)
>> +		domain = irq_default_domain; /* need a separate ipi_default_domain? */
> No tail comments please.
>
> We should neither use irq_default_domain nor have an
> ipi_default_domain.

OK though I understood that you were OK with using the irq_default_domain.

This means that arch code must parse the DT for an IPI domain. I think 
I've seen arch code using the root FDT to search for a specific node. 
I'll try to do something similar to search for an IPI domain.

>> +
>> +	virq = irq_domain_alloc_descs(-1, nr_irqs, 0, NUMA_NO_NODE);
>> +	if (virq <= 0) {
>> +		pr_warn("Can't reserve IPI, failed to alloc descs\n");
>> +		return 0;
>> +	}
>> +
>> +	/* we are reusing hierarchy alloc function, should we create another one? */
>> +	virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
>> +					(void *) dest, true);
>> +	if (virq <= 0) {
>> +		pr_warn("Can't reserve IPI, failed to alloc irqs\n");
>> +		goto free_descs;
>> +	}
>> +
>> +	data = irq_get_irq_data(virq);
>> +	bitmap_copy(data->ipi_mask.cpumask, dest->cpumask, dest->nbits);
>> +	data->ipi_mask.nbits = dest->nbits;
> This does only initialize the first virq data. What about the others?

Right I missed that. I'll fix it.


>
>> +	return virq;
>> +
>> +free_descs:
>> +	irq_free_descs(virq, nr_irqs);
>> +	return 0;
>> +}
>> +
>> +/**
>> + * irq_destroy_ipi() - unreserve an IPI that was previously allocated
>> + * @irq: linux irq number to be destroyed
>> + *
>> + * Return an IPI allocated with irq_reserve_ipi() to the system.
> That wants to explain that it actually destroys a number of virqs not
> just the primary one.
>
>

OK I'll expand on that.

Thanks,
Qais
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web