From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD3DC4332F for ; Fri, 10 Dec 2021 18:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237958AbhLJSsh (ORCPT ); Fri, 10 Dec 2021 13:48:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245560AbhLJSsb (ORCPT ); Fri, 10 Dec 2021 13:48:31 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D2EC061A72 for ; Fri, 10 Dec 2021 10:44:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2F22AB8294F for ; Fri, 10 Dec 2021 18:44:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50FECC341CF; Fri, 10 Dec 2021 18:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639161892; bh=bkBYT4k3ZBuYZ8y2fivhAQZeTAtf+sRlywstAAKtKAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vie496r+Le5KbRmSA4DhUczcT81KaXsgK/oKqf24sLJTgAg/SoAC3SWI7Ne/svESM 2nc60GDANp5C2HpKCBLvf3qD7EXQpRoRn+/3E+LY2GLHpI51lzNVPdI2MvthP5K+Oo JQQ5YYDQkpovdRgT1so7AZyCxkQb4L2ieoDLXnkBTOTDn6FZLE0rvhwFwf0RPmddNI VNBgOZYbJvuaDUq4rhR6CtjSCUAUHerp+OZ1V9d7VDetjIOSPhzD+ylX48DUDjrkqY kbRnVyEpM7xcMgC6GeGJi8zTkUhdA/2fBUnIWfgxovJV4+HTLHhf3+IZs6vzNFDGtA g9UkLIbKGBfFA== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: Alan Hayward , Luis Machado , Salil Akerkar , Basant Kumar Dwivedi , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v7 26/37] arm64/sme: Disable streaming mode and ZA when flushing CPU state Date: Fri, 10 Dec 2021 18:41:22 +0000 Message-Id: <20211210184133.320748-27-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211210184133.320748-1-broonie@kernel.org> References: <20211210184133.320748-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1982; h=from:subject; bh=bkBYT4k3ZBuYZ8y2fivhAQZeTAtf+sRlywstAAKtKAw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhs59SF7IRoTtmIhOBN87ihEgbe/Qa6QjrTf127RPC la4ME1iJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYbOfUgAKCRAk1otyXVSH0KZGB/ 9ghnvNGWa5guiA6StYSHxrVnWZzTmcrO5eLcyirSqX/xiCT7b4OsuHqsRB2kljDua60QdasaPqJ1q2 FwgoGJncOSt7kNB/p6jawba4n7wbFGrXPqIsoqqBlVoXsocBrqmjT19M6Mi7mHYAQEhIRYa4/ba5bR af71FFq9G28tytXml6XY7kQib7US/nyOtDW1YpcZRKa19KES7KolV4D5ZMEHUbDem4z7WRww6eUa52 3cEVqGSKa04ksxS5PWsSNY8jiq9LEPHqHDBIoVx5YUZ9iiqwOvwRAA2H10lGKO6FkSv6y0uWcu0479 ueNpvoo1SPHReWGMLBE74qt5zxhtk7 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Both streaming mode and ZA may increase power consumption when they are enabled and streaming mode makes many FPSIMD and SVE instructions undefined which will cause problems for any kernel mode floating point so disable both when we flush the CPU state. This covers both kernel_neon_begin() and idle and after flushing the state a reload is always required anyway. Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimd.h | 7 +++++++ arch/arm64/kernel/fpsimd.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 99b5b822c47f..a7291917218c 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -306,6 +306,12 @@ static inline void sme_smstop_sm(void) asm volatile(".inst 0xd503427f"); } +static inline void sme_smstop(void) +{ + /* SMSTOP SM is an alias for MSR SVCRSMZA, #0 */ + asm volatile(".inst 0x7f4603d5"); +} + static inline int sme_max_vl(void) { return vec_max_vl(ARM64_VEC_SME); @@ -328,6 +334,7 @@ static inline void sme_alloc(struct task_struct *task) { } static inline void sme_smstart_sm(void) { } static inline void sme_smstop_sm(void) { } +static inline void sme_smstop(void) { } static inline int sme_set_current_vl(unsigned long arg) { diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index fde9f4ee81ac..bb174c1b8ae0 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1771,6 +1771,15 @@ static void fpsimd_flush_cpu_state(void) { WARN_ON(!system_supports_fpsimd()); __this_cpu_write(fpsimd_last_state.st, NULL); + + /* + * Leaving streaming mode enabled will cause issues for any kernel + * NEON and leaving streaming mode or ZA enabled may increase power + * consumption. + */ + if (system_supports_sme()) + sme_smstop(); + set_thread_flag(TIF_FOREIGN_FPSTATE); } -- 2.30.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 52281C433F5 for ; Fri, 10 Dec 2021 19:07:09 +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=p39rGn0vwPnVJINhWF9gAjHk7v3EYj9imlhWNjVSs9U=; b=rhNER97hmwlHky si2fe4RPDwt+I6h+pHcDZVLkW/Oz31NoFxbL0vP5KB7y6Bs9QvZrPZ/ITDpnn5PLrlI3Hu4x4mJTt nxCuSVwrVxPCGf+lEMd/8haoqj3bCZKWVcrKfqQRELUbi3eWXpY2NHzBaLzBq05gd7BnNuSA3SXWw 3chsgseUTNUoYT9+70AoB3hmyoymciuymKoPT0jJgOsgtVmMpNSivXbB5MASfdfVZE3CqSk/lBMSL yQxIcBuqGf4Jf/UoSE9fuD0b0xN8eiW8hkSaSWnwsxbd7aULIBzcXdODW1sMVwfhcilyrrcTukawH luFhSw1gEatASa+fsEWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvlCk-003Ny0-Ag; Fri, 10 Dec 2021 19:05:14 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvkt6-003FjJ-Dv for linux-arm-kernel@lists.infradead.org; Fri, 10 Dec 2021 18:44:58 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id AA247CE2C78; Fri, 10 Dec 2021 18:44:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50FECC341CF; Fri, 10 Dec 2021 18:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639161892; bh=bkBYT4k3ZBuYZ8y2fivhAQZeTAtf+sRlywstAAKtKAw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vie496r+Le5KbRmSA4DhUczcT81KaXsgK/oKqf24sLJTgAg/SoAC3SWI7Ne/svESM 2nc60GDANp5C2HpKCBLvf3qD7EXQpRoRn+/3E+LY2GLHpI51lzNVPdI2MvthP5K+Oo JQQ5YYDQkpovdRgT1so7AZyCxkQb4L2ieoDLXnkBTOTDn6FZLE0rvhwFwf0RPmddNI VNBgOZYbJvuaDUq4rhR6CtjSCUAUHerp+OZ1V9d7VDetjIOSPhzD+ylX48DUDjrkqY kbRnVyEpM7xcMgC6GeGJi8zTkUhdA/2fBUnIWfgxovJV4+HTLHhf3+IZs6vzNFDGtA g9UkLIbKGBfFA== From: Mark Brown To: Catalin Marinas , Will Deacon , Shuah Khan , Shuah Khan Cc: Alan Hayward , Luis Machado , Salil Akerkar , Basant Kumar Dwivedi , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, Mark Brown Subject: [PATCH v7 26/37] arm64/sme: Disable streaming mode and ZA when flushing CPU state Date: Fri, 10 Dec 2021 18:41:22 +0000 Message-Id: <20211210184133.320748-27-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211210184133.320748-1-broonie@kernel.org> References: <20211210184133.320748-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1982; h=from:subject; bh=bkBYT4k3ZBuYZ8y2fivhAQZeTAtf+sRlywstAAKtKAw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBhs59SF7IRoTtmIhOBN87ihEgbe/Qa6QjrTf127RPC la4ME1iJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYbOfUgAKCRAk1otyXVSH0KZGB/ 9ghnvNGWa5guiA6StYSHxrVnWZzTmcrO5eLcyirSqX/xiCT7b4OsuHqsRB2kljDua60QdasaPqJ1q2 FwgoGJncOSt7kNB/p6jawba4n7wbFGrXPqIsoqqBlVoXsocBrqmjT19M6Mi7mHYAQEhIRYa4/ba5bR af71FFq9G28tytXml6XY7kQib7US/nyOtDW1YpcZRKa19KES7KolV4D5ZMEHUbDem4z7WRww6eUa52 3cEVqGSKa04ksxS5PWsSNY8jiq9LEPHqHDBIoVx5YUZ9iiqwOvwRAA2H10lGKO6FkSv6y0uWcu0479 ueNpvoo1SPHReWGMLBE74qt5zxhtk7 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211210_104456_901262_B120A4E9 X-CRM114-Status: GOOD ( 12.83 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Both streaming mode and ZA may increase power consumption when they are enabled and streaming mode makes many FPSIMD and SVE instructions undefined which will cause problems for any kernel mode floating point so disable both when we flush the CPU state. This covers both kernel_neon_begin() and idle and after flushing the state a reload is always required anyway. Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimd.h | 7 +++++++ arch/arm64/kernel/fpsimd.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 99b5b822c47f..a7291917218c 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -306,6 +306,12 @@ static inline void sme_smstop_sm(void) asm volatile(".inst 0xd503427f"); } +static inline void sme_smstop(void) +{ + /* SMSTOP SM is an alias for MSR SVCRSMZA, #0 */ + asm volatile(".inst 0x7f4603d5"); +} + static inline int sme_max_vl(void) { return vec_max_vl(ARM64_VEC_SME); @@ -328,6 +334,7 @@ static inline void sme_alloc(struct task_struct *task) { } static inline void sme_smstart_sm(void) { } static inline void sme_smstop_sm(void) { } +static inline void sme_smstop(void) { } static inline int sme_set_current_vl(unsigned long arg) { diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index fde9f4ee81ac..bb174c1b8ae0 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1771,6 +1771,15 @@ static void fpsimd_flush_cpu_state(void) { WARN_ON(!system_supports_fpsimd()); __this_cpu_write(fpsimd_last_state.st, NULL); + + /* + * Leaving streaming mode enabled will cause issues for any kernel + * NEON and leaving streaming mode or ZA enabled may increase power + * consumption. + */ + if (system_supports_sme()) + sme_smstop(); + set_thread_flag(TIF_FOREIGN_FPSTATE); } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel