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


Groups > linux.kernel > #1385277 > unrolled thread

[PATCH 1/2] genirq: Make irq_destroy_ipi take a cpumask of IPIs to destroy

Started byMatt Redfearn <matt.redfearn@imgtec.com>
First post2016-04-22 17:30 +0200
Last post2016-04-22 17:50 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] genirq: Make irq_destroy_ipi take a cpumask of IPIs to destroy Matt Redfearn <matt.redfearn@imgtec.com> - 2016-04-22 17:30 +0200
    [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi Matt Redfearn <matt.redfearn@imgtec.com> - 2016-04-22 17:30 +0200
      Re: [PATCH 2/2] genirq: Add error code reporting to  irq_{reserve,destroy}_ipi Thomas Gleixner <tglx@linutronix.de> - 2016-04-22 17:40 +0200
        Re: [PATCH 2/2] genirq: Add error code reporting to  irq_{reserve,destroy}_ipi Matt Redfearn <matt.redfearn@imgtec.com> - 2016-04-22 17:50 +0200

#1385277 — [PATCH 1/2] genirq: Make irq_destroy_ipi take a cpumask of IPIs to destroy

FromMatt Redfearn <matt.redfearn@imgtec.com>
Date2016-04-22 17:30 +0200
Subject[PATCH 1/2] genirq: Make irq_destroy_ipi take a cpumask of IPIs to destroy
Message-ID<rqLbQ-419-23@gated-at.bofh.it>
Previously irq_destroy_ipi() would destroy IPIs to all CPUs that were
configured by irq_reserve_ipi(). This change makes it possible to
destroy just a subset of the IPIs. This may be useful to remove IPIs to
CPUs that have been hot removed so that the IRQ numbers allocated within
the IPI domain can be re-used.

The original behaviour is restored by passing the complete mask that the
IPI was created with.

There are currently no users of this function that would break from the
API change.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 include/linux/irqdomain.h |  2 +-
 kernel/irq/ipi.c          | 18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 2aed04396210..e1b81d35e7a3 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -348,7 +348,7 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
 /* IPI functions */
 unsigned int irq_reserve_ipi(struct irq_domain *domain,
 			     const struct cpumask *dest);
-void irq_destroy_ipi(unsigned int irq);
+void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
 
 /* V2 interfaces to support hierarchy IRQ domains. */
 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c
index 14777af8e097..bedc995ae214 100644
--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -106,11 +106,12 @@ free_descs:
 /**
  * irq_destroy_ipi() - unreserve an IPI that was previously allocated
  * @irq:	linux irq number to be destroyed
+ * @dest:	cpumask of cpus which should have the IPI removed
  *
  * Return the IPIs allocated with irq_reserve_ipi() to the system destroying
  * all virqs associated with them.
  */
-void irq_destroy_ipi(unsigned int irq)
+void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 {
 	struct irq_data *data = irq_get_irq_data(irq);
 	struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
@@ -129,10 +130,19 @@ void irq_destroy_ipi(unsigned int irq)
 		return;
 	}
 
-	if (irq_domain_is_ipi_per_cpu(domain))
-		nr_irqs = cpumask_weight(ipimask);
-	else
+	if (WARN_ON(!cpumask_subset(dest, ipimask)))
+		/*
+		 * Must be destroying a subset of CPUs to which this IPI
+		 * was set up to target
+		 */
+		return;
+
+	if (irq_domain_is_ipi_per_cpu(domain)) {
+		irq = irq + cpumask_first(dest) - data->common->ipi_offset;
+		nr_irqs = cpumask_weight(dest);
+	} else {
 		nr_irqs = 1;
+	}
 
 	irq_domain_free_irqs(irq, nr_irqs);
 }
-- 
2.5.0

[toc] | [next] | [standalone]


#1385279 — [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi

