From patchwork Fri Mar 15 14:51:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13593577 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 D1531C54E67 for ; Fri, 15 Mar 2024 14:52:39 +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=PpZzAzjnkxZBOZYKKM6AhOJPuGY43IZOxJiTBxfgxRI=; b=21+Z2+H2b8O4CX ippH2xTgL3PeLKAD3VA8BIwZ60d6XLUK95eFINgtMOR58NYzK8+a3C6sz1VU58+dO0eADywNtvY5O 7GUjPPBbzS76K3AVEDtOtwWz+jsZwAoS9OmK3mOLYUOXyOruhe4QBr95g+o0UNSuH0LCk5f2VQt5y aVpZa32rCu72vxQbzbkoY4C7UJt9iiGViGyT3EWGrj1PhT+lw7tWgqXZ1Xwr3YP57PZiyC3gvrkph zXe67QkWar/HuPcwVlL2p4bLw6oU9P5Qqt1VMkBjPMzvsax8YgMGtJ0DAvvtKyzaDMU2j8JOMqUbe I6bIIU4ZOdWvQ9tzCzmA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl8v7-00000000Z13-3Wu9; Fri, 15 Mar 2024 14:52:29 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rl8v0-00000000YxE-3KPC for linux-arm-kernel@lists.infradead.org; Fri, 15 Mar 2024 14:52:27 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1710514339; 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=+OAfy5jSCSE565FVlqBI8NImsy1fV4FaCH5/hqY0eJo=; b=HT/ESTnVdqzZ10e/Dm5+TfmwrXVRhrL1bj/JndSsmr0RgE4dqub2xeBWUb4zYwruscMCga /USo//4Vw7qhYuyXsB7v+eWBzMQbkrr3YSM59W0Z3a0RkhQRUr3Xyyt9hzAqdmRVj9ZLd2 jHTH8n75LaoIHwywzL7K+M/WoK5sMwX/Iu8OOqRE+0mRwz02EYamx231CPbWwAMcb8z6wZ 6R0rjIxI3Jab510eCboq00w4xmQ8HUvV2yuGkkF3Q+wtoY7+cMfEAwMMJvpk+6yAV2lkHa QuxD+6LvtoZ2nDDzpbCEd3Wd+9a1C7iE0ST+q4M7Mqqa4U7a90CMCOEm31fKMQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1710514339; 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=+OAfy5jSCSE565FVlqBI8NImsy1fV4FaCH5/hqY0eJo=; b=DhxhWUhD+34qeJXfPn5mnpY6NpcbWM3p22JEg1ZD8UDNfw63e37rrOxjPRQjR2wS7pvQal +X+Qh4X25ayYFZCQ== To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: ardb@kernel.org, tglx@linutronix.de, Sebastian Andrzej Siewior Subject: [PATCH v4 2/4] ARM: vfp: Use vfp_lock() in vfp_sync_hwstate(). Date: Fri, 15 Mar 2024 15:51:01 +0100 Message-ID: <20240315145208.3598288-3-bigeasy@linutronix.de> In-Reply-To: <20240315145208.3598288-1-bigeasy@linutronix.de> References: <20240315145208.3598288-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240315_075223_003690_ED29DEBA X-CRM114-Status: GOOD ( 11.00 ) 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. Reviewed-by: Ard Biesheuvel Signed-off-by: Sebastian Andrzej Siewior --- 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 7d234fc82ebf6..49ccd205ad780 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. */