* [PATCH 1/8] x86, irq: Remove not needed irq_reserve_irqs calling
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-01 23:18 ` [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling Yinghai Lu
` (6 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu
Now x86 only support sparseirq path, for that path, calling path like:
early_irq_init
==> arch_probe_nr_irqs : return legacy irq number
==> alloc_desc for legacy irqs and set bits in allocated_irqs
==> arch_early_irq_init
==> irq_reserve_irqs : set bits again
so we can kill one irq_reserve_irqs calling.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/kernel/apic/io_apic.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 6ad4658..398f9c4 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -206,9 +206,6 @@ int __init arch_early_irq_init(void)
count = ARRAY_SIZE(irq_cfgx);
node = cpu_to_node(0);
- /* Make sure the legacy interrupts are marked in the bitmap */
- irq_reserve_irqs(0, legacy_pic->nr_legacy_irqs);
-
for (i = 0; i < count; i++) {
irq_set_chip_data(i, &cfg[i]);
zalloc_cpumask_var_node(&cfg[i].domain, GFP_KERNEL, node);
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
2014-05-01 23:18 ` [PATCH 1/8] x86, irq: Remove not needed irq_reserve_irqs calling Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-02 2:38 ` Simon Horman
2014-05-02 15:19 ` Sergei Shtylyov
2014-05-01 23:18 ` [PATCH 3/8] irq: Use irq_alloc_desc_at instead of irq_reserve_irq Yinghai Lu
` (5 subsequent siblings)
7 siblings, 2 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu, Simon Horman, Magnus Damm, linux-sh
in sh calling path:
register_intc_controller
==> irq_create_identity_mapping/irq_create_strict_mappins
==>irq_alloc_desc: it will set bits on allocate_irq
==> intc_register_irq
==> irq_reserve_irq: set bits again
so we can kill this irq_reserve_irq calling.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Simon Horman <horms@verge.net.au>
Cc: Magnus Damm <magnus.damm@gmail.com>
Cc: linux-sh@vger.kernel.org
---
drivers/sh/intc/core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
index 8f32a13..05118f92 100644
--- a/drivers/sh/intc/core.c
+++ b/drivers/sh/intc/core.c
@@ -81,11 +81,8 @@ static void __init intc_register_irq(struct intc_desc *desc,
unsigned long flags;
/*
- * Register the IRQ position with the global IRQ map, then insert
- * it in to the radix tree.
+ * insert it in to the radix tree.
*/
- irq_reserve_irq(irq);
-
raw_spin_lock_irqsave(&intc_big_lock, flags);
radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
raw_spin_unlock_irqrestore(&intc_big_lock, flags);
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling
2014-05-01 23:18 ` [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling Yinghai Lu
@ 2014-05-02 2:38 ` Simon Horman
2014-05-02 15:19 ` Sergei Shtylyov
1 sibling, 0 replies; 12+ messages in thread
From: Simon Horman @ 2014-05-02 2:38 UTC (permalink / raw)
To: Yinghai Lu
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck,
linux-kernel, Magnus Damm, linux-sh
On Thu, May 01, 2014 at 04:18:16PM -0700, Yinghai Lu wrote:
> in sh calling path:
> register_intc_controller
> ==> irq_create_identity_mapping/irq_create_strict_mappins
> ==>irq_alloc_desc: it will set bits on allocate_irq
> ==> intc_register_irq
> ==> irq_reserve_irq: set bits again
>
> so we can kill this irq_reserve_irq calling.
Thanks, this looks fine to me.
As the file in question has not been updated in well over a year
and I'm not aware of any other outstanding updates to it I think
that the chance of conflicts is low. With that in mind I'm happy
for whoever takes the reset of this series to take this patch too.
Acked-by: Simon Horman <horms+renesas@verge.net.au>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-sh@vger.kernel.org
> ---
> drivers/sh/intc/core.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
> index 8f32a13..05118f92 100644
> --- a/drivers/sh/intc/core.c
> +++ b/drivers/sh/intc/core.c
> @@ -81,11 +81,8 @@ static void __init intc_register_irq(struct intc_desc *desc,
> unsigned long flags;
>
> /*
> - * Register the IRQ position with the global IRQ map, then insert
> - * it in to the radix tree.
> + * insert it in to the radix tree.
> */
> - irq_reserve_irq(irq);
> -
> raw_spin_lock_irqsave(&intc_big_lock, flags);
> radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
> raw_spin_unlock_irqrestore(&intc_big_lock, flags);
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling
2014-05-01 23:18 ` [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling Yinghai Lu
2014-05-02 2:38 ` Simon Horman
@ 2014-05-02 15:19 ` Sergei Shtylyov
1 sibling, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2014-05-02 15:19 UTC (permalink / raw)
To: Yinghai Lu, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
Tony Luck
Cc: linux-kernel, Simon Horman, Magnus Damm, linux-sh
Hello.
On 05/02/2014 03:18 AM, Yinghai Lu wrote:
> in sh calling path:
> register_intc_controller
> ==> irq_create_identity_mapping/irq_create_strict_mappins
> ==>irq_alloc_desc: it will set bits on allocate_irq
> ==> intc_register_irq
> ==> irq_reserve_irq: set bits again
> so we can kill this irq_reserve_irq calling.
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> Cc: Simon Horman <horms@verge.net.au>
> Cc: Magnus Damm <magnus.damm@gmail.com>
> Cc: linux-sh@vger.kernel.org
> ---
> drivers/sh/intc/core.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
> diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c
> index 8f32a13..05118f92 100644
> --- a/drivers/sh/intc/core.c
> +++ b/drivers/sh/intc/core.c
> @@ -81,11 +81,8 @@ static void __init intc_register_irq(struct intc_desc *desc,
> unsigned long flags;
>
> /*
> - * Register the IRQ position with the global IRQ map, then insert
> - * it in to the radix tree.
> + * insert it in to the radix tree.
It makes sense to convert this comment to one-liner now. I'd also have
started it with a capital letter.
> */
> - irq_reserve_irq(irq);
> -
> raw_spin_lock_irqsave(&intc_big_lock, flags);
> radix_tree_insert(&d->tree, enum_id, intc_irq_xlate_get(irq));
> raw_spin_unlock_irqrestore(&intc_big_lock, flags);
WBR, Sergei
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 3/8] irq: Use irq_alloc_desc_at instead of irq_reserve_irq
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
2014-05-01 23:18 ` [PATCH 1/8] x86, irq: Remove not needed irq_reserve_irqs calling Yinghai Lu
2014-05-01 23:18 ` [PATCH 2/8] sh, irq: Remove irq_reserve_irq calling Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-01 23:18 ` [PATCH 4/8] s390: Mark bits in allocated_irqs in general code Yinghai Lu
` (4 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu
irq_reserve_irq actually only set bit allocated_irq, and it is not really
"reserve" and cause confusion.
For !CONFIG_SPARSE_IRQ path, irq_alloc_desc_at() will only set bit
in allocated_irq.
We can use that instead, kill one irq_reserve_irq() calling.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
kernel/irq/chip.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
index 6397df2..aff7481 100644
--- a/kernel/irq/chip.c
+++ b/kernel/irq/chip.c
@@ -28,8 +28,13 @@
int irq_set_chip(unsigned int irq, struct irq_chip *chip)
{
unsigned long flags;
- struct irq_desc *desc = irq_get_desc_lock(irq, &flags, 0);
+ struct irq_desc *desc;
+
+#ifndef CONFIG_SPARSE_IRQ
+ irq_alloc_desc_at(irq, 0);
+#endif
+ desc = irq_get_desc_lock(irq, &flags, 0);
if (!desc)
return -EINVAL;
@@ -38,12 +43,7 @@ int irq_set_chip(unsigned int irq, struct irq_chip *chip)
desc->irq_data.chip = chip;
irq_put_desc_unlock(desc, flags);
- /*
- * For !CONFIG_SPARSE_IRQ make the irq show up in
- * allocated_irqs. For the CONFIG_SPARSE_IRQ case, it is
- * already marked, and this call is harmless.
- */
- irq_reserve_irq(irq);
+
return 0;
}
EXPORT_SYMBOL(irq_set_chip);
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 4/8] s390: Mark bits in allocated_irqs in general code
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
` (2 preceding siblings ...)
2014-05-01 23:18 ` [PATCH 3/8] irq: Use irq_alloc_desc_at instead of irq_reserve_irq Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-01 23:18 ` [PATCH 5/8] irq: Kill irq_reserve_irq/irq_reserve_irqs Yinghai Lu
` (3 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu, Martin Schwidefsky, Heiko Carstens,
linux390
Second irq_reserve_irqs calling is from arch s390, and
s390 does not use SPARSE_IRQ yet.
We could set bits for legacy bits early in !SPARSE_IRQ version
early_irq_init() directly instead of calling irq_reserve_irqs later.
Adding weak version arch_proble_early_allocate_nr_irqs() for
!SPARESE_IRQ, and let s390 to have specific version to
pass correct irq number that need to be marked in allocated_irqs.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
---
arch/s390/kernel/irq.c | 6 +++++-
include/linux/irq.h | 1 +
kernel/irq/irqdesc.c | 10 ++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index c7463aa..47e29be 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -90,9 +90,13 @@ static const struct irq_class irqclass_sub_desc[NR_ARCH_IRQS] = {
[CPU_RST] = {.name = "RST", .desc = "[CPU] CPU Restart"},
};
+int arch_probe_early_allocate_nr_irqs(void)
+{
+ return THIN_INTERRUPT;
+}
+
void __init init_IRQ(void)
{
- irq_reserve_irqs(0, THIN_INTERRUPT);
init_cio_interrupts();
init_airq_interrupts();
init_ext_interrupts();
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 10a0b1a..28cbd3e 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -624,6 +624,7 @@ int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
void irq_free_descs(unsigned int irq, unsigned int cnt);
int irq_reserve_irqs(unsigned int from, unsigned int cnt);
+int arch_probe_early_allocate_nr_irqs(void);
static inline void irq_free_desc(unsigned int irq)
{
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index a7174617..dfb971c 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -248,10 +248,16 @@ struct irq_desc irq_desc[NR_IRQS] __cacheline_aligned_in_smp = {
}
};
+int __weak arch_probe_early_allocate_nr_irqs(void)
+{
+ return 0;
+}
+
int __init early_irq_init(void)
{
int count, i, node = first_online_node;
struct irq_desc *desc;
+ int nr = arch_probe_early_allocate_nr_irqs();
init_irq_default_affinity();
@@ -267,6 +273,10 @@ int __init early_irq_init(void)
lockdep_set_class(&desc[i].lock, &irq_desc_lock_class);
desc_set_defaults(i, &desc[i], node, NULL);
}
+
+ for (i = 0; i < nr; i++)
+ set_bit(i, allocated_irqs);
+
return arch_early_irq_init();
}
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 5/8] irq: Kill irq_reserve_irq/irq_reserve_irqs
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
` (3 preceding siblings ...)
2014-05-01 23:18 ` [PATCH 4/8] s390: Mark bits in allocated_irqs in general code Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-01 23:18 ` [PATCH 6/8] irq: Add new reserved_irqs clear/mark functions Yinghai Lu
` (2 subsequent siblings)
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu
No user any more.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
include/linux/irq.h | 6 ------
kernel/irq/irqdesc.c | 25 -------------------------
2 files changed, 31 deletions(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 28cbd3e..02dc0e4 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -623,7 +623,6 @@ int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
irq_alloc_descs(-1, from, cnt, node)
void irq_free_descs(unsigned int irq, unsigned int cnt);
-int irq_reserve_irqs(unsigned int from, unsigned int cnt);
int arch_probe_early_allocate_nr_irqs(void);
static inline void irq_free_desc(unsigned int irq)
@@ -631,11 +630,6 @@ static inline void irq_free_desc(unsigned int irq)
irq_free_descs(irq, 1);
}
-static inline int irq_reserve_irq(unsigned int irq)
-{
- return irq_reserve_irqs(irq, 1);
-}
-
#ifndef irq_reg_writel
# define irq_reg_writel(val, addr) writel(val, addr)
#endif
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index dfb971c..49bf891 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -400,31 +400,6 @@ err:
EXPORT_SYMBOL_GPL(__irq_alloc_descs);
/**
- * irq_reserve_irqs - mark irqs allocated
- * @from: mark from irq number
- * @cnt: number of irqs to mark
- *
- * Returns 0 on success or an appropriate error code
- */
-int irq_reserve_irqs(unsigned int from, unsigned int cnt)
-{
- unsigned int start;
- int ret = 0;
-
- if (!cnt || (from + cnt) > nr_irqs)
- return -EINVAL;
-
- mutex_lock(&sparse_irq_lock);
- start = bitmap_find_next_zero_area(allocated_irqs, nr_irqs, from, cnt, 0);
- if (start == from)
- bitmap_set(allocated_irqs, start, cnt);
- else
- ret = -EEXIST;
- mutex_unlock(&sparse_irq_lock);
- return ret;
-}
-
-/**
* irq_get_next_irq - get next allocated irq number
* @offset: where to start the search
*
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 6/8] irq: Add new reserved_irqs clear/mark functions
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
` (4 preceding siblings ...)
2014-05-01 23:18 ` [PATCH 5/8] irq: Kill irq_reserve_irq/irq_reserve_irqs Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-02 10:50 ` Thomas Gleixner
2014-05-01 23:18 ` [PATCH 7/8] irq: Add irq_alloc_reserved_desc() Yinghai Lu
2014-05-01 23:18 ` [PATCH 8/8] irq: Do not free unallocated irq descriptors Yinghai Lu
7 siblings, 1 reply; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu
Prepare for ioapic hotplug.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
include/linux/irq.h | 3 +++
kernel/irq/irqdesc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 02dc0e4..2ba3245 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -603,6 +603,9 @@ static inline u32 irq_get_trigger_type(unsigned int irq)
return d ? irqd_get_trigger_type(d) : 0;
}
+int irq_clear_reserved_irqs(unsigned int from, unsigned int cnt);
+int irq_mark_reserved_irqs(int irq, unsigned int from, unsigned int cnt);
+
int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
struct module *owner);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 49bf891..865ebc0 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -97,6 +97,7 @@ int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);
static DEFINE_MUTEX(sparse_irq_lock);
+static DECLARE_BITMAP(reserved_irqs, IRQ_BITMAP_BITS);
static DECLARE_BITMAP(allocated_irqs, IRQ_BITMAP_BITS);
#ifdef CONFIG_SPARSE_IRQ
@@ -400,6 +401,73 @@ err:
EXPORT_SYMBOL_GPL(__irq_alloc_descs);
/**
+ * irq_clear_reserved_irqs - clear irqs reserved
+ * @from: clear from irq number
+ * @cnt: number of irqs to clear
+ *
+ * Returns 0 on success or an appropriate error code
+ */
+int irq_clear_reserved_irqs(unsigned int from, unsigned int cnt)
+{
+ if (!cnt || (from + cnt) > nr_irqs)
+ return -EINVAL;
+
+ mutex_lock(&sparse_irq_lock);
+ bitmap_clear(reserved_irqs, from, cnt);
+ mutex_unlock(&sparse_irq_lock);
+
+ return 0;
+}
+
+/**
+ * irq_mark_reserved_irqs - mark irqs reserved
+ * @irq: Allocate for specific irq number if irq >= 0
+ * @from: mark from irq number
+ * @cnt: number of irqs to mark
+ *
+ * Returns the first irq number or error code
+ */
+int irq_mark_reserved_irqs(int irq, unsigned int from, unsigned int cnt)
+{
+ unsigned int start, reserve;
+ int ret;
+
+ if (!cnt)
+ return -EINVAL;
+
+ if (irq >= 0) {
+ if (from > irq)
+ return -EINVAL;
+ from = irq;
+ }
+
+ mutex_lock(&sparse_irq_lock);
+ start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
+ from, cnt, 0);
+ ret = -EEXIST;
+ if (irq >= 0 && start != irq)
+ goto err;
+
+ if (start + cnt > nr_irqs) {
+ ret = irq_expand_nr_irqs(start + cnt);
+ if (ret)
+ goto err;
+ }
+
+ reserve = bitmap_find_next_zero_area(reserved_irqs, nr_irqs, start,
+ cnt, 0);
+ if (reserve == start) {
+ ret = start;
+ bitmap_set(reserved_irqs, start, cnt);
+ } else
+ ret = -EEXIST;
+
+err:
+ mutex_unlock(&sparse_irq_lock);
+ return ret;
+}
+
+/**
* irq_get_next_irq - get next allocated irq number
* @offset: where to start the search
*
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 6/8] irq: Add new reserved_irqs clear/mark functions
2014-05-01 23:18 ` [PATCH 6/8] irq: Add new reserved_irqs clear/mark functions Yinghai Lu
@ 2014-05-02 10:50 ` Thomas Gleixner
0 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2014-05-02 10:50 UTC (permalink / raw)
To: Yinghai Lu; +Cc: Ingo Molnar, H. Peter Anvin, Tony Luck, LKML
On Thu, 1 May 2014, Yinghai Lu wrote:
> Prepare for ioapic hotplug.
>
> Signed-off-by: Yinghai Lu <yinghai@kernel.org>
> ---
> include/linux/irq.h | 3 +++
> kernel/irq/irqdesc.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 71 insertions(+)
>
> diff --git a/include/linux/irq.h b/include/linux/irq.h
> index 02dc0e4..2ba3245 100644
> --- a/include/linux/irq.h
> +++ b/include/linux/irq.h
> @@ -603,6 +603,9 @@ static inline u32 irq_get_trigger_type(unsigned int irq)
> return d ? irqd_get_trigger_type(d) : 0;
> }
>
> +int irq_clear_reserved_irqs(unsigned int from, unsigned int cnt);
> +int irq_mark_reserved_irqs(int irq, unsigned int from, unsigned int cnt);
> +
> int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
> struct module *owner);
>
> diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
> index 49bf891..865ebc0 100644
> --- a/kernel/irq/irqdesc.c
> +++ b/kernel/irq/irqdesc.c
> @@ -97,6 +97,7 @@ int nr_irqs = NR_IRQS;
> EXPORT_SYMBOL_GPL(nr_irqs);
>
> static DEFINE_MUTEX(sparse_irq_lock);
> +static DECLARE_BITMAP(reserved_irqs, IRQ_BITMAP_BITS);
> static DECLARE_BITMAP(allocated_irqs, IRQ_BITMAP_BITS);
>
> #ifdef CONFIG_SPARSE_IRQ
> @@ -400,6 +401,73 @@ err:
> EXPORT_SYMBOL_GPL(__irq_alloc_descs);
>
> /**
> + * irq_clear_reserved_irqs - clear irqs reserved
> + * @from: clear from irq number
> + * @cnt: number of irqs to clear
> + *
> + * Returns 0 on success or an appropriate error code
> + */
> +int irq_clear_reserved_irqs(unsigned int from, unsigned int cnt)
> +{
> + if (!cnt || (from + cnt) > nr_irqs)
> + return -EINVAL;
> +
> + mutex_lock(&sparse_irq_lock);
> + bitmap_clear(reserved_irqs, from, cnt);
> + mutex_unlock(&sparse_irq_lock);
> +
> + return 0;
> +}
> +
> +/**
> + * irq_mark_reserved_irqs - mark irqs reserved
> + * @irq: Allocate for specific irq number if irq >= 0
> + * @from: mark from irq number
> + * @cnt: number of irqs to mark
> + *
> + * Returns the first irq number or error code
> + */
> +int irq_mark_reserved_irqs(int irq, unsigned int from, unsigned int cnt)
> +{
> + unsigned int start, reserve;
> + int ret;
> +
> + if (!cnt)
> + return -EINVAL;
> +
> + if (irq >= 0) {
> + if (from > irq)
> + return -EINVAL;
> + from = irq;
> + }
> +
> + mutex_lock(&sparse_irq_lock);
> + start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
> + from, cnt, 0);
> + ret = -EEXIST;
> + if (irq >= 0 && start != irq)
> + goto err;
> +
> + if (start + cnt > nr_irqs) {
> + ret = irq_expand_nr_irqs(start + cnt);
> + if (ret)
> + goto err;
> + }
> +
> + reserve = bitmap_find_next_zero_area(reserved_irqs, nr_irqs, start,
> + cnt, 0);
> + if (reserve == start) {
> + ret = start;
> + bitmap_set(reserved_irqs, start, cnt);
> + } else
> + ret = -EEXIST;
And what exactly is the point of this exercise?
Something calls irq_mark_reserved_irqs() which sets the bits in
reserved_irqs and then before the irqs are allocated for the reserved
range some random driver allocates an MSI IRQ and that calls
alloc_irq() which will happily take an interrupt out of the reserved
area.
This is beyond sloppy. Go and find something to hack on which fits
your incompetence. "Hello world!" might be a good starting point.
My patience with you is finally exhausted. I'm not longer going to
deal with you and waste my precious time.
Send your future patches to /dev/null right away as they are going to
end up via procmail there anyway. Spare the bandwidth.
Thanks,
tglx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 7/8] irq: Add irq_alloc_reserved_desc()
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
` (5 preceding siblings ...)
2014-05-01 23:18 ` [PATCH 6/8] irq: Add new reserved_irqs clear/mark functions Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
2014-05-01 23:18 ` [PATCH 8/8] irq: Do not free unallocated irq descriptors Yinghai Lu
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu, Joerg Roedel, Konrad Rzeszutek Wilk,
Sebastian Andrzej Siewior
For ioapic hot-add support, it would be easy if we have continuous
irq numbers for hot added ioapic controller.
We can reserve irq range at first, and later allocate desc for those
pre-reserved irqs when they are needed.
The reasons for not allocating them during reserving:
1. only several pins of one ioapic are used, allocate for all pins, will
waste memory for not used pins.
2. allocate later when is needed could make sure irq_desc is allocated
on local node ram, as dev->node is set at that point.
-v2: update changelog by adding reasons, requested by Konrad.
-v3: according to tglx:
separate core code change with arch code change.
change function name to irq_alloc_reserved_desc.
kill __irq_is_reserved().
remove not need exports.
according to Sebastian:
spare one comments by put two functions together.
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
---
include/linux/irq.h | 3 +++
kernel/irq/irqdesc.c | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index 2ba3245..97b60b9 100644
--- a/include/linux/irq.h
+++ b/include/linux/irq.h
@@ -608,10 +608,13 @@ int irq_mark_reserved_irqs(int irq, unsigned int from, unsigned int cnt);
int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
struct module *owner);
+int __irq_alloc_reserved_desc(int at, int node, struct module *owner);
/* use macros to avoid needing export.h for THIS_MODULE */
#define irq_alloc_descs(irq, from, cnt, node) \
__irq_alloc_descs(irq, from, cnt, node, THIS_MODULE)
+#define irq_alloc_reserved_desc_at(at, node) \
+ __irq_alloc_reserved_desc(at, node, THIS_MODULE)
#define irq_alloc_desc(node) \
irq_alloc_descs(-1, 0, 1, node)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 865ebc0..1a7e663 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -467,6 +467,29 @@ err:
return ret;
}
+ /**
+ * __irq_alloc_reserved_desc - allocate irq descriptor for irq that is already reserved
+ * @irq: Allocate for specific irq number if irq >= 0
+ * @node: Preferred node on which the irq descriptor should be allocated
+ * @owner: Owning module (can be NULL)
+ *
+ * Returns the irq number or error code
+ */
+int __ref __irq_alloc_reserved_desc(int irq, int node, struct module *owner)
+{
+ if (irq < 0)
+ return -EINVAL;
+
+ mutex_lock(&sparse_irq_lock);
+ if (!test_bit(irq, reserved_irqs)) {
+ mutex_unlock(&sparse_irq_lock);
+ return -EINVAL;
+ }
+ mutex_unlock(&sparse_irq_lock);
+
+ return __irq_alloc_descs(irq, irq, 1, node, owner);
+}
+
/**
* irq_get_next_irq - get next allocated irq number
* @offset: where to start the search
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 8/8] irq: Do not free unallocated irq descriptors
2014-05-01 23:18 [PATCH 0/8] irq: core changes for x86 ioapic hotplug Yinghai Lu
` (6 preceding siblings ...)
2014-05-01 23:18 ` [PATCH 7/8] irq: Add irq_alloc_reserved_desc() Yinghai Lu
@ 2014-05-01 23:18 ` Yinghai Lu
7 siblings, 0 replies; 12+ messages in thread
From: Yinghai Lu @ 2014-05-01 23:18 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck
Cc: linux-kernel, Yinghai Lu
Hot-added interrupt controllers can reserve a range of interrupt
numbers, but only allocate some of them. To simplify the release on
hot-remove allow them to iterate over the reserved range, let the
free_desc() code return early when the descriptor does not exist
-v2: changelog from tglx
Signed-off-by: Yinghai Lu <yinghai@kernel.org>
---
kernel/irq/irqdesc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 1a7e663..c3e1f7b 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -166,6 +166,9 @@ static void free_desc(unsigned int irq)
{
struct irq_desc *desc = irq_to_desc(irq);
+ if (!desc)
+ return;
+
unregister_irq_proc(irq, desc);
mutex_lock(&sparse_irq_lock);
--
1.8.4.5
^ permalink raw reply related [flat|nested] 12+ messages in thread