Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932257AbbFDQiV (ORCPT ); Thu, 4 Jun 2015 12:38:21 -0400 Received: from ns.horizon.com ([71.41.210.147]:27612 "HELO ns.horizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S932212AbbFDQiS (ORCPT ); Thu, 4 Jun 2015 12:38:18 -0400 Date: 4 Jun 2015 12:38:16 -0400 Message-ID: <20150604163816.6684.qmail@ns.horizon.com> From: "George Spelvin" To: mingo@kernel.org Subject: Re: [PATCH RFC] x86, tsc: Allow for high latency in quick_pit_calibrate() Cc: adrian.hunter@intel.com, ak@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, luto@amacapital.net, tglx@linutronix.de, torvalds@linux-foundation.org In-Reply-To: <20150603190719.20769.qmail@ns.horizon.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1456 Lines: 39 Ingo Molnar wrote: > - Alternatively, I also tried a different method: to set up the RTC > periodic IRQ during early boot, but not have an IRQ handler, polling > RTC_PF in the rtc_cmos_read(RTC_INTR_FLAGS) IRQ status byte. > > Unfortunately when I do this then PIO based RTC accesses can take > tens of thousands of cycles, and the resulting jitter is pretty bad > and hard to filter: Did you use rtc_cmos_read()? Because that's a rather complex function with lots of locking, to allow NMI access to CMOS. (Basically, it keeps a shadow copy of the address register, which the NMI puts back after it does its nested access.) You want to do the locking and selection of the register to read just once, and have just the raw inb() in the loop. The resultant code looks like this: lock_cmos_prefix(RTC_REG_C); outb(RTC_REG_C, RTC_PORT(0)); for (lots of iterations) { flag = inb(RTC_PORT(1)) & 0x40; } lock_cmos_suffix(RTC_REG_C); That should be a *lot* better. Also, you don't have to enable interrupts in the RTC to get the PF bit set periodically. You only program the interval (register A lsbits), not the IRQ (register B bit 6). In fact, disabling the interrupt is probably safer. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/