public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hood <jdthood@mail.com>
To: Jonathan Lundell <jlundell@pobox.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Question about rtc_lock
Date: 06 Oct 2001 23:24:02 -0400	[thread overview]
Message-ID: <1002425044.978.57.camel@thanatos> (raw)
In-Reply-To: <p05100304b7e4d1f5b152@[207.213.214.37]>
In-Reply-To: <E15prGs-0001G3-00@the-village.bc.nu> <1002379256.857.3.camel@thanatos>  <p05100304b7e4d1f5b152@[207.213.214.37]>

On Sat, 2001-10-06 at 11:24, Jonathan Lundell wrote:
> rtc_interrupt(), you mean.

Right.

> Even if there weren't current interrupt code doing CMOS accesses, it 
> would seem prudent to assume that there might be eventually, the 
> RTC/NVRAM being a multi-purpose shared resource.

I'm not concerned about an irq handler (present or future)
interfering with us as we write to the CMOS RAM.  What I'm
concerned about is getting a rtc interrupt while we hold rtc_lock,
with deadlock being the result (since rtc_interrupt will spin on
the lock).

Either (1) we need to change these spinlocks to _irq, or (2) we
need to know that this bit of code runs only with irqs disabled.
My question is: Is it (1) or (2)?

Or is it (3) Thomas Hood is failing to understand something here?

Assuming the answer is (1), I append a patch that changes the
spinlock calls to _irqsave versions.

Cheers,
Thomas

The patch:
--- linux-2.4.10-ac5-fix/arch/i386/kernel/bootflag.c_PREV	Fri Oct  5 23:20:43 2001
+++ linux-2.4.10-ac5-fix/arch/i386/kernel/bootflag.c	Sat Oct  6 23:15:33 2001
@@ -81,26 +81,30 @@
 
 static void __init sbf_write(u8 v)
 {
+	unsigned long flags;
+
 	if(sbf_port != -1)
 	{
 		v &= ~(1<<7);
 		if(!parity(v))
 			v|=1<<7;
 			
-		spin_lock(&rtc_lock);
+		spin_lock_irqsave(&rtc_lock, flags);
 		CMOS_WRITE(v, sbf_port);
-		spin_unlock(&rtc_lock);
+		spin_unlock_irqrestore(&rtc_lock, flags);
 	}
 }
 
 static u8 __init sbf_read(void)
 {
 	u8 v;
+	unsigned long flags;
+
 	if(sbf_port == -1)
 		return 0;
-	spin_lock(&rtc_lock);
+	spin_lock_irqsave(&rtc_lock, flags);
 	v = CMOS_READ(sbf_port);
-	spin_unlock(&rtc_lock);
+	spin_unlock_irqrestore(&rtc_lock, flags);
 	return v;
 }
 


      reply	other threads:[~2001-10-07  3:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-06  3:49 Question about rtc_lock Thomas Hood
2001-10-06 13:01 ` Alan Cox
2001-10-06 13:06   ` Thomas Hood
2001-10-06 13:13     ` Alan Cox
2001-10-06 14:40       ` Thomas Hood
2001-10-06 15:24         ` Jonathan Lundell
2001-10-07  3:24           ` Thomas Hood [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=1002425044.978.57.camel@thanatos \
    --to=jdthood@mail.com \
    --cc=jlundell@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    /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