public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/9] x86: avoid redundant loop in io_apic_level_ack_pending()
       [not found] <20080405133903.770639386@gmail.com>
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 2/9] x86: use ioapic_read_entry() and ioapic_write_entry() Akinobu Mita
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-io-apic-optimize.patch --]
[-- Type: text/plain, Size: 1253 bytes --]

If one can find an ack pending pin, there is no need to check
the rest of them.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/io_apic_64.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Index: 2.6-git/arch/x86/kernel/io_apic_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_64.c
+++ 2.6-git/arch/x86/kernel/io_apic_64.c
@@ -155,11 +155,10 @@ static inline void io_apic_modify(unsign
 	writel(value, &io_apic->data);
 }
 
-static int io_apic_level_ack_pending(unsigned int irq)
+static bool io_apic_level_ack_pending(unsigned int irq)
 {
 	struct irq_pin_list *entry;
 	unsigned long flags;
-	int pending = 0;
 
 	spin_lock_irqsave(&ioapic_lock, flags);
 	entry = irq_2_pin + irq;
@@ -172,13 +171,17 @@ static int io_apic_level_ack_pending(uns
 			break;
 		reg = io_apic_read(entry->apic, 0x10 + pin*2);
 		/* Is the remote IRR bit set? */
-		pending |= (reg >> 14) & 1;
+		if ((reg >> 14) & 1) {
+			spin_unlock_irqrestore(&ioapic_lock, flags);
+			return true;
+		}
 		if (!entry->next)
 			break;
 		entry = irq_2_pin + entry->next;
 	}
 	spin_unlock_irqrestore(&ioapic_lock, flags);
-	return pending;
+
+	return false;
 }
 
 /*

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 2/9] x86: use ioapic_read_entry() and ioapic_write_entry()
       [not found] <20080405133903.770639386@gmail.com>
  2008-04-05 13:39 ` [patch 1/9] x86: avoid redundant loop in io_apic_level_ack_pending() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 3/9] x86: remove unnecessary memset() Akinobu Mita
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-use-ioapic_write_entry.patch --]
[-- Type: text/plain, Size: 4123 bytes --]

Remove duplicate code by using ioapic_read_entry() and ioapic_write_entry()
in io_apic_{32,64}.c

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/io_apic_32.c |   10 ++--------
 arch/x86/kernel/io_apic_64.c |   25 ++++++-------------------
 2 files changed, 8 insertions(+), 27 deletions(-)

Index: 2.6-git/arch/x86/kernel/io_apic_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_64.c
+++ 2.6-git/arch/x86/kernel/io_apic_64.c
@@ -905,9 +905,8 @@ static void __init setup_IO_APIC_irqs(vo
 static void __init setup_ExtINT_IRQ0_pin(unsigned int apic, unsigned int pin, int vector)
 {
 	struct IO_APIC_route_entry entry;
-	unsigned long flags;
 
-	memset(&entry,0,sizeof(entry));
+	memset(&entry, 0, sizeof(entry));
 
 	disable_8259A_irq(0);
 
@@ -935,10 +934,7 @@ static void __init setup_ExtINT_IRQ0_pin
 	/*
 	 * Add it to the IO-APIC irq-routing table:
 	 */
-	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(apic, 0x11+2*pin, *(((int *)&entry)+1));
-	io_apic_write(apic, 0x10+2*pin, *(((int *)&entry)+0));
-	spin_unlock_irqrestore(&ioapic_lock, flags);
+	ioapic_write_entry(apic, pin, entry);
 
 	enable_8259A_irq(0);
 }
