From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44A76C433F5 for ; Tue, 19 Apr 2022 18:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YSpfL830k/B7Pa0QgBZ8GTGNMiD1Ei/sw3HqDsThVdU=; b=JfyX81S/qSYhxl /pAqChIjUiNMBpUGIZpjugkyne5O5+JqEKI/K1N6eeL4KNVvgfKjbBLJkgm3gswp0DdN3VtFLRdi8 El/idWeaZPYAX0buQyAUV4Z/VFDZ/LNFnekjje8fV/sJHz4dY5lO0k5iMDGtxi5cT56UVtQUUdKMM m1OQt5Mm3uOlWi0OUVI5Ny33rtzHjQaQZ7WtvjXfPWgmxM7B7NMq1n3Ff3N0hQqrTYJUCXH/wCvZ+ oyBax3RLaVJWePs+USPuArbn75AbnFVrG0wLKJoF9LPaBgDUcDU1Cg9AiFMPYBg6ENC5/nCaElAZZ /tr7zoMYyVRYc0lHNfOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngsxW-005pk0-L2; Tue, 19 Apr 2022 18:52:19 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ngsvE-005ohV-1N for linux-arm-kernel@lists.infradead.org; Tue, 19 Apr 2022 18:49:57 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6F764B818E3; Tue, 19 Apr 2022 18:49:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AE55C385A7; Tue, 19 Apr 2022 18:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650394193; bh=NsQzBnqyQikJz4t5vv6/pIfEg6KlxVdCJGyHvursnek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PsLZPyeR7NEosrxFAH6xo9aVOEo6xXUnhE0ADprj/RG8wklR6ikAnBz7hQ+9OLSXl HHgdTY7IfFkZUoVq2EeG/HvVtxxvENLGsyOewpM8GPBxlGo4q1wfJ9zI8vWAChkfKu 3YBW4VpWYO2vqgSyIM/S8lNvXcX+ibogecHS/l4Fo+pEgPRpC04qWELX/lIunJFHv/ YbzkjzijOxaOU55uM3q5P2bvFuned33fzZoacKbSHw/bntB/pytKsNkzAygbOpFH73 QZbR4KQiY2YMF98jIHplltBySjBtq7QXoI4L1k7t8aCoKDFcoIxF2Toq3wYchN978F /O9RSgkhYi2Rg== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ngsa7-005QYF-Vt; Tue, 19 Apr 2022 19:28:08 +0100 From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Catalin Marinas , Will Deacon , Mark Rutland , James Morse , Suzuki K Poulose , Alexandru Elisei , Joey Gouly , kernel-team@android.com Subject: [PATCH v2 10/10] arm64: Use WFxT for __delay() when possible Date: Tue, 19 Apr 2022 19:27:55 +0100 Message-Id: <20220419182755.601427-11-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220419182755.601427-1-maz@kernel.org> References: <20220419182755.601427-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, mark.rutland@arm.com, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, joey.gouly@arm.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220419_114956_270647_07A6FEFD X-CRM114-Status: GOOD ( 16.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Marginally optimise __delay() by using a WFIT/WFET sequence. It probably is a win if no interrupt fires during the delay. Signed-off-by: Marc Zyngier --- arch/arm64/lib/delay.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/arm64/lib/delay.c b/arch/arm64/lib/delay.c index 1688af0a4c97..5b7890139bc2 100644 --- a/arch/arm64/lib/delay.c +++ b/arch/arm64/lib/delay.c @@ -27,7 +27,17 @@ void __delay(unsigned long cycles) { cycles_t start = get_cycles(); - if (arch_timer_evtstrm_available()) { + if (cpus_have_const_cap(ARM64_HAS_WFXT)) { + u64 end = start + cycles; + + /* + * Start with WFIT. If an interrupt makes us resume + * early, use a WFET loop to complete the delay. + */ + wfit(end); + while ((get_cycles() - start) < cycles) + wfet(end); + } else if (arch_timer_evtstrm_available()) { const cycles_t timer_evt_period = USECS_TO_CYCLES(ARCH_TIMER_EVT_STREAM_PERIOD_US); -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel