From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86/ACPI: allow CMOS RTC use even when ACPI says there is none Date: Mon, 28 Jul 2014 14:46:09 +0100 Message-ID: <53D65421.6060305@citrix.com> References: <53D28C91020000780002613E@mail.emea.novell.com> <53D644AF.8000801@citrix.com> <53D6627B02000078000269B3@mail.emea.novell.com> <53D64A7B.9080600@citrix.com> <53D66D020200007800026A2A@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XBlFn-0004tX-2P for xen-devel@lists.xenproject.org; Mon, 28 Jul 2014 13:46:15 +0000 In-Reply-To: <53D66D020200007800026A2A@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser , Tim Deegan List-Id: xen-devel@lists.xenproject.org On 28/07/14 14:32, Jan Beulich wrote: >>>> On 28.07.14 at 15:04, wrote: >> 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. > We won't: If seconds is an invalid value, we bail in the first iteration. > If seconds is a valid value but unchanged on the second iteration, > we bail there (see the still available context below. > > Jan Silly me. I had mentally included the break in the if ( rtc.sec != seconds ) scope. In which case, Reviewed-by: Andrew Cooper Unfortunately we don't have affected hardware to test with. ~Andrew > >>>>> + { >>>>> + 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"); >