Skip to contentSkip to conversation

x86_64 io_apic: Implement remove_pin_to_irq

PATCH New Lu, Yinghai 2 participants 2 messages Jan 8, 2007

lore
Share & tools
lore
#0 lore raw

-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Monday, January 08, 2007 1:31 PM
To: Lu, Yinghai
Cc: Linus Torvalds; Tobias Diedrich; Andrew Morton; Adrian Bunk; Andi Kleen; Linux Kernel Mailing List
Subject: Re: [PATCH 1/4] x86_64 io_apic: Implement remove_pin_to_irq

Quoted 4 lines

Any updates to add_pin_to_irq are wrong. It works fine. If there is something wrong we need to fix remove_pin_to_irq.

What is the problem you see? Sorry I'm dense at the moment.

+static int check_timer_pin(int apic, int pin) {
+ int irq, idx;
+ /*
+ * Test the architecture default i8254 timer pin
+ * of apic 0 pin 2.
+ */
+
+
+ /* If the apic pin pair is in use by another irq fail */
+ irq = irq_from_pin(apic, pin);
+ if ((irq != -1) && (irq != 0)) {
+ apic_printk(APIC_VERBOSE,KERN_INFO "...apic %d pin % in
use by irq %d\n",
+ apic, pin, irq);
+ return 0;
+ }
+
+ /* Add an entry in mp_irqs for irq 0 */
+ idx = update_irq0_entry(apic, pin);
+
+ /* Add an entry in irq_to_pin */
+ add_pin_to_irq(0, apic, pin);
+
+ /* Now setup the irq */
+ setup_IO_APIC_irq(apic, pin, idx, 0);
+
+ /* And finally check to see if the irq works */
+ return do_check_timer_pin(apic, pin);
+}
+

In the check_timer_pin, irq_from_pin could return 0, it mean some entry is for IRQ0 already.
The add_pin_to_irq could add another same entry for it again.

YH

#1 lore raw

PATCH 1/1 x86_64 ioapic: check_timer_pin Don't add_pin_to_irq if it is already there.

Quoted 8 lines · Yinghai
Quoted 4 lines

Any updates to add_pin_to_irq are wrong. It works fine. If there is something wrong we need to fix remove_pin_to_irq.

What is the problem you see? Sorry I'm dense at the moment.

In the check_timer_pin, irq_from_pin could return 0, it mean some entry is for IRQ0 already.
The add_pin_to_irq could add another same entry for it again.

Yep. My oversight. Here is the trivial patch to fix it. I don't see how we could hit this case but if we are going to allow for it we should handle it correctly.

---
 arch/x86_64/kernel/io_apic.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
arch/x86_64/kernel/io_apic.c +2 -1
index 4891959..cc8e9a4 100644
@@ -1687,7 +1687,8 @@ static int check_timer_pin(int apic, int pin)
 	idx = update_irq0_entry(apic, pin);
 
 	/* Add an entry in irq_to_pin */
-	add_pin_to_irq(0, apic, pin);
+	if (irq != 0)
+		add_pin_to_irq(0, apic, pin);
 
 	/* Now setup the irq */
 	setup_IO_APIC_irq(apic, pin, idx, 0);
Signature · 1 line
1.4.4.1.g278f