From patchwork Fri Apr 24 21:43:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Lynch X-Patchwork-Id: 6273621 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3C7CBBF4A6 for ; Fri, 24 Apr 2015 21:46:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5DE5B20377 for ; Fri, 24 Apr 2015 21:46:42 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C450202E5 for ; Fri, 24 Apr 2015 21:46:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YllOC-0000a0-9z; Fri, 24 Apr 2015 21:44:00 +0000 Received: from relay1.mentorg.com ([192.94.38.131]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YllO2-0000WD-3b for linux-arm-kernel@lists.infradead.org; Fri, 24 Apr 2015 21:43:50 +0000 Received: from svr-orw-fem-03.mgc.mentorg.com ([147.34.97.39]) by relay1.mentorg.com with esmtp id 1YllNb-0007Ra-8r from Nathan_Lynch@mentor.com ; Fri, 24 Apr 2015 14:43:23 -0700 Received: from localhost (147.34.91.1) by SVR-ORW-FEM-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server (TLS) id 14.3.224.2; Fri, 24 Apr 2015 14:43:22 -0700 From: Nathan Lynch To: Subject: [PATCH 1/2] clocksource: arm_arch_timer: add arch_timer_okay_for_vdso Date: Fri, 24 Apr 2015 16:43:20 -0500 Message-ID: <1429911801-6069-1-git-send-email-nathan_lynch@mentor.com> X-Mailer: git-send-email 1.9.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150424_144350_172324_7EB00680 X-CRM114-Status: GOOD ( 12.05 ) X-Spam-Score: -0.7 (/) Cc: Mark Rutland , Russell King , Marc Zyngier , Catalin Marinas , Daniel Lezcano , Stephen Boyd , Doug Anderson , Will Deacon , linux-kernel@vger.kernel.org, Thomas Gleixner , Sonny Rao X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The 32-bit ARM VDSO needs to know whether a generic timer is present and whether it is suitable for use by user space. The VDSO initialization code currently duplicates some of the logic from the driver to make this determination, but unfortunately it is incomplete; it will incorrectly enable the VDSO if HYP mode is available or if no interrupt is provided for the virtual timer (see arch_timer_init). In these cases the driver will switch to memory-backed access while the VDSO will attempt to access the counter using cp15 reads. Add an arch_timer_okay_for_vdso API which can reliably inform the VDSO init code whether the arch timer is present and usable. Signed-off-by: Nathan Lynch --- drivers/clocksource/arm_arch_timer.c | 12 ++++++++++++ include/clocksource/arm_arch_timer.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 0aa135ddbf80..b75215523d2f 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -462,6 +462,18 @@ struct timecounter *arch_timer_get_timecounter(void) return &timecounter; } +/* The ARM VDSO init code needs to know: + * - whether a cp15-based arch timer is present; and if so + * - whether the physical or virtual counter is being used. + */ +bool arch_timer_okay_for_vdso(void) +{ + if (!(arch_timers_present & ARCH_CP15_TIMER)) + return false; + + return arch_timer_use_virtual; +} + static void __init arch_counter_register(unsigned type) { u64 start_count; diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 9916d0e4eff5..bfc1e95280c4 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -48,6 +48,7 @@ enum arch_timer_reg { extern u32 arch_timer_get_rate(void); extern u64 (*arch_timer_read_counter)(void); extern struct timecounter *arch_timer_get_timecounter(void); +extern bool arch_timer_okay_for_vdso(void); #else @@ -66,6 +67,11 @@ static inline struct timecounter *arch_timer_get_timecounter(void) return NULL; } +static inline bool arch_timer_okay_for_vdso(void) +{ + return false; +} + #endif #endif