Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2840196pxj; Sun, 23 May 2021 12:40:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyVRWQUEU3mGOUjV6j0mjvi0+f2W9h6Cr/giogwyUDfWJO3YeBXlxVjfTBIq/YXpujXA4h X-Received: by 2002:a05:6e02:1250:: with SMTP id j16mr12145686ilq.217.1621798807096; Sun, 23 May 2021 12:40:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621798807; cv=none; d=google.com; s=arc-20160816; b=EOOJUFkGD2jejaJr9mvwPiAqVPHEAN8z9jpgA0Wq5NuLgpCRtBllgxNt2AyFciDSU8 eJrT939TXoZeFBCtiv6SWD0kPvFRPCo1lffxGGfPuGnca+IT8xtXmM2arPV4UfPRYhek BrrRuAt5PT43POW1QkiccunoK7YIRs2BHEmE6WHsjQYKCUUPZO8c9lZx9t1JEOsRxv4u jqE6THPfM6MkCB98lqPASI3ZYSZ69N97lmnIao7vc7fMdWnK8KrAAINih9iUD5eR6P7l OtdiDSZ1bZkA/NeyOUrFviwB9qAEgCQZHeF7QMQ+OmRnHsYTAbGafZvQpeY8HOZ9HosP kYfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=vmyQjfEP5azVijF45KEydIod+UQzAJJcvZQRIiSoews=; b=y8k8/XuETfJvy5qjHWuhRVBzJGUueuaO3mgEiYhsC8GdfRHF8+Q0x1F0slaGUjinfc GgHqfqFdvFkTXPCjmjjv9JndJx0FBBXz6KP06xmBw4mp1W84z/pdDbNH5mSNFV62Lbwb 5PYUo827ylp7UoC1bGqjcwR5BB6NiBuzlBX4BC+HmRvovtOSyYAe6/j1KOIe41ZzVDwu 2JDPr+Q+plWXnZcc1ZrthtjnefoyLYXCt6Scpxk6m9pDhk5VzyyVoQbrqVK6o5RIxLRd 8HClhNGPcGV+3zXoNamqZHAvmKh389acc5plftLosSus2or27KOG26mLNb4GlrjNmMph hWFQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si12792250jan.4.2021.05.23.12.39.54; Sun, 23 May 2021 12:40:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232100AbhEWTkM (ORCPT + 99 others); Sun, 23 May 2021 15:40:12 -0400 Received: from mga01.intel.com ([192.55.52.88]:60026 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231976AbhEWTj4 (ORCPT ); Sun, 23 May 2021 15:39:56 -0400 IronPort-SDR: iRie9x8RjeYDu2iOpL01LuHnYa1Z+Yd3G9vmgpdJV0wVQ543Y550Ckt9a7qXs3fKoqRdZcgNfg B2w+6CcsbOoA== X-IronPort-AV: E=McAfee;i="6200,9189,9993"; a="222949097" X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="222949097" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 May 2021 12:38:30 -0700 IronPort-SDR: eqkQqmfWx2FuYSG656d3eWgGt0kr8SnhkpqHWF+yNuVUY8RLdVXVTADFpaKwFzvpbQ7HucimpI N6/KSfrqZJ8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="407467153" Received: from chang-linux-3.sc.intel.com ([172.25.66.175]) by fmsmga007.fm.intel.com with ESMTP; 23 May 2021 12:38:29 -0700 From: "Chang S. Bae" To: bp@suse.de, luto@kernel.org, tglx@linutronix.de, mingo@kernel.org, x86@kernel.org Cc: len.brown@intel.com, dave.hansen@intel.com, jing2.liu@intel.com, ravi.v.shankar@intel.com, linux-kernel@vger.kernel.org, chang.seok.bae@intel.com Subject: [PATCH v5 28/28] x86/fpu/amx: Clear the AMX state when appropriate Date: Sun, 23 May 2021 12:32:59 -0700 Message-Id: <20210523193259.26200-29-chang.seok.bae@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210523193259.26200-1-chang.seok.bae@intel.com> References: <20210523193259.26200-1-chang.seok.bae@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When AMX is enabled, and an AMX-task is saved, explicitly initialize the AMX state after the XSAVE. This assures that the kernel will only request idle states with clean AMX state. In the case of the C6 idle state, this allows the hardware to get to a deeper power saving condition. Signed-off-by: Chang S. Bae Reviewed-by: Len Brown Cc: x86@kernel.org Cc: linux-kernel@vger.kernel.org --- Changes from v4: * Added as a new patch. (Thomas Gleixner) --- arch/x86/include/asm/special_insns.h | 6 ++++++ arch/x86/kernel/fpu/core.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/include/asm/special_insns.h b/arch/x86/include/asm/special_insns.h index 2acd6cb62328..f0ed063035eb 100644 --- a/arch/x86/include/asm/special_insns.h +++ b/arch/x86/include/asm/special_insns.h @@ -306,6 +306,12 @@ static inline int enqcmds(void __iomem *dst, const void *src) return 0; } +static inline void tile_release(void) +{ + /* Instruction opcode for TILERELEASE; supported in binutils >= 2.36. */ + asm volatile(".byte 0xc4, 0xe2, 0x78, 0x49, 0xc0"); +} + #endif /* __KERNEL__ */ #endif /* _ASM_X86_SPECIAL_INSNS_H */ diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c index cccfeafe81e5..53a5869078b8 100644 --- a/arch/x86/kernel/fpu/core.c +++ b/arch/x86/kernel/fpu/core.c @@ -106,6 +106,14 @@ int copy_fpregs_to_fpstate(struct fpu *fpu) */ if (fpu->state->xsave.header.xfeatures & XFEATURE_MASK_AVX512) fpu->avx512_timestamp = jiffies; + + /* + * Since the current task's state is safely in the XSAVE buffer, TILERELEASE + * the TILE registers to guarantee that dirty state will not interfere with the + * hardware's ability to enter the core C6 idle state. + */ + if (fpu->state_mask & XFEATURE_MASK_XTILE_DATA) + tile_release(); return 1; } -- 2.17.1