From patchwork Thu Jan 12 20:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13099425 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7528FC61DB3 for ; Thu, 12 Jan 2023 21:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240439AbjALVCK (ORCPT ); Thu, 12 Jan 2023 16:02:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240502AbjALVAN (ORCPT ); Thu, 12 Jan 2023 16:00:13 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9A249FD4 for ; Thu, 12 Jan 2023 12:45:21 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 585AD5C0126; Thu, 12 Jan 2023 15:45:19 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 12 Jan 2023 15:45:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding: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=1673556319; x=1673642719; bh=pj n1W6K0BjFyb36RWaXrdfxBFdNrxOAKuHP5ZTBXTpY=; b=bkrDFX5Y9BlbkrEdyY cJgJ0rRytvYrQrLWGgr5dvZu5KmJz5F+XWP6YtSfIXkSzKy7NxBsCMTLzL/jBkZq ExUGdcETME2eaqS4CptFkKXor8wnER1mlkT7yLYk1qUZ9IIsGl1uuuB7V7Yaquq3 dM8ILTnOf0vSkjEJ5indyl/BZNYk3YCNJDpL4QjgW93U5KHoZiimxK1LdoBgHEx6 F+8mGdsl0k4/+/j7u+R6DetTvzHvnfIQzVNaPBaeQKF/NE11vedb5OWGFOz7MDtx BSWQUS3ZZTjaqsr90EqUd1Tj7J8dihhNXaelCASTfNBpsS/ctlUgw4LilicOUWQv dZqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding: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=1673556319; x=1673642719; bh=pjn1W6K0BjFyb 36RWaXrdfxBFdNrxOAKuHP5ZTBXTpY=; b=AUwtq+yP3nh5Ele6KBsbuXkaVu/pO UQ7mZ+0/OwfjnnpZ8GCRwIkssIpBo/NsgCs5R31cTWtbktAlIoUqFhHE/uXo13hF fkFcx/Bpb6fvSFmoN4M8kZjhCkaaBuyocr4lMAMQqq/kixiGK8CJ55A5Nuxjgk1M 66ZOk49N/XjmY7Jw8K9agy7+sy9d1Vo6/Dsc4g3UzuhAen5BDpYuEqauZsOiBx02 Pry9ObnewomOPGy4gWonXcQX1tPC4cci0AJ7jqsTnEqVnLf6i3s59inE8NyDs+pi WTEavwKOmuxsZF5amBR0ySfTdiLS1m4mfHKF65RYy724gtUuDexiQO/Ug== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeigddugeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepfedtvdejfeelffevhffgjeejheduteetieeguefgkefhhfegjeduueet hefgvdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 15:45:18 -0500 (EST) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, mario.limonciello@amd.com, markgross@kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH] platform/x86: thinkpad_acpi: Remove AMT enablement Date: Thu, 12 Jan 2023 15:45:01 -0500 Message-Id: <20230112204501.487920-1-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Recently AMT mode was enabled (somewhat unexpectedly) on the Lenovo Z13 platform. The FW is advertising it is available and the driver tries to use it - unfortunately it reports the profile mode incorrectly. Note, there is also some extra work needed to enable the dynamic aspect of AMT support that I will be following up with; but more testing is needed first. This patch just fixes things so the profiles are reported correctly. Signed-off-by: Mark Pearson Reviewed-by: Mario Limonciello Reported-by: --- drivers/platform/x86/thinkpad_acpi.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index 1195293b22fd..a95946800ae9 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c @@ -10311,9 +10311,11 @@ static DEFINE_MUTEX(dytc_mutex); static int dytc_capabilities; static bool dytc_mmc_get_available; -static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *profile) +static int convert_dytc_to_profile(int funcmode, int dytcmode, + enum platform_profile_option *profile) { - if (dytc_capabilities & BIT(DYTC_FC_MMC)) { + switch (funcmode) { + case DYTC_FUNCTION_MMC: switch (dytcmode) { case DYTC_MODE_MMC_LOWPOWER: *profile = PLATFORM_PROFILE_LOW_POWER; @@ -10329,8 +10331,7 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p return -EINVAL; } return 0; - } - if (dytc_capabilities & BIT(DYTC_FC_PSC)) { + case DYTC_FUNCTION_PSC: switch (dytcmode) { case DYTC_MODE_PSC_LOWPOWER: *profile = PLATFORM_PROFILE_LOW_POWER; @@ -10344,6 +10345,14 @@ static int convert_dytc_to_profile(int dytcmode, enum platform_profile_option *p default: /* Unknown mode */ return -EINVAL; } + return 0; + case DYTC_FUNCTION_AMT: + /* For now return balanced. It's the closest we have to 'auto' */ + *profile = PLATFORM_PROFILE_BALANCED; + return 0; + default: + /* Unknown function */ + return -EOPNOTSUPP; } return 0; } @@ -10492,6 +10501,7 @@ static int dytc_profile_set(struct platform_profile_handler *pprof, err = dytc_command(DYTC_SET_COMMAND(DYTC_FUNCTION_PSC, perfmode, 1), &output); if (err) goto unlock; + /* system supports AMT, activate it when on balanced */ if (dytc_capabilities & BIT(DYTC_FC_AMT)) dytc_control_amt(profile == PLATFORM_PROFILE_BALANCED); @@ -10507,7 +10517,7 @@ static void dytc_profile_refresh(void) { enum platform_profile_option profile; int output, err = 0; - int perfmode; + int perfmode, funcmode; mutex_lock(&dytc_mutex); if (dytc_capabilities & BIT(DYTC_FC_MMC)) { @@ -10522,8 +10532,9 @@ static void dytc_profile_refresh(void) if (err) return; + funcmode = (output >> DYTC_GET_FUNCTION_BIT) & 0xF; perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF; - convert_dytc_to_profile(perfmode, &profile); + convert_dytc_to_profile(funcmode, perfmode, &profile); if (profile != dytc_current_profile) { dytc_current_profile = profile; platform_profile_notify(); From patchwork Sun Mar 12 02:46:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13171118 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B410FC61DA4 for ; Sun, 12 Mar 2023 02:47:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbjCLCrW (ORCPT ); Sat, 11 Mar 2023 21:47:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjCLCrV (ORCPT ); Sat, 11 Mar 2023 21:47:21 -0500 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 888A636472 for ; Sat, 11 Mar 2023 18:47:18 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 392C132007D7; Sat, 11 Mar 2023 21:47:16 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 11 Mar 2023 21:47:16 -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=fm2; t=1678589235; x= 1678675635; bh=9vTmJ14VZpmHtcKetkVQJf9UufmKu/ovKuUZWt3ALsE=; b=b TQyZCvHMdgst1EVzf/EBaVMcI/2/OWeGXo6D0OBXxyhRCS2yUem6poPRhR748Ef/ +SBf+zk39AX1MeYAnWBfOOtv0X8ujKHQQpyg7HMo94C1D0ojO8jdYefrQe8RWu0g 0LOr8hsniasLlRh9GbzrIO42VChtSaB5oU7T7FGmQAmSUxlDvl3MNgLa5t20xFkq AtnHrf4JMv8Imxi9v3BB0rXZRxd2HMbZEKBJzJFPK7xqF3aeBECwwaOn9qW9vVch CwsT63Bav7JFPP11tfVuBs6al5UIY6LOAOTeCy4E3FlUKVpdphUUNnXSu8NEeKFL mzaZEnPWr1u87iieqtndg== 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=fm2; t=1678589235; x= 1678675635; bh=9vTmJ14VZpmHtcKetkVQJf9UufmKu/ovKuUZWt3ALsE=; b=Q glHHwE8to+Z/mWsWjOmdNiLUxtkQUNMfuuce0QGwx2hVRL8yN3LvWdisgQSMvkLu sbPhvfwaXn9xiqpmKPIFX8QEdsbulMpRjnT+a3mNq+XGdza0Eiuwc7U9mzLRpYmN gZgczIuC9kX80dTkMQHjqC8953paQPq2pnGPTH69EC7ak9p1FQK/6Hlgd57tN91i 1ccVww3XukyTEzXN2RYApfV1XD8KiOWpnQ7KbzS5U7poUrLpgFUnghD8U04blkp9 PN6lpB2bvdvL7I2B735PHOP9ZP/9h1g6I63bYTgHUGL4WEEj9nKj0YmS+p6pwYpa 8/GOI54EoSVa+JHq9pllg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvddvuddggeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepfedtvdejfeelffevhffgjeejheduteetieeguefgkefhhfegjeduueet hefgvdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 11 Mar 2023 21:47:15 -0500 (EST) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, markpearson@lenovo.com, platform-driver-x86@vger.kernel.org Subject: [PATCH 2/2] platform/x86: think-lmi: Add possible_values for ThinkStation Date: Sat, 11 Mar 2023 21:46:35 -0500 Message-Id: <20230312024635.518769-2-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230312024635.518769-1-mpearson-lenovo@squebb.ca> References: <20230312024635.518769-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org ThinkStation platforms don't support the API to return possible_values but instead embed it in the settings string. Try and extract this information and set the possible_values attribute appropriately. Signed-off-by: Mark Pearson --- drivers/platform/x86/think-lmi.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 495a5e045069..52f3472fd1e0 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1432,6 +1432,29 @@ static int tlmi_analyze(void) if (ret || !setting->possible_values) pr_info("Error retrieving possible values for %d : %s\n", i, setting->display_name); + } else { + /* + * Older Thinkstations don't support the bios_selections API. + * Instead they store this as a [Optional:Option1,Option2] section of the + * name string. + * Try and pull that out if it's available. + */ + char *item, *optstart, *optend; + + if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) { + optstart = strstr(item, "[Optional:"); + if (optstart) { + optstart += strlen("[Optional:"); + optend = strstr(optstart, "]"); + if (optend) { + setting->possible_values = + kmalloc(optend - optstart, GFP_KERNEL); + strncpy(setting->possible_values, + optstart, optend - optstart); + setting->possible_values[optend - optstart] = '\0'; + } + } + } } /* If we don't have a possible value mark as N/A */ if (!setting->possible_values) {