From patchwork Wed Jun 26 14:46:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 167812 Delivered-To: patch@linaro.org Received: by 2002:ac9:6410:0:0:0:0:0 with SMTP id r16csp870807ock; Wed, 26 Jun 2019 07:47:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxO59lq0VHpn+1tlBPbR0ccw3tLuaq/FjGTLTDS6IOsKIkJKCYzSi8TUWNOJn5fktz0Opqe X-Received: by 2002:a17:902:42d:: with SMTP id 42mr5699534ple.228.1561560453947; Wed, 26 Jun 2019 07:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561560453; cv=none; d=google.com; s=arc-20160816; b=YlttfiTGIOMt53aF18n11bYhJA90jL50K7kAIKGPm5vTiL9Da3Z6YgRckSELV9hKEy PujXYvNR50htgSKZuHheX6IGLULTYDLWPSuqujAixbDXEqtsDVaqnvxwEjDWQFdy3S6x IPo2dMER7nQFDXdUdV/EMsqKqAr7LqTc1B2+csM/pPDEQVlHDf2FtP0hhQjr10x5WKza VhtFwF0Emdm4aus8xEnyTic6rnMMcny6uf2jyk4/gvZkAEfEmaou6k8lX3gA1WCf5oXN XxPVJNf7lDBMjK7gAQX9C9SdtEPaFUsOO1BId1DeB+YwJc43dm9JHf9az73piPWOjMMQ KAHg== 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; bh=g8xq5QdzKn63u1M0EUnZlEgWbt3e6x6fUijd7UtCicQ=; b=0Sk17w1srqPdP2CwYaWCROcCHOpKbkY6EHw4altYNNJZhBotL3Um0jwa1g4NaUm3Xy S1Po1JhqUADxUVOiyj6EkTr8wVSjwL+EyA7GgBCxrqi7T/VB2WRtH7pY7ZWHdcVIqR0K /FyuDCcIqJSZbiH3ipKkDkRL9hbH9eYDPjF9+A0nHpLSX2znERWjVjAanjegxzGINIbr woK/V1ucVOcmwzG7g+CdCgbEODMhrb8g1J6PcPQFsq6EwpJDCMaEWtOqaEuOK/1zxKhk msZJMc4DUV7ZVNsv0qnQkh653vvbho4/60EtxfXWGeV5jHLASqdiYhEZ5O4O9XFhH3b2 id9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UVaPVeuQ; 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 g14si17191053pgo.579.2019.06.26.07.47.33; Wed, 26 Jun 2019 07:47:33 -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.s=google header.b=UVaPVeuQ; 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 S1728282AbfFZOrc (ORCPT + 30 others); Wed, 26 Jun 2019 10:47:32 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43497 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728254AbfFZOr1 (ORCPT ); Wed, 26 Jun 2019 10:47:27 -0400 Received: by mail-wr1-f66.google.com with SMTP id p13so3043628wru.10 for ; Wed, 26 Jun 2019 07:47:26 -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=g8xq5QdzKn63u1M0EUnZlEgWbt3e6x6fUijd7UtCicQ=; b=UVaPVeuQL6Wc9Py2t8mm/2Sqx0/xqytMEuZ4gtH5Uh7kOTYK0ol8zsgRZh+504UrYO GJxKBEjY5aQTdN9GlYKH3nkRyWNYr5YgIbk/Q0jcSJ2MN5cY/XeFinwe+22WI9BD4f5z 999N71NEIhsSUkRfSopXvhtlPaNTZE/ULLcEauAkXC6fjRyoCjT7xR2gia5sSBefbzBc C/6onK+VPidlHO1dG/zOXeE9sTxRCe3wq0dEH1cyUhFhZd20fdz0i+XS7elAMKBUExP2 kVPdj48uvdazjg0WNJEW8rVG545qgpBx0UKso71Hg2Q8ZTQKbkeTZMwtmNfxogOGV/hy CSQQ== 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=g8xq5QdzKn63u1M0EUnZlEgWbt3e6x6fUijd7UtCicQ=; b=HbFeDkWFg+59i8xIsK/nPIneHl2594V2+ilk4f0okaVxF7ytvSHvA7QYQG+tnvaHD6 Bm4U9k63Z562ZcQkZlm+BL1jbkv+JwzINdPdZWVFzQUmEmhy7LGaXMx4P2xrl/id7XQZ 4SyClkIxrI9atXJ5tG3BZCyRzQ5EUka53mpZ5ICna91BJve+vwkwwNQXrdnz+PXyM2V2 9sqz0kJ67EUY79cx92VwcTQ3nvKMOIQbELpc9nrYwMLBnqQl1T0jNfVb04kdaFPOcDkH LGCKG25bary1d1ABX4gJfiurKYVs3VRcd59pjJ3/+KWNs4lSMEFcrkFWSeq1BsbHp6dp 02Bg== X-Gm-Message-State: APjAAAXexVgn6d2eWJw3nQPU7HJdKVfVmRSqwjYFrFnGHe20U2cJxXdw AG/YJZjvbxSiqzNxLh5EXgWohg== X-Received: by 2002:a5d:4087:: with SMTP id o7mr3997035wrp.277.1561560445192; Wed, 26 Jun 2019 07:47:25 -0700 (PDT) Received: from mai.imgcgcw.net (26.92.130.77.rev.sfr.net. [77.130.92.26]) by smtp.gmail.com with ESMTPSA id h84sm2718557wmf.43.2019.06.26.07.47.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2019 07:47:24 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Dmitry Osipenko , Thierry Reding , Jonathan Hunter , linux-tegra@vger.kernel.org (open list:TEGRA ARCHITECTURE SUPPORT) Subject: [PATCH 08/25] clocksource/drivers/tegra: Replace readl/writel with relaxed versions Date: Wed, 26 Jun 2019 16:46:34 +0200 Message-Id: <20190626144651.16742-8-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190626144651.16742-1-daniel.lezcano@linaro.org> References: <20190626144651.16742-1-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Osipenko The readl/writel functions are inserting memory barrier to ensure that outstanding memory writes are completed, this results in L2 cache syncing being done on Tegra20 and Tegra30 which isn't a very cheap operation. Replace all readl/writel occurrences in the code with the relaxed versions since there is no need for the memory-access syncing. Signed-off-by: Dmitry Osipenko Acked-By: Peter De Schrijver Signed-off-by: Daniel Lezcano --- drivers/clocksource/timer-tegra20.c | 35 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) -- 2.17.1 diff --git a/drivers/clocksource/timer-tegra20.c b/drivers/clocksource/timer-tegra20.c index 3e4f12aee8df..276b55f6ada0 100644 --- a/drivers/clocksource/timer-tegra20.c +++ b/drivers/clocksource/timer-tegra20.c @@ -52,9 +52,9 @@ static int tegra_timer_set_next_event(unsigned long cycles, { void __iomem *reg_base = timer_of_base(to_timer_of(evt)); - writel(TIMER_PTV_EN | - ((cycles > 1) ? (cycles - 1) : 0), /* n+1 scheme */ - reg_base + TIMER_PTV); + writel_relaxed(TIMER_PTV_EN | + ((cycles > 1) ? (cycles - 1) : 0), /* n+1 scheme */ + reg_base + TIMER_PTV); return 0; } @@ -63,7 +63,7 @@ static int tegra_timer_shutdown(struct clock_event_device *evt) { void __iomem *reg_base = timer_of_base(to_timer_of(evt)); - writel(0, reg_base + TIMER_PTV); + writel_relaxed(0, reg_base + TIMER_PTV); return 0; } @@ -72,9 +72,9 @@ static int tegra_timer_set_periodic(struct clock_event_device *evt) { void __iomem *reg_base = timer_of_base(to_timer_of(evt)); - writel(TIMER_PTV_EN | TIMER_PTV_PER | - ((timer_of_rate(to_timer_of(evt)) / HZ) - 1), - reg_base + TIMER_PTV); + writel_relaxed(TIMER_PTV_EN | TIMER_PTV_PER | + ((timer_of_rate(to_timer_of(evt)) / HZ) - 1), + reg_base + TIMER_PTV); return 0; } @@ -84,7 +84,7 @@ static irqreturn_t tegra_timer_isr(int irq, void *dev_id) struct clock_event_device *evt = (struct clock_event_device *)dev_id; void __iomem *reg_base = timer_of_base(to_timer_of(evt)); - writel(TIMER_PCR_INTR_CLR, reg_base + TIMER_PCR); + writel_relaxed(TIMER_PCR_INTR_CLR, reg_base + TIMER_PCR); evt->event_handler(evt); return IRQ_HANDLED; @@ -94,12 +94,12 @@ static void tegra_timer_suspend(struct clock_event_device *evt) { void __iomem *reg_base = timer_of_base(to_timer_of(evt)); - writel(TIMER_PCR_INTR_CLR, reg_base + TIMER_PCR); + writel_relaxed(TIMER_PCR_INTR_CLR, reg_base + TIMER_PCR); } static void tegra_timer_resume(struct clock_event_device *evt) { - writel(usec_config, timer_reg_base + TIMERUS_USEC_CFG); + writel_relaxed(usec_config, timer_reg_base + TIMERUS_USEC_CFG); } static DEFINE_PER_CPU(struct timer_of, tegra_to) = { @@ -123,8 +123,8 @@ static int tegra_timer_setup(unsigned int cpu) { struct timer_of *to = per_cpu_ptr(&tegra_to, cpu); - writel(0, timer_of_base(to) + TIMER_PTV); - writel(TIMER_PCR_INTR_CLR, timer_of_base(to) + TIMER_PCR); + writel_relaxed(0, timer_of_base(to) + TIMER_PTV); + writel_relaxed(TIMER_PCR_INTR_CLR, timer_of_base(to) + TIMER_PCR); irq_force_affinity(to->clkevt.irq, cpumask_of(cpu)); enable_irq(to->clkevt.irq); @@ -148,13 +148,13 @@ static int tegra_timer_stop(unsigned int cpu) static u64 notrace tegra_read_sched_clock(void) { - return readl(timer_reg_base + TIMERUS_CNTR_1US); + return readl_relaxed(timer_reg_base + TIMERUS_CNTR_1US); } #ifdef CONFIG_ARM static unsigned long tegra_delay_timer_read_counter_long(void) { - return readl(timer_reg_base + TIMERUS_CNTR_1US); + return readl_relaxed(timer_reg_base + TIMERUS_CNTR_1US); } static struct delay_timer tegra_delay_timer = { @@ -175,8 +175,9 @@ static struct timer_of suspend_rtc_to = { */ static u64 tegra_rtc_read_ms(struct clocksource *cs) { - u32 ms = readl(timer_of_base(&suspend_rtc_to) + RTC_MILLISECONDS); - u32 s = readl(timer_of_base(&suspend_rtc_to) + RTC_SHADOW_SECONDS); + void __iomem *reg_base = timer_of_base(&suspend_rtc_to); + u32 ms = readl_relaxed(reg_base + RTC_MILLISECONDS); + u32 s = readl_relaxed(reg_base + RTC_SHADOW_SECONDS); return (u64)s * MSEC_PER_SEC + ms; } @@ -261,7 +262,7 @@ static int __init tegra_init_timer(struct device_node *np, bool tegra20) goto out; } - writel(usec_config, timer_reg_base + TIMERUS_USEC_CFG); + writel_relaxed(usec_config, timer_reg_base + TIMERUS_USEC_CFG); for_each_possible_cpu(cpu) { struct timer_of *cpu_to = per_cpu_ptr(&tegra_to, cpu);