Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4902708yba; Tue, 30 Apr 2019 06:17:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqypCUM8KOrfo16Dh6dQAp4cgjrU3uC9iQgrtkISLF/AkqSxMMf3mvj68lyxu6d7oyrzR9q3 X-Received: by 2002:a62:6807:: with SMTP id d7mr68907977pfc.75.1556630231681; Tue, 30 Apr 2019 06:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556630231; cv=none; d=google.com; s=arc-20160816; b=qpYe+2TQxHPKwH2ya1nw2z/goPUxHmwSNDsBOLmTWg4g2+1b5wle13Z/ZNU/BOTeJd 1WsE+9qlMfp+GvpOpwAbb2SelKmwkhbBg1p6u6aOpHwbcbl1Wsoc73H/W1X9Z6cDi9X0 g40hyWB5Cptr+ApkHgGTJBZ2/B8ZfpFwbGGRN1FFcHpIP7GeMHmipFbMnk2MXAa79/4e A1HF1lnSYEUu+3ph1txhXEO3wHGzXdEn5VJN/EsbgBUy27/JHKb7lGqgmkwhQ08zhA/x LfZQA6vbBnpjRDA80U7fwz4yCiNgBtowG/wpLCt7Id4BfTCMdhJ6ceJZhqVyA28zXSAG gBdQ== 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 :message-id:date:subject:cc:to:from; bh=EAY6YnYx1QuMXk5lUktShYqSA8OR/N7RcyfLT7eiu54=; b=Xh3nJ2x0nEjFf93dwuCu3s1Gzn2sPLLb+6aqqvGmW0Wx5R0jozKI466Zm15F6eot+4 Dxfey7ibbvlQXXYqoYr23NK1g+0ie0S88CHkTzMxLlU2r5dtix+uYoWxMbIHX/0YQokU ERTseGjhVz37/3RqtMnpcvDhL6h8LS64tWdJ1nGU0NLoxp0hQ1M5jRnkrjJLtrNpnzzQ ilXZYKUDC3cO6A+qk1Xp30nZIQwmlHDI4uBGhvmqND9ukBEtQoF8Dbj5wM4n6xLKDbq0 aUP9P3dKNms5vL9wZH/FCxnqa1ifbg6qGDQ2cTfpTG3+pidDXVGcVqxRG+NvY7tT8ti+ pd0w== 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 184si3119806pfg.32.2019.04.30.06.16.54; Tue, 30 Apr 2019 06:17:11 -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 S1727668AbfD3NOV (ORCPT + 99 others); Tue, 30 Apr 2019 09:14:21 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46832 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726614AbfD3NOU (ORCPT ); Tue, 30 Apr 2019 09:14:20 -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 1A11D80D; Tue, 30 Apr 2019 06:14:20 -0700 (PDT) Received: from e119886-lin.cambridge.arm.com (unknown [10.37.6.20]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A73E03F5AF; Tue, 30 Apr 2019 06:14:18 -0700 (PDT) From: Andrew Murray To: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] clocksource/arm_arch_timer: extract elf_hwcap use to arch-helper Date: Tue, 30 Apr 2019 14:14:13 +0100 Message-Id: <20190430131413.10017-1-andrew.murray@arm.com> X-Mailer: git-send-email 2.21.0 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 Different mechanisms are used to test and set elf_hwcaps between ARM and ARM64, this results in the use of #ifdef's in this file when setting/testing for the EVTSTRM hwcap. Let's improve readability by extracting this to an arch helper. Signed-off-by: Andrew Murray --- arch/arm/include/asm/arch_timer.h | 13 +++++++++++++ arch/arm64/include/asm/arch_timer.h | 13 +++++++++++++ drivers/clocksource/arm_arch_timer.c | 15 ++------------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h index 0a8d7bba2cb0..f21e038dc9f3 100644 --- a/arch/arm/include/asm/arch_timer.h +++ b/arch/arm/include/asm/arch_timer.h @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -110,6 +111,18 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl) isb(); } +static inline bool arch_timer_set_evtstrm_feature(void) +{ + elf_hwcap |= HWCAP_EVTSTRM; +#ifdef CONFIG_COMPAT + compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM; +#endif +} + +static inline bool arch_timer_have_evtstrm_feature(void) +{ + return elf_hwcap & HWCAP_EVTSTRM; +} #endif #endif diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/arch_timer.h index f2a234d6516c..f371d4a94f06 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -20,6 +20,7 @@ #define __ASM_ARCH_TIMER_H #include +#include #include #include @@ -165,4 +166,16 @@ static inline int arch_timer_arch_init(void) return 0; } +static inline void arch_timer_set_evtstrm_feature(void) +{ + cpu_set_named_feature(EVTSTRM); +#ifdef CONFIG_COMPAT + compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM; +#endif +} + +static inline bool arch_timer_have_evtstrm_feature(void) +{ + return cpu_have_named_feature(EVTSTRM); +} #endif diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 6cc8aff83805..5e507e81515f 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -833,14 +833,7 @@ static void arch_timer_evtstrm_enable(int divider) cntkctl |= (divider << ARCH_TIMER_EVT_TRIGGER_SHIFT) | ARCH_TIMER_VIRT_EVT_EN; arch_timer_set_cntkctl(cntkctl); -#ifdef CONFIG_ARM64 - cpu_set_named_feature(EVTSTRM); -#else - elf_hwcap |= HWCAP_EVTSTRM; -#endif -#ifdef CONFIG_COMPAT - compat_elf_hwcap |= COMPAT_HWCAP_EVTSTRM; -#endif + arch_timer_set_evtstrm_feature(); cpumask_set_cpu(smp_processor_id(), &evtstrm_available); } @@ -1059,11 +1052,7 @@ static int arch_timer_cpu_pm_notify(struct notifier_block *self, } else if (action == CPU_PM_ENTER_FAILED || action == CPU_PM_EXIT) { arch_timer_set_cntkctl(__this_cpu_read(saved_cntkctl)); -#ifdef CONFIG_ARM64 - if (cpu_have_named_feature(EVTSTRM)) -#else - if (elf_hwcap & HWCAP_EVTSTRM) -#endif + if (arch_timer_have_evtstrm_feature()) cpumask_set_cpu(smp_processor_id(), &evtstrm_available); } return NOTIFY_OK; -- 2.21.0