LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "David P. Reed" <dpreed@reed.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: linux-kernel@vger.kernel.org, "David P. Reed" <dpreed@reed.com>
Subject: [PATCH 3/3] x86: fix pcspkr to not use inb_p/outb_p calls.
Date: Sun, 17 Feb 2008 16:56:42 -0500 (EST) [thread overview]
Message-ID: <6gr00g$g7cmat@smtp01.lnh.mail.rcn.net> (raw)
[-- Attachment #1: fix-pcspkr-iodelay.patch --]
[-- Type: text/plain, Size: 2104 bytes --]
Fix pcspkr driver to use explicit timing delay for access to PIT,
rather than inb_p/outb_p calls, which use insufficiently explicit
delays (defaulting to port 80 writes) that can cause freeze problems
on some machines, such as Quanta moterboard machines using ENE EC's.
The explicit timing delay is only needed for accesses to the 8253 PIT.
The standard requirement for the 8253 to respond to successive writes
is 1 microsecond. The 8253 has never been on the expansion bus, so
a proper delay has nothing to do with expansion bus timing, but instead
its internal logic's capability to react to input. Since udelay is correctly
calibrated by the time the pcspkr driver is initialized, we use 1 microsecond
as the timing.
Also shorten lines to less than 80 characters.
Signed-off-by: David P. Reed <dpreed@reed.com>
Index: linux-2.6/drivers/input/misc/pcspkr.c
===================================================================
--- linux-2.6.orig/drivers/input/misc/pcspkr.c
+++ linux-2.6/drivers/input/misc/pcspkr.c
@@ -32,9 +32,11 @@ MODULE_ALIAS("platform:pcspkr");
static DEFINE_SPINLOCK(i8253_lock);
#endif
-static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
+static int pcspkr_event(struct input_dev *dev, unsigned int type,
+ unsigned int code, int value)
{
unsigned int count = 0;
+ unsigned char mask;
unsigned long flags;
if (type != EV_SND)
@@ -51,17 +53,21 @@ static int pcspkr_event(struct input_dev
spin_lock_irqsave(&i8253_lock, flags);
+ mask = inb(0x61);
if (count) {
/* enable counter 2 */
- outb_p(inb_p(0x61) | 3, 0x61);
+ outb(mask | 3, 0x61);
+ /* some 8253's may require 1 usec. between accesses */
/* set command for counter 2, 2 byte write */
- outb_p(0xB6, 0x43);
+ outb(0xB6, 0x43);
+ udelay(1);
/* select desired HZ */
- outb_p(count & 0xff, 0x42);
+ outb(count & 0xff, 0x42);
+ udelay(1);
outb((count >> 8) & 0xff, 0x42);
} else {
/* disable counter 2 */
- outb(inb_p(0x61) & 0xFC, 0x61);
+ outb(mask & 0xFC, 0x61);
}
spin_unlock_irqrestore(&i8253_lock, flags);
--
next reply other threads:[~2008-02-17 21:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-17 21:56 David P. Reed [this message]
2008-02-17 22:23 ` Alan Cox
2008-02-18 3:12 ` Ingo Molnar
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='6gr00g$g7cmat@smtp01.lnh.mail.rcn.net' \
--to=dpreed@reed.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--subject='Re: [PATCH 3/3] x86: fix pcspkr to not use inb_p/outb_p calls.' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).