From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: [patch 9/9] x86: use bitmap library for pin_programmed
Date: Sat, 05 Apr 2008 22:39:12 +0900 [thread overview]
Message-ID: <47f783c4.1aad7e0a.12c1.24dc@mx.google.com> (raw)
In-Reply-To: 20080405133903.770639386@gmail.com
[-- 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
--
prev parent reply other threads:[~2008-04-05 13:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[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 ` Akinobu Mita [this message]
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=47f783c4.1aad7e0a.12c1.24dc@mx.google.com \
--to=akinobu.mita@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox