From: Borislav Petkov <bp@alien8.de>
To: John Stultz <john.stultz@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Jiri Kosina <jkosina@suse.cz>, Borislav Petkov <bp@suse.de>,
Thomas Gleixner <tglx@linutronix.de>,
Rabin Vincent <rabin.vincent@stericsson.com>
Subject: Re: [PATCH] RTC: Add an alarm disable quirk
Date: Fri, 19 Jul 2013 16:26:28 +0200 [thread overview]
Message-ID: <20130719142628.GC19581@pd.tnic> (raw)
In-Reply-To: <20130718225349.GD15992@pd.tnic>
On Fri, Jul 19, 2013 at 12:53:49AM +0200, Borislav Petkov wrote:
> > I assumed it was some sort of BIOS issue where any modification of the
> > RTC_AIE bit caused the alarm irq line to be left high(or something
> > like that) that triggered the immediate power-on on shutdown. But I've
> > not been able to dig down on this.
>
> Ha, this actually fits like an ass on a bucket (don't ask - German
> proverb :-)).
>
> If what you're saying is actually the case, then this explains why not
> writing to 0xb doesn't cause the alarm irq to fire.
>
> Btw, in the trace above we do the disabling twice. Once from
> rtc_timer_remove() and then again from rtc_timer_do_work().
>
> So, if we disable it once and we touch RTC_AIE again causing the second
> time to rearm the alarm irq, this would explain the issue. Which reminds
> me:
>
> Maybe we should read out the alarm interrupt first and disable it only
> if it is enabled - that would save us the modification of RTC_AIE. Cool,
> I'll try that tomorrow.
Well, the below seems to do the trick. But since I don't trust the BIOS
in any way, I'll run it a couple more days here. Btw, I think we should
commit this regardless, as it saves us unneeded writes:
---
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index be06d7150de5..bb265f1651e7 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -304,6 +304,9 @@ static void cmos_irq_enable(struct cmos_rtc *cmos, unsigned char mask)
rtc_control = CMOS_READ(RTC_CONTROL);
cmos_checkintr(cmos, rtc_control);
+ if (rtc_control == mask)
+ return;
+
rtc_control |= mask;
CMOS_WRITE(rtc_control, RTC_CONTROL);
hpet_set_rtc_irq_bit(mask);
@@ -316,6 +319,10 @@ static void cmos_irq_disable(struct cmos_rtc *cmos, unsigned char mask)
unsigned char rtc_control;
rtc_control = CMOS_READ(RTC_CONTROL);
+
+ if (!(rtc_control & mask))
+ return;
+
rtc_control &= ~mask;
CMOS_WRITE(rtc_control, RTC_CONTROL);
hpet_mask_rtc_irq_bit(mask);
--
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
next prev parent reply other threads:[~2013-07-19 14:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-18 15:44 [PATCH] RTC: Add an alarm disable quirk Borislav Petkov
2013-07-18 16:35 ` John Stultz
2013-07-18 22:53 ` Borislav Petkov
2013-07-19 14:26 ` Borislav Petkov [this message]
2013-07-19 15:13 ` Borislav Petkov
2013-07-19 21:34 ` Borislav Petkov
2013-07-20 17:00 ` [PATCH -v2] " Borislav Petkov
2013-07-22 21:00 ` John Stultz
2013-07-22 21:19 ` Borislav Petkov
2013-07-22 22:03 ` John Stultz
2013-07-22 20:59 ` [PATCH] " John Stultz
2013-07-22 21:12 ` Borislav Petkov
2013-07-22 21:15 ` John Stultz
2013-07-22 21:27 ` Borislav Petkov
2013-07-22 22:17 ` John Stultz
2013-07-23 5:03 ` Borislav Petkov
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=20130719142628.GC19581@pd.tnic \
--to=bp@alien8.de \
--cc=bp@suse.de \
--cc=jkosina@suse.cz \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rabin.vincent@stericsson.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