All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@siemens.com>
To: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: [Xenomai] [PATCH] ipipe: x86: Populate vector_irq for all dispatched vectors
Date: Wed, 19 Sep 2012 16:17:54 +0200	[thread overview]
Message-ID: <5059D412.7020202@siemens.com> (raw)
In-Reply-To: <5058C9FE.5030505@xenomai.org>

On 2012-09-18 21:22, Gilles Chanteperdrix wrote:
> On 09/18/2012 09:18 PM, Jan Kiszka wrote:
> 
>> On 2012-09-18 21:12, Gilles Chanteperdrix wrote:
>>> On 09/18/2012 09:10 PM, Jan Kiszka wrote:
>>>
>>>> On 2012-09-18 21:05, Gilles Chanteperdrix wrote:
>>>>> rah, vectors_limit is not needed at all. I do not see which look you are
>>>>> talking about.
>>>>
>>>> 		cfg = irq_cfg(irq);
>>>> 		if (!cpumask_test_cpu(cpu, cfg->domain))
>>>> 			per_cpu(vector_irq, cpu)[vector] = -1;
>>>
>>>
>>> Yes, but :
>>>
>>>>>>> -	for (vector = 0; vector < NR_VECTORS; ++vector) {
>>>>>>> +	for (vector = 0; vector < first_system_vector; ++vector) {
>>>
>>
>> And you know all side effects of that change?
>>
>> My point is: We have a working version, released and tested on machines
>> that make use of the affected code paths.
> 
> 
> Come on, look at the code:
> 
> 	for (vector = 0; vector < first_system_vector; ++vector) {
> 		if (vector == IRQ_MOVE_CLEANUP_VECTOR)
> 			continue;
> 
> 		irq = per_cpu(vector_irq, cpu)[vector];
> 		if (irq < 0)
> 			continue;
> 
> 		cfg = irq_cfg(irq);
> 		if (!cpumask_test_cpu(cpu, cfg->domain))
> 			per_cpu(vector_irq, cpu)[vector] = -1;
> 	}
> 
> It simply skips an initialization to -1 because we know that we already
> initialized this part of the array elsewhere.

Yes, it's simple and obvious - and therefore it was wrong. To be fair:
also in 2.6.38.

Below a patch - using your scheme - that survived both another review
and testing round. And it builds for APIC-less x86-32.

Jan

---8<---

Based on patch by Gilles: This fixes the dispatching of
IRQ_MOVE_CLEANUP_VECTOR in __ipipe_handle_irq and simplifies those
lines by always using vector_irq to translate a vector to a Linux IRQ
number. In contrast to the version in 2.6.38 and before, this one also
properly marks unused vectors above first_system_vector as free.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/include/asm/desc.h    |    8 ++++++++
 arch/x86/kernel/apic/io_apic.c |    3 +++
 arch/x86/kernel/ipipe.c        |   12 ++----------
 arch/x86/kernel/irqinit.c      |    5 +++++
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index e95822d..5a5b415 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -4,6 +4,7 @@
 #include <asm/desc_defs.h>
 #include <asm/ldt.h>
 #include <asm/mmu.h>
+#include <asm/hw_irq.h>
 
 #include <linux/smp.h>
 
@@ -351,6 +352,13 @@ extern unsigned long used_vectors[];
 static inline void alloc_system_vector(int vector)
 {
 	if (!test_bit(vector, used_vectors)) {
+#ifdef CONFIG_X86_LOCAL_APIC
+		unsigned cpu;
+
+		for_each_possible_cpu(cpu)
+			per_cpu(vector_irq, cpu)[vector] =
+				ipipe_apic_vector_irq(vector);
+#endif
 		set_bit(vector, used_vectors);
 		if (first_system_vector > vector)
 			first_system_vector = vector;
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 93f84c9..0dd658d 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1318,6 +1318,9 @@ void __setup_vector_irq(int cpu)
 	}
 	/* Mark the free vectors */
 	for (vector = 0; vector < NR_VECTORS; ++vector) {
+		/* I-pipe requires initialized vector_irq for system vectors */
+		if (test_bit(vector, used_vectors))
+			continue;
 		irq = per_cpu(vector_irq, cpu)[vector];
 		if (irq < 0)
 			continue;
diff --git a/arch/x86/kernel/ipipe.c b/arch/x86/kernel/ipipe.c
index 1a56b5f..fcf8113 100644
--- a/arch/x86/kernel/ipipe.c
+++ b/arch/x86/kernel/ipipe.c
@@ -581,16 +581,8 @@ int __ipipe_handle_irq(struct pt_regs *regs)
 	int irq, vector = regs->orig_ax, flags = 0;
 
 	if (likely(vector < 0)) {
-		vector = ~vector;
-#ifdef CONFIG_X86_LOCAL_APIC
-		if (vector >= FIRST_SYSTEM_VECTOR)
-			irq = ipipe_apic_vector_irq(vector);
-		else
-#endif	/* CONFIG_X86_LOCAL_APIC */
-		{
-			irq = __this_cpu_read(vector_irq[vector]);
-			BUG_ON(irq < 0);
-		}
+		irq = __this_cpu_read(vector_irq[~vector]);
+		BUG_ON(irq < 0);
 	} else { /* Software-generated. */
 		irq = vector;
 		flags = IPIPE_IRQF_NOACK;
diff --git a/arch/x86/kernel/irqinit.c b/arch/x86/kernel/irqinit.c
index 6fa97b2..dd348e1 100644
--- a/arch/x86/kernel/irqinit.c
+++ b/arch/x86/kernel/irqinit.c
@@ -165,6 +165,8 @@ static void __init smp_intr_init(void)
 {
 #ifdef CONFIG_SMP
 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_LOCAL_APIC)
+	unsigned cpu;
+
 	/*
 	 * The reschedule interrupt is a CPU-to-CPU reschedule-helper
 	 * IPI, driven by wakeup.
@@ -254,6 +256,9 @@ static void __init smp_intr_init(void)
 	/* Low priority IPI to cleanup after moving an irq */
 	set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
 	set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors);
+	for_each_possible_cpu(cpu)
+		per_cpu(vector_irq, cpu)[IRQ_MOVE_CLEANUP_VECTOR] =
+			IRQ_MOVE_CLEANUP_VECTOR;
 
 	/* IPI used for rebooting/stopping */
 	alloc_intr_gate(REBOOT_VECTOR, reboot_interrupt);
-- 
1.7.3.4



  reply	other threads:[~2012-09-19 14:17 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 15:56 [Xenomai] ipipe/x86: kernel BUG due to missing IRQ_MOVE_CLEANUP_VECTOR entry in ipipe-core3.2 Gernot Hillier
2012-09-15 22:26 ` Gilles Chanteperdrix
2012-09-16  7:20   ` Jan Kiszka
2012-09-16  8:36     ` Philippe Gerum
2012-09-16  8:50   ` Philippe Gerum
2012-09-16 10:31     ` Gilles Chanteperdrix
2012-09-17  8:13     ` Gilles Chanteperdrix
2012-09-18 17:25       ` Jan Kiszka
2012-09-18 17:28         ` Gilles Chanteperdrix
2012-09-18 18:25           ` Jan Kiszka
2012-09-18 18:31             ` Gilles Chanteperdrix
2012-09-18 18:55               ` Jan Kiszka
2012-09-18 19:01                 ` Gilles Chanteperdrix
2012-09-18 19:10                   ` Jan Kiszka
2012-09-18 19:14                     ` Gilles Chanteperdrix
2012-09-18 19:05                 ` Gilles Chanteperdrix
2012-09-18 19:10                   ` Jan Kiszka
2012-09-18 19:12                     ` Gilles Chanteperdrix
2012-09-18 19:18                       ` Jan Kiszka
2012-09-18 19:22                         ` Gilles Chanteperdrix
2012-09-19 14:17                           ` Jan Kiszka [this message]
2012-09-19 14:28                             ` [Xenomai] [PATCH] ipipe: x86: Populate vector_irq for all dispatched vectors Gilles Chanteperdrix
2012-09-19 14:33                               ` Jan Kiszka
2012-09-19 14:46                                 ` Gilles Chanteperdrix
2012-09-19 14:48                                   ` Jan Kiszka
2012-09-19 15:02                                     ` Gilles Chanteperdrix
2012-09-19 15:18                                       ` Jan Kiszka
2012-09-19 16:09                                         ` Gilles Chanteperdrix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5059D412.7020202@siemens.com \
    --to=jan.kiszka@siemens.com \
    --cc=gilles.chanteperdrix@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.