From: Andrew Morton <akpm@google.com>
To: Daniel Drake <dsd@laptop.org>
Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de,
mingo@redhat.com, hpa@zytor.com, rjw@sisk.pl,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC] wait for VX855 RTC to become ready during resume
Date: Mon, 19 Sep 2011 14:28:01 -0700 [thread overview]
Message-ID: <20110919142801.101ae0ad.akpm@google.com> (raw)
In-Reply-To: <20110919103637.E116D9D401D@zog.reactivated.net>
On Mon, 19 Sep 2011 11:36:37 +0100 (BST)
Daniel Drake <dsd@laptop.org> wrote:
> Hi,
>
> As diagnosed at http://dev.laptop.org/ticket/10757 we are finding that
> the RTC on the VIA VX855 frequently is not 'ready' during system resume.
>
> Reading from it produces zero. This causes the resume code to fail to
> increment the system clock for the amount of time that was spent sleeping,
> so the time is then wrong.
>
> We have found that if we wait for the RTC_REF_CLCK_32KHZ signal, the RTC
> does soon start returning 'good' values.
>
> The patch below demonstrates the solution we have found, but will probably
> make x86 maintainers cry. What would be a good approach to get this
> appropriately quirked and worked around? Detect VX855 southbridge on PCI bus
> and apply the quirk in this case? Do it from OLPC platform code?
>
> Thanks,
> Daniel
>
>
> ---
> arch/x86/kernel/rtc.c | 15 +++++++++++++++
> 1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/arch/x86/kernel/rtc.c b/arch/x86/kernel/rtc.c
> index 88ee70d..3ad2e47 100644
> --- a/arch/x86/kernel/rtc.c
> +++ b/arch/x86/kernel/rtc.c
> @@ -100,6 +100,21 @@ unsigned long mach_get_cmos_time(void)
> unsigned int status, year, mon, day, hour, min, sec, century = 0;
>
> /*
> + * dev.laptop.org #10757, sometimes the RTC returns zero data
> + * immediately after a resume, so this code will give it some
> + * more time by waiting for the 32KHz clock bit to be set, in the
> + * hope that this means it is ready to be used.
> + */
> + if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_REF_CLCK_32KHZ)) {
> + int n = 0;
> + printk(KERN_INFO "rtc is insane, waiting for it\n");
> + while (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_REF_CLCK_32KHZ)) {
> + cpu_relax();
> + n++;
> + }
> + printk(KERN_INFO "rtc was insane for %d counts\n", n);
> + }
If the rtc is permanently insane, the kernel locks up. I'd suggest
adding a timeout.
Perhaps also replace the cpu_relax() with a udelay(1), so the timeout
can be properly implemented and so that the information in that printk
has some useful meaning: "102 microseconds" is better than "11,434 counts".
next prev parent reply other threads:[~2011-09-19 21:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-19 10:36 [RFC] wait for VX855 RTC to become ready during resume Daniel Drake
2011-09-19 21:28 ` Andrew Morton [this message]
2011-10-18 7:24 ` Daniel Drake
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=20110919142801.101ae0ad.akpm@google.com \
--to=akpm@google.com \
--cc=akpm@linux-foundation.org \
--cc=dsd@laptop.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rjw@sisk.pl \
--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