@@ -1600,17 +1596,14 @@ static inline void unlock_ExtINT_logic(v
 	int apic, pin, i;
 	struct IO_APIC_route_entry entry0, entry1;
 	unsigned char save_control, save_freq_select;
-	unsigned long flags;
 
 	pin  = find_isa_irq_pin(8, mp_INT);
 	apic = find_isa_irq_apic(8, mp_INT);
 	if (pin == -1)
 		return;
 
-	spin_lock_irqsave(&ioapic_lock, flags);
-	*(((int *)&entry0) + 1) = io_apic_read(apic, 0x11 + 2 * pin);
-	*(((int *)&entry0) + 0) = io_apic_read(apic, 0x10 + 2 * pin);
-	spin_unlock_irqrestore(&ioapic_lock, flags);
+	entry0 = ioapic_read_entry(apic, pin);
+
 	clear_IO_APIC_pin(apic, pin);
 
 	memset(&entry1, 0, sizeof(entry1));
@@ -1623,10 +1616,7 @@ static inline void unlock_ExtINT_logic(v
 	entry1.trigger = 0;
 	entry1.vector = 0;
 
-	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry1) + 1));
-	io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry1) + 0));
-	spin_unlock_irqrestore(&ioapic_lock, flags);
+	ioapic_write_entry(apic, pin, entry1);
 
 	save_control = CMOS_READ(RTC_CONTROL);
 	save_freq_select = CMOS_READ(RTC_FREQ_SELECT);
@@ -1645,10 +1635,7 @@ static inline void unlock_ExtINT_logic(v
 	CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT);
 	clear_IO_APIC_pin(apic, pin);
 
