mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: davej@codemonkey.org.uk
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org
Subject: i8253 locking.
Date: Thu, 15 May 2003 04:31:00 +0100	[thread overview]
Message-ID: <200305150331.h4F3V00h000522@deviant.impure.org.uk> (raw)

There are still a few places where we play with the RTC
directly, with no locking. This catches some of them.

--- bk-linus/arch/i386/kernel/apm.c	2003-05-11 22:59:28.000000000 +0100
+++ linux-2.5/arch/i386/kernel/apm.c	2003-05-15 03:10:19.000000000 +0100
@@ -1166,9 +1166,13 @@ static void get_time_diff(void)
 #endif
 }
 
-static inline void reinit_timer(void)
+static void reinit_timer(void)
 {
 #ifdef INIT_TIMER_AFTER_SUSPEND
+	unsigned long	flags;
+	extern spinlock_t i8253_lock;
+
+	spin_lock_irqsave(&i8253_lock, flags);
 	/* set the clock to 100 Hz */
 	outb_p(0x34, PIT_MODE);		/* binary, mode 2, LSB/MSB, ch 0 */
 	udelay(10);
@@ -1176,6 +1180,7 @@ static inline void reinit_timer(void)
 	udelay(10);
 	outb(LATCH >> 8, PIT_CH0);	/* MSB */
 	udelay(10);
+	spin_unlock_irqrestore(&i8253_lock, flags);
 #endif
 }
 
diff -urpN --exclude-from=/home/davej/.exclude bk-linus/arch/i386/kernel/i8259.c linux-2.5/arch/i386/kernel/i8259.c
--- bk-linus/arch/i386/kernel/i8259.c	2003-04-22 00:40:42.000000000 +0100
+++ linux-2.5/arch/i386/kernel/i8259.c	2003-04-22 01:23:12.000000000 +0100
@@ -373,11 +373,16 @@ void __init init_ISA_irqs (void)
 
 static void setup_timer(void)
 {
+	extern spinlock_t i8253_lock;
+	unsigned long flags;
+
+	spin_lock_irqsave(&i8253_lock, flags);
 	outb_p(0x34,PIT_MODE);		/* binary, mode 2, LSB/MSB, ch 0 */
 	udelay(10);
 	outb_p(LATCH & 0xff , PIT_CH0);	/* LSB */
 	udelay(10);
 	outb(LATCH >> 8 , PIT_CH0);	/* MSB */
+	spin_unlock_irqrestore(&i8253_lock, flags);
 }
 
 static int timer_resume(struct device *dev, u32 level)

                 reply	other threads:[~2003-05-15  3:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200305150331.h4F3V00h000522@deviant.impure.org.uk \
    --to=davej@codemonkey.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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

all inboxes | Powered by JetHome®