From patchwork Fri Jun 28 13:46:17 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: 13716169 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 2DB75C3064D for ; Fri, 28 Jun 2024 13:47:38 +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=J2uwro0USi9yPDkujdmIPQNGApewYYsXCGLKq5MRblc=; b=4gDjFaJg3ULMXA7MisUlboWSQv YDBAM1Pm+v7d5LR3hyM3W9usISb5teQoU4NylvG+9dABkzifUspQPNOxAdhJAz6D1bHCh01ruJS4F S/swSkokD9MEF6pJyU2kh7TYr0DlSikGg8bYRHj3TAi+o5WNuWlePgajvF74n0F0XGo1caqQOwYHd 4vZl1WLKaKPFfCB/R1F8Jk50QFHQDwZGNKUbj/uaFp0IeKUQp6CVyiP4w7TP7pPZCE302MJVpwu7G NvmnxAaVePsbxwzBx/H+azZCtkFFbFiOo4TeCpE5Nd4EXrvunfYN4CKmoCMFerefyUT3ap7/qQdKH 2uETW1eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sNBwm-0000000DrXK-14t8; Fri, 28 Jun 2024 13:47:28 +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 1sNBwG-0000000DrNj-2dxJ for linux-arm-kernel@lists.infradead.org; Fri, 28 Jun 2024 13:47:03 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1719582414; 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=J2uwro0USi9yPDkujdmIPQNGApewYYsXCGLKq5MRblc=; b=Htjx2RH+Xjjt/8sO2DqbpRfDZ4sABAdpG1cxwbTmsjPcNZ0TU5yWpPyjKiXevu65V0GxHK 6ZB70ZPCQOSlz2FMKrCvS2adBxQcxepIdtYvCz/QPAYYdKqSJxC294HIyfqgl3jNfv3hEh 74eOZnF6Acabjc4LYFzThWNrHNvBpyB5bCFeQmIdrFUtSpl07AV0U66wDFG1JnLylbDApC eUoZPXFtPhOi8kuGBShD5YxFBLrInBbNTgQhCia/KbifF5J8yN4KmShAKZdn/VtbN+RwoK e+GRSdZjEBnn8LTofP0j7S0nfJ6Tehw6UuTju2RfMxnDnT9o1X4G6GGJPs/YmQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1719582414; 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=J2uwro0USi9yPDkujdmIPQNGApewYYsXCGLKq5MRblc=; b=+R9ga/1rCUCxEI4oNdf+kUVnsPb3Nnqsx2P94UMS3GKqeDJDYRTE8tdGYbOp8QeAqRdib8 PheKnPwNgUMqBvBg== To: linux-arm-kernel@lists.infradead.org Cc: Arnd Bergmann , Russell King , Thomas Gleixner , Sebastian Andrzej Siewior , Ard Biesheuvel Subject: [PATCH v5 2/4] ARM: vfp: Use vfp_lock() in vfp_sync_hwstate(). Date: Fri, 28 Jun 2024 15:46:17 +0200 Message-ID: <20240628134648.1852041-3-bigeasy@linutronix.de> In-Reply-To: <20240628134648.1852041-1-bigeasy@linutronix.de> References: <20240628134648.1852041-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240628_064656_837194_140847C8 X-CRM114-Status: GOOD ( 12.01 ) 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. */