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: 41204 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A13720CBB for ; Wed, 19 Nov 2014 18:39:58 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e53sf1087514eek.11 for ; Wed, 19 Nov 2014 10:39:57 -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=VbPf3mLiRMaphuhS/uJqn/upbVHEj5W7ZGrsv92LoNk=; b=kVZlKAgZCYd9UfSd+nue6xKXvcGPuNu5NCSWiQ0DXuVqr64nbokw3t9CcBao2k6vLV ZDNkeqfnccQo/mbPBOoSdCisGQ768VzMulYZ3Dqy+6y5nSU5wWxd1021vNmibRP8N6TZ H+WOClDjcXndZ+XMy7iRqpAvcDrA9ymf6wIOVXhtViW8IArQU+9EcPM8CepNcgZI0eX2 eugirXHTpLYzOsziD77cYJCuyTDUy8Z0QIvqQG3HzPzpfWG/tVkYdn7Piw66ijBvhADF mGdwxy9BpSbefFS23nCsRZX2RVNZ3GF5ZSoCbqdJHmv49jDV9cBZhwHm+cMyBV0Hhl+m tQ8g== X-Gm-Message-State: ALoCoQl+VFVrjvSBt+8+EWO9HuQmSjxUJiQvahuZFTBgZ9oqTLjuGvEGUNcmTo1UZgu4LKgZ+V7o X-Received: by 10.112.138.234 with SMTP id qt10mr3595991lbb.4.1416422397552; Wed, 19 Nov 2014 10:39:57 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.177 with SMTP id k17ls1289046laa.56.gmail; Wed, 19 Nov 2014 10:39:57 -0800 (PST) X-Received: by 10.152.28.193 with SMTP id d1mr1873550lah.17.1416422397407; Wed, 19 Nov 2014 10:39:57 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id b8si2629816lak.84.2014.11.19.10.39.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 19 Nov 2014 10:39:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id f15so1088783lbj.23 for ; Wed, 19 Nov 2014 10:39:57 -0800 (PST) X-Received: by 10.152.8.170 with SMTP id s10mr6805251laa.56.1416422397235; Wed, 19 Nov 2014 10:39:57 -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 ew9csp137951lbc; Wed, 19 Nov 2014 10:39:56 -0800 (PST) X-Received: by 10.70.46.201 with SMTP id x9mr22906785pdm.154.1416422395545; Wed, 19 Nov 2014 10:39:55 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ml10si3868447pab.207.2014.11.19.10.39.54 for ; Wed, 19 Nov 2014 10:39:55 -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 S1756570AbaKSSjo (ORCPT + 26 others); Wed, 19 Nov 2014 13:39:44 -0500 Received: from mail.kernel.org ([198.145.19.201]:35404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756438AbaKSSjl (ORCPT ); Wed, 19 Nov 2014 13:39:41 -0500 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 Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Frederic Weisbecker , preeti@linux.vnet.ibm.com, daniel.lezcano@linaro.org, Kevin Hilman 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=-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.178 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 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: ");