From patchwork Wed Jun 26 14:46:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 11018023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ADC1514E5 for ; Wed, 26 Jun 2019 14:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BF8F28927 for ; Wed, 26 Jun 2019 14:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 908FA28950; Wed, 26 Jun 2019 14:48:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2CFB228927 for ; Wed, 26 Jun 2019 14:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=TCDyvYqOXjVPkjlUTLqvJh6EdE6VzmBuWCq16Srfbn8=; b=oanxAjgaTBRge8nLzwxoXIqqAX RUAlRSTTo5VKr+QgwH3v1TM6wuHMZ+5tnHMHC9pj1ukwX1S2kAxf5jixx+BfQof78lavi2UAV1kkd 0hCimYF2XhbAgnyLcSw6pDeAWixZjQkK64hKQWgXS1+h2XYZE3wq00KXOhwRYAh2yftvQ6QFvWzvv Zf3dcNDm0nlP795W7AG3+lxS6+TG6+gZaWE23ZEI3mXhimRt+yilo7v+l6KWwPOe6YqaYrAZ/SYsX /D4HKpinKnLyGQs/utpoKSkaNu3+/rSfXfUTMOgtaemrfLgkf1TlJfW976BvZz1js1rvnZpPJ+ycJ ApU+rn1A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hg9E6-0003FF-E0; Wed, 26 Jun 2019 14:48:46 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hg9D1-0002RT-Lr for linux-arm-kernel@lists.infradead.org; Wed, 26 Jun 2019 14:47:46 +0000 Received: by mail-wr1-x442.google.com with SMTP id x4so3064868wrt.6 for ; Wed, 26 Jun 2019 07:47:39 -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=cbSVQ22cXPOUgxve/+oaGWixu1F5XT9Nb/A3w74S+UE=; b=ADrxohoqxEA4hrkpsvA4KMOL9BPGGlrCiOlq/QZCevYKtpGMvxsSL52rFciR/q43DH F29Dg//dFlpDIO6EW1kiVSMeZktpL6pUM+nPBO4Ta8KaKFNthzMQ+3UnrxXX2IAFvNsr ttT1a1yAE4ZYsswIxky/yPdZFa0xdNutsvaa7q1rCZB6Mzvx8a1dAp8X311VyQDuF6Zi ASDFEI2fS3zPRj/Oudpv83ZAyCn7TXnh1n1wRQRZqwDtSfV2x+hLtzMc3LBCCHr+Nuqm LeJImWUPEKNBYULG7dzAKjxQPA5NoxP0pg+H0e98H0YnqSdUozrUrvMT1aq1d9c+Z4h3 UeyQ== 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=cbSVQ22cXPOUgxve/+oaGWixu1F5XT9Nb/A3w74S+UE=; b=mZTf2NNJ6I53znbuMBslTdi0rZDTuefWyNbn89V0g4C+XAXqQEifJ7rHWqQLch4DXH RneO0hR4/gZ2BsQiz9+CBlI4qtrJx6f3jVrgyBUWRmcHTubKmiQILuKYDlLWd8mAcpw4 zp/6dKAZrY/ErNgAt8JPGfKlL1b/Sm/50fYi3eCQdrcRaKfJZJ+h6CWnDaHv1x721d8F bk1Fby1tr8kLvPp0MIGDJqyEgE6/RcvfDazSo6JXctdhMq84vnidyC5FsykZwbqhNL4m lQY32osEMaM8sGSYrWspoqri+VOxex/yKJ6sgRZogveEQs0z6tWm812o05nPH6oWTTsT poxA== X-Gm-Message-State: APjAAAVvzkclEaRTw+W61aLv91hbFpR34kV8CD5xtVkBiQG5AN3kCDsE HmRcOQt5WKbaw4HLBD12V92M1A== X-Google-Smtp-Source: APXvYqzTjIqk61G6aHfR2ZgD6gNM87lxfg/p2FltiDAPAz0K8FYGcNPE/L6KykeVG6B+7+bxPjBNFg== X-Received: by 2002:adf:ce88:: with SMTP id r8mr4326334wrn.42.1561560458255; Wed, 26 Jun 2019 07:47:38 -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.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jun 2019 07:47:37 -0700 (PDT) From: Daniel Lezcano To: tglx@linutronix.de Subject: [PATCH 15/25] clocksource/drivers/arm_arch_timer: Extract elf_hwcap use to arch-helper Date: Wed, 26 Jun 2019 16:46:41 +0200 Message-Id: <20190626144651.16742-15-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190626_074740_099849_D2E48055 X-CRM114-Status: GOOD ( 14.50 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Russell King , Andrew Murray , "moderated list:ARM ARCHITECTED TIMER DRIVER" MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Murray Different mechanisms are used to test and set elf_hwcaps between ARM and ARM64, this results in the use of ifdeferry 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 Acked-by: Mark Rutland Acked-by: Will Deacon Signed-off-by: Daniel Lezcano --- arch/arm/include/asm/arch_timer.h | 10 ++++++++++ arch/arm64/include/asm/arch_timer.h | 13 +++++++++++++ drivers/clocksource/arm_arch_timer.c | 15 ++------------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/arch/arm/include/asm/arch_timer.h b/arch/arm/include/asm/arch_timer.h index 4b66ecd6be99..99175812d903 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 @@ -124,6 +125,15 @@ static inline void arch_timer_set_cntkctl(u32 cntkctl) isb(); } +static inline void arch_timer_set_evtstrm_feature(void) +{ + elf_hwcap |= HWCAP_EVTSTRM; +} + +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 50b3ab7ded4f..a847a3ee6cab 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 @@ -240,4 +241,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 5c69c9a9a6a4..3c8afcd3444c 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -804,14 +804,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); } @@ -1040,11 +1033,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;