Skip to content

Commit

Permalink
x86_64: use the global PIT lock
Browse files Browse the repository at this point in the history
Replace the pcspkr private PIT lock by the global PIT lock to serialize the
PIT access all over the place.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Thomas Gleixner authored and Linus Torvalds committed Jul 22, 2007
1 parent 021daae commit 28318da
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions arch/x86_64/kernel/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <acpi/acpi_bus.h>
#endif
#include <asm/8253pit.h>
#include <asm/i8253.h>
#include <asm/pgtable.h>
#include <asm/vsyscall.h>
#include <asm/timex.h>
Expand All @@ -51,6 +52,7 @@ static char *timename = NULL;
DEFINE_SPINLOCK(rtc_lock);
EXPORT_SYMBOL(rtc_lock);
DEFINE_SPINLOCK(i8253_lock);
EXPORT_SYMBOL(i8253_lock);

volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;

Expand Down
11 changes: 8 additions & 3 deletions drivers/input/misc/pcspkr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_DESCRIPTION("PC Speaker beeper driver");
MODULE_LICENSE("GPL");

static DEFINE_SPINLOCK(i8253_beep_lock);
#ifdef CONFIG_X86
/* Use the global PIT lock ! */
#include <asm/i8253.h>
#else
static DEFINE_SPINLOCK(i8253_lock);
#endif

static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
{
Expand All @@ -43,7 +48,7 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
if (value > 20 && value < 32767)
count = PIT_TICK_RATE / value;

spin_lock_irqsave(&i8253_beep_lock, flags);
spin_lock_irqsave(&i8253_lock, flags);

if (count) {
/* enable counter 2 */
Expand All @@ -58,7 +63,7 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
outb(inb_p(0x61) & 0xFC, 0x61);
}

spin_unlock_irqrestore(&i8253_beep_lock, flags);
spin_unlock_irqrestore(&i8253_lock, flags);

return 0;
}
Expand Down
6 changes: 6 additions & 0 deletions include/asm-x86_64/i8253.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __ASM_I8253_H__
#define __ASM_I8253_H__

extern spinlock_t i8253_lock;

#endif /* __ASM_I8253_H__ */

0 comments on commit 28318da

Please sign in to comment.