From patchwork Tue Sep 26 12:55:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13399232 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 8A4AFE7E630 for ; Tue, 26 Sep 2023 12:55:55 +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=aJezb2e64xkTHp/vMUiunewlzex9SFL+V4JRafXUZ3E=; b=urwuP4TWTPTamp tp7fCPKaZbEbJYA6ROCq4dItWimEgM/xwUdZ9PkJDoq8MaLN0JwNMjoSTcRBmwGdrGUJV09nnON/R w01pmHsv/rSmJagug0n3N2uIUdNBSa2a8X4c1d+VGwsWvbH9BYYp3+VeYgPta5oOY/ohfFCnjdGW/ UzOQQo15W7cO5tFVJ229hQQ820zsTwBL5OprkZBY+OjHbjD0pnFcedieRxLPPW931xAqwdt5vYEbJ 47ua8uhM3phsUp0apznWEODuK7pqhUuwlAUvEOVHcSypdpx3DIi01VftUI/vbA2P+Fa7IkdJ+9jkn 4ZaSUGXkCB0hh4JoAsmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ql7b8-00GPAn-14; Tue, 26 Sep 2023 12:55:30 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ql7av-00GP7P-2R for linux-arm-kernel@lists.infradead.org; Tue, 26 Sep 2023 12:55:19 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695732914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/2onH70G0qf/Ey+4wPpHydILR3hGaEi4eJDs/I3/2lY=; b=TDRWqHnZ9i66BOzoODrKbFTEvnSJyrsMqXUVMPt6ifcplNYuYeyaJ8mG4JVBYDQx1z5530 lsBS44as9U8ty1xBxWIb79vvRKvcUmihaUIcAkfbhithCMcj1Guj+Xj0bqlRcNzdhXPWJB 3NV83jyCcvYQfj7tkIHascP65l1us8i70P35ujCNF6KtGXlDnxHkqfKMkoualA8YX1RFG7 6A59Ye/4AAKg7zQBJvz8BcdyT+/pP4PuX/DCoWUKEz/rot1s0McLaD7iZ/aEYNqZnHX7GW /CGH20TGhxlhEpmpGL4wsRGXU7MoipRxgDSJ8rH2s+OqWfMCplQMayrbASf11Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695732914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/2onH70G0qf/Ey+4wPpHydILR3hGaEi4eJDs/I3/2lY=; b=orHjIGz16kcVEslZjGy3Ql4uwUeHgDaJ203rIOhut47Tr7hp8KAG/HalCTOqR6/OORAwLh JqrfLVq9ygZKGLDg== To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: ardb@kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior Subject: [PATCH v3 2/4] ARM: vfp: Use vfp_lock() in vfp_sync_hwstate(). Date: Tue, 26 Sep 2023 14:55:00 +0200 Message-Id: <20230926125502.1127015-3-bigeasy@linutronix.de> In-Reply-To: <20230926125502.1127015-1-bigeasy@linutronix.de> References: <20230926125502.1127015-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230926_055517_934678_EDD11742 X-CRM114-Status: GOOD ( 11.36 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org vfp_sync_hwstate() uses preempt_disable() followed by local_bh_disable() to ensure that it won't get interrupted while checking the VFP state. This harms PREEMPT_RT because softirq handling can get preempted and local_bh_disable() synchronizes the related section with a sleeping lock which does not work with disabled preemption. Use the vfp_lock() to synchronize the access. Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Ard Biesheuvel --- arch/arm/vfp/vfpmodule.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c index 8d321cdb7ac58..3b9360bfc5081 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -540,11 +540,9 @@ static inline void vfp_pm_init(void) { } */ void vfp_sync_hwstate(struct thread_info *thread) { - unsigned int cpu = get_cpu(); + vfp_lock(); - local_bh_disable(); - - if (vfp_state_in_hw(cpu, thread)) { + if (vfp_state_in_hw(raw_smp_processor_id(), thread)) { u32 fpexc = fmrx(FPEXC); /* @@ -555,8 +553,7 @@ void vfp_sync_hwstate(struct thread_info *thread) fmxr(FPEXC, fpexc); } - local_bh_enable(); - put_cpu(); + vfp_unlock(); } /* Ensure that the thread reloads the hardware VFP state on the next use. */