From patchwork Wed Nov 19 18:39:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 5340291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 90ADBC11AC for ; Wed, 19 Nov 2014 18:42:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 78BF720176 for ; Wed, 19 Nov 2014 18:42:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 86CC0200B4 for ; Wed, 19 Nov 2014 18:42:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XrAAd-0000Pv-5c; Wed, 19 Nov 2014 18:40:03 +0000 Received: from mail.kernel.org ([198.145.19.201]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XrAAa-0000M1-1E for linux-arm-kernel@lists.infradead.org; Wed, 19 Nov 2014 18:40:00 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BBAC20220; Wed, 19 Nov 2014 18:39:40 +0000 (UTC) Received: from localhost (c-67-160-101-93.hsd1.wa.comcast.net [67.160.101.93]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1DD72021F; Wed, 19 Nov 2014 18:39:38 +0000 (UTC) From: Kevin Hilman To: Thomas Gleixner , Viresh Kumar Subject: [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Date: Wed, 19 Nov 2014 10:39:36 -0800 Message-Id: <1416422377-13615-2-git-send-email-khilman@kernel.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1416422377-13615-1-git-send-email-khilman@kernel.org> References: <1416422377-13615-1-git-send-email-khilman@kernel.org> X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141119_104000_125054_13ABC202 X-CRM114-Status: GOOD ( 17.16 ) X-Spam-Score: -5.0 (-----) Cc: linaro-kernel@lists.linaro.org, Frederic Weisbecker , daniel.lezcano@linaro.org, linux-kernel@vger.kernel.org, Kevin Hilman , preeti@linux.vnet.ibm.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Viresh Kumar Currently, the ->set_mode() method of a clockevent device is not allowed to fail, so it has no return value. In order to add new clockevent modes, and allow the setting of those modes to fail, we need the clockevent core to be able to detect when setting a mode fails. To allow detection of mode setting failures, introduce a new method ->set_dev_mode() which can return an error if the given mode is not supported or fails. Since all current modes are still not allowed to fail, the core code simply WARNs if any modes fail. Future patches that add new mode support will add proper error recovery based on failure conditions. Signed-off-by: Viresh Kumar Reviewed-by: Kevin Hilman [khilman: rework changelogs, minor formatting/checkpatch cleanups] Signed-off-by: Kevin Hilman Reviewed-by: Preeti U Murthy --- include/linux/clockchips.h | 5 ++++- kernel/time/clockevents.c | 21 ++++++++++++++++++--- kernel/time/timer_list.c | 5 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 2e4cb67f6e56..d969659cf688 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -81,7 +81,8 @@ enum clock_event_mode { * @mode: operating mode assigned by the management code * @features: features * @retries: number of forced programming retries - * @set_mode: set mode function + * @set_dev_mode: set dev mode function + * @set_mode: set mode function (deprecated, use set_dev_mode instead) * @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 @@ -109,6 +110,8 @@ struct clock_event_device { unsigned long retries; void (*broadcast)(const struct cpumask *mask); + int (*set_dev_mode)(enum clock_event_mode mode, + struct clock_event_device *); void (*set_mode)(enum clock_event_mode mode, struct clock_event_device *); void (*suspend)(struct clock_event_device *); diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 9c94c19f1305..1d5ce3ce9228 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -105,7 +105,16 @@ void clockevents_set_mode(struct clock_event_device *dev, enum clock_event_mode mode) { if (dev->mode != mode) { - dev->set_mode(mode, dev); + if (dev->set_dev_mode) { + int ret = dev->set_dev_mode(mode, dev); + + /* Currently available modes shouldn't fail */ + WARN_ONCE(ret, "Requested mode: %d, error: %d\n", + mode, ret); + } else { + dev->set_mode(mode, dev); + } + dev->mode = mode; /* @@ -448,8 +457,14 @@ int __clockevents_update_freq(struct clock_event_device *dev, u32 freq) if (dev->mode == CLOCK_EVT_MODE_ONESHOT) return clockevents_program_event(dev, dev->next_event, false); - if (dev->mode == CLOCK_EVT_MODE_PERIODIC) - dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev); + if (dev->mode == CLOCK_EVT_MODE_PERIODIC) { + /* Shouldn't fail while switching to PERIODIC MODE */ + if (dev->set_dev_mode) + WARN_ON_ONCE(dev->set_dev_mode(CLOCK_EVT_MODE_PERIODIC, + dev)); + else + dev->set_mode(CLOCK_EVT_MODE_PERIODIC, dev); + } return 0; } diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c index 61ed862cdd37..957a04951ef0 100644 --- a/kernel/time/timer_list.c +++ b/kernel/time/timer_list.c @@ -229,7 +229,10 @@ print_tickdevice(struct seq_file *m, struct tick_device *td, int cpu) SEQ_printf(m, "\n"); SEQ_printf(m, " set_mode: "); - print_name_offset(m, dev->set_mode); + if (dev->set_dev_mode) + print_name_offset(m, dev->set_dev_mode); + else + print_name_offset(m, dev->set_mode); SEQ_printf(m, "\n"); SEQ_printf(m, " event_handler: ");