Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4146647pxb; Mon, 27 Sep 2021 10:20:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5uAn9zMUlTu7YbvGCxfmWvfUpvRw6Z/kOJYHlM/WRgnu5nLX9BXScQrp22FqdNXLwGssK X-Received: by 2002:a63:15:: with SMTP id 21mr641669pga.479.1632763200470; Mon, 27 Sep 2021 10:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763200; cv=none; d=google.com; s=arc-20160816; b=CtNPoFYk8+Oezxgl3CDGMmfqnMowEXu8KgClngLWx7UAJ7vW2ZgN5QQluocLxJbQi6 BdpE6abm3qsfub5/LyF7owkNK20g4acVkhbVXGjdzrtApZYdlpjo++hyxhZyoI2f02BT /erw4i3Ci2rj22YVUts6OYOD70Hc5JofZVpAEaJKVBnIHWTj5yHcyrKr5WC8PlRqShhT 3VnKJMNM6Eke0qrnbuCBoKuaeP3nBLmjPtVPhg+W+VbKsRCzoX0kMFoEAcpQvaNSoUmr zogERtFrc7lh+uz1Q2u+qjRs+212Mr7s+7crhXsJXIOwWfstasDetLSVsJFV+5yJf7m2 xe2w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sI7Ytn2Mc7YZEhDSdCQxhD4/01ZVuAJXOVReTSMfirc=; b=kNcoLOGr0kgzXPOmUnX6plY0aztedjN7HzJClBULl7wvQ/0DAu0eaPiSNEoZBHxZ4R YFqgPscD1JiCnjCT5GKeCUo2yeR303MS4PtaoYdtrQk3bBrb4r6lQcYsqRx9SPS+LoUt GPE/FULZn+RNUsFps5YFMSyJHxxIPD4XA/M4r8pRRHybgtKoqmKk5eWjz7GLEtIgQDKS 7hGjO5CUt+ZSMeAhJmUgyLOn0EFS3LkSC0g7GPe1eaeYd5W1XdUlJFCVff/3OFz0To6/ y2pli39zhP+KGvxP4nhzHkrIaB3Wzh6Mm7Ub++QiKmhB3QuZJ6NsI1YeGsbdid32nA9F JuIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="v/yMtd5d"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y28si21369405pgl.452.2021.09.27.10.19.46; Mon, 27 Sep 2021 10:20:00 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="v/yMtd5d"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236327AbhI0RTY (ORCPT + 99 others); Mon, 27 Sep 2021 13:19:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:55022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236527AbhI0ROx (ORCPT ); Mon, 27 Sep 2021 13:14:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 13B5561222; Mon, 27 Sep 2021 17:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762638; bh=TTg8jxlnK+vJcR/2KDfAOFz1xwi+6UGQ0I+f65se//g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/yMtd5dETfj5KbcWk4jofRsm5dMTRsd0yHodsM5M1UpShxlwD15MkXv9m+sJhB9G YhSjI2e18pNodL7ez0k9iYN0Gh0SaHbgNIy8WyYwb68BwVEfobRcbVC8bfuMZdgkbI rC96V9Z7ibYURNq4ax5W0c5ylPZeajVN37+qA2ek= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Pandruvada , Antoine Tenart , Daniel Lezcano , Srinivas Pandruvada Subject: [PATCH 5.10 100/103] thermal/drivers/int340x: Do not set a wrong tcc offset on resume Date: Mon, 27 Sep 2021 19:03:12 +0200 Message-Id: <20210927170229.231708962@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170225.702078779@linuxfoundation.org> References: <20210927170225.702078779@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Antoine Tenart commit 8b4bd256674720709a9d858a219fcac6f2f253b5 upstream. After upgrading to Linux 5.13.3 I noticed my laptop would shutdown due to overheat (when it should not). It turned out this was due to commit fe6a6de6692e ("thermal/drivers/int340x/processor_thermal: Fix tcc setting"). What happens is this drivers uses a global variable to keep track of the tcc offset (tcc_offset_save) and uses it on resume. The issue is this variable is initialized to 0, but is only set in tcc_offset_degree_celsius_store, i.e. when the tcc offset is explicitly set by userspace. If that does not happen, the resume path will set the offset to 0 (in my case the h/w default being 3, the offset would become too low after a suspend/resume cycle). The issue did not arise before commit fe6a6de6692e, as the function setting the offset would return if the offset was 0. This is no longer the case (rightfully). Fix this by not applying the offset if it wasn't saved before, reverting back to the old logic. A better approach will come later, but this will be easier to apply to stable kernels. The logic to restore the offset after a resume was there long before commit fe6a6de6692e, but as a value of 0 was considered invalid I'm referencing the commit that made the issue possible in the Fixes tag instead. Fixes: fe6a6de6692e ("thermal/drivers/int340x/processor_thermal: Fix tcc setting") Cc: stable@vger.kernel.org Cc: Srinivas Pandruvada Signed-off-by: Antoine Tenart Signed-off-by: Daniel Lezcano Reviewed-by: Srinivas Pandruvada Tested-by: Srinivas Pandruvada Link: https://lore.kernel.org/r/20210909085613.5577-2-atenart@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/thermal/intel/int340x_thermal/processor_thermal_device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c @@ -185,7 +185,7 @@ static int tcc_offset_update(unsigned in return 0; } -static unsigned int tcc_offset_save; +static int tcc_offset_save = -1; static ssize_t tcc_offset_degree_celsius_store(struct device *dev, struct device_attribute *attr, const char *buf, @@ -709,7 +709,8 @@ static int proc_thermal_resume(struct de proc_dev = dev_get_drvdata(dev); proc_thermal_read_ppcc(proc_dev); - tcc_offset_update(tcc_offset_save); + if (tcc_offset_save >= 0) + tcc_offset_update(tcc_offset_save); return 0; }