Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp494434pxy; Wed, 5 May 2021 07:12:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxG56DJuMLxXub5llPmbwmliDJlvJUMV4Wys764hUG85TKcdrCS9BQDgdqC4gaFYt8lRF0K X-Received: by 2002:a05:6000:1152:: with SMTP id d18mr20026570wrx.211.1620223952518; Wed, 05 May 2021 07:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620223952; cv=none; d=google.com; s=arc-20160816; b=1FFQeJRO8mybNa4qzrQYsbWsukI0BMavmQmCMQFCW+nJKZdNvNvIYIRmNzYv90zyzo t718k1Eba82ffyX+6NfP91Qi6dz459XNODP7FCyyMIvG4NzDDYd9x/3srjv0dgSTEGk8 0i42KvCzmHJoXa/6kFPtvuT4MbQaXF1VlHJzgi5gtdnWE2VTlxfmQQ058lYR9pnY3UvR 0THCVco+qDhbAe8iLBhhynKW1jJSW1SGio3kyPnUEAVXiQy/vg8ST/+hchrRXvw2RvJD 1xb4CZZICymMyu4gRDHhYLuKCJCNEpQ1k8a3LacPNXG/M7jSP6RwmLWGEkEz6dQR5kLG 7bAg== 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=lr0jY+eXaLK0mYd+So8PA5juOItbH8daDKHoQvbwBZA=; b=VsFnnxP2W2gMRGzR4Va/RxmlC/nZ2v0AF+kBT0H73hSDavJcZZ+FR5nlcjrRJXyGEq CDW7s4iQKYhxz+EKPaVrPWzYfJ20j9cDYYkun24XkJVZaMElCO5fQg/Rp7RzViso2j57 zjfiC3jio4Kr4e4dBMEtWAzbpVI4P+OS3C8Pqyf/6KpRJkwnheaaBeq6w/3v8JsR0RKR nO6WJkblXplNHnAuiwp6K6+V/rEvd9a1KYa1XP8zDbz57YoXXDVdkxwfWHjxlLyzT/r7 mlTLhy9M9covx4zpnUEZOT3RlgirKgHksPrQ9EOeoyxu+yzsHRp0sM6JA/Ff51WowHYP paBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S0fLk5Uv; 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 l11si13984974edv.444.2021.05.05.07.11.53; Wed, 05 May 2021 07:12:32 -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=S0fLk5Uv; 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 S233477AbhEEMNe (ORCPT + 99 others); Wed, 5 May 2021 08:13:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:50458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233762AbhEEMJ3 (ORCPT ); Wed, 5 May 2021 08:09:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 98734613F5; Wed, 5 May 2021 12:08:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620216486; bh=CekMGGwRHJP4yRbHxEVAdIWtBfPYYAxOrhatrDJNNiw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S0fLk5UvNY8MjQxdJ4JyjWFCpamiq1i3TXDjibgekVCvH2DTP31fNl/QUCVJfWuzO hhJFjY5XEyRkEeGPui5gQHvABrPUbEv4PgDsmI/TdGdxmDNjCgcfb+lXYF575jIIrC xl8LF8wuhW14X1VnrgrZVAcElqimHHM21cVki7VM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Pearson , Hans de Goede Subject: [PATCH 5.12 16/17] platform/x86: thinkpad_acpi: Correct thermal sensor allocation Date: Wed, 5 May 2021 14:06:11 +0200 Message-Id: <20210505112325.479732835@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210505112324.956720416@linuxfoundation.org> References: <20210505112324.956720416@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: Mark Pearson commit 6759e18e5cd8745a5dfc5726e4a3db5281ec1639 upstream. On recent Thinkpad platforms it was reported that temp sensor 11 was always incorrectly displaying 66C. It turns out the reason for this is that this location in EC RAM is not a temperature sensor but is the power supply ID (offset 0xC2). Based on feedback from the Lenovo firmware team the EC RAM version can be determined and for the current version (3) only the 0x78 to 0x7F range is used for temp sensors. I don't have any details for earlier versions so I have left the implementation unaltered there. Note - in this block only 0x78 and 0x79 are officially designated (CPU & GPU sensors). The use of the other locations in the block will vary from platform to platform; but the existing logic to detect a sensor presence holds. Signed-off-by: Mark Pearson Link: https://lore.kernel.org/r/20210407212015.298222-1-markpearson@lenovo.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/platform/x86/thinkpad_acpi.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -6260,6 +6260,7 @@ enum thermal_access_mode { enum { /* TPACPI_THERMAL_TPEC_* */ TP_EC_THERMAL_TMP0 = 0x78, /* ACPI EC regs TMP 0..7 */ TP_EC_THERMAL_TMP8 = 0xC0, /* ACPI EC regs TMP 8..15 */ + TP_EC_FUNCREV = 0xEF, /* ACPI EC Functional revision */ TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */ TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */ @@ -6458,7 +6459,7 @@ static const struct attribute_group ther static int __init thermal_init(struct ibm_init_struct *iibm) { - u8 t, ta1, ta2; + u8 t, ta1, ta2, ver = 0; int i; int acpi_tmp7; int res; @@ -6473,7 +6474,14 @@ static int __init thermal_init(struct ib * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for * non-implemented, thermal sensors return 0x80 when * not available + * The above rule is unfortunately flawed. This has been seen with + * 0xC2 (power supply ID) causing thermal control problems. + * The EC version can be determined by offset 0xEF and at least for + * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 + * are not thermal registers. */ + if (!acpi_ec_read(TP_EC_FUNCREV, &ver)) + pr_warn("Thinkpad ACPI EC unable to access EC version\n"); ta1 = ta2 = 0; for (i = 0; i < 8; i++) { @@ -6483,11 +6491,13 @@ static int __init thermal_init(struct ib ta1 = 0; break; } - if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) { - ta2 |= t; - } else { - ta1 = 0; - break; + if (ver < 3) { + if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) { + ta2 |= t; + } else { + ta1 = 0; + break; + } } } if (ta1 == 0) { @@ -6500,9 +6510,12 @@ static int __init thermal_init(struct ib thermal_read_mode = TPACPI_THERMAL_NONE; } } else { - thermal_read_mode = - (ta2 != 0) ? - TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8; + if (ver >= 3) + thermal_read_mode = TPACPI_THERMAL_TPEC_8; + else + thermal_read_mode = + (ta2 != 0) ? + TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8; } } else if (acpi_tmp7) { if (tpacpi_is_ibm() &&