FromMatt Redfearn <matt.redfearn@imgtec.com>
Date2016-04-22 17:30 +0200
Subject[PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi
Message-ID<rqLbR-419-31@gated-at.bofh.it>
In reply to#1385277
Make these functions return appropriate error codes when something goes
wrong.

There are currently no users of this function that would break from the
API change.

Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
---

 include/linux/irqdomain.h |  5 ++---
 kernel/irq/ipi.c          | 31 +++++++++++++++++--------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index e1b81d35e7a3..736abd74c135 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -346,9 +346,8 @@ int irq_domain_xlate_onetwocell(struct irq_domain *d, struct device_node *ctrlr,
 			irq_hw_number_t *out_hwirq, unsigned int *out_type);
 
 /* IPI functions */
-unsigned int irq_reserve_ipi(struct irq_domain *domain,
-			     const struct cpumask *dest);
-void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
+int irq_reserve_ipi(struct irq_domain *domain, const struct cpumask *dest);
+int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest);
 
 /* V2 interfaces to support hierarchy IRQ domains. */
 extern struct irq_data *irq_domain_get_irq_data(struct irq_domain *domain,
diff --git a/kernel/irq/ipi.c b/kernel/irq/ipi.c
index bedc995ae214..c42742208e5e 100644
--- a/kernel/irq/ipi.c
+++ b/kernel/irq/ipi.c
@@ -19,9 +19,9 @@
  *
  * 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
+ * On success it'll return linux irq number and error code on failure
  */
-unsigned int irq_reserve_ipi(struct irq_domain *domain,
+int irq_reserve_ipi(struct irq_domain *domain,
 			     const struct cpumask *dest)
 {
 	unsigned int nr_irqs, offset;
@@ -30,18 +30,18 @@ unsigned int irq_reserve_ipi(struct irq_domain *domain,
 
 	if (!domain ||!irq_domain_is_ipi(domain)) {
 		pr_warn("Reservation on a non IPI domain\n");
-		return 0;
+		return -EINVAL;
 	}
 
 	if (!cpumask_subset(dest, cpu_possible_mask)) {
 		pr_warn("Reservation is not in possible_cpu_mask\n");
-		return 0;
+		return -EINVAL;
 	}
 
 	nr_irqs = cpumask_weight(dest);
 	if (!nr_irqs) {
 		pr_warn("Reservation for empty destination mask\n");
-		return 0;
+		return -EINVAL;
 	}
 
 	if (irq_domain_is_ipi_single(domain)) {
@@ -72,14 +72,14 @@ unsigned int irq_reserve_ipi(struct irq_domain *domain,
 			next = cpumask_next(next, dest);
 		if (next < nr_cpu_ids) {
 			pr_warn("Destination mask has holes\n");
-			return 0;
+			return -EINVAL;
 		}
 	}
 
 	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;
+		return -ENOMEM;
 	}
 
 	virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
@@ -100,7 +100,7 @@ unsigned int irq_reserve_ipi(struct irq_domain *domain,
 
 free_descs:
 	irq_free_descs(virq, nr_irqs);
-	return 0;
+	return -EBUSY;
 }
 
 /**
@@ -108,10 +108,12 @@ free_descs:
  * @irq:	linux irq number to be destroyed
  * @dest:	cpumask of cpus which should have the IPI removed
  *
- * Return the IPIs allocated with irq_reserve_ipi() to the system destroying
- * all virqs associated with them.
+ * The IPIs allocated with irq_reserve_ipi() are retuerned to the system
+ * destroying all virqs associated with them.
+ *
+ * Return 0 on success or error code on failure.
  */
-void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
+int irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 {
 	struct irq_data *data = irq_get_irq_data(irq);
 	struct cpumask *ipimask = data ? irq_data_get_affinity_mask(data) : NULL;
@@ -119,7 +121,7 @@ void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 	unsigned int nr_irqs;
 
 	if (!irq || !data || !ipimask)
-		return;
+		return -EINVAL;
 
 	domain = data->domain;
 	if (WARN_ON(domain == NULL))
@@ -127,7 +129,7 @@ void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 
 	if (!irq_domain_is_ipi(domain)) {
 		pr_warn("Trying to destroy a non IPI domain!\n");
-		return;
+		return -EINVAL;
 	}
 
 	if (WARN_ON(!cpumask_subset(dest, ipimask)))
@@ -135,7 +137,7 @@ void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 		 * Must be destroying a subset of CPUs to which this IPI
 		 * was set up to target
 		 */
-		return;
+		return -EINVAL;
 
 	if (irq_domain_is_ipi_per_cpu(domain)) {
 		irq = irq + cpumask_first(dest) - data->common->ipi_offset;
@@ -145,6 +147,7 @@ void irq_destroy_ipi(unsigned int irq, const struct cpumask *dest)
 	}
 
 	irq_domain_free_irqs(irq, nr_irqs);
+	return 0;
 }
 
 /**
-- 
2.5.0

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


#1385287 — Re: [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi

FromThomas Gleixner <tglx@linutronix.de>
Date2016-04-22 17:40 +0200
SubjectRe: [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi
Message-ID<rqLlw-44Z-13@gated-at.bofh.it>
In reply to#1385279
On Fri, 22 Apr 2016, Matt Redfearn wrote:

> Make these functions return appropriate error codes when something goes
> wrong.

And the reason for this change is?

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


#1385301 — Re: [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi

FromMatt Redfearn <matt.redfearn@imgtec.com>
Date2016-04-22 17:50 +0200
SubjectRe: [PATCH 2/2] genirq: Add error code reporting to irq_{reserve,destroy}_ipi
Message-ID<rqLvc-49a-25@gated-at.bofh.it>
In reply to#1385287
On Fri, Apr 22, 2016 at 05:35:46PM +0200, Thomas Gleixner wrote:
> On Fri, 22 Apr 2016, Matt Redfearn wrote:
> 
> > Make these functions return appropriate error codes when something goes
> > wrong.
> 
> And the reason for this change is?

Hi Thomas,

Mainly for irq_destroy_ipi, where the first patch in the set makes
it possible for the request to fail. But in general with both of these
functions it is possible for them to silently fail without giving the
caller any idication if inapropriate arguments are passed.

Thanks,
Matt

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web