From patchwork Tue Jun 25 06:43:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b0029jYz23tw for ; Tue, 25 Jun 2024 16:43:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzu7-0007yU-Jc; Tue, 25 Jun 2024 06:43:47 +0000 Received: from mail-pl1-f177.google.com ([209.85.214.177]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzu5-0007y2-UT for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:46 +0000 Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1fa07e4f44eso24082035ad.2 for ; Mon, 24 Jun 2024 23:43:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297824; x=1719902624; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ta5/LRbXQ3RliA35v2oimbopNJrpW5WCDrfXmEM/a5Q=; b=lnwSPBylRYFXdZZTVc92wU1tGcGwfMc9remZajyZYftcCd7EDt3jH1FjC4epj0fjcp 2xOmT5KzwRDL2N57Va68AtKBUnZeP2s1ouEDTNqRRUT0Sm3wpq2H6QOPDJtW19pAEuyx 5z2NXhc+FjmwDE8OmWNOOloYFbjpAQMpTqfsZZT4EcJtXvzEuEEtOW6XdRGZpBbnTmvm Okt8+b7JLQ/UBTa2RenYOu1K3PsfPOpWlpqBUzM9i4CM3aOHDV1cQUUUIJbtELeTaCPO ohZglQAOEcglHcf98N9/SpqTUD+wQdjlRi4EYi5zK1Lk+CF5UAnCNnjEuZnXUrHi/dGT AlXw== X-Gm-Message-State: AOJu0YxrsSFCiiqLz/6Jmpb3xGrdVr14Bq9Q7wQdtkUiYSyUlXxVYD9N 9r+S+bAlxikvkOjxzgLd8U4DwLF313Lw5Q4zpZg7vo8VdU/+vFhsg7Z2DxMj X-Google-Smtp-Source: AGHT+IFZ3NgDB3mDCSOs7BOxyyn33Kp6tefq9Bu94CbdrsznjPFtDEf2/Jj/hkJCPGOgIIXK/ubbUg== X-Received: by 2002:a17:902:d481:b0:1fa:d3d:a68d with SMTP id d9443c01a7336-1fa23bdded8mr72635765ad.22.1719297823769; Mon, 24 Jun 2024 23:43:43 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:42 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/7][SRU][Noble] platform/x86/amd/pmf: Differentiate PMF ACPI versions Date: Tue, 25 Jun 2024 14:43:15 +0800 Message-ID: <20240625064321.3302827-2-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.177; envelope-from=vicamo@gmail.com; helo=mail-pl1-f177.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 For family 1AH, certain PMF features have been enhanced - leading to a newer APMF (AMD PMF) spec (BIOS and PMF driver interface) called v2. This information would be fed into the if_version field of the verify_interface method of the APMF call from the BIOS. Use this information to store the version number to differentiate between v1 or v2 and also store the information into the PMF private data structure, as this information would be required for further code branching to support the latest silicon. Reviewed-by: Kuppuswamy Sathyanarayanan Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-2-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit a33e9e106601b5271561e7d79a3d3c4e7e84f07f) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/acpi.c | 6 ++++-- drivers/platform/x86/amd/pmf/pmf.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index f2eb07ef855a..1f287a147c57 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -218,8 +218,10 @@ static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) return err; pdev->supported_func = output.supported_functions; - dev_dbg(pdev->dev, "supported functions:0x%x notifications:0x%x\n", - output.supported_functions, output.notification_mask); + dev_dbg(pdev->dev, "supported functions:0x%x notifications:0x%x version:%u\n", + output.supported_functions, output.notification_mask, output.version); + + pdev->pmf_if_version = output.version; return 0; } diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 66cae1cca73c..e51ac981af73 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -231,6 +231,7 @@ struct amd_pmf_dev { u64 policy_addr; void *policy_base; bool smart_pc_enabled; + u16 pmf_if_version; }; struct apmf_sps_prop_granular { From patchwork Tue Jun 25 06:43:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b002Ptcz23tx for ; Tue, 25 Jun 2024 16:43:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzu8-0007zA-VP; Tue, 25 Jun 2024 06:43:48 +0000 Received: from mail-pl1-f180.google.com ([209.85.214.180]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzu7-0007yP-Ss for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:48 +0000 Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fa75f53f42so1069405ad.0 for ; Mon, 24 Jun 2024 23:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297825; x=1719902625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dElhqt0M2cyEl0NDRDiDhuSS8iNRNd+bVjs7L+Iydzg=; b=P/5WsO4K7boegOLWcaiTVbrIayWs9cXpLFqsIKtLgxQd9qQZXAZBRana2yP0xngFjN gWwCQTqNlG7aTP/AoW+xICSQv5WCPUFWXnLdIcX82sbhZin7ShJZjZWM7d8babEwPU9H ohBte3x8P8vOxNjlXF4G2BHIxGfQQRuWgoSKR6ynqJnfkRHHKgNyQa/lZLV4RrYiKIX5 uULIZF1/Pz5hEJuBBgf3klb7JNmwxeeqIZ+TQamvhb8t7tyhhfAgkIPz1ndk+76dIl38 8aHFqXOTnzwNykrgGY+4DIvQgOoEwyHm5R6GmsyiaJTB4tGB2B8F5EVgJgiwft5cC/2i yLkA== X-Gm-Message-State: AOJu0Yy0mvNpOxAykBrPEVeexhXHbI14TqMcQDyRCHbnaVuQRF+Ycdlj ulXWNchMecN+2+cQtuVpsnBui4zFaPp5wZ/rDW9p9fcgsu/NHZ2YyUeU+Cud X-Google-Smtp-Source: AGHT+IFRrO4soWM2fI7A2zqrGUm7txFkn6tGnnJfKDg0euFiIMFeNo/mIMReShGklx4uQCAYP2IEEw== X-Received: by 2002:a17:902:e542:b0:1f6:1780:f7b1 with SMTP id d9443c01a7336-1fa23f1b5a9mr70646795ad.17.1719297825131; Mon, 24 Jun 2024 23:43:45 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:44 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/7][SRU][Noble] platform/x86/amd/pmf: Disable debugfs support for querying power thermals Date: Tue, 25 Jun 2024 14:43:16 +0800 Message-ID: <20240625064321.3302827-3-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.180; envelope-from=vicamo@gmail.com; helo=mail-pl1-f180.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 The GET interface to receive the active power thermal information from the PMFW has been deprecated. Hence drop the debugfs support from version2 onwards. Reviewed-by: Kuppuswamy Sathyanarayanan Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-3-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit 233f78e11e1fa0387d1600875bef02a2d714f2e2) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/core.c | 5 +++-- drivers/platform/x86/amd/pmf/pmf.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 4f734e049f4a..2230bc2b1f59 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -113,8 +113,9 @@ static void amd_pmf_dbgfs_unregister(struct amd_pmf_dev *dev) static void amd_pmf_dbgfs_register(struct amd_pmf_dev *dev) { dev->dbgfs_dir = debugfs_create_dir("amd_pmf", NULL); - debugfs_create_file("current_power_limits", 0644, dev->dbgfs_dir, dev, - ¤t_power_limits_fops); + if (dev->pmf_if_version == PMF_IF_V1) + debugfs_create_file("current_power_limits", 0644, dev->dbgfs_dir, dev, + ¤t_power_limits_fops); } int amd_pmf_get_power_source(void) diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index e51ac981af73..4364af72a7a3 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -83,6 +83,8 @@ #define TA_OUTPUT_RESERVED_MEM 906 #define MAX_OPERATION_PARAMS 4 +#define PMF_IF_V1 1 + /* AMD PMF BIOS interfaces */ struct apmf_verify_interface { u16 size; From patchwork Tue Jun 25 06:43:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b000rx1z20ZS for ; Tue, 25 Jun 2024 16:43:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzuB-00080N-6D; Tue, 25 Jun 2024 06:43:51 +0000 Received: from mail-pf1-f169.google.com ([209.85.210.169]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzu8-0007yl-VI for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:49 +0000 Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-706738c209bso1493468b3a.3 for ; Mon, 24 Jun 2024 23:43:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297827; x=1719902627; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rU22gmG33nxYhYy6ZC4KTKUX81yqxzOb9KMdVv/BaqQ=; b=HQIS/0WO3TsH9hEORifV+mNwe8SZAPylbKv2GOoSecSthWXHX7o3dOID5OcICM4fpQ 62/K5L1sy7LBKPD4mgrOpxdg/NdZVcIId3nwHAiM940/4jirweMkdIE8q9st5hJwsLFd YT017T/W0pbfKNRvELdxKpPWWRFyWEBIcdCewfuT8W/6KhgOF+e0LgRrRPqBOd3qya3k K7eSATLYEPi7x0pMw7XgjCafzHMv/tM54+TZ4UMECRMevRsI39MApJGr43aZlgmP7ntZ hKhOvhtTYOIFwAJ7E44W+3N8wuxGKje8wSutP7W20sf5KLfCHNgksfhQ4t0DwEtrJF5l m1yw== X-Gm-Message-State: AOJu0YzPgGzE+jK4LZv0lB7ZasEafcRyT724JzqEkP6upL9xQaGvRRAh mVcWEC/8kjvHDCzelQCkTnkA4wym6CRZgRijNp5itjCe3B+VvFvoGNamdkQF X-Google-Smtp-Source: AGHT+IE88GmSengtkX+bXwbvRAUmWNlOOShoUZXs+CRkkMC8Lt3kaFxekEXsfBA/EUq8pWrPfbTDug== X-Received: by 2002:a05:6a20:8b17:b0:1b5:cf26:ed09 with SMTP id adf61e73a8af0-1bcf7e3cab2mr5302655637.7.1719297826899; Mon, 24 Jun 2024 23:43:46 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:45 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/7][SRU][Noble] platform/x86/amd/pmf: Add support to get sbios requests in PMF driver Date: Tue, 25 Jun 2024 14:43:17 +0800 Message-ID: <20240625064321.3302827-4-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.169; envelope-from=vicamo@gmail.com; helo=mail-pf1-f169.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 Update the APMF function index 2 for family 1Ah, that gets the information of SBIOS requests (like the pending requests from BIOS, custom notifications, updation of power limits etc). Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-4-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit 5fdc8b82aab4c8430bbd8d26a3c3898aaff90a40) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/acpi.c | 5 +++++ drivers/platform/x86/amd/pmf/pmf.h | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 1f287a147c57..13af83b187ac 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -166,6 +166,11 @@ int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data return apmf_if_call_store_buffer(pdev, APMF_FUNC_AUTO_MODE, data, sizeof(*data)); } +int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req) +{ + return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, req, sizeof(*req)); +} + int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req) { return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 4364af72a7a3..5d722e2772b8 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -116,6 +116,18 @@ struct apmf_sbios_req { u8 skin_temp_hs2; } __packed; +struct apmf_sbios_req_v2 { + u16 size; + u32 pending_req; + u8 rsd; + u32 ppt_pmf; + u32 ppt_pmf_apu_only; + u32 stt_min_limit; + u8 skin_temp_apu; + u8 skin_temp_hs2; + u32 custom_policy[10]; +} __packed; + struct apmf_fan_idx { u16 size; u8 fan_ctl_mode; @@ -612,6 +624,7 @@ void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev); void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev); void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t time_elapsed_ms); int apmf_get_sbios_requests(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req); +int apmf_get_sbios_requests_v2(struct amd_pmf_dev *pdev, struct apmf_sbios_req_v2 *req); void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event); int amd_pmf_reset_amt(struct amd_pmf_dev *dev); From patchwork Tue Jun 25 06:43:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b000tNlz214Y for ; Tue, 25 Jun 2024 16:43:59 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzuC-00081U-Eg; Tue, 25 Jun 2024 06:43:52 +0000 Received: from mail-pl1-f179.google.com ([209.85.214.179]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzuA-0007zn-Vm for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:51 +0000 Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1f9e2affc8cso30089135ad.2 for ; Mon, 24 Jun 2024 23:43:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297828; x=1719902628; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UB3fr/50vudLqr+uG+PmbjH5JaC+HMpPevh/OvrHHVs=; b=Cfp57vNk21FOVG795Q+6VCI7MUfQdU21BUMoKWs0+7hfLhlYbY9tHnh/kdgDIDeT6V ZJB5C8rvr/f4QvxqQBOO78K6XfB+OtT/OjS/GT6raXEDNjhtBYvzvKdPSctqcp92r1M2 G9aNbptkwccsDYFYlvXpZhZRYC8ig1cRmU5G7I/UzDTHYqF4xUJY5bqhRSIIrumb1/Wp f7obH6m9FKN7TIWaWYd0vc9JkmgP2j+h32ieOPsNSh9zZNXoGWZrv1+fnljz8jIj+czm IR9cmkkPlpJBIwj0jIqHNEl0MsaaYuv4l4sAPel/JXuRcC1IlbxaiiYhKKzeOlCWJwLs Dz3A== X-Gm-Message-State: AOJu0YxSTNTqF8SFoGyMcdPDD3oVsNhQSDrLXCfaFK2UYJkRdCVemYvE o1gkcjQJ2kkOOItH/kvOVu90axpIjgT3ejolPtl0EeACm39lJT+uR2wg2sBt X-Google-Smtp-Source: AGHT+IFdiHZwCJDsGrehUSBVgzwUpPjzBVBU2llo80pUOEvFkzGSodCqt5UEG1P+GqnV/W0XWE9LzA== X-Received: by 2002:a17:902:a3ce:b0:1fa:13fc:33ea with SMTP id d9443c01a7336-1fa23ecc3e2mr60602005ad.16.1719297828201; Mon, 24 Jun 2024 23:43:48 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:47 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/7][SRU][Noble] platform/x86/amd/pmf: Add support to notify sbios heart beat event Date: Tue, 25 Jun 2024 14:43:18 +0800 Message-ID: <20240625064321.3302827-5-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.179; envelope-from=vicamo@gmail.com; helo=mail-pl1-f179.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 Add support for newer revision of the heart beat notify events. This event is used to notify to the OEM BIOS on driver load/unload/suspend/resume scenarios. If OEM BIOS does not receive the heart beat event from PMF driver, OEM BIOS shall conclude that PMF driver is no more active and BIOS will update to the legacy system power thermals. Reviewed-by: Kuppuswamy Sathyanarayanan Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-5-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit 6262938eef28254f49c34af48e18cb543b0db5cd) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/acpi.c | 41 +++++++++++++++++++++++++++-- drivers/platform/x86/amd/pmf/core.c | 10 +++++++ drivers/platform/x86/amd/pmf/pmf.h | 17 ++++++++++++ 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 13af83b187ac..f0360eea81e6 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -140,6 +140,43 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work) kfree(info); } +int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag) +{ + struct sbios_hb_event_v2 args = { }; + struct acpi_buffer params; + union acpi_object *info; + + args.size = sizeof(args); + + switch (flag) { + case ON_LOAD: + args.load = 1; + break; + case ON_UNLOAD: + args.unload = 1; + break; + case ON_SUSPEND: + args.suspend = 1; + break; + case ON_RESUME: + args.resume = 1; + break; + default: + dev_dbg(dev->dev, "Failed to send v2 heartbeat event, flag:0x%x\n", flag); + return -EINVAL; + } + + params.length = sizeof(args); + params.pointer = &args; + + info = apmf_if_call(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2, ¶ms); + if (!info) + return -EIO; + + kfree(info); + return 0; +} + int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx) { union acpi_object *info; @@ -327,7 +364,7 @@ void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev) { acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev); - if (pmf_dev->hb_interval) + if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) cancel_delayed_work_sync(&pmf_dev->heart_beat); if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) && @@ -351,7 +388,7 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) goto out; } - if (pmf_dev->hb_interval) { + if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) { /* send heartbeats only if the interval is not zero */ INIT_DELAYED_WORK(&pmf_dev->heart_beat, apmf_sbios_heartbeat_notify); schedule_delayed_work(&pmf_dev->heart_beat, 0); diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 2230bc2b1f59..5d4f80698a8b 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -300,6 +300,9 @@ static int amd_pmf_suspend_handler(struct device *dev) if (pdev->smart_pc_enabled) cancel_delayed_work_sync(&pdev->pb_work); + if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2)) + amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_SUSPEND); + return 0; } @@ -314,6 +317,9 @@ static int amd_pmf_resume_handler(struct device *dev) return ret; } + if (is_apmf_func_supported(pdev, APMF_FUNC_SBIOS_HEARTBEAT_V2)) + amd_pmf_notify_sbios_heartbeat_event_v2(pdev, ON_RESUME); + if (pdev->smart_pc_enabled) schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000)); @@ -444,6 +450,8 @@ static int amd_pmf_probe(struct platform_device *pdev) amd_pmf_dbgfs_register(dev); amd_pmf_init_features(dev); apmf_install_handler(dev); + if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2)) + amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_LOAD); dev_info(dev->dev, "registered PMF device successfully\n"); @@ -455,6 +463,8 @@ static void amd_pmf_remove(struct platform_device *pdev) struct amd_pmf_dev *dev = platform_get_drvdata(pdev); amd_pmf_deinit_features(dev); + if (is_apmf_func_supported(dev, APMF_FUNC_SBIOS_HEARTBEAT_V2)) + amd_pmf_notify_sbios_heartbeat_event_v2(dev, ON_UNLOAD); apmf_acpi_deinit(dev); amd_pmf_dbgfs_unregister(dev); mutex_destroy(&dev->lock); diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 5d722e2772b8..fc1e91d3c22b 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -30,6 +30,7 @@ #define APMF_FUNC_STATIC_SLIDER_GRANULAR 9 #define APMF_FUNC_DYN_SLIDER_AC 11 #define APMF_FUNC_DYN_SLIDER_DC 12 +#define APMF_FUNC_SBIOS_HEARTBEAT_V2 16 /* Message Definitions */ #define SET_SPL 0x03 /* SPL: Sustained Power Limit */ @@ -85,6 +86,21 @@ #define PMF_IF_V1 1 +struct sbios_hb_event_v2 { + u16 size; + u8 load; + u8 unload; + u8 suspend; + u8 resume; +} __packed; + +enum sbios_hb_v2 { + ON_LOAD, + ON_UNLOAD, + ON_SUSPEND, + ON_RESUME, +}; + /* AMD PMF BIOS interfaces */ struct apmf_verify_interface { u16 size; @@ -600,6 +616,7 @@ int amd_pmf_get_power_source(void); int apmf_install_handler(struct amd_pmf_dev *pmf_dev); int apmf_os_power_slider_update(struct amd_pmf_dev *dev, u8 flag); int amd_pmf_set_dram_addr(struct amd_pmf_dev *dev, bool alloc_buffer); +int amd_pmf_notify_sbios_heartbeat_event_v2(struct amd_pmf_dev *dev, u8 flag); /* SPS Layer */ int amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf); From patchwork Tue Jun 25 06:43:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951937 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b003KHHz23v2 for ; Tue, 25 Jun 2024 16:44:00 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzuE-00084W-ME; Tue, 25 Jun 2024 06:43:54 +0000 Received: from mail-pl1-f177.google.com ([209.85.214.177]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzuC-00080r-L6 for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:52 +0000 Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1fa55dbf2e7so10865605ad.2 for ; Mon, 24 Jun 2024 23:43:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297830; x=1719902630; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ypN7LIUgt+B0mdLXnkhojXuvB/AhUm4U35GClGpkZb4=; b=G9nhJQF4kMJdNWW08Dm+ptW+HKx9jk8rkRmsv8NS7o/BQ2zZh4Q8tOudHLIr1DhqmJ gtC+e1fiBpgjZwSQzoxhq3CwzXR2vdf6cOLSe/e91Jwi1mGCaJH7xrOD8SxWIwcpr4QM eh8fjcoMxDIvCZyFJGWsY8kaerNeM66kdP+F7/yUgvXRh2+nksgQ360o9aiZY3tnAvXi /Fg5TUu4PCBj1NDUXFuVKwA3ZKtatYZ9bSuix73KRTJxdwcDoDwoMEcpzLChZi0CgzBq 5O6dDoHBj/ytWZYCrFvjWLRgusFM9pokcqxW8YXN5JyZI4z+T4OtQL/FIoV2+VPsFUR8 U0wQ== X-Gm-Message-State: AOJu0YyWdz6hmDjCrFuTqT9DR0mB0LLJ7NdmW/aeFiBwTQaT81H6fSzb eUFyaCDUinB8MPfCfnQOsIp2ekRn1UH77isSa1rYAF57wQPivhbRQjOiA4ge X-Google-Smtp-Source: AGHT+IF5rUjDBmHatjU5LWe9oT7n9ZT3RkjiQS+UYcqfkARgl8akWAD+PJF9neCkKJS8Vv++hoXNxg== X-Received: by 2002:a17:902:e742:b0:1f9:fca9:742a with SMTP id d9443c01a7336-1fa15943472mr98404885ad.57.1719297830050; Mon, 24 Jun 2024 23:43:50 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:49 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/7][SRU][Noble] platform/x86/amd/pmf: Add support to get APTS index numbers for static slider Date: Tue, 25 Jun 2024 14:43:19 +0800 Message-ID: <20240625064321.3302827-6-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.177; envelope-from=vicamo@gmail.com; helo=mail-pl1-f177.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 APMF spec has a newer section called the APTS (AMD Performance and Thermal State) information, where each slider/power mode is associated with an index number. Add support to get these indices for the Static Slider. Reviewed-by: Ilpo Järvinen Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-6-Shyam-sundar.S-k@amd.com Signed-off-by: Ilpo Järvinen (cherry picked from commit 48d38f569261bc6faa2b099be7a4029e538e095f) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/acpi.c | 10 ++++++ drivers/platform/x86/amd/pmf/pmf.h | 25 +++++++++++++ drivers/platform/x86/amd/pmf/sps.c | 56 ++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index f0360eea81e6..82dafe74fc6d 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -96,6 +96,16 @@ int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index) return !!(pdev->supported_func & BIT(index - 1)); } +int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev, + struct apmf_static_slider_granular_output_v2 *data) +{ + if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) + return -EINVAL; + + return apmf_if_call_store_buffer(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR, + data, sizeof(*data)); +} + int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, struct apmf_static_slider_granular_output *data) { diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index fc1e91d3c22b..bba68deb3a2a 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -85,6 +85,7 @@ #define MAX_OPERATION_PARAMS 4 #define PMF_IF_V1 1 +#define PMF_IF_V2 2 struct sbios_hb_event_v2 { u16 size; @@ -224,6 +225,14 @@ enum power_modes { POWER_MODE_MAX, }; +enum power_modes_v2 { + POWER_MODE_BEST_PERFORMANCE, + POWER_MODE_BALANCED, + POWER_MODE_BEST_POWER_EFFICIENCY, + POWER_MODE_ENERGY_SAVE, + POWER_MODE_V2_MAX, +}; + struct amd_pmf_dev { void __iomem *regbase; void __iomem *smu_virt_addr; @@ -264,6 +273,10 @@ struct amd_pmf_dev { u16 pmf_if_version; }; +struct apmf_sps_prop_granular_v2 { + u8 power_states[POWER_SOURCE_MAX][POWER_MODE_V2_MAX]; +} __packed; + struct apmf_sps_prop_granular { u32 fppt; u32 sppt; @@ -285,6 +298,16 @@ struct amd_pmf_static_slider_granular { struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX][POWER_MODE_MAX]; }; +struct apmf_static_slider_granular_output_v2 { + u16 size; + struct apmf_sps_prop_granular_v2 sps_idx; +} __packed; + +struct amd_pmf_static_slider_granular_v2 { + u16 size; + struct apmf_sps_prop_granular_v2 sps_idx; +}; + struct os_power_slider { u16 size; u8 slider_event; @@ -634,6 +657,8 @@ const char *amd_pmf_source_as_str(unsigned int state); int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf); +int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev, + struct apmf_static_slider_granular_output_v2 *data); /* Auto Mode Layer */ int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data); diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 33e23e25c8b1..0cf38bdae7a4 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -10,9 +10,26 @@ #include "pmf.h" +static struct amd_pmf_static_slider_granular_v2 config_store_v2; static struct amd_pmf_static_slider_granular config_store; #ifdef CONFIG_AMD_PMF_DEBUG +static const char *slider_v2_as_str(unsigned int state) +{ + switch (state) { + case POWER_MODE_BEST_PERFORMANCE: + return "Best Performance"; + case POWER_MODE_BALANCED: + return "Balanced"; + case POWER_MODE_BEST_POWER_EFFICIENCY: + return "Best Power Efficiency"; + case POWER_MODE_ENERGY_SAVE: + return "Energy Save"; + default: + return "Unknown Power Mode"; + } +} + static const char *slider_as_str(unsigned int state) { switch (state) { @@ -63,10 +80,44 @@ static void amd_pmf_dump_sps_defaults(struct amd_pmf_static_slider_granular *dat pr_debug("Static Slider Data - END\n"); } + +static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v2 *data) +{ + unsigned int i, j; + + pr_debug("Static Slider APTS state index data - BEGIN"); + pr_debug("size: %u\n", data->size); + + for (i = 0; i < POWER_SOURCE_MAX; i++) + for (j = 0; j < POWER_MODE_V2_MAX; j++) + pr_debug("%s %s: %u\n", amd_pmf_source_as_str(i), slider_v2_as_str(j), + data->sps_idx.power_states[i][j]); + + pr_debug("Static Slider APTS state index data - END\n"); +} #else static void amd_pmf_dump_sps_defaults(struct amd_pmf_static_slider_granular *data) {} +static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v2 *data) {} #endif +static void amd_pmf_load_defaults_sps_v2(struct amd_pmf_dev *dev) +{ + struct apmf_static_slider_granular_output_v2 output; + unsigned int i, j; + + memset(&config_store_v2, 0, sizeof(config_store_v2)); + apmf_get_static_slider_granular_v2(dev, &output); + + config_store_v2.size = output.size; + + for (i = 0; i < POWER_SOURCE_MAX; i++) + for (j = 0; j < POWER_MODE_V2_MAX; j++) + config_store_v2.sps_idx.power_states[i][j] = + output.sps_idx.power_states[i][j]; + + amd_pmf_dump_sps_defaults_v2(&config_store_v2); +} + static void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev) { struct apmf_static_slider_granular_output output; @@ -256,7 +307,10 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->current_profile = PLATFORM_PROFILE_BALANCED; if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) { - amd_pmf_load_defaults_sps(dev); + if (dev->pmf_if_version == PMF_IF_V2) + amd_pmf_load_defaults_sps_v2(dev); + else + amd_pmf_load_defaults_sps(dev); /* update SPS balanced power mode thermals */ amd_pmf_set_sps_power_limits(dev); From patchwork Tue Jun 25 06:43:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b020VB2z20Z9 for ; Tue, 25 Jun 2024 16:44:02 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzuG-00087f-1q; Tue, 25 Jun 2024 06:43:56 +0000 Received: from mail-pl1-f181.google.com ([209.85.214.181]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzuE-000839-GT for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:54 +0000 Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fa75f53f42so1070095ad.0 for ; Mon, 24 Jun 2024 23:43:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297832; x=1719902632; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8XfOr2uBC64ZNOZjy89bkZj5uTBRqIlxsIha9A7ceJk=; b=BGcVki8XfTbiBTGccKBc7YE2bI35uqxCWumUr52l2HGZ4Dz4F0z+qt5HDqxLN3UqrJ Yezp8JvRoXfmT2dhvm6TzI2jmhmgs04i/SCDVkdpYj+1/Fi4ZcQMPrF+QlhUtWb2gH0f etEo2YLEN8Dtp5ES6S+U5wuxGOMf9iqO7BUvK4YP3nq1w8wqI9pKSR8LQkBKo1vqPKGV W9lBB7FPlHITcWBfjOte/gvtyx4F08MeRctAy2+secFrfT6ulmSJM0mLyPkHZiM0KLlj iyvTbjRdsPVJDvrH+pZMAqC+fOxzyKaGojnaLuXxjM1RLffqOuAX/QrroN1AhvYnoQ+C Lt5Q== X-Gm-Message-State: AOJu0Yxkd2R+U1Fu1cGaV3PQtPCVimqQCXxKwGg5BLvp+2FJ6Fc8ppNx XjAeZxo4R27mbSWwqVDVn/kgDNPzKESBb82O7pSNK92rM5NdKY+grYWXM8x4 X-Google-Smtp-Source: AGHT+IGwJzpYkJLo6xGG9GWcTiSmXoYIpt1OJi7bujSeKip/gXXNToRm+C7MkM5LG86Cm9wIezwRBw== X-Received: by 2002:a17:903:22c5:b0:1f9:cbe1:af0 with SMTP id d9443c01a7336-1fa23f0725cmr76956035ad.5.1719297831647; Mon, 24 Jun 2024 23:43:51 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:50 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 6/7][SRU][Noble] platform/x86/amd/pmf: Add support to get sps default APTS index values Date: Tue, 25 Jun 2024 14:43:20 +0800 Message-ID: <20240625064321.3302827-7-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.181; envelope-from=vicamo@gmail.com; helo=mail-pl1-f181.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 During the driver probe, the default cache values for the static slider would be obtained by evaluating the APTS method. Add support to use these values as the thermal settings to be updated on the system based on the changing platform-profiles. Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-7-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit 3eecb434d7f21be5fc79604b67954be30d7e39cb) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/acpi.c | 74 +++++++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 25 ++++++++++ drivers/platform/x86/amd/pmf/sps.c | 51 +++++++++++++++++++- 3 files changed, 148 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 82dafe74fc6d..d0cf46e2fc8e 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -90,12 +90,86 @@ static int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *des return err; } +static union acpi_object *apts_if_call(struct amd_pmf_dev *pdev, u32 state_index) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + acpi_handle ahandle = ACPI_HANDLE(pdev->dev); + struct acpi_object_list apts_if_arg_list; + union acpi_object apts_if_args[3]; + acpi_status status; + + apts_if_arg_list.count = 3; + apts_if_arg_list.pointer = &apts_if_args[0]; + + apts_if_args[0].type = ACPI_TYPE_INTEGER; + apts_if_args[0].integer.value = 1; + apts_if_args[1].type = ACPI_TYPE_INTEGER; + apts_if_args[1].integer.value = state_index; + apts_if_args[2].type = ACPI_TYPE_INTEGER; + apts_if_args[2].integer.value = 0; + + status = acpi_evaluate_object(ahandle, "APTS", &apts_if_arg_list, &buffer); + if (ACPI_FAILURE(status)) { + dev_err(pdev->dev, "APTS state_idx:%u call failed\n", state_index); + kfree(buffer.pointer); + return NULL; + } + + return buffer.pointer; +} + +static int apts_if_call_store_buffer(struct amd_pmf_dev *pdev, + u32 index, void *data, size_t out_sz) +{ + union acpi_object *info; + size_t size; + int err = 0; + + info = apts_if_call(pdev, index); + if (!info) + return -EIO; + + if (info->type != ACPI_TYPE_BUFFER) { + dev_err(pdev->dev, "object is not a buffer\n"); + err = -EINVAL; + goto out; + } + + size = *(u16 *)info->buffer.pointer; + if (info->buffer.length < size) { + dev_err(pdev->dev, "buffer smaller than header size %u < %zu\n", + info->buffer.length, size); + err = -EINVAL; + goto out; + } + + if (size < out_sz) { + dev_err(pdev->dev, "buffer too small %zu\n", size); + err = -EINVAL; + goto out; + } + + memcpy(data, info->buffer.pointer, out_sz); +out: + kfree(info); + return err; +} + int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index) { /* If bit-n is set, that indicates function n+1 is supported */ return !!(pdev->supported_func & BIT(index - 1)); } +int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev, + struct amd_pmf_apts_granular_output *data, u32 apts_idx) +{ + if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) + return -EINVAL; + + return apts_if_call_store_buffer(pdev, apts_idx, data, sizeof(*data)); +} + int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *pdev, struct apmf_static_slider_granular_output_v2 *data) { diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index bba68deb3a2a..49965583e0af 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -87,6 +87,29 @@ #define PMF_IF_V1 1 #define PMF_IF_V2 2 +#define APTS_MAX_STATES 16 + +/* APTS PMF BIOS Interface */ +struct amd_pmf_apts_output { + u16 table_version; + u32 fan_table_idx; + u32 pmf_ppt; + u32 ppt_pmf_apu_only; + u32 stt_min_limit; + u8 stt_skin_temp_limit_apu; + u8 stt_skin_temp_limit_hs2; +} __packed; + +struct amd_pmf_apts_granular_output { + u16 size; + struct amd_pmf_apts_output val; +} __packed; + +struct amd_pmf_apts_granular { + u16 size; + struct amd_pmf_apts_output val[APTS_MAX_STATES]; +}; + struct sbios_hb_event_v2 { u16 size; u8 load; @@ -659,6 +682,8 @@ int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf); int apmf_get_static_slider_granular_v2(struct amd_pmf_dev *dev, struct apmf_static_slider_granular_output_v2 *data); +int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev, + struct amd_pmf_apts_granular_output *data, u32 apts_idx); /* Auto Mode Layer */ int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data); diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 0cf38bdae7a4..96bd2140302c 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -12,6 +12,7 @@ static struct amd_pmf_static_slider_granular_v2 config_store_v2; static struct amd_pmf_static_slider_granular config_store; +static struct amd_pmf_apts_granular apts_config_store; #ifdef CONFIG_AMD_PMF_DEBUG static const char *slider_v2_as_str(unsigned int state) @@ -95,11 +96,55 @@ static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v pr_debug("Static Slider APTS state index data - END\n"); } + +static void amd_pmf_dump_apts_sps_defaults(struct amd_pmf_apts_granular *info) +{ + int i; + + pr_debug("Static Slider APTS index default values data - BEGIN"); + + for (i = 0; i < APTS_MAX_STATES; i++) { + pr_debug("Table Version[%d] = %u\n", i, info->val[i].table_version); + pr_debug("Fan Index[%d] = %u\n", i, info->val[i].fan_table_idx); + pr_debug("PPT[%d] = %u\n", i, info->val[i].pmf_ppt); + pr_debug("PPT APU[%d] = %u\n", i, info->val[i].ppt_pmf_apu_only); + pr_debug("STT Min[%d] = %u\n", i, info->val[i].stt_min_limit); + pr_debug("STT APU[%d] = %u\n", i, info->val[i].stt_skin_temp_limit_apu); + pr_debug("STT HS2[%d] = %u\n", i, info->val[i].stt_skin_temp_limit_hs2); + } + + pr_debug("Static Slider APTS index default values data - END"); +} #else static void amd_pmf_dump_sps_defaults(struct amd_pmf_static_slider_granular *data) {} static void amd_pmf_dump_sps_defaults_v2(struct amd_pmf_static_slider_granular_v2 *data) {} +static void amd_pmf_dump_apts_sps_defaults(struct amd_pmf_apts_granular *info) {} #endif +static void amd_pmf_load_apts_defaults_sps_v2(struct amd_pmf_dev *pdev) +{ + struct amd_pmf_apts_granular_output output; + struct amd_pmf_apts_output *ps; + int i; + + memset(&apts_config_store, 0, sizeof(apts_config_store)); + + ps = apts_config_store.val; + + for (i = 0; i < APTS_MAX_STATES; i++) { + apts_get_static_slider_granular_v2(pdev, &output, i); + ps[i].table_version = output.val.table_version; + ps[i].fan_table_idx = output.val.fan_table_idx; + ps[i].pmf_ppt = output.val.pmf_ppt; + ps[i].ppt_pmf_apu_only = output.val.ppt_pmf_apu_only; + ps[i].stt_min_limit = output.val.stt_min_limit; + ps[i].stt_skin_temp_limit_apu = output.val.stt_skin_temp_limit_apu; + ps[i].stt_skin_temp_limit_hs2 = output.val.stt_skin_temp_limit_hs2; + } + + amd_pmf_dump_apts_sps_defaults(&apts_config_store); +} + static void amd_pmf_load_defaults_sps_v2(struct amd_pmf_dev *dev) { struct apmf_static_slider_granular_output_v2 output; @@ -307,10 +352,12 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev) dev->current_profile = PLATFORM_PROFILE_BALANCED; if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) { - if (dev->pmf_if_version == PMF_IF_V2) + if (dev->pmf_if_version == PMF_IF_V2) { amd_pmf_load_defaults_sps_v2(dev); - else + amd_pmf_load_apts_defaults_sps_v2(dev); + } else { amd_pmf_load_defaults_sps(dev); + } /* update SPS balanced power mode thermals */ amd_pmf_set_sps_power_limits(dev); From patchwork Tue Jun 25 06:43:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1951939 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W7b0300Hhz20ZS for ; Tue, 25 Jun 2024 16:44:02 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sLzuH-0008Bm-Cb; Tue, 25 Jun 2024 06:43:57 +0000 Received: from mail-pg1-f181.google.com ([209.85.215.181]) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sLzuG-00086U-LG for kernel-team@lists.ubuntu.com; Tue, 25 Jun 2024 06:43:56 +0000 Received: by mail-pg1-f181.google.com with SMTP id 41be03b00d2f7-6bce380eb96so3358065a12.0 for ; Mon, 24 Jun 2024 23:43:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719297834; x=1719902634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xveb76W+qDTqBLTYyg0lTvgx/rFS9dPg5mcco8bhUYw=; b=WyO8Cse2t/wG0ZvRqRILd6A3T6vj+xoELuTPTn1V0VnGHGJQm1rJTIPA+U6G8QchNH fDONX7TVuV0h+L+ovIKbdBFPdcTfQIXP5X+F04K4vOfyvyKzwf5tqm2i9CuS/AGF3du9 2EP1O6SiNmavYllnqXvDFSnYIO11ge8Cp5N/vZNwccuSiw9mYxqm0nHV6IF7mAbSxKeW xO4/7KRB6nvy86+pHyrG1FdzPSTT0TlcapOhfM719qEoO7tPqtpy3VWFNdTAMQFr96fk MFuhfBPET1LnBXWcyYWINzaZw1kKkOwSm33ZB6epbv6sm01ZOSp2uaObzfODoiGUoqUv IMkg== X-Gm-Message-State: AOJu0YzQyzqyktCBkFZurbZeUZEJL6oAp84PhiIdNLtdEuelpbzTayai qz0k6nnqpNM8S4e95dG9GhIib/06Z3mUozUAFurhplrColO5v8frjfo2sbvV X-Google-Smtp-Source: AGHT+IGBB9jmK8SBiqdI7T1spyMPfTu8P7SeFrrRuTVsRpBij5rUoZHOYsZR+Pqw8yFej6XuKWKL5A== X-Received: by 2002:a05:6a20:7487:b0:1b7:4adb:1dc2 with SMTP id adf61e73a8af0-1bcf7eaf9acmr6769638637.21.1719297833842; Mon, 24 Jun 2024 23:43:53 -0700 (PDT) Received: from localhost.localdomain (125-229-129-140.hinet-ip.hinet.net. [125.229.129.140]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fa1d3773d1sm46767525ad.270.2024.06.24.23.43.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jun 2024 23:43:53 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 7/7][SRU][Noble] platform/x86/amd/pmf: Update sps power thermals according to the platform-profiles Date: Tue, 25 Jun 2024 14:43:21 +0800 Message-ID: <20240625064321.3302827-8-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240625064321.3302827-1-vicamo.yang@canonical.com> References: <20240625064321.3302827-1-vicamo.yang@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.215.181; envelope-from=vicamo@gmail.com; helo=mail-pg1-f181.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Shyam Sundar S K BugLink: https://bugs.launchpad.net/bugs/2058330 Update power thermals according to the platform-profiles selected by the user. Co-developed-by: Patil Rajesh Reddy Signed-off-by: Patil Rajesh Reddy Signed-off-by: Shyam Sundar S K Link: https://lore.kernel.org/r/20240306114415.3267603-8-Shyam-sundar.S-k@amd.com Reviewed-by: Ilpo Järvinen Signed-off-by: Ilpo Järvinen (cherry picked from commit 8362e862fb87992f083f75dd49d029e8fc0d803b) Signed-off-by: You-Sheng Yang --- drivers/platform/x86/amd/pmf/pmf.h | 2 ++ drivers/platform/x86/amd/pmf/sps.c | 42 ++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 49965583e0af..282f80274d4e 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -51,6 +51,8 @@ #define GET_STT_LIMIT_APU 0x20 #define GET_STT_LIMIT_HS2 0x21 #define SET_P3T 0x23 /* P3T: Peak Package Power Limit */ +#define SET_PMF_PPT 0x25 +#define SET_PMF_PPT_APU_ONLY 0x26 /* OS slider update notification */ #define DC_BEST_PERF 0 diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c index 96bd2140302c..92f7fb22277d 100644 --- a/drivers/platform/x86/amd/pmf/sps.c +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -190,6 +190,19 @@ static void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev) amd_pmf_dump_sps_defaults(&config_store); } +static void amd_pmf_update_slider_v2(struct amd_pmf_dev *dev, int idx) +{ + amd_pmf_send_cmd(dev, SET_PMF_PPT, false, apts_config_store.val[idx].pmf_ppt, NULL); + amd_pmf_send_cmd(dev, SET_PMF_PPT_APU_ONLY, false, + apts_config_store.val[idx].ppt_pmf_apu_only, NULL); + amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false, + apts_config_store.val[idx].stt_min_limit, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false, + apts_config_store.val[idx].stt_skin_temp_limit_apu, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, false, + apts_config_store.val[idx].stt_skin_temp_limit_hs2, NULL); +} + void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, struct amd_pmf_static_slider_granular *table) { @@ -222,6 +235,32 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, } } +static int amd_pmf_update_sps_power_limits_v2(struct amd_pmf_dev *pdev, int pwr_mode) +{ + int src, index; + + src = amd_pmf_get_power_source(); + + switch (pwr_mode) { + case POWER_MODE_PERFORMANCE: + index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BEST_PERFORMANCE]; + amd_pmf_update_slider_v2(pdev, index); + break; + case POWER_MODE_BALANCED_POWER: + index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BALANCED]; + amd_pmf_update_slider_v2(pdev, index); + break; + case POWER_MODE_POWER_SAVER: + index = config_store_v2.sps_idx.power_states[src][POWER_MODE_BEST_POWER_EFFICIENCY]; + amd_pmf_update_slider_v2(pdev, index); + break; + default: + return -EINVAL; + } + + return 0; +} + int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf) { int mode; @@ -230,6 +269,9 @@ int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf) if (mode < 0) return mode; + if (pmf->pmf_if_version == PMF_IF_V2) + return amd_pmf_update_sps_power_limits_v2(pmf, mode); + amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL); return 0;