From patchwork Mon Nov 13 13:57:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 164493 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1215620vqg; Mon, 13 Nov 2023 05:58:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHslkOBANlMkf+VqO8oZX0M5L/jUF2afNm2XHugLhoP105LLUqvSq2FkK1G8zZSvhThynY5 X-Received: by 2002:a17:903:483:b0:1cc:ec21:9a64 with SMTP id jj3-20020a170903048300b001ccec219a64mr4515491plb.17.1699883891727; Mon, 13 Nov 2023 05:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699883891; cv=none; d=google.com; s=arc-20160816; b=bmKxYWuWF1ixifQnHQILE9HQMBzdrjvlOCpe7t7VgXq7FOm+pyl9vx/uaxsV41j706 64xgnNrrQBB+SLNZ7vcsUYkVYVcmKjuzw+pEULa2ha+AFRA6DmTZdzG1XWIMsCGO9/8v DqdlvNgXF0Mztg4/vxRoRoxcQT2JrilcFX+VET7ROV/xQA2HmwEuBtV3RWGqUk/CiiPG HX4YRHn/5NFAl3YEgjrs1hF4OqkqYgFo2f0XgQLsbQkICFMduTq8NQXloZWiYv0jir+k va/cE5JwhxXIVhssrd/Um0b6RKXknYoo5lYkrQY3Se8MpAmCVPAvB92u6/01peqj7Xfx pyKQ== 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 :feedback-id:dkim-signature:dkim-signature; bh=ha0eA38T6ZoNAC1OyeuaR9EpucxVvCf1ZGeaLoyGkTU=; fh=+rAJo31mX98eFjhCVkNLurLUzZEmrDewDflUI8yJoQ8=; b=ajRYgsDhvXwUyrXnLeKtWT3MjRrLZbUwlHaJ3n4g/TaxAlQF2YZrV5n2tesO8i3G+P mq4KT0xcFySGyvkj7VUorNdKoOK+ViaFgLdpBSPZfr+nzB9E2zTVYly9kVWdRrZB7hRW STWSB2sxHlMstPViiUhV0/7n327fFBkjha8yubi4Y8xBYtmo6fwaD4IyMNgpzJ5PhBp4 fTMgxOZh3Axsg26ctW5bDbGhJSDr5xy/8ztyocG1CggovZwhz5Zqo0TuLRZ/ryXYVQ3H uLXITFWOM32YhMW5CUPQHy6jNKOBUGceGWabxWTEwdb7OAD2JakRgM51z+hyGeFdSzvI a+xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@squebb.ca header.s=fm1 header.b=OzXgJe88; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=MdJr8VDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id q15-20020a170902eb8f00b001cc467f87f8si5880457plg.381.2023.11.13.05.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 05:58:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@squebb.ca header.s=fm1 header.b=OzXgJe88; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=MdJr8VDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E365F80C65E5; Mon, 13 Nov 2023 05:58:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230397AbjKMN6D (ORCPT + 29 others); Mon, 13 Nov 2023 08:58:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbjKMN6C (ORCPT ); Mon, 13 Nov 2023 08:58:02 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2F0D54; Mon, 13 Nov 2023 05:57:58 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 203125C017F; Mon, 13 Nov 2023 08:57:58 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 13 Nov 2023 08:57:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1699883878; x= 1699970278; bh=ha0eA38T6ZoNAC1OyeuaR9EpucxVvCf1ZGeaLoyGkTU=; b=O zXgJe88B6D+hVxNMZoo3SGTRGECVz9IgMU9rTGb03sBkYdR2boZNPeRpizB3QLV+ sWjU60AP6WQpLeVYadmC8MjVVGPz8GcsTekqRJsFm5MnrAiQbHKsYgHu8N9kvZwk MPCKkY3VuzEXvMnwOio7s5PE4PYCUt2D3KwrG5TInEq5muRE4ybtC64QjXxRkdvT EIK1DWORyQeFXZz+ETtAtgSGrArpa/vPsiAyWxzxWRz7i+v+U64cC5/hm+6+7u4K hyAdrU/qtR+NdrkLFIAl5VKM2R/YP+xq9QeH7bkWJstVkTSKRaKYdTvwh2HErf7I L8J6EGErQpKgs4YmpICuA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1699883878; x= 1699970278; bh=ha0eA38T6ZoNAC1OyeuaR9EpucxVvCf1ZGeaLoyGkTU=; b=M dJr8VDypmZq8eDdYZRg0javeGRZsjFK5YV9D0lqxuqKdWuahcsAMMqlMTvpzYuaH WSr9XsRqAYnQFLu/ruCBBSCVdAAxdNW5absBis2j+X1KiOTIYN+SfGe5vd8NtkKz KYEYxrZozZzxUcmOocMsunGbJt/AvaO7Bi0FCF6xUHThY7nJVIswrTSM+B9MSLQQ 6fg1JvQGTOtIVqDtkIPeMFEt2GlQnDMzI1TymQenkXi8dC9WwxtpZKZCm+SsDKd8 qTW+yUEtODWMgNUBejkkQgvRbH8L4lwprfNMvylBPpADOvzEvoaaph6Tur5XdF++ DS3sYm5VpMN16lVlDNcIA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeftddgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepfedtvdejfeelffevhffgjeejheduteetieeguefgkefhhfegjeduueet hefgvdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 13 Nov 2023 08:57:57 -0500 (EST) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: platform-driver-x86@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, ibm-acpi-devel@lists.sourceforge.net, mario.limonciello@amd.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] platform/x86: Add support for improved performance mode Date: Mon, 13 Nov 2023 08:57:29 -0500 Message-ID: <20231113135741.4787-1-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 13 Nov 2023 05:58:10 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782013495811711044 X-GMAIL-MSGID: 1782457451190057241 Some new Thinkpads have a new improved performance mode available. Add support to make this mode usable. To avoid having to create a new profile, just use the improved performance mode in place of the existing performance mode, when available. Tested on P14s AMD G4 AMD. Signed-off-by: Mark Pearson --- Changes in v2: updated implementation for DYTC_UP_SUPPORT define drivers/platform/x86/thinkpad_acpi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index ad460417f901..ed8860caa9c1 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10136,6 +10136,7 @@ static struct ibm_struct proxsensor_driver_data = { #define DYTC_CMD_SET 1 /* To enable/disable IC function mode */ #define DYTC_CMD_MMC_GET 8 /* To get current MMC function and mode */ +#define DYTC_CMD_UP_CAP 0xA /* To get Ultra-performance capability */ #define DYTC_CMD_RESET 0x1ff /* To reset back to default */ #define DYTC_CMD_FUNC_CAP 3 /* To get DYTC capabilities */ @@ -10152,6 +10153,7 @@ static struct ibm_struct proxsensor_driver_data = { #define DYTC_FUNCTION_STD 0 /* Function = 0, standard mode */ #define DYTC_FUNCTION_CQL 1 /* Function = 1, lap mode */ +#define DYTC_FUNCTION_TMS 9 /* Function = 9, TMS mode */ #define DYTC_FUNCTION_MMC 11 /* Function = 11, MMC mode */ #define DYTC_FUNCTION_PSC 13 /* Function = 13, PSC mode */ #define DYTC_FUNCTION_AMT 15 /* Function = 15, AMT mode */ @@ -10163,11 +10165,14 @@ static struct ibm_struct proxsensor_driver_data = { #define DYTC_MODE_MMC_LOWPOWER 3 /* Low power mode */ #define DYTC_MODE_MMC_BALANCE 0xF /* Default mode aka balanced */ #define DYTC_MODE_MMC_DEFAULT 0 /* Default mode from MMC_GET, aka balanced */ +#define DYTC_NOMODE 0xF /* When Function does not have a mode */ #define DYTC_MODE_PSC_LOWPOWER 3 /* Low power mode */ #define DYTC_MODE_PSC_BALANCE 5 /* Default mode aka balanced */ #define DYTC_MODE_PSC_PERFORM 7 /* High power mode aka performance */ +#define DYTC_UP_SUPPORT 8 /* Ultra-performance (TMS) mode support */ + #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */ #define DYTC_ERR_SUCCESS 1 /* CMD completed successful */ @@ -10185,6 +10190,7 @@ static enum platform_profile_option dytc_current_profile; static atomic_t dytc_ignore_event = ATOMIC_INIT(0); static DEFINE_MUTEX(dytc_mutex); static int dytc_capabilities; +static bool dytc_ultraperf_cap; /* ultra performance capable */ static bool dytc_mmc_get_available; static int profile_force; @@ -10355,6 +10361,17 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, if (err) goto unlock; + /* Set TMS mode appropriately (enable for performance), if available */ + if (dytc_ultraperf_cap) { + int cmd; + + cmd = DYTC_SET_COMMAND(DYTC_FUNCTION_TMS, DYTC_NOMODE, + profile == PLATFORM_PROFILE_PERFORMANCE); + err = dytc_command(cmd, &output); + if (err) + return err; + } + if (dytc_capabilities & BIT(DYTC_FC_MMC)) { if (profile == PLATFORM_PROFILE_BALANCED) { /* @@ -10429,6 +10446,7 @@ static struct platform_profile_handler dytc_profile = { static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) { int err, output; + int cmd; /* Setup supported modes */ set_bit(PLATFORM_PROFILE_LOW_POWER, dytc_profile.choices); @@ -10484,6 +10502,16 @@ static int tpacpi_dytc_profile_init(struct ibm_init_struct *iibm) dbg_printk(TPACPI_DBG_INIT, "No DYTC support available\n"); return -ENODEV; } + err = dytc_command(DYTC_CMD_UP_CAP, &output); + dytc_ultraperf_cap = output & DYTC_UP_SUPPORT ? true : false; + if (dytc_ultraperf_cap) { + pr_debug("TMS is supported\n"); + /* Disable TMS by default - only use with performance mode */ + cmd = DYTC_SET_COMMAND(DYTC_FUNCTION_TMS, DYTC_NOMODE, 0); + err = dytc_command(cmd, &output); + if (err) + return err; + } dbg_printk(TPACPI_DBG_INIT, "DYTC version %d: thermal mode available\n", dytc_version);