From patchwork Fri Jul 4 04:21:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 33065 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BA5E1203AC for ; Fri, 4 Jul 2014 04:22:41 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf5960024oag.5 for ; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) 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=K1c4EBVNqy33mCDjDTEb2OhghCkKAnmhNq9c1yFvAq8=; b=jJ4/3b6lItaIiEARpWyO5Rn2CYm7LHENGuvyGTYIX3n7HRVb1rG3EPxmVnXwxRZ2f/ PUV1er8kXF34LVKdoPkQTZpK+Xyza0F2dPpMledbZikQm+uJ10ADNSQIGO7A/bNdlBqd 18W9TPLorNRr6V+4gwdjEsm0IG9ZL0pZ0ftNjvImEcNNixkV5VQxduP+9rnDAH11KHDC z8kjpZIfYOYOzT2ux3gx4g3w7l6cF47iZEhhqU6rQ3q4QwEAeiP8hiNAJ425jCse4B70 1ZPqlZ5+7scmQJwmEZJRpgLKwy6ytheTlQ2O8KHVWapEb+PqlCNutFXxyDN2mjQp7Bx+ nBLA== X-Gm-Message-State: ALoCoQk1IaPW+FpyeCKS3fWfjfxQ/L63kbeLGFgKEZygX6FngD87yFvGk792Ze9BujzFdnpDeKMb X-Received: by 10.50.66.200 with SMTP id h8mr27844927igt.1.1404447761315; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.98.225 with SMTP id o88ls744264qge.88.gmail; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) X-Received: by 10.52.189.161 with SMTP id gj1mr6327042vdc.2.1404447761192; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id ux9si14656576vdc.7.2014.07.03.21.22.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Jul 2014 21:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.172 as permitted sender) client-ip=209.85.128.172; Received: by mail-ve0-f172.google.com with SMTP id jz11so1160402veb.31 for ; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) X-Received: by 10.52.23.71 with SMTP id k7mr6276179vdf.27.1404447761128; Thu, 03 Jul 2014 21:22:41 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp437581vcb; Thu, 3 Jul 2014 21:22:40 -0700 (PDT) X-Received: by 10.66.254.4 with SMTP id ae4mr8507582pad.99.1404447760237; Thu, 03 Jul 2014 21:22:40 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id go6si34388047pac.116.2014.07.03.21.22.39; Thu, 03 Jul 2014 21:22:39 -0700 (PDT) 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 S1754226AbaGDEWa (ORCPT + 27 others); Fri, 4 Jul 2014 00:22:30 -0400 Received: from mail-pd0-f179.google.com ([209.85.192.179]:33213 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750999AbaGDEVl (ORCPT ); Fri, 4 Jul 2014 00:21:41 -0400 Received: by mail-pd0-f179.google.com with SMTP id w10so1310147pde.38 for ; Thu, 03 Jul 2014 21:21:41 -0700 (PDT) X-Received: by 10.70.108.164 with SMTP id hl4mr7937545pdb.64.1404447701111; Thu, 03 Jul 2014 21:21:41 -0700 (PDT) Received: from localhost (c-67-183-17-239.hsd1.wa.comcast.net. [67.183.17.239]) by mx.google.com with ESMTPSA id iv2sm42674861pbc.19.2014.07.03.21.21.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Jul 2014 21:21:40 -0700 (PDT) From: Kevin Hilman To: Thomas Gleixner , Viresh Kumar Cc: linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Frederic Weisbecker , preeti@linux.vnet.ibm.com, daniel.lezcano@linaro.org Subject: [PATCH 1/2] clockevents: introduce ->set_dev_mode() which can return error Date: Thu, 3 Jul 2014 21:21:35 -0700 Message-Id: <1404447696-4105-2-git-send-email-khilman@linaro.org> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1404447696-4105-1-git-send-email-khilman@linaro.org> References: <1404447696-4105-1-git-send-email-khilman@linaro.org> 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: khilman@linaro.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.128.172 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 ad362c260ef4..4758dfb818cf 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; /* @@ -446,8 +455,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: ");