From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
Keir Fraser <keir@xen.org>, Tim Deegan <tim@xen.org>
Subject: Re: [PATCH] x86/ACPI: allow CMOS RTC use even when ACPI says there is none
Date: Mon, 28 Jul 2014 14:04:59 +0100 [thread overview]
Message-ID: <53D64A7B.9080600@citrix.com> (raw)
In-Reply-To: <53D6627B02000078000269B3@mail.emea.novell.com>
On 28/07/14 13:47, Jan Beulich wrote:
>
>>> +
>>> + start = NOW();
>>> + do { /* must try at least 2.228 ms */
>>> + t2 = NOW() - start;
>>> + } while ( (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) &&
>>> + t2 < MILLISECS(3) );
>>> +
>>> + __get_cmos_time(&rtc);
>>> +
>>> + spin_unlock_irqrestore(&rtc_lock, flags);
>>> +
>>> + if ( likely(!cmos_rtc_probe) ||
>>> + t1 > SECONDS(1) || t2 >= MILLISECS(3) ||
>>> + rtc.sec >= 60 || rtc.min >= 60 || rtc.hour >= 24 ||
>>> + !rtc.day || rtc.day > 31 ||
>>> + !rtc.mon || rtc.mon > 12 )
>>> break;
>>> - for ( i = 0 ; i < 1000000 ; i++ ) /* must try at least 2.228 ms */
>>> - if ( !(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) )
>>> +
>>> + if ( seconds < 60 )
>> Seconds doesn't appear to be updated before this point, meaning that we
>> will reprobe even if we find a plausible RTC.
> But that's exactly the point: We want to go through the loop twice.
> Only if the second round results in updated seconds do we consider
> the RTC okay for use.
Right, but in the case that the RTC is handing back static values (which
is slightly more likely if we are probing something which might not be a
CMOS RTC), we will sit in the loop forever.
If on the second iteration seconds haven’t increased we should declare
the probe to have failed.
>
>>> + {
>>> + if ( rtc.sec != seconds )
>>> + cmos_rtc_probe = 0;
>>> break;
>>> + }
>>> +
>>> + process_pending_softirqs();
>>> +
>>> + seconds = rtc.sec;
>>> + }
>>>
>>> - res = __get_cmos_time();
>>> + if ( unlikely(cmos_rtc_probe) )
>>> + panic("No CMOS RTC found - system must be booted from EFI");
>> What happens in the case that we broke because of the validity checks
>> for t1,t2 or rtc ? Do we want to differentiate between "no RTC" and
>> "RTC giving bogus values" ?
> How would you suggest to tell one from the other?
>
> Jan
>
Now you put it like that, those two cases are rather hard to disentangle.
~Andrew
next prev parent reply other threads:[~2014-07-28 13:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 14:57 [PATCH] x86/ACPI: allow CMOS RTC use even when ACPI says there is none Jan Beulich
2014-07-28 12:40 ` Andrew Cooper
2014-07-28 12:47 ` Jan Beulich
2014-07-28 13:04 ` Andrew Cooper [this message]
2014-07-28 13:32 ` Jan Beulich
2014-07-28 13:46 ` Andrew Cooper
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=53D64A7B.9080600@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).