From patchwork Mon Jul 1 10:56:54 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: 13717905 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 8B7A7C2BD09 for ; Mon, 1 Jul 2024 11:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=s6GnQ90TAizPCumEOLD6neigcNHuWHXShBrqIm6g/lI=; b=FX3vOGXOPO6/MEAk7TvIbDEZUq hxmi0EcoDrenrmWieZl7HI1ezLGtqZUhWwwAUQPwDmkkEigBvt9qcLloAIgYi6/nzNqaIOBO5pcNh j6vkoJwI8zfyuqWSc7KwoA3sUKnNLlykQRvT8NVJi4omKJ9Sv5RMErFiaCUSTvYTS7q4ypcIDgrlt 0AGR9P4eM3dIWgDUhqjOA19Bc+WN6IqsbtuSLlgldY5K86TzoI7lq7thTSFt01f+riczb9bRelBX0 0NK738mny0qqeR0K1zzWUoCngjnNANA3+B14/0BDwWGyaawKZ8oPp8U5abKL6XgNbjGXIM4hYohoV t8y9Sk6Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOEpU-00000002pne-3dxV; Mon, 01 Jul 2024 11:04:16 +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 1sOEom-00000002pYP-43n6 for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 11:03:41 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1719831811; 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=s6GnQ90TAizPCumEOLD6neigcNHuWHXShBrqIm6g/lI=; b=S0SGR0mT/Ro2AzfDVZDBN88zQHeqcKROo8w0uUlWTSh6KjCCAlo1rX+ZToenkZTJX+nSx+ XYyZQ5kNE1a22zxgH6OvgV/Y0c8x6wUAKixNcb/T6U+2vF7WJPCMQ9ZTyyeyN8iCuOnzoF Sfy5zcSXfuRIQh3fgUt1wWR29GXdOriyJmdpMCrn4EDN6J3xHbgj0hm3Xc9MHHNsSDL6Bu Mxp8b3gcs93sAPnQ/3f/LxInRxdq8eDJcG5wrv8aqjy+rZAdwS2PMKl4PucNKpV+xf3mpb l2Rd6Rhu3EQXT2iKKwDHe7d8xkU0w5RHpPCshu6P6JOZEXevN8CawgJaIe8BSA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1719831811; 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=s6GnQ90TAizPCumEOLD6neigcNHuWHXShBrqIm6g/lI=; b=GPSM6WYG9lndGGrhsnBKauQfSLBYHqXp9Db0VJ22fvZOhRpkrcwJ7LKH5fVbFg/lX+e7t4 BbMlCqxhwYlUb/BQ== To: linux-arm-kernel@lists.infradead.org Cc: Arnd Bergmann , Russell King , Thomas Gleixner , Sebastian Andrzej Siewior , Ard Biesheuvel Subject: [PATCH v6 2/4] ARM: vfp: Use vfp_state_hold() in vfp_sync_hwstate(). Date: Mon, 1 Jul 2024 12:56:54 +0200 Message-ID: <20240701110317.99631-3-bigeasy@linutronix.de> In-Reply-To: <20240701110317.99631-1-bigeasy@linutronix.de> References: <20240701110317.99631-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_040333_174585_DE136A7F X-CRM114-Status: GOOD ( 12.07 ) 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_state_hold() 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 63de164c7fc7b..1726db0500760 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_state_hold(); - 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_state_release(); } /* Ensure that the thread reloads the hardware VFP state on the next use. */