From patchwork Wed Jun 14 12:39:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 105504 Delivered-To: patch@linaro.org Received: by 10.140.91.77 with SMTP id y71csp272028qgd; Wed, 14 Jun 2017 05:42:37 -0700 (PDT) X-Received: by 10.99.115.79 with SMTP id d15mr439096pgn.140.1497444156977; Wed, 14 Jun 2017 05:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1497444156; cv=none; d=google.com; s=arc-20160816; b=CuG5puXeU7YdtA+QwfM0Nn7zLtp8QGvU1P5uXr8jnPMpwdU35xBtjdnphkBLjYsNg3 5+U5MtbQ38YJskaurBWG10b53hCH4cpRzPv9RazS6N8NFuRl/2zg1tpWWqUXK/f9KS5w 6H8X+lMNYZbHrWV2+gy3DKX42hNJ1BXTMCh4rrU9hCouUW48USZqZPGNLWOKaVrGE8xr rwfif8sYtW0ZiX6xdHalTgjiczN5PGVlG5w63eeZPUcjLgKODRljlNrvIIbwjz/0NYEm JEdJv3ET0egIn5bsgCkQf7ubLwOOPo8f/yu/kYJPS9uVxsOT8Y1a4TCNtI62oK3NXz2Y SIIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=b/9MO8ZqLbbdZKGCC9VZ6jGcYCWTa/tTnTNxXzkeAaI=; b=C7sFGIlsQ6vtRo7Drmsj2kgKWyue3qHWm4pYNjDax50593QE1X+RtkJnBJE1R3Ew/W Tvf+NYLgkUD5LzDd1/vhdYb9Wks9Um2doBa4qycHSd0Dz27l25d/p0U3dhnQ2LhDMt17 A9kq9uJm7+ArXcYPeDK8FZjNhbjaZTD9dElAFznK4JPWe2Rw0y56lsKVMY3youfeOqiF FXBxaD79qT/s61tJaVxQl/yAu+QPyZIvWSwHTBwrw3IArveagrRPREdJrvf7kfgqqCpZ RHWqjpmCmLv76Pl8UW9CmJA6BQWPRQUgRbxyPM21ZjrkFWXNMkrQZaXi2nzReypI5Opf /TmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.b=jW54Wi4+; 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 d15si617600plj.367.2017.06.14.05.42.36; Wed, 14 Jun 2017 05:42:36 -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 header.b=jW54Wi4+; 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 S1752746AbdFNMmY (ORCPT + 25 others); Wed, 14 Jun 2017 08:42:24 -0400 Received: from mail-wr0-f178.google.com ([209.85.128.178]:35709 "EHLO mail-wr0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752667AbdFNMmS (ORCPT ); Wed, 14 Jun 2017 08:42:18 -0400 Received: by mail-wr0-f178.google.com with SMTP id q97so188269034wrb.2 for ; Wed, 14 Jun 2017 05:42:17 -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:in-reply-to:references; bh=b/9MO8ZqLbbdZKGCC9VZ6jGcYCWTa/tTnTNxXzkeAaI=; b=jW54Wi4+0CrBoymDUMcjYU0wPD+dmo3E3fOvIsj2ydqFOogrZANL9ZeV1XnUG/Yx0M MwAIFdwEqwVpARSWhS7lCS6lKe9P//1/mHwW9a189quSqGl9QgMJwsoA5DtOphyLZsoY Ce45jdGFbmaY93DB8NKUjVmalN7WJwGJGoUfY= 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:in-reply-to :references; bh=b/9MO8ZqLbbdZKGCC9VZ6jGcYCWTa/tTnTNxXzkeAaI=; b=k4P851hoE3SOCQN8GKbkYgh4r5EMw+/g/zBr1oNbvXcHNAMCnLHqayjCNPhinQQE02 0NXpruaZdP13Yk6UYsXj4eR43o8NTXtfnkggcMSvctiQ+hl0Lt/QaEHjKYMBxJX9ZmYe PRkUcRuRW9S+cMcgCtiLsj+wtJ9BkmJr1eamfGxRyxGRs354bEeWKEv658oXSbdltpgX od386Tz2rztYPNECaSGhjyEICkbvRIPlrqfZVstweH9TRtA6iKXYEVZEFVxEIO2Eh9q0 xYsLStKfVGdIrs0iTih1+uPKeXokysB6T9nezoULhgoHw8Wm3HejP3En9H/oVhoQrRPs 9UnQ== X-Gm-Message-State: AKS2vOwLi4AEkf/+hxThWyOvSFollG3xIQg0Vkbi0/iZQC1G4AKGdMfC 5mU75zje1CyoLeUR X-Received: by 10.223.171.77 with SMTP id r13mr357516wrc.83.1497444132035; Wed, 14 Jun 2017 05:42:12 -0700 (PDT) Received: from localhost.localdomain ([2a01:e35:879a:6cd0:19a:b336:54d7:46e9]) by smtp.gmail.com with ESMTPSA id 80sm1457015wmg.17.2017.06.14.05.42.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 05:42:11 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Linus Walleij , Andrew Jeffery , Joel Stanley , Jonas Jensen Subject: [PATCH 19/23] clocksource/drivers/fttmr010: Optimize sched_clock() Date: Wed, 14 Jun 2017 14:39:40 +0200 Message-Id: <1497443984-12371-19-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497443984-12371-1-git-send-email-daniel.lezcano@linaro.org> References: <20170614123800.GH2261@mai> <1497443984-12371-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij 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 Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-fttmr010.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/clocksource/timer-fttmr010.c b/drivers/clocksource/timer-fttmr010.c index a21020c..b56d7bd 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) { @@ -302,15 +305,17 @@ static int __init fttmr010_common_init(struct device_node *np, bool is_aspeed) "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.