From patchwork Wed Jun 28 08:05:14 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: 13295329 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 8A765EB64DC for ; Wed, 28 Jun 2023 08:06:10 +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=77mrozfZ/VBlmPNGV/e+ckZJXb81CHWksy3ZfK4jZY4=; b=CpdocYXHA6GncG ZqS8Y5NECDXL4SvmLTCtw33Ryh8VtCobzUbuvzuL3slWOTBat24jw6XT578M5RLWeYIeeUDA1J/6m hxm1eG4VPe+Dx3KaDokqO3Bf8ISBv5TA5qi3zgXVN/P5C7RUqx0/1Coe6W2o5kvjlwtIZPMqUfj19 RcXh18G58FcJIypXbR9MwpknEi/n3ZYWESBC7K59Hl+HsJmTUiXNOOa0W8em8AXwlIH7YpFdvcvOe 6TjWeBf0Uprc5jmDmYae4mIJjZw32hsk6nkP5xR8ChB6jwOk2wiy3DPHUwmhGnPbY40XzvP9CAGWX LvdCgqRdyTFq4/IKPRpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBI-00F7Yf-0N; Wed, 28 Jun 2023 08:05:40 +0000 Received: from galois.linutronix.de ([193.142.43.55]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qEQBF-00F7XK-2n for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2023 08:05:39 +0000 From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687939533; 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=HrA5rCi04S6iMZETdNVv7bbSACeaTlVUJZyjM+9n7RM=; b=Bxl4gLvlIZmB0oNBCX9SkSzneNyNiifzdmDNERngEpg2cOhagROErwASoVc2ylaHfO7XCV cgV7drKpSA7qgmoJEVxQ6+I0ex+TEP2jKgwhsuMFeEOTVUHSH+LvmI6eIQcdT0MyySFLto j3LfO4cRcp9LGziertxf3OX0XTfM2+ZLdTD5Y1xOiKbtmk/hjG/5QDSOihTqK2dvGSlg76 xjUqJUHR3g+JdY+a8liqXel/0WydvwvKclbA0TVdNRpp/B4udFchv7vGobDeox1Dv609pH 4s9QvTIjDWrd4Q4vFZE+nkTqF26qt9cmJZiJPDQZ44NV8iPUzy9xRAg4VTuFLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687939533; 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=HrA5rCi04S6iMZETdNVv7bbSACeaTlVUJZyjM+9n7RM=; b=meOtisLKBh/RR9OaSBb3CcAD0Oiy0VnuZ5Vd1ytoMuzUdCHdz2JAxKKJsokviie7LiaMDC WMOUkw9XUV2/gXAg== To: linux-arm-kernel@lists.infradead.org Cc: Russell King , Ard Biesheuvel , Thomas Gleixner , Sebastian Andrzej Siewior Subject: [PATCH v2 2/4] ARM: vfp: Use vfp_lock() in vfp_sync_hwstate(). Date: Wed, 28 Jun 2023 10:05:14 +0200 Message-Id: <20230628080516.798032-3-bigeasy@linutronix.de> In-Reply-To: <20230628080516.798032-1-bigeasy@linutronix.de> References: <20230628080516.798032-1-bigeasy@linutronix.de> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230628_010538_052269_E3208A59 X-CRM114-Status: GOOD ( 12.48 ) 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 --- 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 0a21e13095809..524aec81134ba 100644 --- a/arch/arm/vfp/vfpmodule.c +++ b/arch/arm/vfp/vfpmodule.c @@ -539,11 +539,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); /* @@ -554,8 +552,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. */