Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1261408 > unrolled thread
| Started by | Qais Yousef <qais.yousef@imgtec.com> |
|---|---|
| First post | 2015-11-03 12:20 +0100 |
| Last post | 2015-11-09 11:20 +0100 |
| 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.
[PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core Qais Yousef <qais.yousef@imgtec.com> - 2015-11-03 12:20 +0100
Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core kbuild test robot <lkp@intel.com> - 2015-11-03 13:10 +0100
Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core Thomas Gleixner <tglx@linutronix.de> - 2015-11-07 13:20 +0100
Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core Thomas Gleixner <tglx@linutronix.de> - 2015-11-07 14:40 +0100
Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core Qais Yousef <qais.yousef@imgtec.com> - 2015-11-09 11:20 +0100
| From | Qais Yousef <qais.yousef@imgtec.com> |
|---|---|
| Date | 2015-11-03 12:20 +0100 |
| Subject | [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core |
| Message-ID | <qqHN8-1ZB-19@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 associated 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 | 98 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+)
diff --git a/include/linux/irqdomain.h b/include/linux/irqdomain.h
index 422b6a1617b8..9ba67bfe8ad2 100644
--- a/include/linux/irqdomain.h
+++ b/include/linux/irqdomain.h
@@ -39,6 +39,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
@@ -333,6 +334,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 22aa9612ef7c..dd240914301d 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -852,6 +852,104 @@ 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;
+ unsigned int nr_irqs;
+ int virq, i;
+
+ 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 = ipi_mask_weight(dest);
+
+ 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;
+ }
+
+ 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;
+ }
+
+ for (i = virq; i < virq + nr_irqs; i++) {
+ data = irq_get_irq_data(i);
+ data->common->ipi_mask = ipi_mask_alloc(dest->nbits);
+ if (!data->common->ipi_mask)
+ goto free_ipi_mask;
+ ipi_mask_copy(data->common->ipi_mask, dest);
+ }
+
+ return virq;
+
+free_ipi_mask:
+ for (i = virq; i < virq + nr_irqs; i++) {
+ data = irq_get_irq_data(i);
+ ipi_mask_free(data->common->ipi_mask);
+ }
+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 the IPIs allocated with irq_reserve_ipi() to the system destroying all
+ * virqs associated with them.
+ */
+void irq_destroy_ipi(unsigned int irq)
+{
+ struct irq_data *data = irq_get_irq_data(irq);
+ struct irq_domain *domain;
+ unsigned int nr_irqs, i;
+
+ 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;
+ }
+
+ nr_irqs = ipi_mask_weight(data->common->ipi_mask);
+ ipi_mask_free(data->common->ipi_mask);
+
+ for (i = irq + 1; i < irq + nr_irqs; i++) {
+ data = irq_get_irq_data(i);
+ ipi_mask_free(data->common->ipi_mask);
+ }
+
+ irq_domain_free_irqs(irq, nr_irqs);
+}
+
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
/**
* irq_domain_create_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]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2015-11-03 13:10 +0100 |
| Subject | Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core |
| Message-ID | <qqIzx-2w3-39@gated-at.bofh.it> |
| In reply to | #1261408 |
[Multipart message — attachments visible in raw view] — view raw
Hi Qais,
[auto build test ERROR on tip/irq/core -- 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/20151103-192028
config: mips-jz4740 (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=mips
All errors (new ones prefixed by >>):
kernel/irq/irqdomain.c: In function 'irq_reserve_ipi':
>> kernel/irq/irqdomain.c:890:9: error: implicit declaration of function '__irq_domain_alloc_irqs' [-Werror=implicit-function-declaration]
virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
^
kernel/irq/irqdomain.c: In function 'irq_destroy_ipi':
>> kernel/irq/irqdomain.c:950:2: error: implicit declaration of function 'irq_domain_free_irqs' [-Werror=implicit-function-declaration]
irq_domain_free_irqs(irq, nr_irqs);
^
cc1: some warnings being treated as errors
vim +/__irq_domain_alloc_irqs +890 kernel/irq/irqdomain.c
884 virq = irq_domain_alloc_descs(-1, nr_irqs, 0, NUMA_NO_NODE);
885 if (virq <= 0) {
886 pr_warn("Can't reserve IPI, failed to alloc descs\n");
887 return 0;
888 }
889
> 890 virq = __irq_domain_alloc_irqs(domain, virq, nr_irqs, NUMA_NO_NODE,
891 (void *) dest, true);
892 if (virq <= 0) {
893 pr_warn("Can't reserve IPI, failed to alloc irqs\n");
894 goto free_descs;
895 }
896
897 for (i = virq; i < virq + nr_irqs; i++) {
898 data = irq_get_irq_data(i);
899 data->common->ipi_mask = ipi_mask_alloc(dest->nbits);
900 if (!data->common->ipi_mask)
901 goto free_ipi_mask;
902 ipi_mask_copy(data->common->ipi_mask, dest);
903 }
904
905 return virq;
906
907 free_ipi_mask:
908 for (i = virq; i < virq + nr_irqs; i++) {
909 data = irq_get_irq_data(i);
910 ipi_mask_free(data->common->ipi_mask);
911 }
912 free_descs:
913 irq_free_descs(virq, nr_irqs);
914 return 0;
915 }
916
917 /**
918 * irq_destroy_ipi() - unreserve an IPI that was previously allocated
919 * @irq: linux irq number to be destroyed
920 *
921 * Return the IPIs allocated with irq_reserve_ipi() to the system destroying all
922 * virqs associated with them.
923 */
924 void irq_destroy_ipi(unsigned int irq)
925 {
926 struct irq_data *data = irq_get_irq_data(irq);
927 struct irq_domain *domain;
928 unsigned int nr_irqs, i;
929
930 if (!irq || !data)
931 return;
932
933 domain = data->domain;
934 if (WARN_ON(domain == NULL))
935 return;
936
937 if (!irq_domain_is_ipi(domain)) {
938 pr_warn("Not an IPI domain!\n");
939 return;
940 }
941
942 nr_irqs = ipi_mask_weight(data->common->ipi_mask);
943 ipi_mask_free(data->common->ipi_mask);
944
945 for (i = irq + 1; i < irq + nr_irqs; i++) {
946 data = irq_get_irq_data(i);
947 ipi_mask_free(data->common->ipi_mask);
948 }
949
> 950 irq_domain_free_irqs(irq, nr_irqs);
951 }
952
953 #ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-11-07 13:20 +0100 |
| Subject | Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core |
| Message-ID | <qsaDn-29u-7@gated-at.bofh.it> |
| In reply to | #1261408 |
On Tue, 3 Nov 2015, Qais Yousef wrote: > 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 associated virq to send one to 1 or more cpus. Please move that to ipi.c as well. 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]
| From | Thomas Gleixner <tglx@linutronix.de> |
|---|---|
| Date | 2015-11-07 14:40 +0100 |
| Subject | Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core |
| Message-ID | <qsbSO-2TM-15@gated-at.bofh.it> |
| In reply to | #1261408 |
On Tue, 3 Nov 2015, Qais Yousef wrote: > + > + /* always allocate a virq per cpu */ > + nr_irqs = ipi_mask_weight(dest); That's not really a good assumption. Not all architectures need seperate interrupt numbers / descriptors because they can allocate from a per cpu interrupt space. We really want to handle that here as well. So we need a flag in the IPI domain which tells us whether that allocation needs to be weight(desc) or 1. 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]
| From | Qais Yousef <qais.yousef@imgtec.com> |
|---|---|
| Date | 2015-11-09 11:20 +0100 |
| Subject | Re: [PATCH 07/14] genirq: Add a new generic IPI reservation code to irq core |
| Message-ID | <qsRIn-55g-49@gated-at.bofh.it> |
| In reply to | #1264837 |
On 11/07/2015 01:31 PM, Thomas Gleixner wrote: > On Tue, 3 Nov 2015, Qais Yousef wrote: >> + >> + /* always allocate a virq per cpu */ >> + nr_irqs = ipi_mask_weight(dest); > That's not really a good assumption. Not all architectures need > seperate interrupt numbers / descriptors because they can allocate > from a per cpu interrupt space. We really want to handle that here as > well. So we need a flag in the IPI domain which tells us whether that > allocation needs to be weight(desc) or 1. OK. But is it bad to always allocate the weight? I thought allocating virqs is cheap, or maybe not? 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