aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2016-04-11 04:57:52 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-05-02 07:42:51 -0400
commit222df54fd8b7641dcc81476f157806bb3144ee1d (patch)
tree2153984fd6a2acc0f70022e95ca7f1f2a66dc098
parent651e8b54abdeeaa36f5f54ffa05c18707a3cc1d0 (diff)
genirq: Allow the affinity of a percpu interrupt to be set/retrieved
In order to prepare the genirq layer for the concept of partitionned percpu interrupts, let's allow an affinity to be associated with such an interrupt. We introduce: - irq_set_percpu_devid_partition: flag an interrupt as a percpu-devid interrupt, and associate it with an affinity - irq_get_percpu_devid_partition: allow the affinity of that interrupt to be retrieved. This will allow a driver to discover which CPUs the per-cpu interrupt can actually fire on. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: devicetree@vger.kernel.org Cc: Jason Cooper <jason@lakedaemon.net> Cc: Will Deacon <will.deacon@arm.com> Cc: Rob Herring <robh+dt@kernel.org> Link: http://lkml.kernel.org/r/1460365075-7316-3-git-send-email-marc.zyngier@arm.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--include/linux/irq.h4
-rw-r--r--include/linux/irqdesc.h1
-rw-r--r--kernel/irq/irqdesc.c26
3 files changed, 30 insertions, 1 deletions
diff --git a/include/linux/irq.h b/include/linux/irq.h
index c4de62348ff2..4d758a7c604a 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -530,6 +530,10 @@ static inline void irq_set_chip_and_handler(unsigned int irq, struct irq_chip *c
530} 530}
531 531
532extern int irq_set_percpu_devid(unsigned int irq); 532extern int irq_set_percpu_devid(unsigned int irq);
533extern int irq_set_percpu_devid_partition(unsigned int irq,
534 const struct cpumask *affinity);
535extern int irq_get_percpu_devid_partition(unsigned int irq,
536 struct cpumask *affinity);
533 537
534extern void 538extern void
535__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained, 539__irq_set_handler(unsigned int irq, irq_flow_handler_t handle, int is_chained,
diff --git a/include/linux/irqdesc.h b/include/linux/irqdesc.h
index dcca77c4b9d2..b51beebf9804 100644
--- a/include/linux/irqdesc.h
+++ b/include/linux/irqdesc.h
@@ -66,6 +66,7 @@ struct irq_desc {
66 int threads_handled_last; 66 int threads_handled_last;
67 raw_spinlock_t lock; 67 raw_spinlock_t lock;
68 struct cpumask *percpu_enabled; 68 struct cpumask *percpu_enabled;
69 const struct cpumask *percpu_affinity;
69#ifdef CONFIG_SMP 70#ifdef CONFIG_SMP
70 const struct cpumask *affinity_hint; 71 const struct cpumask *affinity_hint;
71 struct irq_affinity_notify *affinity_notify; 72 struct irq_affinity_notify *affinity_notify;
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 0ccd028817d7..8731e1c5d1e7 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -595,7 +595,8 @@ void __irq_put_desc_unlock(struct irq_desc *desc, unsigned long flags, bool bus)
595 chip_bus_sync_unlock(desc); 595 chip_bus_sync_unlock(desc);
596} 596}
597 597
598int irq_set_percpu_devid(unsigned int irq) 598int irq_set_percpu_devid_partition(unsigned int irq,
599 const struct cpumask *affinity)
599{ 600{
600 struct irq_desc *desc = irq_to_desc(irq); 601 struct irq_desc *desc = irq_to_desc(irq);
601 602
@@ -610,10 +611,33 @@ int irq_set_percpu_devid(unsigned int irq)
610 if (!desc->percpu_enabled) 611 if (!desc->percpu_enabled)
611 return -ENOMEM; 612 return -ENOMEM;
612 613
614 if (affinity)
615 desc->percpu_affinity = affinity;
616 else
617 desc->percpu_affinity = cpu_possible_mask;
618
613 irq_set_percpu_devid_flags(irq); 619 irq_set_percpu_devid_flags(irq);
614 return 0; 620 return 0;
615} 621}
616 622
623int irq_set_percpu_devid(unsigned int irq)
624{
625 return irq_set_percpu_devid_partition(irq, NULL);
626}
627
628int irq_get_percpu_devid_partition(unsigned int irq, struct cpumask *affinity)
629{
630 struct irq_desc *desc = irq_to_desc(irq);
631
632 if (!desc || !desc->percpu_enabled)
633 return -EINVAL;
634
635 if (affinity)
636 cpumask_copy(affinity, desc->percpu_affinity);
637
638 return 0;
639}
640
617void kstat_incr_irq_this_cpu(unsigned int irq) 641void kstat_incr_irq_this_cpu(unsigned int irq)
618{ 642{
619 kstat_incr_irqs_this_cpu(irq_to_desc(irq)); 643 kstat_incr_irqs_this_cpu(irq_to_desc(irq));