Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3711509ybl; Sun, 15 Dec 2019 16:20:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwM0UR8JSWusaLNAWwiBLzJy2Cy4KqyuRf41R2LRY+3QtdicwJleDbZZnoaUv+0Y0hV0RLT X-Received: by 2002:a9d:684e:: with SMTP id c14mr29199791oto.340.1576455653337; Sun, 15 Dec 2019 16:20:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576455653; cv=none; d=google.com; s=arc-20160816; b=Rj+0B3ZJ7Y5BjN+uWlTVANBE0wRh13JUiXUQNAKFWXrUbGoqzsFGyQg7DDzRLV3yz+ meLIZq/pwf0Y2dTCFvwH5la2TARXKXiJnF9fz3pf4vUpXR9nUwcg1ORn3GROalzEexW6 5x91xWqSE2lWuiLe+XpQfU0MYvtHB/ATcviq0BqSvvMqZdp95IISakbct63LBqPVbZ0m WYgNHqPDR76YBYol+6OkryRLzYu13E3fjhlK0xVISZpDWELyj43b8/pVobWXgRPPGbNN Ws4SSRsHurMWHQ2DIUmFJChZJOr3cVcu0gHTmqt6i6zsD6H1DwVekANXRnv4JlCRkQkp sW+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pqQp4+UbbRX/7xlzqwr46OCkSlvgFANLzi802cRaz4A=; b=0AzWGNJ71kf/8nSmR3ck3i9vDAtdSd1GMH3GLjSZLgbqU7JyBv37e7qqZKCTvbV7kL DkzrGSMSFh6kQsXle6/PwmgXB++6lPG+r1vuWDC8JjOvljV0ajvbOTUB9uU+LGq/TA3d aiNVCKlRjx6YQXk1V052UJWwkRi7YJd9aKGvNsLEPi2d2H3vKTRAqLLKzHmCT4ZvaYie Q70O2U10J2WeLTQtR2PENGsd8XUYPBGGDWd4P5J688dRDuQH2dRU7xZqrlo9PriisU/G waxYQDG9GenxlozGxWgOEvcvCLc1V1LQG1VWv4FxelcUI+P1IoDXQ4KAalRhj7biht+t sOlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="GyH7/Io5"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2si8961978otc.130.2019.12.15.16.20.42; Sun, 15 Dec 2019 16:20:53 -0800 (PST) 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=@gmail.com header.s=20161025 header.b="GyH7/Io5"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfLPATz (ORCPT + 99 others); Sun, 15 Dec 2019 19:19:55 -0500 Received: from mail-qv1-f65.google.com ([209.85.219.65]:41102 "EHLO mail-qv1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726373AbfLPATy (ORCPT ); Sun, 15 Dec 2019 19:19:54 -0500 Received: by mail-qv1-f65.google.com with SMTP id x1so714638qvr.8; Sun, 15 Dec 2019 16:19:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pqQp4+UbbRX/7xlzqwr46OCkSlvgFANLzi802cRaz4A=; b=GyH7/Io5fH/c/CUmowH+I8vPoZ8s483kMhc3an3/j9mKJEAGIdoesqC3IMwmIaJf03 ofn1CUUMWPYu6mLP1xPuGDobPBCRrctiJt71rFvn7BUCtLlI4zPp0N4uYuDweGoKXOCP onnsUA8IcLU1SG6wQREkSB57Jh1vP8OF5a9qw0sBK2sVIapT0w/2JQUScUrHqEMKVXCo ooyArdT1qkWIdNyhNVcqZbqJALcl1PuEzHCZd4RDv1JRQBkR9eTxP0/m9dGoWfhFWn64 6Li8U0KzRuQBfnhK4YnbQvWKuqIf+s+y01QrEgZcw3jGf/crhDv1JKa9Y3gPAa70XxBP xA9Q== 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:mime-version:content-transfer-encoding; bh=pqQp4+UbbRX/7xlzqwr46OCkSlvgFANLzi802cRaz4A=; b=LpPyGrdlsnDefrW26luId5Dz3iUq4ejMXH/3TdXcG4JZlstI4GND6BC/bwN/alTWlO 93Tsz4W4b16y78NPEMaqgEYhxFjkOLAMwHYzXd0CJnE89O9zq0enT1F5O///zOpZgRLv CgA0zXyM+l2P2L65SBXn2mHHOU1eNO+Mh72G+pInN5H05E2pa6wUJWgnHYWO5s0s5Nql c3S2L4DqHe5EtGp/AE88nbGx4vf1YXA25LHqtzSTBXDTgcH5o6JyuRwCG79HCpg4pBcw JzcsR2B986lwhImtHHOyjUzYDlvmNGsNmHf1RiktCUyzXRalPJSJCx76jgzs7+NZ3blW 3+XQ== X-Gm-Message-State: APjAAAWlmE2MKZKu0mWfgkNyTrD/dmKI/GGiuw89foO+Vwh1FzBYdztB YFjwG8Vopv33X6s5Vl7unng= X-Received: by 2002:ad4:5614:: with SMTP id ca20mr95564qvb.43.1576455593249; Sun, 15 Dec 2019 16:19:53 -0800 (PST) Received: from auth1-smtp.messagingengine.com (auth1-smtp.messagingengine.com. [66.111.4.227]) by smtp.gmail.com with ESMTPSA id l20sm3935350qtj.60.2019.12.15.16.19.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Dec 2019 16:19:52 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id 1D85822430; Sun, 15 Dec 2019 19:19:52 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sun, 15 Dec 2019 19:19:52 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddtgedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne goufhorhhtvggutfgvtghiphdvucdlgedtmdenucfjughrpefhvffufffkofgjfhgggfes tdekredtredttdenucfhrhhomhepuehoqhhunhcuhfgvnhhguceosghoqhhunhdrfhgvnh hgsehgmhgrihhlrdgtohhmqeenucfkphephedvrdduheehrdduuddurdejudenucfrrghr rghmpehmrghilhhfrhhomhepsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrg hlihhthidqieelvdeghedtieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeep ghhmrghilhdrtghomhesfhhigihmvgdrnhgrmhgvnecuvehluhhsthgvrhfuihiivgepvd X-ME-Proxy: Received: from localhost (unknown [52.155.111.71]) by mail.messagingengine.com (Postfix) with ESMTPA id B1E9530600FE; Sun, 15 Dec 2019 19:19:49 -0500 (EST) From: Boqun Feng To: linux-hyperv@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Michael Kelley , Vincenzo Frascino , Catalin Marinas , Will Deacon , Thomas Gleixner , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Sasha Levin , xen-devel@lists.xenproject.org, Stefano Stabellini , Boqun Feng , Russell King , Mark Rutland , Marc Zyngier , Daniel Lezcano , Allison Randal , Enrico Weigelt , Geert Uytterhoeven , Huacai Chen Subject: [RFC 3/6] arm/arm64: clocksource: Introduce vclock_mode Date: Mon, 16 Dec 2019 08:19:19 +0800 Message-Id: <20191216001922.23008-4-boqun.feng@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191216001922.23008-1-boqun.feng@gmail.com> References: <20191216001922.23008-1-boqun.feng@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Similar to x86, use a vclock_mode in arch_clocksource_data to differ clocksoures use different read function in vDSO. No functional changes, only preparation for support vDSO in ARM64 on Hyper-V. Note: the changes for arm are only because arm and arm64 share the same code in the arch timer driver and require arch_clocksource_data having the same field. Signed-off-by: Boqun Feng (Microsoft) --- arch/arm/include/asm/clocksource.h | 6 +++++- arch/arm/kernel/vdso.c | 1 - arch/arm64/include/asm/clocksource.h | 6 +++++- arch/arm64/include/asm/mshyperv.h | 2 +- arch/arm64/include/asm/vdso/compat_gettimeofday.h | 5 +++-- arch/arm64/include/asm/vdso/gettimeofday.h | 5 +++-- arch/arm64/include/asm/vdso/vsyscall.h | 4 +--- drivers/clocksource/arm_arch_timer.c | 8 ++++---- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/arch/arm/include/asm/clocksource.h b/arch/arm/include/asm/clocksource.h index 0b350a7e26f3..017c5ab6e587 100644 --- a/arch/arm/include/asm/clocksource.h +++ b/arch/arm/include/asm/clocksource.h @@ -1,8 +1,12 @@ #ifndef _ASM_CLOCKSOURCE_H #define _ASM_CLOCKSOURCE_H +#define VCLOCK_NONE 0 /* No vDSO clock available. */ +#define VCLOCK_CNTVCT 1 /* vDSO should use cntvcnt */ +#define VCLOCK_MAX 1 + struct arch_clocksource_data { - bool vdso_direct; /* Usable for direct VDSO access? */ + int vclock_mode; }; #endif diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index c89ac1b9d28b..09e46ec420fe 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -263,4 +263,3 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long addr) if (!IS_ERR(vma)) mm->context.vdso = addr; } - diff --git a/arch/arm64/include/asm/clocksource.h b/arch/arm64/include/asm/clocksource.h index 0ece64a26c8c..fbe80057468c 100644 --- a/arch/arm64/include/asm/clocksource.h +++ b/arch/arm64/include/asm/clocksource.h @@ -2,8 +2,12 @@ #ifndef _ASM_CLOCKSOURCE_H #define _ASM_CLOCKSOURCE_H +#define VCLOCK_NONE 0 /* No vDSO clock available. */ +#define VCLOCK_CNTVCT 1 /* vDSO should use cntvcnt */ +#define VCLOCK_MAX 1 + struct arch_clocksource_data { - bool vdso_direct; /* Usable for direct VDSO access? */ + int vclock_mode; }; #endif diff --git a/arch/arm64/include/asm/mshyperv.h b/arch/arm64/include/asm/mshyperv.h index 9cc4aeddf2d0..0afb00e3501d 100644 --- a/arch/arm64/include/asm/mshyperv.h +++ b/arch/arm64/include/asm/mshyperv.h @@ -90,7 +90,7 @@ extern void hv_get_vpreg_128(u32 reg, struct hv_get_vp_register_output *result); #define hv_set_reference_tsc(val) \ hv_set_vpreg(HV_REGISTER_REFERENCE_TSC, val) #define hv_set_clocksource_vdso(val) \ - ((val).archdata.vdso_direct = false) + ((val).archdata.vclock_mode = VCLOCK_NONE) #if IS_ENABLED(CONFIG_HYPERV) #define hv_enable_stimer0_percpu_irq(irq) enable_percpu_irq(irq, 0) diff --git a/arch/arm64/include/asm/vdso/compat_gettimeofday.h b/arch/arm64/include/asm/vdso/compat_gettimeofday.h index c50ee1b7d5cd..630d04c3c92e 100644 --- a/arch/arm64/include/asm/vdso/compat_gettimeofday.h +++ b/arch/arm64/include/asm/vdso/compat_gettimeofday.h @@ -8,6 +8,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #include @@ -117,10 +118,10 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) u64 res; /* - * clock_mode == 0 implies that vDSO are enabled otherwise + * clock_mode == VCLOCK_NONE implies that vDSO are disabled so * fallback on syscall. */ - if (clock_mode) + if (clock_mode == VCLOCK_NONE) return __VDSO_USE_SYSCALL; /* diff --git a/arch/arm64/include/asm/vdso/gettimeofday.h b/arch/arm64/include/asm/vdso/gettimeofday.h index b08f476b72b4..e6e3fe0488c7 100644 --- a/arch/arm64/include/asm/vdso/gettimeofday.h +++ b/arch/arm64/include/asm/vdso/gettimeofday.h @@ -8,6 +8,7 @@ #ifndef __ASSEMBLY__ #include +#include #include #define __VDSO_USE_SYSCALL ULLONG_MAX @@ -71,10 +72,10 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode) u64 res; /* - * clock_mode == 0 implies that vDSO are enabled otherwise + * clock_mode == VCLOCK_NONE implies that vDSO are disabled so * fallback on syscall. */ - if (clock_mode) + if (clock_mode == VCLOCK_NONE) return __VDSO_USE_SYSCALL; /* diff --git a/arch/arm64/include/asm/vdso/vsyscall.h b/arch/arm64/include/asm/vdso/vsyscall.h index 0c20a7c1bee5..07f78b0da498 100644 --- a/arch/arm64/include/asm/vdso/vsyscall.h +++ b/arch/arm64/include/asm/vdso/vsyscall.h @@ -24,9 +24,7 @@ struct vdso_data *__arm64_get_k_vdso_data(void) static __always_inline int __arm64_get_clock_mode(struct timekeeper *tk) { - u32 use_syscall = !tk->tkr_mono.clock->archdata.vdso_direct; - - return use_syscall; + return tk->tkr_mono.clock->archdata.vclock_mode; } #define __arch_get_clock_mode __arm64_get_clock_mode diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 9a5464c625b4..9b8d4d00b53b 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -69,7 +69,7 @@ static enum arch_timer_ppi_nr arch_timer_uses_ppi = ARCH_TIMER_VIRT_PPI; static bool arch_timer_c3stop; static bool arch_timer_mem_use_virtual; static bool arch_counter_suspend_stop; -static bool vdso_default = true; +static int vdso_default = VCLOCK_CNTVCT; static cpumask_t evtstrm_available = CPU_MASK_NONE; static bool evtstrm_enable = IS_ENABLED(CONFIG_ARM_ARCH_TIMER_EVTSTREAM); @@ -560,8 +560,8 @@ void arch_timer_enable_workaround(const struct arch_timer_erratum_workaround *wa * change both the default value and the vdso itself. */ if (wa->read_cntvct_el0) { - clocksource_counter.archdata.vdso_direct = false; - vdso_default = false; + clocksource_counter.archdata.vclock_mode = VCLOCK_NONE; + vdso_default = VCLOCK_NONE; } } @@ -979,7 +979,7 @@ static void __init arch_counter_register(unsigned type) } arch_timer_read_counter = rd; - clocksource_counter.archdata.vdso_direct = vdso_default; + clocksource_counter.archdata.vclock_mode = vdso_default; } else { arch_timer_read_counter = arch_counter_get_cntvct_mem; } -- 2.24.0