From patchwork Mon Oct 16 15:28:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115924 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3813436qgn; Mon, 16 Oct 2017 08:28:56 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TSXOmUQErTuAcLm4kUIE36nR5PZNmuBYaaWSJxWwG6OtVwKVfTYbgQ8bzMHwhqo7GDc+mC X-Received: by 10.99.94.198 with SMTP id s189mr6261735pgb.32.1508167736591; Mon, 16 Oct 2017 08:28:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508167736; cv=none; d=google.com; s=arc-20160816; b=OjmYIXpT8Q53PsnMZmm6lqDo8B06cgucEFDE+IQNMP8VJM90ttGG7JH5IDiO+p6qV4 T2Mjyr6XmZ1xWGx6GDV6p/8GSaaQtxp5K7MpcLwlcYhWB8k7+IEri7slSFBbOEpS1VaO ygYRGfuPsmHyDEC7wg3aNxaUtW4w3rCq86/mb99d3aCTbBylhQ6PFg5JYEW8YSiTG/sK NMYS/JEDLlgbzsgLidzVNpYcqTW7frr8TUJOlXJsL1kIp6hzkzLNzlXnR/BCxVtQSecH Ky4bkXwQvHdpOV5FVxTRooJ4oJOZpc5kjZVhJFnMGQBAjPcg0lLhFxsp7w4YCUKTQiAs fNZg== 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:arc-authentication-results; bh=9ZoLs53fCIPfiaYUbtdl9T1eD4tBoiL113nCgt4tCMM=; b=MTI7XHJ/ZgOglhW+0yAFclmUvb5RAN/7YtelBPcsCo7Q+RoeuAWF75Jy0/CQxqlfAW KTkLffFHlnZmkJYdzl0JqEFtgsLa6T/HaBEx70TfHD+bOLMVZ2wgeyV69LQTcfuzTUkn 8B3rkl2wkL6Sx05/r/RGQA97gZ4AsHzCMNB0z37oEB7RjorxdrG1zWUpFr5A+0To+fZi +rcKvRTBwVLxf3qfK/Tpa1NQvA97ZaU3smlqlDCOsMgU+HReDDVgOHj5Kf1et3T0QNvB YJjZtHfUwWdb7kOKPjyfYQRiPX5MIgNQFqFwd7JZTkZzS4m29Vlisp/LT/jv/rSaZWGF P5GA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si3244889pge.370.2017.10.16.08.28.56; Mon, 16 Oct 2017 08:28:56 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754056AbdJPP2w (ORCPT + 27 others); Mon, 16 Oct 2017 11:28:52 -0400 Received: from foss.arm.com ([217.140.101.70]:58572 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753693AbdJPP2u (ORCPT ); Mon, 16 Oct 2017 11:28:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A493315A2; Mon, 16 Oct 2017 08:28:50 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EFE23F483; Mon, 16 Oct 2017 08:28:49 -0700 (PDT) From: Mark Rutland To: daniel.lezcano@linaro.org Cc: marc.zyngier@arm.com, tglx@linutronix.de, ard.biesheuvel@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland Subject: [PATCH 1/2] clocksource: arm_arch_timer: validate CNTFRQ after enabling frame Date: Mon, 16 Oct 2017 16:28:38 +0100 Message-Id: <20171016152839.14964-2-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171016152839.14964-1-mark.rutland@arm.com> References: <20171016152839.14964-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ard Biesheuvel The ACPI GTDT code validates the CNTFRQ field of each MMIO timer frame against the CNTFRQ system register of the current CPU, to ensure that they are equal, which is mandated by the architecture. However, reading the CNTFRQ field of a frame is not possible until the RFRQ bit in the frame's CNTACRn register is set, and doing so before that willl produce the following error: arch_timer: [Firmware Bug]: CNTFRQ mismatch: frame @ 0x00000000e0be0000: (0x00000000), CPU: (0x0ee6b280) arch_timer: Disabling MMIO timers due to CNTFRQ mismatch arch_timer: Failed to initialize memory-mapped timer. The reason is that the CNTFRQ field is RES0 if access is not enabled. So move the validation of CNTFRQ into the loop that iterates over the timers to find the best frame, but defer it until after we have selected the best frame, which should also have enabled the RFRQ bit. Signed-off-by: Ard Biesheuvel Signed-off-by: Mark Rutland --- drivers/clocksource/arm_arch_timer.c | 38 ++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 17 deletions(-) -- 2.11.0 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index fd4b7f684bd0..14e2419063e9 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -1268,10 +1268,6 @@ arch_timer_mem_find_best_frame(struct arch_timer_mem *timer_mem) iounmap(cntctlbase); - if (!best_frame) - pr_err("Unable to find a suitable frame in timer @ %pa\n", - &timer_mem->cntctlbase); - return best_frame; } @@ -1372,6 +1368,8 @@ static int __init arch_timer_mem_of_init(struct device_node *np) frame = arch_timer_mem_find_best_frame(timer_mem); if (!frame) { + pr_err("Unable to find a suitable frame in timer @ %pa\n", + &timer_mem->cntctlbase); ret = -EINVAL; goto out; } @@ -1420,7 +1418,7 @@ arch_timer_mem_verify_cntfrq(struct arch_timer_mem *timer_mem) static int __init arch_timer_mem_acpi_init(int platform_timer_count) { struct arch_timer_mem *timers, *timer; - struct arch_timer_mem_frame *frame; + struct arch_timer_mem_frame *frame, *best_frame = NULL; int timer_count, i, ret = 0; timers = kcalloc(platform_timer_count, sizeof(*timers), @@ -1432,14 +1430,6 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count) if (ret || !timer_count) goto out; - for (i = 0; i < timer_count; i++) { - ret = arch_timer_mem_verify_cntfrq(&timers[i]); - if (ret) { - pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n"); - goto out; - } - } - /* * While unlikely, it's theoretically possible that none of the frames * in a timer expose the combination of feature we want. @@ -1448,12 +1438,26 @@ static int __init arch_timer_mem_acpi_init(int platform_timer_count) timer = &timers[i]; frame = arch_timer_mem_find_best_frame(timer); - if (frame) - break; + if (!best_frame) + best_frame = frame; + + ret = arch_timer_mem_verify_cntfrq(timer); + if (ret) { + pr_err("Disabling MMIO timers due to CNTFRQ mismatch\n"); + goto out; + } + + if (!best_frame) /* implies !frame */ + /* + * Only complain about missing suitable frames if we + * haven't already found one in a previous iteration. + */ + pr_err("Unable to find a suitable frame in timer @ %pa\n", + &timer->cntctlbase); } - if (frame) - ret = arch_timer_mem_frame_register(frame); + if (best_frame) + ret = arch_timer_mem_frame_register(best_frame); out: kfree(timers); return ret; From patchwork Mon Oct 16 15:28:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 115925 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3813446qgn; Mon, 16 Oct 2017 08:28:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA/KUU0Bp3QEAMqSPOzXvWYjipRNni6hIN55dauqdOexPzv0UooPLTUhFJMrF5WzccLKB4s X-Received: by 10.99.159.2 with SMTP id g2mr8472568pge.233.1508167737590; Mon, 16 Oct 2017 08:28:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508167737; cv=none; d=google.com; s=arc-20160816; b=KKMxakamkqQTpkHfyTETKwfajCGCnn/dU02ts1yiOiwEUp37/abM8DgWnHIo+OE0Wi lfQezLGzTaEraWlhewOS0hhTOkumDwzSazlVu3ELCsz5HBAaAHfVp2ZLf4hWQgPD9YHM a9+0eUgJJ50dRwO87krqY0VsgLa8HNZ0nSZ2J5/GzfuH3wQm1Q3iQIM2X7C/uwy2r0qs 3bp5K/5IfjXFC+gNSUja28W8fQkja6qzuBofcsGpuv7ifOaXEl3LRwbezU08HRfHpEGq gy1fnvykasY+BNR6ZY9Cy0CwZ+/pGUcFWThBUa3G9pj4UOuxbc1F5DG8d6oK3e44rZ5v ERrg== 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:arc-authentication-results; bh=pDO8j1j8h5Dg+YsxLGJKncsqNAS68mU9zLkCAKjBUII=; b=QErKDwUO1c4xJmE7q91m9ZFrG5KDl0q66wirFLQGBfI826hjXhtGeZ4PSKMS1Gn3IX 2vGwui6fsMd0LxLPDpN8TY33Ta8wR3V9ied/7qGqzGoxLSSjPvZ4+d2l7qholhTwyYlX MdXeqgnAd3SNSLzzoHDcMGk8/tfpg8uAHe/27JVRQNPpK6U8ok9/M7EeSdjNqA2Pn834 HdWGL8Aod1e/JJiN4N/TX18K8hMoDixLQ0vcI5+2kz5JdzVO3Yo4VPCBbhupdKgJmgsw eFFF8jyysvMUwYhQloVcWI1xVhPKeehypra104toQPc8QACQBJD5T7VmLwB3KWIT5RWI E5Cw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si3244889pge.370.2017.10.16.08.28.57; Mon, 16 Oct 2017 08:28:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754229AbdJPP2z (ORCPT + 27 others); Mon, 16 Oct 2017 11:28:55 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58582 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753693AbdJPP2x (ORCPT ); Mon, 16 Oct 2017 11:28:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D364F164F; Mon, 16 Oct 2017 08:28:52 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7DD5F3F483; Mon, 16 Oct 2017 08:28:51 -0700 (PDT) From: Mark Rutland To: daniel.lezcano@linaro.org Cc: marc.zyngier@arm.com, tglx@linutronix.de, ard.biesheuvel@linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland Subject: [PATCH 2/2] clocksource: arm_arch_timer: fix DEFINE_PER_CPU expansion Date: Mon, 16 Oct 2017 16:28:39 +0100 Message-Id: <20171016152839.14964-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171016152839.14964-1-mark.rutland@arm.com> References: <20171016152839.14964-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Our ctags mangling script can't handle newlines inside of a DEFINE_PER_CPU(), leading to an annoying message whenever tags are built: ctags: Warning: drivers/clocksource/arm_arch_timer.c:302: null expansion of name pattern "\1" This was dealt with elsewhere in commit: 25528213fe9f75f4 ("tags: Fix DEFINE_PER_CPU expansions") ... by ensuring each DEFINE_PER_CPU() was contained on a single line, even where this would violate the usual code style (checkpatch warnings and all). Let's do the same for the arch timer driver, and get rid of the distraction. Signed-off-by: Mark Rutland Cc: Daniel Lezcano Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org --- drivers/clocksource/arm_arch_timer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.11.0 Acked-by: Mark Rutland diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 14e2419063e9..0ecf5beb56ec 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -299,8 +299,7 @@ static u64 notrace arm64_858921_read_cntvct_el0(void) #endif #ifdef CONFIG_ARM_ARCH_TIMER_OOL_WORKAROUND -DEFINE_PER_CPU(const struct arch_timer_erratum_workaround *, - timer_unstable_counter_workaround); +DEFINE_PER_CPU(const struct arch_timer_erratum_workaround *, timer_unstable_counter_workaround); EXPORT_SYMBOL_GPL(timer_unstable_counter_workaround); DEFINE_STATIC_KEY_FALSE(arch_timer_read_ool_enabled);