From patchwork Tue May 8 12:17:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 8468 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 4499823E42 for ; Tue, 8 May 2012 12:18:38 +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 F23EBA187FC for ; Tue, 8 May 2012 12:18:37 +0000 (UTC) Received: by yhpp61 with SMTP id p61so1376165yhp.11 for ; Tue, 08 May 2012 05:18:37 -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:mime-version:content-type :x-gm-message-state; bh=0NxOvbAKyrC4x2lSqAtiVB4GK37HCdYVocZkjbwLBDs=; b=mf3M6T2ML41N17+mNbU3mHZgN29ukwDY3PoCI7UUcighczrW8pKvdW4yBXU9dZbGLf /3GCfRuaIsFFjOi2y+G2dL2erjM4nT0AFIMxaGzF0sJ/pb21qNEJlxN4F32drjrzPuhd nsVGAkt8qURD1tU8HUtN7xddmcE/clyJgJpBPTYgZmibgYrFiwJP4uRrynjgOq/DX2EI fa/IJ0eTVbMSvK9Icac4yWm523CoqQDNSfPWoUNQigL4Dq99EJRV6ztWfkUXRYJ43+TW WnTPxAizA6iiPx23vJ5FlFlNWC7otX4v3s4zefwVhaNu26nMIBl8s0POuxGICepF1uV5 Uldg== Received: by 10.50.51.163 with SMTP id l3mr10411208igo.3.1336479517257; Tue, 08 May 2012 05:18:37 -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.73.147 with SMTP id q19csp195271ibj; Tue, 8 May 2012 05:18:34 -0700 (PDT) Received: by 10.14.45.3 with SMTP id o3mr616340eeb.24.1336479514333; Tue, 08 May 2012 05:18:34 -0700 (PDT) Received: from eu1sys200aog115.obsmtp.com (eu1sys200aog115.obsmtp.com. [207.126.144.139]) by mx.google.com with SMTP id a2si6081818eeg.98.2012.05.08.05.18.28 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 08 May 2012 05:18:34 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.139; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.139 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob115.postini.com ([207.126.147.11]) with SMTP ID DSNKT6kPDJPw2hBFwW8A1um53lJiqkp1D8qL@postini.com; Tue, 08 May 2012 12:18:34 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7649DE4; Tue, 8 May 2012 12:17:57 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DE1BB254E; Tue, 8 May 2012 12:17:56 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 87416A807B; Tue, 8 May 2012 14:17:51 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Tue, 8 May 2012 14:17:56 +0200 From: Linus Walleij To: Thomas Gleixner , Russell King , Cc: Colin Cross , Rob Herring , Santosh Shilimkar , Shiraz Hashim , Linus Walleij Subject: [PATCH 1/2] clockevents: add an optional frequency update function Date: Tue, 8 May 2012 14:17:49 +0200 Message-ID: <1336479469-9246-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkxdyzrdx14H5QF7ZnWsBMSVmAzczcup2SQEg8N6HRBfY4zj99XMwDXx2gy62KMLDEEeNPm From: Linus Walleij For some clockevents, especially for periodic ones, we get a problem when the frequency of the clock driving the event changes. We previously have a solution for one-shot events that will simply reprogram the next event. This introduces an optional callback so that drivers can update constant timer latch values derived from HZ. Cc: Thomas Gleixner Reported-by: Shiraz Hashim Signed-off-by: Linus Walleij --- include/linux/clockchips.h | 3 +++ kernel/time/clockevents.c | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 81e803e..c83d008 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -70,6 +70,7 @@ enum clock_event_nofitiers { * @features: features * @retries: number of forced programming retries * @set_mode: set mode function + * @update_freq: function called to update timer clock frequency * @broadcast: function to broadcast events * @min_delta_ticks: minimum delta value in ticks stored for reconfiguration * @max_delta_ticks: maximum delta value in ticks stored for reconfiguration @@ -97,6 +98,8 @@ struct clock_event_device { void (*broadcast)(const struct cpumask *mask); void (*set_mode)(enum clock_event_mode mode, struct clock_event_device *); + void (*update_freq)(enum clock_event_mode mode, + struct clock_event_device *); unsigned long min_delta_ticks; unsigned long max_delta_ticks; diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 9cd928f..0444bad 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -346,13 +346,17 @@ void clockevents_config_and_register(struct clock_event_device *dev, * @dev: device to modify * @freq: new device frequency * - * Reconfigure and reprogram a clock event device in oneshot - * mode. Must be called on the cpu for which the device delivers per + * Reconfigure and reprogram a clock event device. + * Must be called on the cpu for which the device delivers per * cpu timer events with interrupts disabled! Returns 0 on success, * -ETIME when the event is in the past. */ int clockevents_update_freq(struct clock_event_device *dev, u32 freq) { + /* Call down to the driver to reconfigure for new frequency */ + if (dev->update_freq) + dev->update_freq(dev->mode, dev); + clockevents_config(dev, freq); if (dev->mode != CLOCK_EVT_MODE_ONESHOT)