-	spin_lock_irqsave(&ioapic_lock, flags);
-	io_apic_write(apic, 0x11 + 2 * pin, *(((int *)&entry0) + 1));
-	io_apic_write(apic, 0x10 + 2 * pin, *(((int *)&entry0) + 0));
-	spin_unlock_irqrestore(&ioapic_lock, flags);
+	ioapic_write_entry(apic, pin, entry0);
 }
 
 /*
Index: 2.6-git/arch/x86/kernel/io_apic_32.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_32.c
+++ 2.6-git/arch/x86/kernel/io_apic_32.c
@@ -1260,7 +1260,6 @@ static void __init setup_IO_APIC_irqs(vo
 {
 	struct IO_APIC_route_entry entry;
 	int apic, pin, idx, irq, first_notcon = 1, vector;
-	unsigned long flags;
 
 	apic_printk(APIC_VERBOSE, KERN_DEBUG "init IO_APIC IRQs\n");
 
@@ -1326,9 +1325,7 @@ static void __init setup_IO_APIC_irqs(vo
 			if (!apic && (irq < 16))
 				disable_8259A_irq(irq);
 		}
-		spin_lock_irqsave(&ioapic_lock, flags);
-		__ioapic_write_entry(apic, pin, entry);
-		spin_unlock_irqrestore(&ioapic_lock, flags);
+		ioapic_write_entry(apic, pin, entry);
 	}
 	}
 
@@ -2789,7 +2786,6 @@ int __init io_apic_get_redir_entries (in
 int io_apic_set_pci_routing (int ioapic, int pin, int irq, int edge_level, int active_high_low)
 {
 	struct IO_APIC_route_entry entry;
-	unsigned long flags;
 
 	if (!IO_APIC_IRQ(irq)) {
 		printk(KERN_ERR "IOAPIC[%d]: Invalid reference to IRQ 0\n",
@@ -2830,9 +2826,7 @@ int io_apic_set_pci_routing (int ioapic,
 	if (!ioapic && (irq < 16))
 		disable_8259A_irq(irq);
 
-	spin_lock_irqsave(&ioapic_lock, flags);
-	__ioapic_write_entry(ioapic, pin, entry);
-	spin_unlock_irqrestore(&ioapic_lock, flags);
+	ioapic_write_entry(ioapic, pin, entry);
 
 	return 0;
 }

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 3/9] x86: remove unnecessary memset()
       [not found] <20080405133903.770639386@gmail.com>
  2008-04-05 13:39 ` [patch 1/9] x86: avoid redundant loop in io_apic_level_ack_pending() Akinobu Mita
  2008-04-05 13:39 ` [patch 2/9] x86: use ioapic_read_entry() and ioapic_write_entry() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 4/9] x86: remove unnecessary tmp local variable Akinobu Mita
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-io-apic-noneed-memset-zero.patch --]
[-- Type: text/plain, Size: 640 bytes --]

No need to clear the memory allocated by alloc_bootmem().
It is already filled with zero.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/io_apic_64.c |    1 -
 1 file changed, 1 deletion(-)

Index: 2.6-git/arch/x86/kernel/io_apic_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_64.c
+++ 2.6-git/arch/x86/kernel/io_apic_64.c
@@ -2304,7 +2304,6 @@ static struct resource * __init ioapic_s
 	res = (void *)mem;
 
 	if (mem != NULL) {
-		memset(mem, 0, n);
 		mem += sizeof(struct resource) * nr_ioapics;
 
 		for (i = 0; i < nr_ioapics; i++) {

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 4/9] x86: remove unnecessary tmp local variable
       [not found] <20080405133903.770639386@gmail.com>
                   ` (2 preceding siblings ...)
  2008-04-05 13:39 ` [patch 3/9] x86: remove unnecessary memset() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 5/9] x86: use cpumask_of_cpu() Akinobu Mita
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-io-apic-kill-tmp-var.patch --]
[-- Type: text/plain, Size: 1399 bytes --]

There is no reason to use obscurer name.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/io_apic_32.c |    3 +--
 arch/x86/kernel/io_apic_64.c |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

Index: 2.6-git/arch/x86/kernel/io_apic_32.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_32.c
+++ 2.6-git/arch/x86/kernel/io_apic_32.c
@@ -2028,8 +2028,7 @@ static inline void init_IO_APIC_traps(vo
 	 * 0x80, because int 0x80 is hm, kind of importantish. ;)
 	 */
 	for (irq = 0; irq < NR_IRQS ; irq++) {
-		int tmp = irq;
-		if (IO_APIC_IRQ(tmp) && !irq_vector[tmp]) {
+		if (IO_APIC_IRQ(irq) && !irq_vector[irq]) {
 			/*
 			 * Hmm.. We don't have an entry for this,
 			 * so default to an old-fashioned 8259
Index: 2.6-git/arch/x86/kernel/io_apic_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_64.c
+++ 2.6-git/arch/x86/kernel/io_apic_64.c
@@ -1516,8 +1516,7 @@ static inline void init_IO_APIC_traps(vo
 	 * 0x80, because int 0x80 is hm, kind of importantish. ;)
 	 */
 	for (irq = 0; irq < NR_IRQS ; irq++) {
-		int tmp = irq;
-		if (IO_APIC_IRQ(tmp) && !irq_cfg[tmp].vector) {
+		if (IO_APIC_IRQ(irq) && !irq_cfg[irq].vector) {
 			/*
 			 * Hmm.. We don't have an entry for this,
 			 * so default to an old-fashioned 8259

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 5/9] x86: use cpumask_of_cpu()
       [not found] <20080405133903.770639386@gmail.com>
                   ` (3 preceding siblings ...)
  2008-04-05 13:39 ` [patch 4/9] x86: remove unnecessary tmp local variable Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 6/9] x86: use cpu_online() Akinobu Mita
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-use-cpumask_of_cpu.patch --]
[-- Type: text/plain, Size: 1981 bytes --]

Use cpumask_of_cpu() rather than the pair of cpus_clear() and cpu_set().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/cpu/mcheck/mce_amd_64.c |    4 ++--
 arch/x86/kernel/genapic_flat_64.c       |    5 +----
 arch/x86/kernel/io_apic_64.c            |    4 +---
 3 files changed, 4 insertions(+), 9 deletions(-)

Index: 2.6-git/arch/x86/kernel/genapic_flat_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/genapic_flat_64.c
+++ 2.6-git/arch/x86/kernel/genapic_flat_64.c
@@ -138,12 +138,9 @@ static cpumask_t physflat_target_cpus(vo
 
 static cpumask_t physflat_vector_allocation_domain(int cpu)
 {
-	cpumask_t domain = CPU_MASK_NONE;
-	cpu_set(cpu, domain);
-	return domain;
+	return cpumask_of_cpu(cpu);
 }
 
-
 static void physflat_send_IPI_mask(cpumask_t cpumask, int vector)
 {
 	send_IPI_mask_sequence(cpumask, vector);
Index: 2.6-git/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
+++ 2.6-git/arch/x86/kernel/cpu/mcheck/mce_amd_64.c
@@ -254,8 +254,8 @@ struct threshold_attr {
 static cpumask_t affinity_set(unsigned int cpu)
 {
 	cpumask_t oldmask = current->cpus_allowed;
-	cpumask_t newmask = CPU_MASK_NONE;
-	cpu_set(cpu, newmask);
+	cpumask_t newmask = cpumask_of_cpu(cpu);
+
 	set_cpus_allowed(current, newmask);
 	return oldmask;
 }
Index: 2.6-git/arch/x86/kernel/io_apic_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/io_apic_64.c
+++ 2.6-git/arch/x86/kernel/io_apic_64.c
@@ -1351,9 +1351,7 @@ static int ioapic_retrigger_irq(unsigned
 	unsigned long flags;
 
 	spin_lock_irqsave(&vector_lock, flags);
-	cpus_clear(mask);
-	cpu_set(first_cpu(cfg->domain), mask);
-
+	mask = cpumask_of_cpu(first_cpu(cfg->domain));
 	send_IPI_mask(mask, cfg->vector);
 	spin_unlock_irqrestore(&vector_lock, flags);
 

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 6/9] x86: use cpu_online()
       [not found] <20080405133903.770639386@gmail.com>
                   ` (4 preceding siblings ...)
  2008-04-05 13:39 ` [patch 5/9] x86: use cpumask_of_cpu() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 7/9] use BUILD_BUG_ON() for the size of struct intel_mp_floating Akinobu Mita
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-use-cpu_online.patch --]
[-- Type: text/plain, Size: 893 bytes --]

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/reboot.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Index: 2.6-git/arch/x86/kernel/reboot.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/reboot.c
+++ 2.6-git/arch/x86/kernel/reboot.c
@@ -412,12 +412,12 @@ static void native_machine_shutdown(void
 #ifdef CONFIG_X86_32
 	/* See if there has been given a command line override */
 	if ((reboot_cpu != -1) && (reboot_cpu < NR_CPUS) &&
-		cpu_isset(reboot_cpu, cpu_online_map))
+		cpu_online(reboot_cpu))
 		reboot_cpu_id = reboot_cpu;
 #endif
 
 	/* Make certain the cpu I'm about to reboot on is online */
-	if (!cpu_isset(reboot_cpu_id, cpu_online_map))
+	if (!cpu_online(reboot_cpu_id))
 		reboot_cpu_id = smp_processor_id();
 
 	/* Make certain I only run on the appropriate processor */

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 7/9] use BUILD_BUG_ON() for the size of struct intel_mp_floating
       [not found] <20080405133903.770639386@gmail.com>
                   ` (5 preceding siblings ...)
  2008-04-05 13:39 ` [patch 6/9] x86: use cpu_online() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 8/9] x86_64: use MP_intsrc_info() Akinobu Mita
  2008-04-05 13:39 ` [patch 9/9] x86: use bitmap library for pin_programmed Akinobu Mita
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-use-build-bug-on.patch --]
[-- Type: text/plain, Size: 1947 bytes --]

Use BUILD_BUG_ON() rather than runtime diagnosis (in i386)
or compile-time error technology with extern non-exsistent function
(in x86_64)

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/mpparse_32.c |    7 +++----
 arch/x86/kernel/mpparse_64.c |    8 +++-----
 2 files changed, 6 insertions(+), 9 deletions(-)

Index: 2.6-git/arch/x86/kernel/mpparse_32.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_32.c
+++ 2.6-git/arch/x86/kernel/mpparse_32.c
@@ -716,14 +716,13 @@ void __init get_smp_config (void)
 	 */
 }
 
-static int __init smp_scan_config (unsigned long base, unsigned long length)
+static int __init smp_scan_config(unsigned long base, unsigned long length)
 {
 	unsigned long *bp = phys_to_virt(base);
 	struct intel_mp_floating *mpf;
 
-	printk(KERN_INFO "Scan SMP from %p for %ld bytes.\n", bp,length);
-	if (sizeof(*mpf) != 16)
-		printk("Error: MPF size\n");
+	printk(KERN_INFO "Scan SMP from %p for %ld bytes.\n", bp, length);
+	BUILD_BUG_ON(sizeof(*mpf) != 16);
 
 	while (length > 0) {
 		mpf = (struct intel_mp_floating *)bp;
Index: 2.6-git/arch/x86/kernel/mpparse_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_64.c
+++ 2.6-git/arch/x86/kernel/mpparse_64.c
@@ -534,15 +534,13 @@ void __init get_smp_config (void)
 	 */
 }
 
-static int __init smp_scan_config (unsigned long base, unsigned long length)
+static int __init smp_scan_config(unsigned long base, unsigned long length)
 {
-	extern void __bad_mpf_size(void); 
 	unsigned int *bp = phys_to_virt(base);
 	struct intel_mp_floating *mpf;
 
-	Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
-	if (sizeof(*mpf) != 16)
-		__bad_mpf_size();
+	Dprintk("Scan SMP from %p for %ld bytes.\n", bp, length);
+	BUILD_BUG_ON(sizeof(*mpf) != 16);
 
 	while (length > 0) {
 		mpf = (struct intel_mp_floating *)bp;

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 8/9] x86_64: use MP_intsrc_info()
       [not found] <20080405133903.770639386@gmail.com>
                   ` (6 preceding siblings ...)
  2008-04-05 13:39 ` [patch 7/9] use BUILD_BUG_ON() for the size of struct intel_mp_floating Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  2008-04-05 13:39 ` [patch 9/9] x86: use bitmap library for pin_programmed Akinobu Mita
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-use-MP_intsrc_info.patch --]
[-- Type: text/plain, Size: 3900 bytes --]

Remove duplicate code by using MP_intsrc_info() in mpparse_{32,64}.c

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/mpparse_32.c |   23 ++++-------------------
 arch/x86/kernel/mpparse_64.c |   23 ++++-------------------
 2 files changed, 8 insertions(+), 38 deletions(-)

Index: 2.6-git/arch/x86/kernel/mpparse_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_64.c
+++ 2.6-git/arch/x86/kernel/mpparse_64.c
@@ -193,9 +193,9 @@ static void __init MP_ioapic_info (struc
 	nr_ioapics++;
 }
 
-static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
+static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
 {
-	mp_irqs [mp_irq_entries] = *m;
+	mp_irqs[mp_irq_entries] = *m;
 	Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
 		" IRQ %02x, APIC ID %x, APIC INT %02x\n",
 			m->mpc_irqtype, m->mpc_irqflag & 3,
@@ -741,14 +741,7 @@ mp_override_legacy_irq(u8 bus_irq, u8 po
 	intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;	   /* APIC ID */
 	intsrc.mpc_dstirq = pin;				    /* INTIN# */
 
-	Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n", 
-		intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-		(intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-		intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
-
-	mp_irqs[mp_irq_entries] = intsrc;
-	if (++mp_irq_entries == MAX_IRQ_SOURCES)
-		panic("Max # of irq sources exceeded!\n");
+	MP_intsrc_info(&intsrc);
 }
 
 void __init mp_config_acpi_legacy_irqs(void)
@@ -803,15 +796,7 @@ void __init mp_config_acpi_legacy_irqs(v
 		intsrc.mpc_srcbusirq = i;		   /* Identity mapped */
 		intsrc.mpc_dstirq = i;
 
-		Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
-			"%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-			(intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-			intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, 
-			intsrc.mpc_dstirq);
-
-		mp_irqs[mp_irq_entries] = intsrc;
-		if (++mp_irq_entries == MAX_IRQ_SOURCES)
-			panic("Max # of irq sources exceeded!\n");
+		MP_intsrc_info(&intsrc);
 	}
 }
 
Index: 2.6-git/arch/x86/kernel/mpparse_32.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_32.c
+++ 2.6-git/arch/x86/kernel/mpparse_32.c
@@ -274,9 +274,9 @@ static void __init MP_ioapic_info (struc
 	nr_ioapics++;
 }
 
-static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
+static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
 {
-	mp_irqs [mp_irq_entries] = *m;
+	mp_irqs[mp_irq_entries] = *m;
 	Dprintk("Int: type %d, pol %d, trig %d, bus %d,"
 		" IRQ %02x, APIC ID %x, APIC INT %02x\n",
 			m->mpc_irqtype, m->mpc_irqflag & 3,
@@ -960,14 +960,7 @@ mp_override_legacy_irq(u8 bus_irq, u8 po
 	intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;	   /* APIC ID */
 	intsrc.mpc_dstirq = pin;				    /* INTIN# */
 
-	Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, %d-%d\n",
-		intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-		(intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-		intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, intsrc.mpc_dstirq);
-
-	mp_irqs[mp_irq_entries] = intsrc;
-	if (++mp_irq_entries == MAX_IRQ_SOURCES)
-		panic("Max # of irq sources exceeded!\n");
+	MP_intsrc_info(&intsrc);
 }
 
 void __init mp_config_acpi_legacy_irqs (void)
@@ -1029,15 +1022,7 @@ void __init mp_config_acpi_legacy_irqs (
 		intsrc.mpc_srcbusirq = i;		   /* Identity mapped */
 		intsrc.mpc_dstirq = i;
 
-		Dprintk("Int: type %d, pol %d, trig %d, bus %d, irq %d, "
-			"%d-%d\n", intsrc.mpc_irqtype, intsrc.mpc_irqflag & 3, 
-			(intsrc.mpc_irqflag >> 2) & 3, intsrc.mpc_srcbus, 
-			intsrc.mpc_srcbusirq, intsrc.mpc_dstapic, 
-			intsrc.mpc_dstirq);
-
-		mp_irqs[mp_irq_entries] = intsrc;
-		if (++mp_irq_entries == MAX_IRQ_SOURCES)
-			panic("Max # of irq sources exceeded!\n");
+		MP_intsrc_info(&intsrc);
 	}
 }
 

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [patch 9/9] x86: use bitmap library for pin_programmed
       [not found] <20080405133903.770639386@gmail.com>
                   ` (7 preceding siblings ...)
  2008-04-05 13:39 ` [patch 8/9] x86_64: use MP_intsrc_info() Akinobu Mita
@ 2008-04-05 13:39 ` Akinobu Mita
  8 siblings, 0 replies; 9+ messages in thread
From: Akinobu Mita @ 2008-04-05 13:39 UTC (permalink / raw)
  To: linux-kernel; +Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin

[-- Attachment #1: x86-mpparse-use-bitmap.patch --]
[-- Type: text/plain, Size: 3893 bytes --]

Use bitmap library for pin_programmed rather than reinvent
bitmaps.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 arch/x86/kernel/mpparse_32.c |   15 ++++++---------
 arch/x86/kernel/mpparse_64.c |   16 +++++++---------
 2 files changed, 13 insertions(+), 18 deletions(-)

Index: 2.6-git/arch/x86/kernel/mpparse_64.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_64.c
+++ 2.6-git/arch/x86/kernel/mpparse_64.c
@@ -21,6 +21,7 @@
 #include <linux/mc146818rtc.h>
 #include <linux/acpi.h>
 #include <linux/module.h>
+#include <linux/bitmap.h>
 
 #include <asm/smp.h>
 #include <asm/mtrr.h>
@@ -643,7 +644,7 @@ static struct mp_ioapic_routing {
 	int			apic_id;
 	int			gsi_start;
 	int			gsi_end;
-	u32			pin_programmed[4];
+	DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
 } mp_ioapic_routing[MAX_IO_APICS];
 
 static int mp_find_ioapic(int gsi)
@@ -802,9 +803,8 @@ void __init mp_config_acpi_legacy_irqs(v
 
 int mp_register_gsi(u32 gsi, int triggering, int polarity)
 {
-	int ioapic = -1;
-	int ioapic_pin = 0;
-	int idx, bit = 0;
+	int ioapic;
+	int ioapic_pin;
 
 	if (acpi_irq_model != ACPI_IRQ_MODEL_IOAPIC)
 		return gsi;
@@ -826,21 +826,19 @@ int mp_register_gsi(u32 gsi, int trigger
 	 * with redundant pin->gsi mappings (but unique PCI devices);
 	 * we only program the IOAPIC on the first.
 	 */
-	bit = ioapic_pin % 32;
-	idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
-	if (idx > 3) {
+	if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
 		printk(KERN_ERR "Invalid reference to IOAPIC pin "
 			"%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
 			ioapic_pin);
 		return gsi;
 	}
-	if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
+	if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
 		Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
 			mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
 		return gsi;
 	}
 
-	mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
+	set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
 
 	io_apic_set_pci_routing(ioapic, ioapic_pin, gsi,
 		triggering == ACPI_EDGE_SENSITIVE ? 0 : 1,
Index: 2.6-git/arch/x86/kernel/mpparse_32.c
===================================================================
--- 2.6-git.orig/arch/x86/kernel/mpparse_32.c
+++ 2.6-git/arch/x86/kernel/mpparse_32.c
@@ -859,7 +859,7 @@ static struct mp_ioapic_routing {
 	int			apic_id;
 	int			gsi_base;
 	int			gsi_end;
-	u32			pin_programmed[4];
+	DECLARE_BITMAP(pin_programmed, MP_MAX_IOAPIC_PIN + 1);
 } mp_ioapic_routing[MAX_IO_APICS];
 
 static int mp_find_ioapic (int gsi)
@@ -1031,9 +1031,8 @@ void __init mp_config_acpi_legacy_irqs (
 
 int mp_register_gsi(u32 gsi, int triggering, int polarity)
 {
-	int ioapic = -1;
-	int ioapic_pin = 0;
-	int idx, bit = 0;
+	int ioapic;
+	int ioapic_pin;
 	static int pci_irq = IRQ_COMPRESSION_START;
 	/*
 	 * Mapping between Global System Interrupts, which
@@ -1062,21 +1061,19 @@ int mp_register_gsi(u32 gsi, int trigger
 	 * with redundant pin->gsi mappings (but unique PCI devices);
 	 * we only program the IOAPIC on the first.
 	 */
-	bit = ioapic_pin % 32;
-	idx = (ioapic_pin < 32) ? 0 : (ioapic_pin / 32);
-	if (idx > 3) {
+	if (ioapic_pin > MP_MAX_IOAPIC_PIN) {
 		printk(KERN_ERR "Invalid reference to IOAPIC pin "
 			"%d-%d\n", mp_ioapic_routing[ioapic].apic_id, 
 			ioapic_pin);
 		return gsi;
 	}
-	if ((1<<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {
+	if (test_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed)) {
 		Dprintk(KERN_DEBUG "Pin %d-%d already programmed\n",
 			mp_ioapic_routing[ioapic].apic_id, ioapic_pin);
 		return (gsi < IRQ_COMPRESSION_START ? gsi : gsi_to_irq[gsi]);
 	}
 
-	mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1<<bit);
+	set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
 
 	/*
 	 * For GSI >= 64, use IRQ compression

-- 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-04-05 13:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20080405133903.770639386@gmail.com>
2008-04-05 13:39 ` [patch 1/9] x86: avoid redundant loop in io_apic_level_ack_pending() Akinobu Mita
2008-04-05 13:39 ` [patch 2/9] x86: use ioapic_read_entry() and ioapic_write_entry() Akinobu Mita
2008-04-05 13:39 ` [patch 3/9] x86: remove unnecessary memset() Akinobu Mita
2008-04-05 13:39 ` [patch 4/9] x86: remove unnecessary tmp local variable Akinobu Mita
2008-04-05 13:39 ` [patch 5/9] x86: use cpumask_of_cpu() Akinobu Mita
2008-04-05 13:39 ` [patch 6/9] x86: use cpu_online() Akinobu Mita
2008-04-05 13:39 ` [patch 7/9] use BUILD_BUG_ON() for the size of struct intel_mp_floating Akinobu Mita
2008-04-05 13:39 ` [patch 8/9] x86_64: use MP_intsrc_info() Akinobu Mita
2008-04-05 13:39 ` [patch 9/9] x86: use bitmap library for pin_programmed Akinobu Mita

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox