From patchwork Tue Dec 9 22:03:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 42076 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6F62E260BE for ; Tue, 9 Dec 2014 22:03:59 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf1086671wgh.6 for ; Tue, 09 Dec 2014 14:03:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=A3FsKw1sXzaC/afksZGuhUv84qdGUkdNq1f7bhnPWz8=; b=O7HXOMm/GaHGp+zlhF7t5iDTqQ5syEcTI6eDWb2gvr09+k9vfA+ojHF254qKWufrcX Y612f8RYEt5F1zLSgupCIA14roGu/gmS9ZfwwKMiGdWvKgVOrNodG3Lfk/iV4GiK+usP b+uzNctRH5JlbsxL5kQZ92wNytnCGICIQ8rEvwPe2sI0T93pjEzHJh4m+uKkiOj+kBMv LisWq2UZS5yejygKO2ZRWW3/TZEmeUx51NkJo9wbmmXAERoNGKMygeDbK1CQA4BHLhE7 FoIMIG84cJwYSVdUcj3qcfpcvkwBl6deIGTIj64GeiUrURUWs1k9SD+ywO8KIEqWCvnE 80xw== X-Gm-Message-State: ALoCoQnbBzgMWvFU+TUgBk0T7OHwI2hA4VrnpmaEu8FRk1VEDBfneoZFDakgSGMSWV8fh3r20pXZ X-Received: by 10.194.92.34 with SMTP id cj2mr11328wjb.5.1418162638716; Tue, 09 Dec 2014 14:03:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.40 with SMTP id s8ls109727lae.100.gmail; Tue, 09 Dec 2014 14:03:58 -0800 (PST) X-Received: by 10.152.2.74 with SMTP id 10mr732566las.38.1418162638455; Tue, 09 Dec 2014 14:03:58 -0800 (PST) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id uo8si2620827lbb.96.2014.12.09.14.03.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 14:03:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by mail-lb0-f169.google.com with SMTP id p9so1327127lbv.28 for ; Tue, 09 Dec 2014 14:03:58 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr629586lbc.23.1418162638366; Tue, 09 Dec 2014 14:03:58 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp812345lbc; Tue, 9 Dec 2014 14:03:56 -0800 (PST) X-Received: by 10.70.90.80 with SMTP id bu16mr1350804pdb.44.1418162634606; Tue, 09 Dec 2014 14:03:54 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lp1si3879344pab.57.2014.12.09.14.03.53 for ; Tue, 09 Dec 2014 14:03:54 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753362AbaLIWDm (ORCPT + 27 others); Tue, 9 Dec 2014 17:03:42 -0500 Received: from mail.kernel.org ([198.145.19.201]:59626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753312AbaLIWDi (ORCPT ); Tue, 9 Dec 2014 17:03:38 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 068FB20131; Tue, 9 Dec 2014 22:03:37 +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 3558E201C7; Tue, 9 Dec 2014 22:03:36 +0000 (UTC) From: Kevin Hilman To: Thomas Gleixner , Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Frederic Weisbecker , preeti@linux.vnet.ibm.com Subject: [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Date: Tue, 9 Dec 2014 14:03:33 -0800 Message-Id: <1418162614-19182-2-git-send-email-khilman@kernel.org> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418162614-19182-1-git-send-email-khilman@kernel.org> References: <1418162614-19182-1-git-send-email-khilman@kernel.org> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linux-kernel-owner@vger.kernel.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 55449909f114..f7614041240e 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: ");