From patchwork Wed Nov 16 02:49:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 20671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3061841wru; Tue, 15 Nov 2022 18:54:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gJB64hE0unHbygBJe5WVfjAq/m49RVOXcaDXrYG2c+kpJD5HqaQ/nvOqVAp9z/qItPyy7 X-Received: by 2002:a17:902:76c2:b0:188:4ba9:79f9 with SMTP id j2-20020a17090276c200b001884ba979f9mr6883823plt.90.1668567240267; Tue, 15 Nov 2022 18:54:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668567240; cv=none; d=google.com; s=arc-20160816; b=ZF4NtrRVQvpF4QZ9y+3J+eJ4UyAhYpVLFLF73VQ7XML9wb/Hs5x7PT5ch4RjHWQHaW 9JHc49uui3eqneCWMTEFAOCTdKGEaTp7hbDcjlF05cwJo8+Sdlw906c6dzwha58AhD/D ys47O7IrD6DoVmJLTRwEiWeB3ALROt2EV7JqXGYOqnPwHVtsV7DzVQDCwvdtJYA+FYEC AWiOskDE0eJRbR8bqDtFUsKpkRTBbdpZkNaSxofh0Hms5gRllvY2rv3ziEDl0ds3clmA T9Rflgz6j/2T+se/QFmIo4G/UMLHSrMIBRSHkHc21P6e9XXcpjnLy5v+iKbDUy3gaJKw PYLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=f2FnT7gFxz5ezFIsqqTl7mGhz4x4Ei7v/gD+2ahtltY=; b=HO4v2cXznCBC4/qtS+UMKXhzGswyY3lmsRt89RwsZ1sLl3MbWuTWprSVyzPp7Egssc w6tCJhK5qhmIQFHWXu+YvN4x9OhuILFVIcedSLR9feHD9grSbA7ftUw2DpAbW5rnTWq8 ftx+8D+6kadwX2w2NSv10LIf7ZcxYi1ZfBI7b8YeXOS8k2555LN9ghiiLQknrELhfzmD ka5qdu5VP+tor/fgsKDJfekGWHLPh+c/cBUpIXYucWzIDKGOOrzSKYvG7a7/hlS5oYqK DAWN35bsZW/1uxRaVZN/4JR1tsLr96IZ2Di8QMkHUBoc+1PIoHF0xZgfifvsfITVlYfs jIHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BATXj3C+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a170902704300b001781f860a6dsi13253122plt.228.2022.11.15.18.53.45; Tue, 15 Nov 2022 18:54:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BATXj3C+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231678AbiKPCuM (ORCPT + 99 others); Tue, 15 Nov 2022 21:50:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229976AbiKPCuK (ORCPT ); Tue, 15 Nov 2022 21:50:10 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9224E1E72F; Tue, 15 Nov 2022 18:50:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668567009; x=1700103009; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=s20sResmhc8ejFkXsCSWiCoJuJKw41o0gUFDOP1PetU=; b=BATXj3C+hC65EHgfynScfTiMorass7QgXJpsmy9ijP57/EsQQcnggBO6 8u+CLohvGms9xDx/NdHAOMudEmaJvQzRbu+mV7eEVPRF9raIsb46eLP6F yC1fM4q4Qk2R7a2h3TNWJfZIeWDwWV4mFDS6I4dHPlrdHWbXkiq7UVWdO tmEOb8BcFn8TbJ1UyuFINikH+XfjRCp4m3RFT6tnFVCy/1HzwpKL0ryc8 H+UVBv2E2MTBXmlI0tInWrlkkNNzNr7grpSM1aJ8pPLOZfigR0aLi88VF z5RmAdBOzmDFPMaWqVOSJgeWS4uzeqLhcBVuChg3MtiBSMUBelr1qf5GX g==; X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="314243438" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="314243438" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 18:50:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="707974583" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="707974583" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by fmsmga004.fm.intel.com with ESMTP; 15 Nov 2022 18:50:06 -0800 From: Srinivas Pandruvada To: afael@kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Ricardo Neri Subject: [PATCH 1/2] thermal: intel: Prevent accidental clearing of HFI status Date: Tue, 15 Nov 2022 18:49:48 -0800 Message-Id: <20221116024949.2590043-1-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749619562923500333?= X-GMAIL-MSGID: =?utf-8?q?1749619562923500333?= When there is a package thermal interrupt with PROCHOT log, it will be processed and cleared. It is possible that there is an active HFI event status, which is about to get processed or getting processed. While clearing PROCHOT log bit, it will also clear HFI status bit. This means that hardware is free to update HFI memory. When clearing a package thermal interrupt, some processors will generate a "general protection fault" when any of the read only bit is set to 1. The driver maintains a mask of all read-write bits which can be set. This mask doesn't include HFI status bit. This bit will also be cleared, as it will be assumed read-only bit. So, add HFI status bit 26 to the mask. Signed-off-by: Srinivas Pandruvada Reviewed-by: Ricardo Neri --- drivers/thermal/intel/therm_throt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c index 8352083b87c7..9e8ab31d756e 100644 --- a/drivers/thermal/intel/therm_throt.c +++ b/drivers/thermal/intel/therm_throt.c @@ -197,7 +197,7 @@ static const struct attribute_group thermal_attr_group = { #define THERM_STATUS_PROCHOT_LOG BIT(1) #define THERM_STATUS_CLEAR_CORE_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(13) | BIT(15)) -#define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11)) +#define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(26)) static void clear_therm_status_log(int level) { From patchwork Wed Nov 16 02:49:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: srinivas pandruvada X-Patchwork-Id: 20672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3061865wru; Tue, 15 Nov 2022 18:54:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5RE/Nbmmdqp17isZ69heWRrVp14uzZzWtZ2MyD5b2jr4cG6y9tLUr0f71NrElOYAIAqhkF X-Received: by 2002:a17:90a:6384:b0:213:c302:695e with SMTP id f4-20020a17090a638400b00213c302695emr1487732pjj.131.1668567243268; Tue, 15 Nov 2022 18:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668567243; cv=none; d=google.com; s=arc-20160816; b=hpvrLOJ/0toSxEBxNSWcE+GKCg7MW/Ny1SkICy/9MlcpdJPBJWKGrrSImpmaOr6ViI XQttpSnmpxgMVFj0IXfDlb0JuW21OVhint44n6bKBjqsRuShytUBQdLIc9gAAtOkhgNc lWlImuthGTGfhtYcbxvGHSdMgnpcDK++2jGcEbxpUcQ8GxujLxKsKZj9joT6+b5l1EE3 2e0bhjJyyPf3AI3F9UHYCjytReJAP3EbTiafpD11yEDjnyYKZ0y9/mmVHGyIuNJds1UV +NYWhmU2r/w6FrlKd2nCw+xK/6Dyn8gqlOGE+zCOxeiE7cZ9SmlY19kYkTGYI7kWOoCb dWxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h1uBKmcu3P8CqVtDOsil2Zy6ta95bzEhar7nMr9n93A=; b=MZux8GC+iXt+yFiXHk1B5dPJH/fzIJFEvVO+mLDaqtAq+KrQoyakZc2cCqnbLzBL+R JxkNDg3OYSy30oTZToEQlsGPbwzW89HYvkvj1FOxcMjRwxXN1KaghY/89PFb9bGKRH8t Y0v3OqLSas4Oznrj9vBRbqmUjs9v2mILxGsCaSgLhst0HHfNkdAFfxVSN+JjOPoenMdY QTxZyc7rhbc/EE3zcR4VFx7hqh2V2TKHgjP9WUs1H58B+XSGaIjAWBxxi4qi6GeWipVp 1CycWW13G7q5IhkqT7PYdjje2JjJcUAYFAfq7eU7Rxx41UfIGxhTXGqUR2cazIV62N9k cIXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kvKHTX/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s7-20020a170902a50700b00176ab430a57si12761397plq.546.2022.11.15.18.53.47; Tue, 15 Nov 2022 18:54:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kvKHTX/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbiKPCuQ (ORCPT + 99 others); Tue, 15 Nov 2022 21:50:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231657AbiKPCuL (ORCPT ); Tue, 15 Nov 2022 21:50:11 -0500 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5336C1E73C; Tue, 15 Nov 2022 18:50:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668567010; x=1700103010; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cLfHUw/Qj0gHLRW82tX3x7kJi/yXarnUVQ5877/Hb4c=; b=kvKHTX/Ym/pM3vHdviZ1PIgeKnENxbb1VcVp9SikCd5d/OFVLYYAxZ3U 99iaqAmK32+VTO1ueDA0IE8Fj6wZF/QT7wHZLkupXgSAijwZFgT5b+qMW L0rYr5VRFqZm8COcb3xy7u59ZD9EnF3YlAMB+MrJsDuP5HUQVc68KjsR9 9sTUK8lFav3wBjRQx1pJMOgBNvVApxbsjrof4XxBKRfUKXgpGK5bboxGd bHYXveGzA4dJG2JgTeNP4FmaiF5r8fdwxrODzhtgGAISSOcKv5VyfdqPr zbpPwt7QbCHflx1SUPbgU+mQmzfz2XfhbuQxf/P+ife5HyCqN0W/syO1v A==; X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="314243439" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="314243439" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 18:50:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10532"; a="707974587" X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="707974587" Received: from spandruv-desk.jf.intel.com ([10.54.75.8]) by fmsmga004.fm.intel.com with ESMTP; 15 Nov 2022 18:50:06 -0800 From: Srinivas Pandruvada To: afael@kernel.org, daniel.lezcano@linaro.org, amitk@kernel.org, rui.zhang@intel.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada , Ricardo Neri Subject: [PATCH 2/2] thermal: intel: Protect clearing of thermal status bits Date: Tue, 15 Nov 2022 18:49:49 -0800 Message-Id: <20221116024949.2590043-2-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221116024949.2590043-1-srinivas.pandruvada@linux.intel.com> References: <20221116024949.2590043-1-srinivas.pandruvada@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749619565282117771?= X-GMAIL-MSGID: =?utf-8?q?1749619565282117771?= The clearing of the package thermal status is done by Read-Modify-Write operation. This may result in clearing of some new status bits which are being or about to be processed. For example, while clearing of HFI status, after read of thermal status register, a new thermal status bit is set by the hardware. But during write back, the newly generated status bit will be set to 0 or cleared. So, it is not safe to do read-modify-write. Since thermal status Read-Write bits can be set to only 0 not 1, it is safe to set all other bits to 1 which are not getting cleared. Create a common interface for clearing package thermal status bits. Use this interface to replace existing code to clear thermal package status bits. It is safe to call from different CPUs without protection as there is no read-modify-write. Also wrmsrl results in just single instruction. For example while CPU 0 and CPU 3 are clearing bit 1 and 3 respectively. If CPU 3 wins the race, it will write 0x4000aa2, then CPU 1 will write 0x4000aa8. The bits which are not part of clear are set to 1. The default mask for bits, which can be written here is 0x4000aaa. Signed-off-by: Srinivas Pandruvada Reviewed-by: Ricardo Neri --- drivers/thermal/intel/intel_hfi.c | 8 ++----- drivers/thermal/intel/therm_throt.c | 23 ++++++++++---------- drivers/thermal/intel/thermal_interrupt.h | 6 +++++ drivers/thermal/intel/x86_pkg_temp_thermal.c | 9 ++------ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c index a0640f762dc5..c9e0827c9ebe 100644 --- a/drivers/thermal/intel/intel_hfi.c +++ b/drivers/thermal/intel/intel_hfi.c @@ -42,9 +42,7 @@ #include "../thermal_core.h" #include "intel_hfi.h" - -#define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | \ - BIT(9) | BIT(11) | BIT(26)) +#include "thermal_interrupt.h" /* Hardware Feedback Interface MSR configuration bits */ #define HW_FEEDBACK_PTR_VALID_BIT BIT(0) @@ -304,9 +302,7 @@ void intel_hfi_process_event(__u64 pkg_therm_status_msr_val) * Let hardware know that we are done reading the HFI table and it is * free to update it again. */ - pkg_therm_status_msr_val &= THERM_STATUS_CLEAR_PKG_MASK & - ~PACKAGE_THERM_STATUS_HFI_UPDATED; - wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, pkg_therm_status_msr_val); + thermal_clear_package_intr_status(PACKAGE_LEVEL, PACKAGE_THERM_STATUS_HFI_UPDATED); queue_delayed_work(hfi_updates_wq, &hfi_instance->update_work, HFI_UPDATE_INTERVAL); diff --git a/drivers/thermal/intel/therm_throt.c b/drivers/thermal/intel/therm_throt.c index 9e8ab31d756e..4bb7fddaa143 100644 --- a/drivers/thermal/intel/therm_throt.c +++ b/drivers/thermal/intel/therm_throt.c @@ -190,32 +190,33 @@ static const struct attribute_group thermal_attr_group = { }; #endif /* CONFIG_SYSFS */ -#define CORE_LEVEL 0 -#define PACKAGE_LEVEL 1 - #define THERM_THROT_POLL_INTERVAL HZ #define THERM_STATUS_PROCHOT_LOG BIT(1) #define THERM_STATUS_CLEAR_CORE_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(13) | BIT(15)) #define THERM_STATUS_CLEAR_PKG_MASK (BIT(1) | BIT(3) | BIT(5) | BIT(7) | BIT(9) | BIT(11) | BIT(26)) -static void clear_therm_status_log(int level) +/* + * Clear the bits in package thermal status register for bit = 1 + * in bitmask + */ +void thermal_clear_package_intr_status(int level, u64 bit_mask) { + u64 msr_val; int msr; - u64 mask, msr_val; if (level == CORE_LEVEL) { msr = MSR_IA32_THERM_STATUS; - mask = THERM_STATUS_CLEAR_CORE_MASK; + msr_val = THERM_STATUS_CLEAR_CORE_MASK; } else { msr = MSR_IA32_PACKAGE_THERM_STATUS; - mask = THERM_STATUS_CLEAR_PKG_MASK; + msr_val = THERM_STATUS_CLEAR_PKG_MASK; } - rdmsrl(msr, msr_val); - msr_val &= mask; - wrmsrl(msr, msr_val & ~THERM_STATUS_PROCHOT_LOG); + msr_val &= ~bit_mask; + wrmsrl(msr, msr_val); } +EXPORT_SYMBOL_GPL(thermal_clear_package_intr_status); static void get_therm_status(int level, bool *proc_hot, u8 *temp) { @@ -295,7 +296,7 @@ static void __maybe_unused throttle_active_work(struct work_struct *work) state->average = avg; re_arm: - clear_therm_status_log(state->level); + thermal_clear_package_intr_status(state->level, THERM_STATUS_PROCHOT_LOG); schedule_delayed_work_on(this_cpu, &state->therm_work, THERM_THROT_POLL_INTERVAL); } diff --git a/drivers/thermal/intel/thermal_interrupt.h b/drivers/thermal/intel/thermal_interrupt.h index 01e7bed2ffc7..01dfd4cdb5df 100644 --- a/drivers/thermal/intel/thermal_interrupt.h +++ b/drivers/thermal/intel/thermal_interrupt.h @@ -2,6 +2,9 @@ #ifndef _INTEL_THERMAL_INTERRUPT_H #define _INTEL_THERMAL_INTERRUPT_H +#define CORE_LEVEL 0 +#define PACKAGE_LEVEL 1 + /* Interrupt Handler for package thermal thresholds */ extern int (*platform_thermal_package_notify)(__u64 msr_val); @@ -15,4 +18,7 @@ extern bool (*platform_thermal_package_rate_control)(void); /* Handle HWP interrupt */ extern void notify_hwp_interrupt(void); +/* Common function to clear Package thermal status register */ +extern void thermal_clear_package_intr_status(int level, u64 bit_mask); + #endif /* _INTEL_THERMAL_INTERRUPT_H */ diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c index a0e234fce71a..84c3a116ed04 100644 --- a/drivers/thermal/intel/x86_pkg_temp_thermal.c +++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c @@ -265,7 +265,6 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work) struct thermal_zone_device *tzone = NULL; int cpu = smp_processor_id(); struct zone_device *zonedev; - u64 msr_val, wr_val; mutex_lock(&thermal_zone_mutex); raw_spin_lock_irq(&pkg_temp_lock); @@ -279,12 +278,8 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work) } zonedev->work_scheduled = false; - rdmsrl(MSR_IA32_PACKAGE_THERM_STATUS, msr_val); - wr_val = msr_val & ~(THERM_LOG_THRESHOLD0 | THERM_LOG_THRESHOLD1); - if (wr_val != msr_val) { - wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, wr_val); - tzone = zonedev->tzone; - } + thermal_clear_package_intr_status(PACKAGE_LEVEL, THERM_LOG_THRESHOLD0 | THERM_LOG_THRESHOLD1); + tzone = zonedev->tzone; enable_pkg_thres_interrupt(); raw_spin_unlock_irq(&pkg_temp_lock);