Skip to content

Commit

Permalink
x86: use bitmap library for pin_programmed
Browse files Browse the repository at this point in the history
Use bitmap library for pin_programmed rather than reinvent
bitmaps.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Akinobu Mita authored and Ingo Molnar committed Apr 26, 2008
1 parent 4abc1a0 commit a1a33fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions arch/x86/kernel/mpparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,6 @@ void __init find_smp_config(void)
#ifdef CONFIG_X86_IO_APIC

#define MP_ISA_BUS 0
#define MP_MAX_IOAPIC_PIN 127

extern struct mp_ioapic_routing mp_ioapic_routing[MAX_IO_APICS];

Expand Down Expand Up @@ -982,9 +981,8 @@ void __init mp_config_acpi_legacy_irqs(void)

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;
#ifdef CONFIG_X86_32
#define MAX_GSI_NUM 4096
#define IRQ_COMPRESSION_START 64
Expand Down Expand Up @@ -1024,15 +1022,13 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
* 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);
#ifdef CONFIG_X86_32
Expand All @@ -1042,7 +1038,7 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
#endif
}

mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1 << bit);
set_bit(ioapic_pin, mp_ioapic_routing[ioapic].pin_programmed);
#ifdef CONFIG_X86_32
/*
* For GSI >= 64, use IRQ compression
Expand Down
6 changes: 4 additions & 2 deletions include/asm-x86/io_apic.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __ASM_IO_APIC_H
#define __ASM_IO_APIC_H

#include <asm/types.h>
#include <linux/types.h>
#include <asm/mpspec.h>
#include <asm/apicdef.h>

Expand Down Expand Up @@ -110,11 +110,13 @@ extern int nr_ioapic_registers[MAX_IO_APICS];
* MP-BIOS irq configuration table structures:
*/

#define MP_MAX_IOAPIC_PIN 127

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);
};

/* I/O APIC entries */
Expand Down

0 comments on commit a1a33fa

Please sign in to comment.