From patchwork Sun Jun 11 21:26:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 103568 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp677187qgd; Sun, 11 Jun 2017 14:26:42 -0700 (PDT) X-Received: by 10.99.116.2 with SMTP id p2mr105669pgc.162.1497216402557; Sun, 11 Jun 2017 14:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497216402; cv=none; d=google.com; s=arc-20160816; b=oVGwHEXLZ3EVt8/Gs+jskAp4fNs0WLT898IiEiVhBni56aBmVtftW9OUgL4OCFkPkf P8K5XVFLKGDXEKXT09obeWkYai0b008Yul6EBwQdILFP4jEW+tsPp7L0t0ySsT0S1A4b bS2ppMWJt9u3A9Uqht7CUnJqn80xkRzO9wfgKhMFQkUVHSYAyFgJO5xtYAFgcx3uFwhm KEt1aMetdnkpm3zpB7N1LZwpesXxa7dR7FiKinHcPGNvnpioEV6EDPV652dOcNuikqXL MfXccM1w4SNTtgRCPd7ebvBZCXJ5/IPankR1HWMCNbZcBWaimRoK/I/kXrBcKcC+AkTi A+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Y3yMZIXFTxKMQgz89snuMO7CHFg7xJA5BdLfW1ijhl8=; b=ymC+Q+s2EYPCblnXtLfvdyCi13U2hLP4qrWoEhfhLRVS3Sps7lrEiLF6j+cWGmeNCb UpAhTQcS77BwtTg86/tST5yOYlK+ZODXHEzR6hEUM59gIJGAqsJIWKFNA/LEEFPyBFY+ T5+8pwSQGAnILLoemNi/cXWqm8tbcKSNQLydb0KQp+2XsMIopjxf34z1tXcoVc40bmya D9tfq7mxFPkQXMSGTWt82An7Dgqt/93RzkWhDARilasv7bUwH1t/B6eLZUpWx9dqDmvi mrSqDQ8+N1AYaD90B7PbxGH+M8EuV5FVjPAtd57LK7xJmFN3IyTlG/5q4Dhv+31Cz/YX 2xFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si5571196plb.101.2017.06.11.14.26.42; Sun, 11 Jun 2017 14:26:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751982AbdFKV0j (ORCPT + 25 others); Sun, 11 Jun 2017 17:26:39 -0400 Received: from mail-lf0-f42.google.com ([209.85.215.42]:33688 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbdFKV0i (ORCPT ); Sun, 11 Jun 2017 17:26:38 -0400 Received: by mail-lf0-f42.google.com with SMTP id m77so19915483lfe.0 for ; Sun, 11 Jun 2017 14:26:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=Y3yMZIXFTxKMQgz89snuMO7CHFg7xJA5BdLfW1ijhl8=; b=Vc4vFy98Cart072clBlmsrFICuPhnxwcHZSKpMAWGidAJP7x+SWWkhqQ4B4wqz088T kCKVYekT0YYtHT6oijeImkvFyI6NUbk1kJnVtLlXnkeCryuPIgxFGkc/LUsODE0iGUoc vMNRV6gFPX/T2j4avn+ojcKx07LD4zEMXIExY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y3yMZIXFTxKMQgz89snuMO7CHFg7xJA5BdLfW1ijhl8=; b=apH+InhUtHYUIdTNIAJIC3Z3mk9NoltWzqMm7OCbETJqljsJoT9lPP1rxTNChICIUl 9rq/ZQmOwfBSLrIigv89NQQFvCh+Utt0XYlx3xzCmOt6U/pwG36vG4FxvO+yD+AEuDA1 c4loocDdIc9WpSSFWPrPmjX58YSTVDfhoGUtcoIMRG8RnirUImal378yZtY1XrBW5frk Utbqw4/cVhWh/JemGtbM8Ads0rG2SmktTdWKluYTSWIrvVe6IAhTKGxI87ADPlXL87wF Smw4AfBfnkAML0IHAmOIrc3+2hDsZCsmaIQw9PzhUVCknlmZo76UWbI8SZaJ/vfRi/sF U/PQ== X-Gm-Message-State: AODbwcCrD4AVRJfKl0x7Ws5nCSYvmnm6LLc9VycKse8OSx97bcGDPrzL pZZBf++wLaiXjIrb X-Received: by 10.25.20.227 with SMTP id 96mr3181153lfu.8.1497216396775; Sun, 11 Jun 2017 14:26:36 -0700 (PDT) Received: from fabina.bredbandsbolaget.se (c-797771d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.119.121]) by smtp.gmail.com with ESMTPSA id 1sm2116318ljg.53.2017.06.11.14.26.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Jun 2017 14:26:35 -0700 (PDT) From: Linus Walleij To: Daniel Lezcano , Thomas Gleixner , Joel Stanley , Jonas Jensen Cc: Janos Laube , Paulius Zaleckas , linux-arm-kernel@lists.infradead.org, Hans Ulli Kroll , Florian Fainelli , linux-kernel@vger.kernel.org, Linus Walleij , Andrew Jeffery Subject: [PATCH 1/2] drivers/clocksource/fttmr010: Optimize sched_clock() Date: Sun, 11 Jun 2017 23:26:16 +0200 Message-Id: <20170611212617.6906-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The sched_clock() call should be really fast so we want to avoid an extra if() clause on the read path if possible. Implement two sched_clock_read() functions, one if the timer counts up and one if it counts down. Incidentally this also mirrors how clocksource_mmio_init() works and make things simple and easy to understand. Suggested-by: Daniel Lezcano Cc: Andrew Jeffery Cc: Joel Stanley Cc: Jonas Jensen Signed-off-by: Linus Walleij --- drivers/clocksource/timer-fttmr010.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.9.4 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index f8801507a687..5e82469995cb 100644 --- a/drivers/clocksource/timer-fttmr010.c +++ b/drivers/clocksource/timer-fttmr010.c @@ -91,13 +91,16 @@ static inline struct fttmr010 *to_fttmr010(struct clock_event_device *evt) return container_of(evt, struct fttmr010, clkevt); } -static u64 notrace fttmr010_read_sched_clock(void) +static u64 notrace fttmr010_read_sched_clock_up(void) { - if (local_fttmr->count_down) - return ~readl(local_fttmr->base + TIMER2_COUNT); return readl(local_fttmr->base + TIMER2_COUNT); } +static u64 notrace fttmr010_read_sched_clock_down(void) +{ + return ~readl(local_fttmr->base + TIMER2_COUNT); +} + static int fttmr010_timer_set_next_event(unsigned long cycles, struct clock_event_device *evt) { @@ -304,15 +307,17 @@ static int __init fttmr010_timer_init(struct device_node *np) "FTTMR010-TIMER2", fttmr010->tick_rate, 300, 32, clocksource_mmio_readl_down); + sched_clock_register(fttmr010_read_sched_clock_down, 32, + fttmr010->tick_rate); } else { writel(0, fttmr010->base + TIMER2_LOAD); clocksource_mmio_init(fttmr010->base + TIMER2_COUNT, "FTTMR010-TIMER2", fttmr010->tick_rate, 300, 32, clocksource_mmio_readl_up); + sched_clock_register(fttmr010_read_sched_clock_up, 32, + fttmr010->tick_rate); } - sched_clock_register(fttmr010_read_sched_clock, 32, - fttmr010->tick_rate); /* * Setup clockevent timer (interrupt-driven) on timer 1.