From patchwork Thu Jul 19 01:19:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 10133 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 26D3823F08 for ; Thu, 19 Jul 2012 01:19:28 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id D5E5CA183FC for ; Thu, 19 Jul 2012 01:19:27 +0000 (UTC) Received: by yhpp61 with SMTP id p61so2451658yhp.11 for ; Wed, 18 Jul 2012 18:19:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-content-scanned:x-cbid:x-ibm-iss-spamdetectors :x-ibm-iss-detailinfo:x-gm-message-state; bh=JQX8lEwLT9yzHIDv6rXjH0ABQWwc60PVsrfLAnZQB50=; b=cnBiEOfDFE0zC1Izymw6DnrZVEiFX86/pFQ14rvjeDE5rqYvP2QXiJ85X4xM+4XfME 185brffKgHtttZZxDGnnMDcFCspzLvUnOaf4ezln/WgcAuGuOo3duHkn0Sx9vwpFxgiS 8syjIlTmwk0wiotnHPTkpy+g8OJ21eldB6+dWR3SQxmXUDDQ71mCjd9TLpAbDLR6dZfV TqshbFAEv/Rmzzy0uK+Ndf2LTQYNkmW+V8kVClHBt8Qn1fouH66aNd/5WNf1i+qtf5Ya E2vwyY6xYvlOE6eVzXNV2WGeA9EQFR5iz+nydL8wK+d+nibXxfxiccS97mxEobKFhhGC N7xw== Received: by 10.50.46.232 with SMTP id y8mr3739803igm.57.1342660767044; Wed, 18 Jul 2012 18:19:27 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.153.7 with SMTP id i7csp5418ibw; Wed, 18 Jul 2012 18:19:25 -0700 (PDT) Received: by 10.50.236.70 with SMTP id us6mr3776262igc.8.1342660765684; Wed, 18 Jul 2012 18:19:25 -0700 (PDT) Received: from e34.co.us.ibm.com (e34.co.us.ibm.com. [32.97.110.152]) by mx.google.com with ESMTPS id v8si666047ict.65.2012.07.18.18.19.24 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 Jul 2012 18:19:25 -0700 (PDT) Received-SPF: neutral (google.com: 32.97.110.152 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=32.97.110.152; Authentication-Results: mx.google.com; spf=neutral (google.com: 32.97.110.152 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) smtp.mail=john.stultz@linaro.org Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 18 Jul 2012 19:19:24 -0600 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 18 Jul 2012 19:19:22 -0600 Received: from d03relay02.boulder.ibm.com (d03relay02.boulder.ibm.com [9.17.195.227]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 708C3C40003; Thu, 19 Jul 2012 01:19:20 +0000 (WET) Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay02.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6J1JLFF137222; Wed, 18 Jul 2012 19:19:21 -0600 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6J1JLQ0016573; Wed, 18 Jul 2012 19:19:21 -0600 Received: from kernel.stglabs.ibm.com (kernel.stglabs.ibm.com [9.114.214.19]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q6J1JJSY016530; Wed, 18 Jul 2012 19:19:20 -0600 From: John Stultz To: lkml Cc: Catalin Marinas , Andrew Morton , Ingo Molnar , Richard Cochran , Prarit Bhargava , Thomas Gleixner , John Stultz Subject: [PATCH 1/2] jiffies: Allow CLOCK_TICK_RATE to be undefined Date: Wed, 18 Jul 2012 21:19:12 -0400 Message-Id: <1342660753-10382-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1342660753-10382-1-git-send-email-john.stultz@linaro.org> References: <1342660753-10382-1-git-send-email-john.stultz@linaro.org> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12071901-1780-0000-0000-000007877481 X-IBM-ISS-SpamDetectors: X-IBM-ISS-DetailInfo: BY=3.00000287; HX=3.00000193; KW=3.00000007; PH=3.00000001; SC=3.00000004; SDB=6.00157818; UDB=6.00035605; UTC=2012-07-19 01:19:23 X-Gm-Message-State: ALoCoQkbaVqFgn+ITdKegLjjCpFUtoITpDtExG8Hj43C98UF9qo9cjoOeGIe0wCwIlucvxV7l/am From: Catalin Marinas CLOCK_TICK_RATE is a legacy constant that defines the timer device's granularity. On hardware with particularly coarse granularity, this constant is used to reduce accumulated time error when using jiffies as a clocksource, by calculating the hardware's actual tick length rather then just assuming it is 1sec/HZ. However, for the most part this is unnecessary, as most modern systems don't use jiffies for their clocksource, and their tick device is sufficiently fine grained to avoid major error. Thus, this patch allows an architecture to not define CLOCK_TICK_RATE, in which case ACTHZ defaults to (HZ << 8). Signed-off-by: Catalin Marinas Acked-by: Arnd Bergmann Cc: Andrew Morton Cc: Ingo Molnar Cc: Richard Cochran Cc: Prarit Bhargava Cc: Thomas Gleixner [jstultz: commit log tweaks] Signed-off-by: John Stultz --- include/linux/jiffies.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h index 265e2c3..a2134be 100644 --- a/include/linux/jiffies.h +++ b/include/linux/jiffies.h @@ -39,9 +39,6 @@ # error Invalid value of HZ. #endif -/* LATCH is used in the interval timer and ftape setup. */ -#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ - /* Suppose we want to divide two numbers NOM and DEN: NOM/DEN, then we can * improve accuracy by shifting LSH bits, hence calculating: * (NOM << LSH) / DEN @@ -54,8 +51,15 @@ #define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH)) \ + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN)) +#ifdef CLOCK_TICK_RATE +/* LATCH is used in the interval timer and ftape setup. */ +#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ) /* For divider */ + /* HZ is the requested value. ACTHZ is actual HZ ("<< 8" is for accuracy) */ #define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8)) +#else +#define ACTHZ (HZ << 8) +#endif /* TICK_NSEC is the time between ticks in nsec assuming real ACTHZ */ #define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))