From patchwork Fri Nov 18 00:03:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 9435507 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 899B660469 for ; Fri, 18 Nov 2016 00:06:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F8B5296F5 for ; Fri, 18 Nov 2016 00:06:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 62A2C29720; Fri, 18 Nov 2016 00:06:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD326296F5 for ; Fri, 18 Nov 2016 00:06:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751574AbcKRAGF (ORCPT ); Thu, 17 Nov 2016 19:06:05 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:50314 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751243AbcKRAGF (ORCPT ); Thu, 17 Nov 2016 19:06:05 -0500 Received: from localhost ([127.0.0.1] helo=[127.0.1.1]) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1c7WeU-0000eT-Ng; Fri, 18 Nov 2016 01:03:35 +0100 Message-Id: <20161117234809.950746890@linutronix.de> User-Agent: quilt/0.63-1 Date: Fri, 18 Nov 2016 00:03:22 -0000 From: Thomas Gleixner To: LKML Cc: Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, Peter Zijlstra , x86@kernel.org, rt@linutronix.de, Borislav Petkov Subject: [patch 01/12] thermal/x86_pkg_temp: Cleanup thermal interrupt handling References: <20161117231435.891545908@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline; filename=thermal-x86_pkg_temp--Cleanup-thermal-interrupt-handling.patch Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Wenn a package is removed nothing restores the thermal interrupt MSR so the content will be stale when a CPU of that package becomes online again. Aside of that the work function reenables interrupts before acknowledging the current one, which is the wrong order to begin with. Signed-off-by: Thomas Gleixner --- drivers/thermal/x86_pkg_temp_thermal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/thermal/x86_pkg_temp_thermal.c +++ b/drivers/thermal/x86_pkg_temp_thermal.c @@ -334,7 +334,6 @@ static void pkg_temp_thermal_threshold_w pkg_work_scheduled[phy_id] = 0; spin_unlock_irqrestore(&pkg_work_lock, flags); - enable_pkg_thres_interrupt(); rdmsrl(MSR_IA32_PACKAGE_THERM_STATUS, msr_val); if (msr_val & THERM_LOG_THRESHOLD0) { wrmsrl(MSR_IA32_PACKAGE_THERM_STATUS, @@ -346,6 +345,9 @@ static void pkg_temp_thermal_threshold_w msr_val & ~THERM_LOG_THRESHOLD1); notify = true; } + + enable_pkg_thres_interrupt(); + if (notify) { pr_debug("thermal_zone_device_update\n"); thermal_zone_device_update(phdev->tzone, @@ -505,6 +507,13 @@ static int pkg_temp_thermal_device_remov list_for_each_entry_safe(phdev, n, &phy_dev_list, list) { if (phdev->phys_proc_id == phys_proc_id) { thermal_zone_device_unregister(phdev->tzone); + /* + * Restore original MSR value for package + * thermal interrupt. + */ + wrmsr_on_cpu(cpu, MSR_IA32_PACKAGE_THERM_INTERRUPT, + phdev->start_pkg_therm_low, + phdev->start_pkg_therm_high); list_del(&phdev->list); kfree(phdev); break;