From patchwork Tue Aug 2 15:11:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934736 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 20A87C19F2C for ; Tue, 2 Aug 2022 15:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233060AbiHBPNg (ORCPT ); Tue, 2 Aug 2022 11:13:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiHBPNg (ORCPT ); Tue, 2 Aug 2022 11:13:36 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D52115A3C for ; Tue, 2 Aug 2022 08:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YA827ZrlSixSW5WFK2X4SEZgeMko0xvnQMLlCoo3FAqeipjg4BACEzhN4/88K77Ol+OnLK6uQNU5NXxs7Kz6mYt8YmM388nlq7wCmcbbE4+I/4nHDe8HSFKTq5C+uDv0bbi7RymgzJ7bYtWbB+55qh2f2jeoP92+ITXlDTgFCBpvTMoCt3sA9pWS+5k88G84X8MEXScw7r4D8sigiOyZ039tmwIdkXkG5JOPswkEqBq+wTpU8qs16BZMhX2LTPRCnYj1cZlpdp+Dw/WdV5p3gq9VoDAvJG3k3/5KVesLfAz7xUVVNTTSS66eQ+qeVImHdU4gvn8LgPzZZkXAum9jZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gVSpId4jVLGTbgOHqCCKM2+jdc64WVdpeCW6hwS9rjY=; b=PHG6Szos9bpw5pmT22Z2GlozRbZ7ww2q0UYB/771y3GdgmFzTm0RbC547bidjn2XVuFLB35xCJ8toagv5sP7mZFyOoRIix8yXf1/KW6m4bgGbYXexvNeiiIIusnOXm7cwmj6Grna796yzPOUrCGhPVwyyrZJ8EnNkX5IJdOgsacQZy5uZ2IUYewteQ32oCSNrcckJEjzF9dt9BSSjS9/HZy5xFsfmdM1U+BFvb2BTVL58prgl0xTh7sTirfeehqNWeNbryna/FK5W+TNuGdgG8HA5fu6yu8jQVZs1VhwgGQUsKc59YynxGqYURgJoJQObm8J4nEtL8L8CJLBenFlIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gVSpId4jVLGTbgOHqCCKM2+jdc64WVdpeCW6hwS9rjY=; b=QCAmVL2dK8f4vUahf6Jqb4A/BSm6+c2+Jgqo3c+PU0kgs4P8WA33iOj0LghF7hxr7lWCUu+NyopTkqarfaB/FHyGLxNJ5yeqyk72KBR2FKHj0lIYEzNn1UuL65zlrh0h87fWCW7vKp2PC7UNSSXXujUJWuucSrqjeXaMdLyvOnI= Received: from BN0PR04CA0178.namprd04.prod.outlook.com (2603:10b6:408:eb::33) by DM6PR12MB2953.namprd12.prod.outlook.com (2603:10b6:5:189::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.14; Tue, 2 Aug 2022 15:13:31 +0000 Received: from BN8NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::d1) by BN0PR04CA0178.outlook.office365.com (2603:10b6:408:eb::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16 via Frontend Transport; Tue, 2 Aug 2022 15:13:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT066.mail.protection.outlook.com (10.13.177.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:31 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:28 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 01/11] platform/x86/amd/pmf: Add support for PMF core layer Date: Tue, 2 Aug 2022 20:41:39 +0530 Message-ID: <20220802151149.2123699-2-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: daa17966-c5f3-41c1-b77c-08da74998f7a X-MS-TrafficTypeDiagnostic: DM6PR12MB2953:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VHdEhr5dMtDla+QIKSXz+PWh6eVIOL/lfJGJwUos0hUe3MePPVSYL+/qtNy9piptLjr6RiN6Y0ceEg8RDn5R1Y4yIQ34+6s0/YovpSbMty+67CBpFes7SKPVzzyQThh8VoG6PL20BL1QtrjH7mxdxpLcdR54IDi/jeRHm0zgIVHd6g5PlV/Pj4h94+PY4LR0zkevUdg6yCROM6BXTOe8QsSnICHlnvEOgjs0m1Alv2wrwoltsa5SJCKrBTCY0+q+TmTLax85NToU+A1AZjeaVilwTF9rzWlGmTOg1iUupc66oEISVcfOEVkJdkK187dHpxTk2LEPUtOCjexWejINXpvUaCQav78lwYQbo+e3X2y1KnFJ7WdF8dyv51/FAXDX9w3SLsN8JiIbyny0p7vs/LOyhks9oXNkmYNbGvj8azi9CBBwt1QGlvqEJy221qQO8e9tkxbULd7IA7Jv8jcBDQ/NS+xR4MOu2FgNJDpS5Ec79+z43b7Z5fvJeFpv7bu56QkxSOaC5gYOFwAvub/Ok+N70blptNweUOQBqtWgcTUUfd/9eTDz0rbhyYNTSbnuf2yJiD2V8kx2sAVVhFG2w0IZXsgGhG55jVZtQYs7fRtsBmJ74kSiaO3pRLJyMs4yiugfIjTUJvFG+LXdLd5VneZ4uCDEkpfkJFpUzuEQ9HmfIpfWpaSVmEMsbt7jkOhj1b/OaFnsIZSO9XYEB2k7LGXelQArS4eHJr0+jKGYPLh8h9RMsM99MoPTqh4KWy+SGeL3rYw7lcI8BH3yhwW1vkCjMMdqydDxPk3/aDV9QPl1wycScYpuxvA0KWh1/wL5HuYXkkuO+OSlaQzBHgyPKA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(376002)(396003)(39860400002)(46966006)(36840700001)(40470700004)(40480700001)(47076005)(8676002)(2906002)(30864003)(81166007)(356005)(5660300002)(82310400005)(86362001)(36860700001)(70206006)(4326008)(70586007)(82740400003)(316002)(26005)(478600001)(8936002)(40460700003)(41300700001)(7696005)(36756003)(6666004)(54906003)(186003)(110136005)(1076003)(336012)(2616005)(83380400001)(16526019)(426003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:31.1411 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: daa17966-c5f3-41c1-b77c-08da74998f7a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2953 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org PMF core layer is meant to abstract the common functionalities across PMF features. This layer also does the plumbing work like setting up the mailbox channel for the communication between the PMF driver and the PMFW (Power Management Firmware) running on the SMU. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/Kconfig | 2 + drivers/platform/x86/amd/Makefile | 1 + drivers/platform/x86/amd/pmf/Kconfig | 15 ++ drivers/platform/x86/amd/pmf/Makefile | 8 + drivers/platform/x86/amd/pmf/core.c | 235 ++++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 46 +++++ 6 files changed, 307 insertions(+) create mode 100644 drivers/platform/x86/amd/pmf/Kconfig create mode 100644 drivers/platform/x86/amd/pmf/Makefile create mode 100644 drivers/platform/x86/amd/pmf/core.c create mode 100644 drivers/platform/x86/amd/pmf/pmf.h diff --git a/drivers/platform/x86/amd/Kconfig b/drivers/platform/x86/amd/Kconfig index c0d0a3c5170c..a825af8126c8 100644 --- a/drivers/platform/x86/amd/Kconfig +++ b/drivers/platform/x86/amd/Kconfig @@ -3,6 +3,8 @@ # AMD x86 Platform Specific Drivers # +source "drivers/platform/x86/amd/pmf/Kconfig" + config AMD_PMC tristate "AMD SoC PMC driver" depends on ACPI && PCI && RTC_CLASS diff --git a/drivers/platform/x86/amd/Makefile b/drivers/platform/x86/amd/Makefile index a03fbb08e808..2c229198e24c 100644 --- a/drivers/platform/x86/amd/Makefile +++ b/drivers/platform/x86/amd/Makefile @@ -8,3 +8,4 @@ amd-pmc-y := pmc.o obj-$(CONFIG_AMD_PMC) += amd-pmc.o amd_hsmp-y := hsmp.o obj-$(CONFIG_AMD_HSMP) += amd_hsmp.o +obj-$(CONFIG_AMD_PMF) += pmf/ diff --git a/drivers/platform/x86/amd/pmf/Kconfig b/drivers/platform/x86/amd/pmf/Kconfig new file mode 100644 index 000000000000..ef771bbe1198 --- /dev/null +++ b/drivers/platform/x86/amd/pmf/Kconfig @@ -0,0 +1,15 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# AMD PMF Driver +# + +config AMD_PMF + tristate "AMD Platform Management Framework" + depends on ACPI + help + This driver provides support for the AMD Platform Management Framework. + The goal is to enhance end user experience by making AMD PCs smarter, + quiter, power efficient by adapting to user behavior and environment. + + To compile this driver as a module, choose M here: the module will + be called amd_pmf. diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile new file mode 100644 index 000000000000..459005f659e5 --- /dev/null +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/x86/amd/pmf +# AMD Platform Management Framework +# + +obj-$(CONFIG_AMD_PMF) += amd-pmf.o +amd-pmf-objs := core.o diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c new file mode 100644 index 000000000000..aef97965c181 --- /dev/null +++ b/drivers/platform/x86/amd/pmf/core.c @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * AMD Platform Management Framework Driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Shyam Sundar S K + */ + +#include +#include +#include +#include +#include "pmf.h" + +/* PMF-SMU communication registers */ +#define AMD_PMF_REGISTER_MESSAGE 0xA18 +#define AMD_PMF_REGISTER_RESPONSE 0xA78 +#define AMD_PMF_REGISTER_ARGUMENT 0xA58 + +/* Base address of SMU for mapping physical address to virtual address */ +#define AMD_PMF_SMU_INDEX_ADDRESS 0xB8 +#define AMD_PMF_SMU_INDEX_DATA 0xBC +#define AMD_PMF_MAPPING_SIZE 0x01000 +#define AMD_PMF_BASE_ADDR_OFFSET 0x10000 +#define AMD_PMF_BASE_ADDR_LO 0x13B102E8 +#define AMD_PMF_BASE_ADDR_HI 0x13B102EC +#define AMD_PMF_BASE_ADDR_LO_MASK GENMASK(15, 0) +#define AMD_PMF_BASE_ADDR_HI_MASK GENMASK(31, 20) + +/* SMU Response Codes */ +#define AMD_PMF_RESULT_OK 0x01 +#define AMD_PMF_RESULT_CMD_REJECT_BUSY 0xFC +#define AMD_PMF_RESULT_CMD_REJECT_PREREQ 0xFD +#define AMD_PMF_RESULT_CMD_UNKNOWN 0xFE +#define AMD_PMF_RESULT_FAILED 0xFF + +/* List of supported CPU ids */ +#define AMD_CPU_ID_PS 0x14e8 + +#define PMF_MSG_DELAY_MIN_US 50 +#define RESPONSE_REGISTER_LOOP_MAX 20000 + +#define DELAY_MIN_US 2000 +#define DELAY_MAX_US 3000 + +static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset) +{ + return ioread32(dev->regbase + reg_offset); +} + +static inline void amd_pmf_reg_write(struct amd_pmf_dev *dev, int reg_offset, u32 val) +{ + iowrite32(val, dev->regbase + reg_offset); +} + +static void __maybe_unused amd_pmf_dump_registers(struct amd_pmf_dev *dev) +{ + u32 value; + + value = amd_pmf_reg_read(dev, AMD_PMF_REGISTER_RESPONSE); + dev_dbg(dev->dev, "AMD_PMF_REGISTER_RESPONSE:%x\n", value); + + value = amd_pmf_reg_read(dev, AMD_PMF_REGISTER_ARGUMENT); + dev_dbg(dev->dev, "AMD_PMF_REGISTER_ARGUMENT:%d\n", value); + + value = amd_pmf_reg_read(dev, AMD_PMF_REGISTER_MESSAGE); + dev_dbg(dev->dev, "AMD_PMF_REGISTER_MESSAGE:%x\n", value); +} + +int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data) +{ + int rc; + u32 val; + + mutex_lock(&dev->lock); + + /* Wait until we get a valid response */ + rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMF_REGISTER_RESPONSE, + val, val != 0, PMF_MSG_DELAY_MIN_US, + PMF_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX); + if (rc) { + dev_err(dev->dev, "failed to talk to SMU\n"); + goto out_unlock; + } + + /* Write zero to response register */ + amd_pmf_reg_write(dev, AMD_PMF_REGISTER_RESPONSE, 0); + + /* Write argument into argument register */ + amd_pmf_reg_write(dev, AMD_PMF_REGISTER_ARGUMENT, arg); + + /* Write message ID to message ID register */ + amd_pmf_reg_write(dev, AMD_PMF_REGISTER_MESSAGE, message); + + /* Wait until we get a valid response */ + rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMF_REGISTER_RESPONSE, + val, val != 0, PMF_MSG_DELAY_MIN_US, + PMF_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX); + if (rc) { + dev_err(dev->dev, "SMU response timed out\n"); + goto out_unlock; + } + + switch (val) { + case AMD_PMF_RESULT_OK: + if (get) { + /* PMFW may take longer time to return back the data */ + usleep_range(DELAY_MIN_US, 10 * DELAY_MAX_US); + *data = amd_pmf_reg_read(dev, AMD_PMF_REGISTER_ARGUMENT); + } + break; + case AMD_PMF_RESULT_CMD_REJECT_BUSY: + dev_err(dev->dev, "SMU not ready. err: 0x%x\n", val); + rc = -EBUSY; + goto out_unlock; + case AMD_PMF_RESULT_CMD_UNKNOWN: + dev_err(dev->dev, "SMU cmd unknown. err: 0x%x\n", val); + rc = -EINVAL; + goto out_unlock; + case AMD_PMF_RESULT_CMD_REJECT_PREREQ: + case AMD_PMF_RESULT_FAILED: + default: + dev_err(dev->dev, "SMU cmd failed. err: 0x%x\n", val); + rc = -EIO; + goto out_unlock; + } + +out_unlock: + mutex_unlock(&dev->lock); + amd_pmf_dump_registers(dev); + return rc; +} + +static const struct pci_device_id pmf_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) }, + { } +}; + +static const struct acpi_device_id amd_pmf_acpi_ids[] = { + {"AMDI0102", 0}, + { } +}; +MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids); + +static int amd_pmf_probe(struct platform_device *pdev) +{ + struct amd_pmf_dev *dev; + struct pci_dev *rdev; + u32 base_addr_lo; + u32 base_addr_hi; + u64 base_addr; + u32 val; + int err; + + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + + dev->dev = &pdev->dev; + + rdev = pci_get_domain_bus_and_slot(0, 0, PCI_DEVFN(0, 0)); + if (!rdev || !pci_match_id(pmf_pci_ids, rdev)) { + pci_dev_put(rdev); + return -ENODEV; + } + + dev->cpu_id = rdev->device; + err = pci_write_config_dword(rdev, AMD_PMF_SMU_INDEX_ADDRESS, AMD_PMF_BASE_ADDR_LO); + if (err) { + dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMF_SMU_INDEX_ADDRESS); + pci_dev_put(rdev); + return pcibios_err_to_errno(err); + } + + err = pci_read_config_dword(rdev, AMD_PMF_SMU_INDEX_DATA, &val); + if (err) { + pci_dev_put(rdev); + return pcibios_err_to_errno(err); + } + + base_addr_lo = val & AMD_PMF_BASE_ADDR_HI_MASK; + + err = pci_write_config_dword(rdev, AMD_PMF_SMU_INDEX_ADDRESS, AMD_PMF_BASE_ADDR_HI); + if (err) { + dev_err(dev->dev, "error writing to 0x%x\n", AMD_PMF_SMU_INDEX_ADDRESS); + pci_dev_put(rdev); + return pcibios_err_to_errno(err); + } + + err = pci_read_config_dword(rdev, AMD_PMF_SMU_INDEX_DATA, &val); + if (err) { + pci_dev_put(rdev); + return pcibios_err_to_errno(err); + } + + base_addr_hi = val & AMD_PMF_BASE_ADDR_LO_MASK; + pci_dev_put(rdev); + base_addr = ((u64)base_addr_hi << 32 | base_addr_lo); + + dev->regbase = devm_ioremap(dev->dev, base_addr + AMD_PMF_BASE_ADDR_OFFSET, + AMD_PMF_MAPPING_SIZE); + if (!dev->regbase) + return -ENOMEM; + + platform_set_drvdata(pdev, dev); + + mutex_init(&dev->lock); + dev_info(dev->dev, "registered PMF device successfully\n"); + + return 0; +} + +static int amd_pmf_remove(struct platform_device *pdev) +{ + struct amd_pmf_dev *dev = platform_get_drvdata(pdev); + + mutex_destroy(&dev->lock); + kfree(dev->buf); + return 0; +} + +static struct platform_driver amd_pmf_driver = { + .driver = { + .name = "amd-pmf", + .acpi_match_table = amd_pmf_acpi_ids, + }, + .probe = amd_pmf_probe, + .remove = amd_pmf_remove, +}; +module_platform_driver(amd_pmf_driver); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("AMD Platform Management Framework Driver"); diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h new file mode 100644 index 000000000000..1c2e942e5096 --- /dev/null +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * AMD Platform Management Framework Driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Shyam Sundar S K + */ + +#ifndef PMF_H +#define PMF_H + +/* Message Definitions */ +#define SET_SPL 0x03 /* SPL: Sustained Power Limit */ +#define SET_SPPT 0x05 /* SPPT: Slow Package Power Tracking */ +#define SET_FPPT 0x07 /* FPPT: Fast Package Power Tracking */ +#define GET_SPL 0x0B +#define GET_SPPT 0x0D +#define GET_FPPT 0x0F +#define SET_DRAM_ADDR_HIGH 0x14 +#define SET_DRAM_ADDR_LOW 0x15 +#define SET_TRANSFER_TABLE 0x16 +#define SET_STT_MIN_LIMIT 0x18 /* STT: Skin Temperature Tracking */ +#define SET_STT_LIMIT_APU 0x19 +#define SET_STT_LIMIT_HS2 0x1A +#define SET_SPPT_APU_ONLY 0x1D +#define GET_SPPT_APU_ONLY 0x1E +#define GET_STT_MIN_LIMIT 0x1F +#define GET_STT_LIMIT_APU 0x20 +#define GET_STT_LIMIT_HS2 0x21 + +struct amd_pmf_dev { + void __iomem *regbase; + void __iomem *smu_virt_addr; + void *buf; + u32 base_addr; + u32 cpu_id; + struct device *dev; + struct mutex lock; /* protects the PMF interface */ +}; + +/* Core Layer */ +int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data); + +#endif /* PMF_H */ From patchwork Tue Aug 2 15:11:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934737 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 0C010C00140 for ; Tue, 2 Aug 2022 15:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234534AbiHBPNi (ORCPT ); Tue, 2 Aug 2022 11:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiHBPNh (ORCPT ); Tue, 2 Aug 2022 11:13:37 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2062.outbound.protection.outlook.com [40.107.212.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36064167CA for ; Tue, 2 Aug 2022 08:13:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ld+At1CB9kIHmk88GNqSFqBIDwoPX9+TgnxdoBdtxpncdWEEQ2peBi99m8SLUlA19pWGisNuPVURDLzQYmTEcBEG5xcBAL8PVMDRjO1dnK9hQR9CRcXUfL9cDIqmhnvk+bnd+GE/ADCjubX1fMpGWiYKt1Gtdw4vCoGTACi3d8L61PFK13+R9RpRiT5S1eac6Ze7QcQZalHABHp9ba8QFLrh4WtDNGC9Ls8H9KGN6xgV/Q6JD4wMFrs8E9SfoymaiV2oxs+UVXSq8aoS2K7KKlfF8r3Fr8YXs/HdDuxiVFIBTwLbX/wcDOmyPQaRSYb+hOFAquo4Wg+5R5at97duVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qEfp4ldm16oSN9d3efOkwmvwp8vQ4ETb0EGmM04DzVc=; b=crBaHhImWX+OxJbOwR+0X9pmFp/WD47YJZLWNf17rEnjZX9UPjeRa0A8UUcFLFZRoKC5bZiEWLBdGAzOt1SCsbTvrJsg6d82De/S6oE1/+r5QXHNQhv4j68jO+HeziC7Opb+Pvl56lj5fYmmtu30mctFhNBzt4ewDS2/n6U9Q6de1I/CzyzxYuW5XpGtstgBmrO9awx8jBQMX+Hwv+NepaQsErf8kdCsPwEpX/sqZovWAFZVg/zfFa2vL52e1Eknjn+s6s4rj41awwXXlmOuAvEsMbyB78SUPPQxavO+gnjekbtJ1ZI0xloFpRddqwWUgiV56gjLLMvRDaXDHSOVlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qEfp4ldm16oSN9d3efOkwmvwp8vQ4ETb0EGmM04DzVc=; b=B4ClFI1UcT0TRPVNhhQKPSOmjw74e66zljVysEJq8vyw5xvEqg+0jmQHHqvkPUgI3Xd0iZnzL4eUU9cq36sO4mThvJ+lQYZMjbCGz4khxa6fVZ/lX2QY94G1tiLd+uOuDAU5qYuu0UgwrJEtM1RSAsDjDMUhT51UQBbeoJj+BdA= Received: from BN0PR04CA0166.namprd04.prod.outlook.com (2603:10b6:408:eb::21) by BN6PR12MB1348.namprd12.prod.outlook.com (2603:10b6:404:1f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 2 Aug 2022 15:13:33 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::1) by BN0PR04CA0166.outlook.office365.com (2603:10b6:408:eb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12 via Frontend Transport; Tue, 2 Aug 2022 15:13:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:33 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:30 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 02/11] platform/x86/amd/pmf: Add support for PMF APCI layer Date: Tue, 2 Aug 2022 20:41:40 +0530 Message-ID: <20220802151149.2123699-3-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d900993c-a828-4947-78bd-08da749990e4 X-MS-TrafficTypeDiagnostic: BN6PR12MB1348:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ubfqa2+QBWC3h5xJUclMVnTJsgafplJ37IAdw4eq3yTAVaVp+VLOney5IaG7rmuE+nNYl6Yh42DrgQXT/e0gKJDlmHDVi7wNEfj4GIyf3Oo6jtFuSQbqhSApCbLXZ64UBfcuv43lPER9+GyjTKlwuIlB17yDNcOPTdEDBvGcTPSLcYvip8jEekWyLolOi2OVkxlUcIy0/L/AZXd2MSLe6utldFdgztjSWa5xukPfZSJePi9iMqDBkVUjSn0rDPS7P6cT388mBCdx94gf/Hqbcc3ojHm0+j8bZFPJ/oN5PajaZyCVgkdnLcGqijJ4OqIAGZWIsUi0hGbahSXGU1/j5g149g26H9VHbIeYOqKquo90gClkC2zfQhfR+S7aZxzfOYnHkViOtSVUwSr89NEHzrulOX/AJ88ZN7guDMVWEyx4YOnbEL/hodvdNVMpFes0LsfDK7DSdWPbaz7LJaNNgjvBXJ1/6TeJGYm6ol2S6bS7W8QSD5WwgI5rLbfZV/bjcLjsBYuh+K91JVh5EVqAcMY/00qaEf43mF7UUphbnDtGHiHBwbvz0siPOxKKKDgk8Zr3BjsQk2nfk4iJ1yYFP4ssfqdP8mEvhhLheR/5qvWfMrNNb2tHSQh/ZPigsioN6p+juWTZrfB36ffMw8qVsTS5pfhNydUhCLBkapVVDuIYqEoEcYXBNN3p7tPYdgBEyYwR9C8vRVCc3tlSa4gF86JA7GJPCtNFtPt9XNKL49f2qBCTqkzjJKGjVqFHbPODVZyhAxvuSxCbeuBnwdmfigXjyHnz4oXfYSd3dQBqTjhDdUcx/tiTliJ2T1ur6v7jfg0aQvQUbRcQGZDK4ITkOg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(136003)(39860400002)(376002)(346002)(46966006)(40470700004)(36840700001)(186003)(16526019)(336012)(83380400001)(426003)(47076005)(8676002)(478600001)(54906003)(110136005)(316002)(36756003)(70586007)(70206006)(26005)(40460700003)(2906002)(4326008)(8936002)(41300700001)(6666004)(86362001)(36860700001)(356005)(82740400003)(82310400005)(81166007)(40480700001)(7696005)(2616005)(1076003)(5660300002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:33.5432 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d900993c-a828-4947-78bd-08da749990e4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1348 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org PMF driver implements the ACPI methods as defined by AMD for PMF Support. The ACPI layer acts as a glue that helps in providing the infrastructure for OEMs customization. OEMs can refer to PMF support documentation to decide on the list of functions to be supported on their specific platform model. AMD mandates that PMF ACPI fn0 and fn1 to be implemented which provides the set of functions, params and the notifications that would be sent to PMF driver so that PMF driver can adapt and react. Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/acpi.c | 151 ++++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/core.c | 1 + drivers/platform/x86/amd/pmf/pmf.h | 23 ++++ 4 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/amd/pmf/acpi.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 459005f659e5..2617eba773ce 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -5,4 +5,4 @@ # obj-$(CONFIG_AMD_PMF) += amd-pmf.o -amd-pmf-objs := core.o +amd-pmf-objs := core.o acpi.o diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c new file mode 100644 index 000000000000..b378f9e31194 --- /dev/null +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -0,0 +1,151 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Platform Management Framework Driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Shyam Sundar S K + */ + +#include +#include "pmf.h" + +static union acpi_object *apmf_if_call(struct amd_pmf_dev *pdev, int fn, struct acpi_buffer *param) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + acpi_handle ahandle = ACPI_HANDLE(pdev->dev); + struct acpi_object_list apmf_if_arg_list; + union acpi_object apmf_if_args[2]; + acpi_status status; + + apmf_if_arg_list.count = 2; + apmf_if_arg_list.pointer = &apmf_if_args[0]; + + apmf_if_args[0].type = ACPI_TYPE_INTEGER; + apmf_if_args[0].integer.value = fn; + + if (param) { + apmf_if_args[1].type = ACPI_TYPE_BUFFER; + apmf_if_args[1].buffer.length = param->length; + apmf_if_args[1].buffer.pointer = param->pointer; + } else { + apmf_if_args[1].type = ACPI_TYPE_INTEGER; + apmf_if_args[1].integer.value = 0; + } + + status = acpi_evaluate_object(ahandle, "APMF", &apmf_if_arg_list, &buffer); + if (ACPI_FAILURE(status)) { + dev_err(pdev->dev, "APMF method:%d call failed\n", fn); + kfree(buffer.pointer); + return NULL; + } + + return buffer.pointer; +} + +static int apmf_if_call_store_buffer(struct amd_pmf_dev *pdev, int fn, void *dest, size_t out_sz) +{ + union acpi_object *info; + size_t size; + int err = 0; + + info = apmf_if_call(pdev, fn, NULL); + if (!info) + return -EIO; + + if (info->type != ACPI_TYPE_BUFFER) { + dev_err(pdev->dev, "object is not a buffer\n"); + err = -EINVAL; + goto out; + } + + if (info->buffer.length < 2) { + dev_err(pdev->dev, "buffer too small\n"); + err = -EINVAL; + goto out; + } + + size = *(u16 *)info->buffer.pointer; + if (info->buffer.length < size) { + dev_err(pdev->dev, "buffer smaller then headersize %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(dest, 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)); +} + +static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) +{ + struct apmf_verify_interface output; + int err; + + err = apmf_if_call_store_buffer(pdev, APMF_FUNC_VERIFY_INTERFACE, &output, sizeof(output)); + if (err) + 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); + + return 0; +} + +static int apmf_get_system_params(struct amd_pmf_dev *dev) +{ + struct apmf_system_params params; + int err; + + if (!is_apmf_func_supported(dev, APMF_FUNC_GET_SYS_PARAMS)) + return -EINVAL; + + err = apmf_if_call_store_buffer(dev, APMF_FUNC_GET_SYS_PARAMS, ¶ms, sizeof(params)); + if (err) + return err; + + dev_dbg(dev->dev, "system params mask:0x%x flags:0x%x cmd_code:0x%x\n", + params.valid_mask, + params.flags, + params.command_code); + params.flags = params.flags & params.valid_mask; + + return 0; +} + +int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) +{ + int ret; + + ret = apmf_if_verify_interface(pmf_dev); + if (ret) { + dev_err(pmf_dev->dev, "APMF verify interface failed :%d\n", ret); + goto out; + } + + ret = apmf_get_system_params(pmf_dev); + if (ret) { + dev_err(pmf_dev->dev, "APMF apmf_get_system_params failed :%d\n", ret); + goto out; + } + +out: + return ret; +} diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index aef97965c181..c5002b7bb904 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -204,6 +204,7 @@ static int amd_pmf_probe(struct platform_device *pdev) if (!dev->regbase) return -ENOMEM; + apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); mutex_init(&dev->lock); diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 1c2e942e5096..bdadbff168ee 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -11,6 +11,12 @@ #ifndef PMF_H #define PMF_H +#include + +/* APMF Functions */ +#define APMF_FUNC_VERIFY_INTERFACE 0 +#define APMF_FUNC_GET_SYS_PARAMS 1 + /* Message Definitions */ #define SET_SPL 0x03 /* SPL: Sustained Power Limit */ #define SET_SPPT 0x05 /* SPPT: Slow Package Power Tracking */ @@ -30,6 +36,21 @@ #define GET_STT_LIMIT_APU 0x20 #define GET_STT_LIMIT_HS2 0x21 +/* AMD PMF BIOS interfaces */ +struct apmf_verify_interface { + u16 size; + u16 version; + u32 notification_mask; + u32 supported_functions; +} __packed; + +struct apmf_system_params { + u16 size; + u32 valid_mask; + u32 flags; + u8 command_code; +} __packed; + struct amd_pmf_dev { void __iomem *regbase; void __iomem *smu_virt_addr; @@ -38,9 +59,11 @@ struct amd_pmf_dev { u32 cpu_id; struct device *dev; struct mutex lock; /* protects the PMF interface */ + u32 supported_func; }; /* Core Layer */ +int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data); #endif /* PMF_H */ From patchwork Tue Aug 2 15:11:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934738 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 C9268C00140 for ; Tue, 2 Aug 2022 15:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229460AbiHBPNn (ORCPT ); Tue, 2 Aug 2022 11:13:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234193AbiHBPNm (ORCPT ); Tue, 2 Aug 2022 11:13:42 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2048.outbound.protection.outlook.com [40.107.237.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1C92167CA for ; Tue, 2 Aug 2022 08:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B0WPvSR+v2VLzm0c8uAsp83V9S3Fd1xO67YTuZuxeftHkMCOY3K0hR2Xc0vaQ5L0BxW61jkfjLt1JflzbADNSPbGX6ovdrWBGYXawAcT7HyXKysxK1B3CzcrVMMQwzJMW1/mUbMzv/DNSK4wrpZNPVBeEbk62b2m4QT3sBACJx23iwwMMky2g2yocIBKjjEnXNKMrJZ+Sv/pECpuVo3t4jQBqcGVW3x5lrar6hHEZfblAss1gvMsRpwPxxVDN9SvXtpnXQevwr7ZIAjGz3WCHUV1IeuVS9DXWtJZ5UxLeadHRl3gdn9oX7KCdvEH8f2vXXBl/NiiXlvzdw/duTZcrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AaIPWtxr7lMdscHSn2ArgjZlFk6RyhcFbGqcJek8aaI=; b=Iw6hb0xeky5prP5hyi8PWwb9XQT7DYBtWtVVo8ZuBgQ5yj/SQlnCbTG7bJpE1+WX/4B47Dv/hV4CJ96/2tIhf0L5gzm8qQh2gD6gxaiGfr6G0HNyP7U9YFkWVYhBebn5A0mBCNk/TWNVwnkVHWLZjZJ7q0RWHPY0JGPndsr7rnSKXkL8Qx1fxtw7zyCeVF7DryqFbye7DakQV+j1Hm/tm2c5C/Mzg8kJdgBLcRiOuo9JkJDy2EZ+Azcokgm275dkApxGLqqs9BkxrO77HGFPiTxaY8lhPrroEYVi0NH/Jx8cxjY9CqI5NaRsu5W1SJ2CvpruVmZ8+KKD3mnGTDCMkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AaIPWtxr7lMdscHSn2ArgjZlFk6RyhcFbGqcJek8aaI=; b=GVamsCNmCEPTGOEbOKMY52seQr8Ezuv4cknpAsc7GH5mOJI3LnyvfwtucIgmyFHVTz3eW/8Ba7b9rWjWskKSruhKsPuLNzdMfzi46ZGFSwe2NtSpljkb1OLGD1KwEX9MTNFnoWolSLd/eAyZ3SxjKdAVDMPj2QfYPsRo738Dzd8= Received: from BN9PR03CA0324.namprd03.prod.outlook.com (2603:10b6:408:112::29) by BL1PR12MB5900.namprd12.prod.outlook.com (2603:10b6:208:398::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15; Tue, 2 Aug 2022 15:13:36 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:112:cafe::89) by BN9PR03CA0324.outlook.office365.com (2603:10b6:408:112::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16 via Frontend Transport; Tue, 2 Aug 2022 15:13:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:36 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:33 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 03/11] platform/x86/amd/pmf: Add support SPS PMF feature Date: Tue, 2 Aug 2022 20:41:41 +0530 Message-ID: <20220802151149.2123699-4-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 88de5d87-ba06-4934-04f1-08da7499927f X-MS-TrafficTypeDiagnostic: BL1PR12MB5900:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6PwkWs1S8uWnmx04VcENLUB6g6+jQI+B9kguyu+lpZYm62KfIpd+uiqkrIbtT2lXRx4PAFAIxzjFXYB35AQsIAvQZ6cetz954Q232iIxVFmr8SeGjure2pnPYa8Mxvw7vo2YQzMJSwhmy4ABOnIknVLSGLwQ/xtQ3p8BwvToKcLXniF8dwMeg4ZWL9bT1m2Jgv0ekQFNUmMnmz/trkOgcapPG9tmuWH38Uc9Ps4qVUbpUGvL2u6axZ5Nidj/dvmA7soiK17pGhu+u4ViNVJ9zJWiP+MaE/D416co+C6hG2uD3bNBxP04CZ+Sm9ZNo+V5v+SC7kStj22J+qdG+EHRJh/RLUCtnV8+nH8gnXWQOvPxm6w/rENPhdbX5lGVjWxo95U7pYGzUzcPq0atkOPUUzsDH5yX5LDWFvUUNoVSlCsG9dZmak9hPZSLA5K5BqkK+WARy1EhLrc11RrV7TWITqeSUx/5AGYCixNAkfoRyPonhIONBs8neuLrcldb2SQD8+3qBBFgqPvu25wdaDGwa0QB/MUVxaD+GQW56Fj2nb6CM/b6UovwCXGX9S6/RGTyfT9gmgnZXEOvKPrAsCuSNmgFjvbaGIOr4KBSkNU047Pz3JQb7qCHG6P5pk8uL1nyDc670VbrqMRBrRl3Nww9qIgBEak8mNWuUUvTcN43hEf1cEVq2hWPZ65v9b6Ei3e6YyFFmB1dV+oktDBYVQBEpOcZDm/lR9wIs+6chmMynTxdU8oTxGi7W/NQAjbcfFymvRmeYTggS80ibawORD1vkinBhCiowu9cf7BvHjt/mn4LKHQRCgADEy9jZ1Aww/5q2k61hOPmK2Mx6oS2H0pG0w== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(346002)(136003)(376002)(39860400002)(46966006)(40470700004)(36840700001)(16526019)(40460700003)(186003)(478600001)(426003)(336012)(83380400001)(5660300002)(86362001)(70206006)(70586007)(4326008)(8676002)(81166007)(7696005)(30864003)(82740400003)(356005)(47076005)(2616005)(41300700001)(6666004)(110136005)(36756003)(54906003)(316002)(82310400005)(2906002)(1076003)(40480700001)(26005)(8936002)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:36.2181 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 88de5d87-ba06-4934-04f1-08da7499927f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5900 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org SPS (a.k.a. Static Power Slider) gives a feel of Windows performance power slider for the Linux users, where the user selects a certain mode (like "balanced", "low-power" or "performance") and the thermals associated with each selected mode gets applied from the silicon side via the mailboxes defined through PMFW. PMF driver hooks to platform_profile by reading the PMF ACPI fn9 to see if the support is being advertised by ACPI interface. If supported, the PMF driver reacts to platform_profile selection choices made by the user and adjust the system thermal behavior. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/Makefile | 2 +- drivers/platform/x86/amd/pmf/acpi.c | 10 ++ drivers/platform/x86/amd/pmf/core.c | 26 +++++ drivers/platform/x86/amd/pmf/pmf.h | 64 +++++++++++ drivers/platform/x86/amd/pmf/sps.c | 149 ++++++++++++++++++++++++++ 5 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/amd/pmf/sps.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 2617eba773ce..557521a80427 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -5,4 +5,4 @@ # obj-$(CONFIG_AMD_PMF) += amd-pmf.o -amd-pmf-objs := core.o acpi.o +amd-pmf-objs := core.o acpi.o sps.o diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index b378f9e31194..5997ab724f3a 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -93,6 +93,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(struct amd_pmf_dev *pdev, + struct apmf_static_slider_granular_output *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)); +} + static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) { struct apmf_verify_interface output; diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index c5002b7bb904..a70ab6c9608a 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "pmf.h" /* PMF-SMU communication registers */ @@ -45,6 +46,14 @@ #define DELAY_MIN_US 2000 #define DELAY_MAX_US 3000 +int amd_pmf_get_power_source(void) +{ + if (power_supply_is_system_supplied() > 0) + return POWER_SOURCE_AC; + else + return POWER_SOURCE_DC; +} + static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset) { return ioread32(dev->regbase + reg_offset); @@ -138,6 +147,21 @@ static const struct pci_device_id pmf_pci_ids[] = { { } }; +static void amd_pmf_init_features(struct amd_pmf_dev *dev) +{ + /* Enable Static Slider */ + if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) { + amd_pmf_init_sps(dev); + dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n"); + } +} + +static void amd_pmf_deinit_features(struct amd_pmf_dev *dev) +{ + if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) + amd_pmf_deinit_sps(dev); +} + static const struct acpi_device_id amd_pmf_acpi_ids[] = { {"AMDI0102", 0}, { } @@ -206,6 +230,7 @@ static int amd_pmf_probe(struct platform_device *pdev) apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); + amd_pmf_init_features(dev); mutex_init(&dev->lock); dev_info(dev->dev, "registered PMF device successfully\n"); @@ -218,6 +243,7 @@ static int amd_pmf_remove(struct platform_device *pdev) struct amd_pmf_dev *dev = platform_get_drvdata(pdev); mutex_destroy(&dev->lock); + amd_pmf_deinit_features(dev); kfree(dev->buf); return 0; } diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index bdadbff168ee..5c867dac7d44 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -12,10 +12,12 @@ #define PMF_H #include +#include /* APMF Functions */ #define APMF_FUNC_VERIFY_INTERFACE 0 #define APMF_FUNC_GET_SYS_PARAMS 1 +#define APMF_FUNC_STATIC_SLIDER_GRANULAR 9 /* Message Definitions */ #define SET_SPL 0x03 /* SPL: Sustained Power Limit */ @@ -36,6 +38,8 @@ #define GET_STT_LIMIT_APU 0x20 #define GET_STT_LIMIT_HS2 0x21 +#define ARG_NONE 0 + /* AMD PMF BIOS interfaces */ struct apmf_verify_interface { u16 size; @@ -51,6 +55,30 @@ struct apmf_system_params { u8 command_code; } __packed; +enum amd_stt_skin_temp { + STT_TEMP_APU, + STT_TEMP_HS2, + STT_TEMP_COUNT, +}; + +enum amd_slider_op { + SLIDER_OP_GET, + SLIDER_OP_SET, +}; + +enum power_source { + POWER_SOURCE_AC, + POWER_SOURCE_DC, + POWER_SOURCE_MAX, +}; + +enum power_modes { + POWER_MODE_PERFORMANCE, + POWER_MODE_BALANCED_POWER, + POWER_MODE_POWER_SAVER, + POWER_MODE_MAX, +}; + struct amd_pmf_dev { void __iomem *regbase; void __iomem *smu_virt_addr; @@ -60,10 +88,46 @@ struct amd_pmf_dev { struct device *dev; struct mutex lock; /* protects the PMF interface */ u32 supported_func; + enum platform_profile_option current_profile; + struct platform_profile_handler pprof; +}; + +struct apmf_sps_prop_granular { + u32 fppt; + u32 sppt; + u32 sppt_apu_only; + u32 spl; + u32 stt_min; + u8 stt_skin_temp[STT_TEMP_COUNT]; + u32 fan_id; +} __packed; + +/* Static Slider */ +struct apmf_static_slider_granular_output { + u16 size; + struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX * POWER_MODE_MAX]; +} __packed; + +struct amd_pmf_static_slider_granular { + u16 size; + struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX][POWER_MODE_MAX]; }; /* Core Layer */ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); +int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index); int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data); +int amd_pmf_get_power_source(void); + +/* SPS Layer */ +u8 amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf); +void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, + struct amd_pmf_static_slider_granular *table); +int amd_pmf_init_sps(struct amd_pmf_dev *dev); +void amd_pmf_deinit_sps(struct amd_pmf_dev *dev); +int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, + struct apmf_static_slider_granular_output *output); +void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev); + #endif /* PMF_H */ diff --git a/drivers/platform/x86/amd/pmf/sps.c b/drivers/platform/x86/amd/pmf/sps.c new file mode 100644 index 000000000000..ef4df3fd774b --- /dev/null +++ b/drivers/platform/x86/amd/pmf/sps.c @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Platform Management Framework (PMF) Driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Shyam Sundar S K + */ + +#include "pmf.h" + +static int amd_pmf_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile); +static int amd_pmf_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile); +static struct amd_pmf_static_slider_granular config_store; + +void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev) +{ + struct apmf_static_slider_granular_output output; + int i, j, idx = 0; + + memset(&config_store, 0, sizeof(config_store)); + apmf_get_static_slider_granular(dev, &output); + + for (i = 0; i < POWER_SOURCE_MAX; i++) { + for (j = 0; j < POWER_MODE_MAX; j++) { + config_store.prop[i][j].spl = output.prop[idx].spl; + config_store.prop[i][j].sppt = output.prop[idx].sppt; + config_store.prop[i][j].sppt_apu_only = + output.prop[idx].sppt_apu_only; + config_store.prop[i][j].fppt = output.prop[idx].fppt; + config_store.prop[i][j].stt_min = output.prop[idx].stt_min; + config_store.prop[i][j].stt_skin_temp[STT_TEMP_APU] = + output.prop[idx].stt_skin_temp[STT_TEMP_APU]; + config_store.prop[i][j].stt_skin_temp[STT_TEMP_HS2] = + output.prop[idx].stt_skin_temp[STT_TEMP_HS2]; + config_store.prop[i][j].fan_id = output.prop[idx].fan_id; + idx++; + } + } +} + +void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx, + struct amd_pmf_static_slider_granular *table) +{ + int src = amd_pmf_get_power_source(); + + if (op == SLIDER_OP_SET) { + amd_pmf_send_cmd(dev, SET_SPL, false, config_store.prop[src][idx].spl, NULL); + amd_pmf_send_cmd(dev, SET_FPPT, false, config_store.prop[src][idx].fppt, NULL); + amd_pmf_send_cmd(dev, SET_SPPT, false, config_store.prop[src][idx].sppt, NULL); + amd_pmf_send_cmd(dev, SET_SPPT_APU_ONLY, false, + config_store.prop[src][idx].sppt_apu_only, NULL); + amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false, + config_store.prop[src][idx].stt_min, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false, + config_store.prop[src][idx].stt_skin_temp[STT_TEMP_APU], NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, false, + config_store.prop[src][idx].stt_skin_temp[STT_TEMP_HS2], NULL); + } else if (op == SLIDER_OP_GET) { + amd_pmf_send_cmd(dev, GET_SPL, true, ARG_NONE, &table->prop[src][idx].spl); + amd_pmf_send_cmd(dev, GET_FPPT, true, ARG_NONE, &table->prop[src][idx].fppt); + amd_pmf_send_cmd(dev, GET_SPPT, true, ARG_NONE, &table->prop[src][idx].sppt); + amd_pmf_send_cmd(dev, GET_SPPT_APU_ONLY, true, ARG_NONE, + &table->prop[src][idx].sppt_apu_only); + amd_pmf_send_cmd(dev, GET_STT_MIN_LIMIT, true, ARG_NONE, + &table->prop[src][idx].stt_min); + amd_pmf_send_cmd(dev, GET_STT_LIMIT_APU, true, ARG_NONE, + (u32 *)&table->prop[src][idx].stt_skin_temp[STT_TEMP_APU]); + amd_pmf_send_cmd(dev, GET_STT_LIMIT_HS2, true, ARG_NONE, + (u32 *)&table->prop[src][idx].stt_skin_temp[STT_TEMP_HS2]); + } +} + +static int amd_pmf_profile_get(struct platform_profile_handler *pprof, + enum platform_profile_option *profile) +{ + struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof); + + *profile = pmf->current_profile; + return 0; +} + +u8 amd_pmf_get_pprof_modes(struct amd_pmf_dev *pmf) +{ + u8 mode; + + switch (pmf->current_profile) { + case PLATFORM_PROFILE_PERFORMANCE: + mode = POWER_MODE_PERFORMANCE; + break; + case PLATFORM_PROFILE_BALANCED: + mode = POWER_MODE_BALANCED_POWER; + break; + case PLATFORM_PROFILE_LOW_POWER: + mode = POWER_MODE_POWER_SAVER; + break; + default: + dev_err(pmf->dev, "Unknown Platform Profile.\n"); + break; + } + + return mode; +} + +int amd_pmf_profile_set(struct platform_profile_handler *pprof, + enum platform_profile_option profile) +{ + struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof); + u8 mode; + + pmf->current_profile = profile; + mode = amd_pmf_get_pprof_modes(pmf); + amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL); + return 0; +} + +int amd_pmf_init_sps(struct amd_pmf_dev *dev) +{ + int err = 0; + + dev->pprof.profile_get = amd_pmf_profile_get; + dev->pprof.profile_set = amd_pmf_profile_set; + + /* Setup supported modes */ + set_bit(PLATFORM_PROFILE_LOW_POWER, dev->pprof.choices); + set_bit(PLATFORM_PROFILE_BALANCED, dev->pprof.choices); + set_bit(PLATFORM_PROFILE_PERFORMANCE, dev->pprof.choices); + + /* Create platform_profile structure and register */ + err = platform_profile_register(&dev->pprof); + if (err) { + dev_err(dev->dev, "Failed to register SPS support, this is most likely an SBIOS bug: %d\n", + err); + return -EEXIST; + } + + dev->current_profile = PLATFORM_PROFILE_BALANCED; + amd_pmf_load_defaults_sps(dev); + + return err; +} + +void amd_pmf_deinit_sps(struct amd_pmf_dev *dev) +{ + platform_profile_remove(); +} From patchwork Tue Aug 2 15:11:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934739 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 BA4D4C19F2C for ; Tue, 2 Aug 2022 15:13:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234193AbiHBPNp (ORCPT ); Tue, 2 Aug 2022 11:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234624AbiHBPNn (ORCPT ); Tue, 2 Aug 2022 11:13:43 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2068.outbound.protection.outlook.com [40.107.100.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 481BB17581 for ; Tue, 2 Aug 2022 08:13:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HtFS7hM7YP66CLlp3G6WZAp2b9UdAMrQkKXchAVLTZr/0Khgkz3pT1zbsYyjV3nd1JNq7WfEqxEQJM1XL+fX3RmlNECtao0xb0J3taGdfXnOk0tgeX3f0YjuIgeT1wfcKzrOKEr1w9COVpRi6/ZkbZ1/+9fmpNVg+CsBTbGBnsTW16wJM4zfEosZsF3Bu41FEFGTYZCoRPZw+zqRx8tlId11lEu6YMMPQYTppx7dq9vex6m7frxqodyrlGBmhrgs6+QDY9xW2aKw5sJtanMpkQoRdwQTQSgKIphnDpUJX0Vl7/mqmWY7V1uXf1yfsv9Mu0gwtiPo5WlNJN6bDo45cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LTOPTtcTtLwYERkeUC8c+spsPlj86ria9DxLk1EUKGg=; b=aq6FB5CsmfTBiw9DPZ6I3PNIbYd3D01iYLZSf+6frDDqRUrDhCTejkyjEqS5Ks237ZeDqWikSrDTflfhSAdst+bDg6xmRBlzrzwqdfKXjFy0AC1sCv7xrDgDiY9QCXcv8a58IHuKuzeV8ZseA74P/LcjStyQCnF5ONHFRvap14lCOwPDgVB9YGss5k5lKNPOWu12lSBL+n+6CGlDxerZiWM9ERr4IJts9pLwAin6u53Do9N8eymIBhN31P4S/NHVtNt9nZF/o+wuMETJc1+2KVY3K6kXzYXbO/BAvt/XdUaAz0lBvjIIG6zJgaP9oVydwE0XWFg4XGJ7yjzyy83P5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LTOPTtcTtLwYERkeUC8c+spsPlj86ria9DxLk1EUKGg=; b=Oa8wKcIEMMv0cAXr8kHp0Kl82arMZipxdx64m7N8TM59ayXdcq7cgiE2nr2uHmDDrf0F5JO7PiqDZkzj79TcDD4BCFtjjhkys6ZpCp5tQjYAtd7trwmHDdah1u9QQfuTGvMH8OKPnhDB4LHgZARYfPEwIN2XRPaGVMKpsxBjcOU= Received: from BN8PR07CA0011.namprd07.prod.outlook.com (2603:10b6:408:ac::24) by MW4PR12MB6801.namprd12.prod.outlook.com (2603:10b6:303:1e8::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Tue, 2 Aug 2022 15:13:40 +0000 Received: from BN8NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ac:cafe::6d) by BN8PR07CA0011.outlook.office365.com (2603:10b6:408:ac::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Tue, 2 Aug 2022 15:13:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT026.mail.protection.outlook.com (10.13.177.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:39 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:36 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 04/11] platform/x86/amd/pmf: Add debugfs information Date: Tue, 2 Aug 2022 20:41:42 +0530 Message-ID: <20220802151149.2123699-5-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b038b122-f473-496b-bc8e-08da74999440 X-MS-TrafficTypeDiagnostic: MW4PR12MB6801:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y8jAwxq9atjkxx2x9lBZ69v8UXBC7A34v88RfEgUEOfuuPQLrPcDFhrfsPG09GVbs4SEJ0kc3DvSMbhCb4HAeFharXDFTzh70ez6KR0Snn5J8mRtEgkY1CWgciTtMqrwtZO9qg0fVxwZqgDUuroxBCBR4OCMBG10zGWfov9TIT8NWL7V5qWiUImBkrkdg1JTUxRTdRCkCwBj5phHQd7xx/SiRGV+pyd9jlWzV6WV1LZEBPI4fQ4ZcO+WhdHLb9nvy/AuYNDNN0pGHPIojp7oxz004wbS/TADn3UZ/R4Zx83pGj0WeQg4QazqpbR7eXEyJog/PzmLavACDXyJR2exaczI9DkEl+s6IQYZyesODEG/UARIC5mAvrri2H+OOjaui2InZ6L8HC7fsHPMYNd1xxRsEOlBj2XFI/C7hrSFZNou4o0/TeXX6aYONuCXuivOscJJEVGyBC6Bnte5Iacla+4g4xGl6O5+xUud0cQz68vIOyyjlhl+opHaLSsBmd34G/a9Zkz86AnMj0lmsiM4oV9tNoItA8RyUBJtE2c/z6wWwkiwSOvNykOpY2QEdSh7Xn19gnJMVMg/Eygft4MCi6TL4AkZ52vBuw+RPtt0y2uNo5LQ7w4tMcb0DOGFFDYKsuS6pOyhthyXCkR8BLC7WSaifm/Z/8zNFbdGkU7Hdfzwya8Mk8sFx6tGLn739uzjFKcTQzhvyuHEr+SrrYV9rwrBVdl04uF5VykV6l+/wqNrVNCRhLPuAUVwtYojPTP4Np49lBbbpAIDptZhxgpzyxJx9k2OMgrnrH3Ze+krH9s1JURNlwuT4V1tpc/qCcCI3b/kU8cf8o2bhfp6HZG8Tg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(136003)(39860400002)(376002)(396003)(40470700004)(46966006)(36840700001)(26005)(356005)(16526019)(186003)(86362001)(478600001)(1076003)(2616005)(7696005)(8936002)(82310400005)(40460700003)(81166007)(336012)(426003)(47076005)(2906002)(41300700001)(6666004)(82740400003)(83380400001)(5660300002)(110136005)(36860700001)(36756003)(40480700001)(316002)(8676002)(54906003)(70586007)(70206006)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:39.1810 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b038b122-f473-496b-bc8e-08da74999440 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6801 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Add debugfs support to the PMF driver so that using this interface the live counters from the PMFW can be queried to see if the power parameters are getting set properly when a certain power mode change happens. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/core.c | 36 +++++++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 1 + 2 files changed, 37 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index a70ab6c9608a..032d9dc5e09f 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -8,6 +8,7 @@ * Author: Shyam Sundar S K */ +#include #include #include #include @@ -46,6 +47,39 @@ #define DELAY_MIN_US 2000 #define DELAY_MAX_US 3000 +static int current_power_limits_show(struct seq_file *seq, void *unused) +{ + struct amd_pmf_dev *dev = seq->private; + struct amd_pmf_static_slider_granular table; + int mode, src = 0; + + mode = amd_pmf_get_pprof_modes(dev); + src = amd_pmf_get_power_source(); + amd_pmf_update_slider(dev, SLIDER_OP_GET, mode, &table); + seq_printf(seq, "spl:%u fppt:%u sppt:%u sppt_apu_only:%u stt_min:%u stt[APU]:%u stt[HS2]: %u\n", + table.prop[src][mode].spl, + table.prop[src][mode].fppt, + table.prop[src][mode].sppt, + table.prop[src][mode].sppt_apu_only, + table.prop[src][mode].stt_min, + table.prop[src][mode].stt_skin_temp[STT_TEMP_APU], + table.prop[src][mode].stt_skin_temp[STT_TEMP_HS2]); + return 0; +} +DEFINE_SHOW_ATTRIBUTE(current_power_limits); + +static void amd_pmf_dbgfs_unregister(struct amd_pmf_dev *dev) +{ + debugfs_remove_recursive(dev->dbgfs_dir); +} + +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); +} + int amd_pmf_get_power_source(void) { if (power_supply_is_system_supplied() > 0) @@ -231,6 +265,7 @@ static int amd_pmf_probe(struct platform_device *pdev) apmf_acpi_init(dev); platform_set_drvdata(pdev, dev); amd_pmf_init_features(dev); + amd_pmf_dbgfs_register(dev); mutex_init(&dev->lock); dev_info(dev->dev, "registered PMF device successfully\n"); @@ -244,6 +279,7 @@ static int amd_pmf_remove(struct platform_device *pdev) mutex_destroy(&dev->lock); amd_pmf_deinit_features(dev); + amd_pmf_dbgfs_unregister(dev); kfree(dev->buf); return 0; } diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 5c867dac7d44..e13542359403 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -90,6 +90,7 @@ struct amd_pmf_dev { u32 supported_func; enum platform_profile_option current_profile; struct platform_profile_handler pprof; + struct dentry *dbgfs_dir; }; struct apmf_sps_prop_granular { From patchwork Tue Aug 2 15:11:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934740 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 0F1C3C00140 for ; Tue, 2 Aug 2022 15:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234638AbiHBPNx (ORCPT ); Tue, 2 Aug 2022 11:13:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234624AbiHBPNw (ORCPT ); Tue, 2 Aug 2022 11:13:52 -0400 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2081.outbound.protection.outlook.com [40.107.101.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADF4F17E12 for ; Tue, 2 Aug 2022 08:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GoxSCeo92Jm+1HML7fuSxThtmtSmVCUIhKWGC7sgyR8TSnc3DsYqUGq7MHdFH0Sn7uXVkvf383sN7OzEz6oXc/rke2Sce7aQ67HQaFzP3oWOuV+CuteZWadqSc8aBPUpktzn8MmJYk8SwrIBg7xcceWKUM3FEMtaGWFegTDz9pOXb0hF51U/7cZSdzZSOCwMrU/0ZzBo8oQuj0Vsdj+8dp/A5hcjRD/nhNxkG2sg0xyt+aFYScYer8Cj7vHBfbojHbuC5zbEDLFINhmnJ+bvO3pq4UJRnhoIDSrO6hGvPzcpMosWROS9Rpg8m/xeT11xoUwVPRx60ddQCnWDbXTkEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=limAfm3k9EK/VDKG3jPPmZHdQDT1QJootq+Z84wxrSk=; b=j8Sq8U9WMzU7av0biBX+0895sXwwObdyqvZlt5IlYatCO8iN+vlYiR1qX9loXEYEzSkW3zKyEQd2Ui7KFgVnuJKqxJ9GH+DOhLdBB0/rfhYBC4JvTmRm0dmYu4PTAC0qI9ZGi18sMtRKNuGabNJ/qhUTJt7ar172XFYoxlXdvO867r4tWayZRiBlCQH6hY0x84yGzzgv5x7wnFnOlZMBtpU6qLsRUg8EU1inzUfjCAJ0m79tjPwqkBfruzL0SUxWjsux+x/+exwRvQ9NAklntj3o05NXhabc9ADiNKnbOOE15IrE3oRH+x6X+x+aj+G6+6ErdRgCAxfILFHoa3c0+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=limAfm3k9EK/VDKG3jPPmZHdQDT1QJootq+Z84wxrSk=; b=Ns98Axp+rSH0bI9FJWY+qnXGQsY8ea09fDhn5aRnC26uVyMoyKAZNi4iNiUbRu/+q8+U03wfmx8Uigd6dTxj+rsle2kskc4ya+NM4s+393fA3+NJL5vE5cEL1T+9nc4/Q1+w0O8PfWKY+DyPip62oHk6jvdvQ/lzecol6XlFFWU= Received: from BN9PR03CA0844.namprd03.prod.outlook.com (2603:10b6:408:13d::9) by MW5PR12MB5681.namprd12.prod.outlook.com (2603:10b6:303:19e::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16; Tue, 2 Aug 2022 15:13:49 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::1c) by BN9PR03CA0844.outlook.office365.com (2603:10b6:408:13d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Tue, 2 Aug 2022 15:13:48 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:48 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:38 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 05/11] platform/x86/amd/pmf: Add heartbeat signal support Date: Tue, 2 Aug 2022 20:41:43 +0530 Message-ID: <20220802151149.2123699-6-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e100184-e6cf-4a27-5650-08da749999cf X-MS-TrafficTypeDiagnostic: MW5PR12MB5681:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: o+fwk2GSqg1sDjqHUmE3KFM7XQKQUIJVmVw55JHUYRXUexvlBsAOTIi7tUkoX7EEfzuodMso38JzBbBT8OaGOCng4IrtDovMicEZ/LHep9wX87PmhiC/peGrmozkawMBtxmrc9MWYLzHeokyMkj5Ao+mVFMAoR9v+BEcUFA8fWtWLbwm8HkPDMcyjZehG4X+YEv/YoxG+PA+WzH2g4RZOejY4c81AFx/wfd55tJDHJeVdRt15BboN95chN6Fz5ukym5AqfwniZ0jrPGu/mcqch1v0TiXKaDp78QXhaorzkJgrzx5Ao63CiQkaSZvx/ykCiawFxdQNjnClOtMTDKwjkYbK/Lyyk/lmHkQdrojoN/lpF4XnFwtznr0jrMX/HjgVm9oZp64SyGY2SDri6+1FCJA+py5uO6ZQY/wGoeSDsfCdNZOqRo1xMNbYLveh6dcbApjB+2vyBSkLN9zkfC2FCiBGUrdVgMY54LbiuERCa4RYRm/vYBNGD7MTjLV+en0obMwGDNgjqm8YyQYilBqiofLsEfNt4oAMt8T39JurK+oMWdDZZOMEoTJYdyQWSkDFXUz4DCGHUdKGLuyw1MCHL8KL2wGWSy0+c4RgOQXPhtYFXqICi/UxjgtRizYqgh9arj6cbUDY4//K1qFN6kEVDCQVpe/Ju1MG8cF9pfqVr8P8sggbn4TU2bfzhrtITzQhkNso8liJOG5dUrGgWkt2flRHwmwmUhs7j1CLth6G1WgF8cMK272JKGhTYqv40W8rxgpYBxnf4xlaOTtxry/5vyiYwoaBh/zSYf+mL7A39S70ck2kmfoThxFSDi9rQ+1g87eV91dAr0uMIXpKFQo4A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(136003)(376002)(346002)(40470700004)(36840700001)(46966006)(6666004)(7696005)(41300700001)(26005)(40480700001)(316002)(478600001)(54906003)(110136005)(86362001)(82310400005)(356005)(82740400003)(40460700003)(81166007)(336012)(426003)(1076003)(2616005)(16526019)(186003)(47076005)(36860700001)(83380400001)(36756003)(2906002)(8936002)(70206006)(5660300002)(8676002)(70586007)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:48.4885 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e100184-e6cf-4a27-5650-08da749999cf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5681 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org PMF driver can send periodic heartbeat signals to OEM BIOS. When BIOS does not receive the signal after a period of time, it can infer that AMDPMF has hung or failed to load. In this situation, BIOS can fallback to legacy operations. OEM can modify the time interval of the signal or completely disable signals through ACPI Method. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/acpi.c | 34 +++++++++++++++++++++++++++-- drivers/platform/x86/amd/pmf/core.c | 1 + drivers/platform/x86/amd/pmf/pmf.h | 5 +++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 5997ab724f3a..6af0e23257ea 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -103,6 +103,22 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, data, sizeof(*data)); } +static void apmf_sbios_heartbeat_notify(struct work_struct *work) +{ + struct amd_pmf_dev *dev = container_of(work, struct amd_pmf_dev, heart_beat.work); + union acpi_object *info; + + dev_dbg(dev->dev, "Sending heartbeat to SBIOS\n"); + info = apmf_if_call(dev, APMF_FUNC_SBIOS_HEARTBEAT, NULL); + if (!info) + goto out; + + schedule_delayed_work(&dev->heart_beat, msecs_to_jiffies(dev->hb_interval * 1000)); + +out: + kfree(info); +} + static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) { struct apmf_verify_interface output; @@ -131,15 +147,23 @@ static int apmf_get_system_params(struct amd_pmf_dev *dev) if (err) return err; - dev_dbg(dev->dev, "system params mask:0x%x flags:0x%x cmd_code:0x%x\n", + dev_dbg(dev->dev, "system params mask:0x%x flags:0x%x cmd_code:0x%x heartbeat:%d\n", params.valid_mask, params.flags, - params.command_code); + params.command_code, + params.heartbeat_int); params.flags = params.flags & params.valid_mask; + dev->hb_interval = params.heartbeat_int; return 0; } +void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev) +{ + if (pmf_dev->hb_interval) + cancel_delayed_work_sync(&pmf_dev->heart_beat); +} + int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) { int ret; @@ -156,6 +180,12 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) goto out; } + if (pmf_dev->hb_interval) { + /* 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); + } + out: return ret; } diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 032d9dc5e09f..87a1f9b27d2c 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -279,6 +279,7 @@ static int amd_pmf_remove(struct platform_device *pdev) mutex_destroy(&dev->lock); amd_pmf_deinit_features(dev); + apmf_acpi_deinit(dev); amd_pmf_dbgfs_unregister(dev); kfree(dev->buf); return 0; diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index e13542359403..5b85a7fe0f38 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -17,6 +17,7 @@ /* APMF Functions */ #define APMF_FUNC_VERIFY_INTERFACE 0 #define APMF_FUNC_GET_SYS_PARAMS 1 +#define APMF_FUNC_SBIOS_HEARTBEAT 4 #define APMF_FUNC_STATIC_SLIDER_GRANULAR 9 /* Message Definitions */ @@ -53,6 +54,7 @@ struct apmf_system_params { u32 valid_mask; u32 flags; u8 command_code; + u32 heartbeat_int; } __packed; enum amd_stt_skin_temp { @@ -91,6 +93,8 @@ struct amd_pmf_dev { enum platform_profile_option current_profile; struct platform_profile_handler pprof; struct dentry *dbgfs_dir; + int hb_interval; /* SBIOS heartbeat interval */ + struct delayed_work heart_beat; }; struct apmf_sps_prop_granular { @@ -116,6 +120,7 @@ struct amd_pmf_static_slider_granular { /* Core Layer */ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); +void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev); int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index); int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data); int amd_pmf_get_power_source(void); From patchwork Tue Aug 2 15:11:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934742 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 61E30C00140 for ; Tue, 2 Aug 2022 15:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235462AbiHBPOA (ORCPT ); Tue, 2 Aug 2022 11:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234720AbiHBPN6 (ORCPT ); Tue, 2 Aug 2022 11:13:58 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2049.outbound.protection.outlook.com [40.107.94.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B7B615A3C for ; Tue, 2 Aug 2022 08:13:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhLzyt404i/hYPJr2P5jqbnseMHlsvMuOpSoo00FFwlBQ63C/TLXgi7YvUHcB60S4iJDryAotX0PZp2/jeVkYPG/C8m7JHq3G7Gtd75qWkihv5u2b1DWn3xiNfkXlx0LqYFVlu8NsMCOMJmK5uqoImZyz1S2yrowIfAEDBjCP4gO+ve45Do2syvBhj/4dRkGVvQCQpesVpiKi/v4h3NnUqT9R4XpIE0CSmAbdH7GcBa7/d3EfWXYIZEWAUpA84foH3OUXBLUwdT+g1bDNLnSDU2zgmHGl/76pO68jOPoV4MnpZmzJ3ieWSLCtQ6INDH18TsYXraVDLP81YAEBbHwsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qYBcCPDCv7Qpa0lwCE3pLndlz9ZE0d9f/l2udmVSmcU=; b=eQWIoghhtpgBIRQv+mVktfwKVGO7IY8rTgxWcJoYwfOa/uBWkOKYrghPsAnnCG+FGPEJUjXjOZjo/1mNCuDfWBHQlg11P6ZbtZLTqB+VEMMHdRJ+O1Ad99uYQmI28qils3HJUR5Da3+JnC37M+QJbpZNA058hXSf/tCM25y3gGnjS88ibbSDrZ/GEKUy7yUXpTJknn21bkqJyTSHK20wjPXMcJO1JBg++ui89fbYZlq/PSYCgeqTDUVpHAPsI0wWwRrjBHZj0eK5NrEurvGUqooHZPGTuTt7ss9JPtQIHkAwLX+ZXH+yLCW9J+4L1fDyqvIMSPIZokTwvBb0ZN1F0Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qYBcCPDCv7Qpa0lwCE3pLndlz9ZE0d9f/l2udmVSmcU=; b=PhsfHL0r5r3pfcxZ5bjq6qnJzmSAdt9iGE09cf22zxzJOBwpsnzkSQ63zF+3SxlqMZ3HriO07IHPCA99brdHwdHFdq0pMeg44zHYQ8K6MZiJ0XdaE6vtaH0OhCEGiT0k+lG/tRD+r0Mep3uT4mM61lnycdSEzvgi8kry7WijUBU= Received: from BN9PR03CA0855.namprd03.prod.outlook.com (2603:10b6:408:13d::20) by CH2PR12MB3799.namprd12.prod.outlook.com (2603:10b6:610:21::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.14; Tue, 2 Aug 2022 15:13:52 +0000 Received: from BN8NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::7e) by BN9PR03CA0855.outlook.office365.com (2603:10b6:408:13d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Tue, 2 Aug 2022 15:13:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT034.mail.protection.outlook.com (10.13.176.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:52 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:48 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 06/11] platform/x86/amd/pmf: Add fan control support Date: Tue, 2 Aug 2022 20:41:44 +0530 Message-ID: <20220802151149.2123699-7-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e4c69c97-b980-4f10-ce7d-08da74999bfa X-MS-TrafficTypeDiagnostic: CH2PR12MB3799:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZE7pQdcraxEM4rFMcFVjO9bYNIoxbo5YusBVqnVW+XF+eV9DKnn4dtlpFilcrYflA+Ns7chnYsRoygpQbQChFzYN+OwvZV8+qeX0ICG0ozDpNC3UbNPwJFdOY39bZg8t9b6foEgIeVPWi4iNqxz0KZpSOJIs5EmU+N5lcqXrbmd8HDpMAttjiuE5FKLkgzF9CRN7Ac7/SKIqMat89DKfWH8WY4B+Z8uwbFiKc2HPw+/kATeq9irhvPJAylnP0o+KEN0ZHnrRCL/DiQl+FrlP/TUR4rbBnMnQImah6PLDuPGafYPAVNaq6dX25VPodIgAwXPQGIH3YuBW7ejJXsQbxib97SWkT6dzGix+uIUmrPI1Me9QsBGSkSRiCgLFKU2yhD8j326dchTHrig1E1O0SVW87wcJhws5JsHeF27o2M8lrBnNXDrQXivhJUIdjH041lXxyZ2Fi9okMHn5T5dDAePLRFSR/AdEp7uoGXWtYGPMFtXaVfMHOe2v0Y+C35KQMek+r/MpOExi/InXsXbH1vvgxKBz4oy3++8mjmyPHhMW64cqRpKViE1/+JPulKBBOD8XQEye9MWu5jgg83J4Z1OKZqT069DQJ4JJT3+DCbLekyG1gJmy967dM809vvD9S3K0HpjAdGiKoQaRcnrv5ifst7iXIFy7CqF1NnaT/EeLynQdErAM6s7+EkD3yHTFZyq30QXOEQIm696ZVihZjKBtniX1IMIZEAK5gGoZ0OiOQxKZ9iiI4h9Ul+op7ORCeL1UEwet+xPx3LAQz/E7p9omBx9gcKKsKCiG/EnjzoMl46/I+W8GwwrSO90zsX+Y5XNB2a4nqyr8qVbTiUbCMg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(346002)(396003)(376002)(39860400002)(46966006)(36840700001)(40470700004)(82310400005)(82740400003)(7696005)(26005)(6666004)(41300700001)(478600001)(356005)(70586007)(81166007)(4326008)(5660300002)(2906002)(8936002)(40460700003)(86362001)(8676002)(83380400001)(36756003)(40480700001)(54906003)(316002)(70206006)(47076005)(110136005)(186003)(16526019)(2616005)(1076003)(426003)(336012)(36860700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:52.1288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e4c69c97-b980-4f10-ce7d-08da74999bfa X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB3799 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org PMF has a generic interface defined via PMF ACPI fn9 for influencing fan policy during mode switch. PMF ACPI fn9 will normally be invoked when AMDPMF needs to change the fan table index for the EC. When AMDPMF is loaded this function will be invoked to change fan speed. OEM can also choose to report the actual fan table index and fan RPM to PMF through OEM structure. This information will be communicated by PMF driver to customer BIOS. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/acpi.c | 25 +++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 16 ++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 6af0e23257ea..1fc4d1400364 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -119,6 +119,31 @@ static void apmf_sbios_heartbeat_notify(struct work_struct *work) kfree(info); } +int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx) +{ + union acpi_object *info; + struct apmf_fan_idx args; + struct acpi_buffer params; + int err = 0; + + args.size = sizeof(args); + args.fan_ctl_mode = manual; + args.fan_ctl_idx = idx; + + params.length = sizeof(args); + params.pointer = (void *)&args; + + info = apmf_if_call(pdev, APMF_FUNC_SET_FAN_IDX, ¶ms); + if (!info) { + err = -EIO; + goto out; + } + +out: + kfree(info); + return err; +} + static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) { struct apmf_verify_interface output; diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 5b85a7fe0f38..d40613a30ed7 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -18,6 +18,7 @@ #define APMF_FUNC_VERIFY_INTERFACE 0 #define APMF_FUNC_GET_SYS_PARAMS 1 #define APMF_FUNC_SBIOS_HEARTBEAT 4 +#define APMF_FUNC_SET_FAN_IDX 7 #define APMF_FUNC_STATIC_SLIDER_GRANULAR 9 /* Message Definitions */ @@ -39,6 +40,9 @@ #define GET_STT_LIMIT_APU 0x20 #define GET_STT_LIMIT_HS2 0x21 +/* Fan Index for Auto Mode */ +#define FAN_INDEX_AUTO 0xFFFFFFFF + #define ARG_NONE 0 /* AMD PMF BIOS interfaces */ @@ -57,6 +61,12 @@ struct apmf_system_params { u32 heartbeat_int; } __packed; +struct apmf_fan_idx { + u16 size; + u8 fan_ctl_mode; + u32 fan_ctl_idx; +} __packed; + enum amd_stt_skin_temp { STT_TEMP_APU, STT_TEMP_HS2, @@ -118,6 +128,11 @@ struct amd_pmf_static_slider_granular { struct apmf_sps_prop_granular prop[POWER_SOURCE_MAX][POWER_MODE_MAX]; }; +struct fan_table_control { + bool manual; + unsigned long fan_id; +}; + /* Core Layer */ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev); @@ -136,4 +151,5 @@ int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev, void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev); +int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); #endif /* PMF_H */ From patchwork Tue Aug 2 15:11:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934741 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 AB724C19F2C for ; Tue, 2 Aug 2022 15:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234720AbiHBPOA (ORCPT ); Tue, 2 Aug 2022 11:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235174AbiHBPN7 (ORCPT ); Tue, 2 Aug 2022 11:13:59 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F6501836B for ; Tue, 2 Aug 2022 08:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OAoH2nfonqtOlXRPp3t3+kJ1o6dMqm8i4hG9XS1k//dfRUUpYF6ZpTD/2GTqftrVrLj9pAXyszW1dbx4qWQPdeZrHr/4LrP2CvG3qhhRG1XeuSe7dJzVJELLFVNdJ4QI3raq4oVRVHMUh82LpcTZHmfZFWM5qD7RzlaiEZ2ORkPnZN6Y2MhOyCZY2hq8t0SCm24pCIzVeUi+wbkidFlo0t/9gxkWCkAh1ZNqrBsLQiBqHeg7FKvBUIhaKN+CECm89Ekcaz5yuUON+xXcH1P4O28NEXCa+VoyGrqNOYg9fw3pSmZeLuwKMKm90x0vLglyOkEXFKIZQlxQdZ8NFFczKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KweDhXGMwvHJKrkEWzw/bPMKlksfPkmZcDqiICO/bww=; b=ZWIGrRrcpWn+RW/GxSnWC/dwWJR1nNK7+o2e1Ru8QSxp2WNQl90xWeu6kk0/vBonbarZSgHCde60ICjR/a7Vcn9/i0uZk6hVEpLU9s1c+Rqld98LtSyTKHH6SJOSXaL8BYLTnPNgYTJ+jtQ5Uoh6EJYSabCDwncZKAPtQUWvF0zn+dymWGYvPS2jRD47C+O0Hrw6rZvxEvYXLQuTBcH+S/v3cUH3NUnasnzx6Pz9g0rxzFzx7EIUxQ6dEWKtKzdmwmvyhDKXPQ23SEhOKwRi1hW1NhRRHXpmoWVWt0WnWj0Iq8q1raKj24WCsoHlpsI0desGAhtkNGu2nWt+8bg4Sg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KweDhXGMwvHJKrkEWzw/bPMKlksfPkmZcDqiICO/bww=; b=wS05kOZU32dVTQ9c9bVgHGeeB3zVcyL7nZxWzwi0DKKJvXlcYiZ6riIRy4W+NnnZy8csEegvQV7A7Wlqb4FldEkG7hR3LmmnqjJEoN7fJs69LqEWFAzrg0l6b+5gks5Mh2TErDAvsoZSrEdqk9qCj+8xLjLsX3HjDVv/gv2Bwlw= Received: from BN0PR04CA0102.namprd04.prod.outlook.com (2603:10b6:408:ec::17) by BN9PR12MB5308.namprd12.prod.outlook.com (2603:10b6:408:105::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Tue, 2 Aug 2022 15:13:53 +0000 Received: from BN8NAM11FT006.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ec:cafe::6d) by BN0PR04CA0102.outlook.office365.com (2603:10b6:408:ec::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.12 via Frontend Transport; Tue, 2 Aug 2022 15:13:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT006.mail.protection.outlook.com (10.13.177.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:53 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:50 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 07/11] platform/x86/amd/pmf: Get performance metrics from PMFW Date: Tue, 2 Aug 2022 20:41:45 +0530 Message-ID: <20220802151149.2123699-8-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 723e9c50-7c3e-4dec-2b19-08da74999cb5 X-MS-TrafficTypeDiagnostic: BN9PR12MB5308:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nn8HkfAesoq3FZM+wtY4QwcQNvPxg7U6E0rglusTZdZLskoJ7bn1iujDlJ/5dkceOM78G0dF3Jm0xD8Fkd0Widi+0Np1x05Vx0Zh+2UoifGq64c/J6s6go6t7/cDJy8WJ0ivojoE1dFegJJxpKTIgMSwKtYhMizf/2VLe1sTWAN9h/SO8Q9apmYpGdl6489QRVsqFvU6bPFz8VftnHONdHFbnWCuqVDGBlDIi5yFuDrEFup0jKeI259Hp1knIAQIbDPRfJcjwVA1LpC0EH98qL/d3MhZnGvD8/3ADIfFuhqahpDjALx1vp6V+S9z2Pe6LldnegWoKYbg1TQZBF9WfV1PBVPd++08PFUYbuRp8RGI23JVCwDdBhpi43oJUWTW7u+kMBRs8cr5Kii/B2Fh6rfPEFYRuJmeO/5oFMrua/4yzT5LyKoMrKYUKg2zDqKOsAVGH2VM2niKTtWD9LAzW/0T8cyZRLHx5pMuPBrILScDx3rawLKPMNqmyb4/Xk8G63qX2Gkrq01b1vYfqdRHalTlYxWvr2EXcpg13BVlNLMUjdjbver83n+JpNRZFmavrNveeZsbtp5sRkeRux5CLJGujHGxwCFq8vIYLnX9NIwRPkAAapwOj4GzUdylm5RPrtyJcfWvvhZdTEu4MbJZGZEB3r5IW0ddiiDtC0XEN3HwXtl9bucbYCphcTPX/DL5VnJUkbKfP/yjZbhco/vhW0lrBXEUD0M+MU92O+4EsRVJiQ9mvIeCtUmB38lYn4A1kNCN+hx+jRLpusBZfnV9axqXkSH4Op65dyICn2nTeq0t/W5QsMddnZhi4eT991sTUvzDvCKHj+/NcI9FvakYNg== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(39860400002)(346002)(136003)(396003)(376002)(40470700004)(46966006)(36840700001)(41300700001)(478600001)(82310400005)(1076003)(2616005)(16526019)(5660300002)(83380400001)(2906002)(86362001)(8936002)(336012)(47076005)(426003)(7696005)(36860700001)(6666004)(26005)(186003)(40460700003)(316002)(81166007)(36756003)(70586007)(356005)(70206006)(82740400003)(8676002)(4326008)(40480700001)(54906003)(110136005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:53.3658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 723e9c50-7c3e-4dec-2b19-08da74999cb5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT006.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5308 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org PMF driver polls for metrics information from PMFW to understand the system behavior, power consumption etc. This metrics table information will be used the PMF features to tweak the thermal heuristics. The poll duration can also be changed by the user by changing the poll duration time. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/core.c | 52 +++++++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/pmf.h | 39 ++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 87a1f9b27d2c..762f769bf7ee 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -47,6 +47,11 @@ #define DELAY_MIN_US 2000 #define DELAY_MAX_US 3000 +/* override Metrics Table sample size time (in ms) */ +static int metrics_table_loop_ms = 1000; +module_param(metrics_table_loop_ms, int, 0644); +MODULE_PARM_DESC(metrics_table_loop_ms, " Metrics Table sample size time (default = 1000ms) "); + static int current_power_limits_show(struct seq_file *seq, void *unused) { struct amd_pmf_dev *dev = seq->private; @@ -88,6 +93,25 @@ int amd_pmf_get_power_source(void) return POWER_SOURCE_DC; } +static void amd_pmf_get_metrics(struct work_struct *work) +{ + struct amd_pmf_dev *dev = container_of(work, struct amd_pmf_dev, work_buffer.work); + ktime_t time_elapsed_ms; + int socket_power; + + /* Transfer table contents */ + memset(dev->buf, 0, sizeof(dev->m_table)); + amd_pmf_send_cmd(dev, SET_TRANSFER_TABLE, 0, 7, NULL); + memcpy(&dev->m_table, dev->buf, sizeof(dev->m_table)); + + time_elapsed_ms = ktime_to_ms(ktime_get()) - dev->start_time; + /* Calculate the avg SoC power consumption */ + socket_power = dev->m_table.apu_power + dev->m_table.dgpu_power; + + dev->start_time = ktime_to_ms(ktime_get()); + schedule_delayed_work(&dev->work_buffer, msecs_to_jiffies(metrics_table_loop_ms)); +} + static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset) { return ioread32(dev->regbase + reg_offset); @@ -181,6 +205,34 @@ static const struct pci_device_id pmf_pci_ids[] = { { } }; +int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev) +{ + u64 phys_addr; + u32 hi, low; + + INIT_DELAYED_WORK(&dev->work_buffer, amd_pmf_get_metrics); + + /* Get Metrics Table Address */ + dev->buf = kzalloc(sizeof(dev->m_table), GFP_KERNEL); + if (!dev->buf) + return -ENOMEM; + + phys_addr = virt_to_phys(dev->buf); + hi = phys_addr >> 32; + low = phys_addr & GENMASK(31, 0); + + amd_pmf_send_cmd(dev, SET_DRAM_ADDR_HIGH, 0, hi, NULL); + amd_pmf_send_cmd(dev, SET_DRAM_ADDR_LOW, 0, low, NULL); + + /* + * Start collecting the metrics data after a small delay + * or else, we might end up getting stale values from PMFW. + */ + schedule_delayed_work(&dev->work_buffer, msecs_to_jiffies(metrics_table_loop_ms * 3)); + + return 0; +} + static void amd_pmf_init_features(struct amd_pmf_dev *dev) { /* Enable Static Slider */ diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index d40613a30ed7..42e4a5f512c0 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -67,6 +67,41 @@ struct apmf_fan_idx { u32 fan_ctl_idx; } __packed; +struct smu_pmf_metrics { + u16 gfxclk_freq; /* in MHz */ + u16 socclk_freq; /* in MHz */ + u16 vclk_freq; /* in MHz */ + u16 dclk_freq; /* in MHz */ + u16 memclk_freq; /* in MHz */ + u16 spare; + u16 gfx_activity; /* in Centi */ + u16 uvd_activity; /* in Centi */ + u16 voltage[2]; /* in mV */ + u16 currents[2]; /* in mA */ + u16 power[2];/* in mW */ + u16 core_freq[8]; /* in MHz */ + u16 core_power[8]; /* in mW */ + u16 core_temp[8]; /* in centi-Celsius */ + u16 l3_freq; /* in MHz */ + u16 l3_temp; /* in centi-Celsius */ + u16 gfx_temp; /* in centi-Celsius */ + u16 soc_temp; /* in centi-Celsius */ + u16 throttler_status; + u16 current_socketpower; /* in mW */ + u16 stapm_orig_limit; /* in W */ + u16 stapm_cur_limit; /* in W */ + u32 apu_power; /* in mW */ + u32 dgpu_power; /* in mW */ + u16 vdd_tdc_val; /* in mA */ + u16 soc_tdc_val; /* in mA */ + u16 vdd_edc_val; /* in mA */ + u16 soc_edcv_al; /* in mA */ + u16 infra_cpu_maxfreq; /* in MHz */ + u16 infra_gfx_maxfreq; /* in MHz */ + u16 skin_temp; /* in centi-Celsius */ + u16 device_state; +} __packed; + enum amd_stt_skin_temp { STT_TEMP_APU, STT_TEMP_HS2, @@ -105,6 +140,9 @@ struct amd_pmf_dev { struct dentry *dbgfs_dir; int hb_interval; /* SBIOS heartbeat interval */ struct delayed_work heart_beat; + struct smu_pmf_metrics m_table; + struct delayed_work work_buffer; + ktime_t start_time; }; struct apmf_sps_prop_granular { @@ -138,6 +176,7 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev); int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsigned long index); int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 *data); +int amd_pmf_init_metrics_table(struct amd_pmf_dev *dev); int amd_pmf_get_power_source(void); /* SPS Layer */ From patchwork Tue Aug 2 15:11:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934743 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 473B7C19F28 for ; Tue, 2 Aug 2022 15:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234770AbiHBPOB (ORCPT ); Tue, 2 Aug 2022 11:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234624AbiHBPN7 (ORCPT ); Tue, 2 Aug 2022 11:13:59 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B07317E12 for ; Tue, 2 Aug 2022 08:13:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eIqB7mdovrrV/r7n5qTGQPcheNsOouzD+tdwyjoaF3lH7BvhnSAVG9d6nW4n5y+feuGOjh7Gxdmvyh5qcs5+/2sOuOcoMvp2GylnulVpAOiMOM5alAK9z7KkcOkLysPO/qqwbajDGJ6xLpS6FuyapPykhk2jN5N68dfWYPFixGibn6YYAfMXtJQZn4Y4OSLDQG1tk2VBGY4T/Tnqck2Y4hpLF+UcF1pwzVZtc6/Ramq4qtCqTQXaVXDfyAqTlRLjouKhrDH/kPGxlDSl6SFOwRZBMvsVuDjjQnie+QgsRgOBP23v3cA4nGO0i3ZopV+StnbrxoNGFExxFx+cwA5X9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nI6cHWUJw+4RiG0e7yIZ58X/qTKYxXIvSDax1xLZXUE=; b=dOs6vArtvuUgjaSecdtJcCMZx/9koipJ5YnLCyegFjp1h3tkhVNomPOkbSJAC0x4qrUCjV2tXMAIFhniHZk1hZiUcMr6kFZps28KksW2BBewuU41A1svq3u5ekM7d21xhIGV1B7/T12QixZD8vEU66Z5euOTMF0IHYSMvRP7r8Oqhaulxcw05xQgFTVMjDV4V7ucaTmlIiZAmf/sH0IpMSWWNy/NIoEX6txVVYhK37AA8ZRAAWYNvxFuFJlrxebDbTWuRXRIRK61VwNlOHDuM6+E96HtOtXTT4U9gcTfXApsQVDCjWUO96ql56NN0eWCvh8cT9+hfiK0zzOfWfmvHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nI6cHWUJw+4RiG0e7yIZ58X/qTKYxXIvSDax1xLZXUE=; b=idCIWKzBM+0apuTLB659s2wSNSlmO+Sil7PA+ABZMUtWaKwpe+5+Fn5b2Nl0dvw0xlh+AGQjKgZHqeQ3KioajHwBQq+QAFWTgcsKLjTw1RzvN4fkECXjR3pzYqapCs5ogJgIkvK9r39EPWhcCRO+GCXSFA4X1DvYKGASa+IhNUg= Received: from BN0PR04CA0172.namprd04.prod.outlook.com (2603:10b6:408:eb::27) by IA1PR12MB6161.namprd12.prod.outlook.com (2603:10b6:208:3eb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16; Tue, 2 Aug 2022 15:13:55 +0000 Received: from BN8NAM11FT036.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::17) by BN0PR04CA0172.outlook.office365.com (2603:10b6:408:eb::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.16 via Frontend Transport; Tue, 2 Aug 2022 15:13:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT036.mail.protection.outlook.com (10.13.177.168) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:55 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:52 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 08/11] platform/x86/amd/pmf: Add support for Auto mode feature Date: Tue, 2 Aug 2022 20:41:46 +0530 Message-ID: <20220802151149.2123699-9-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69eb26aa-6260-442f-bf33-08da74999e29 X-MS-TrafficTypeDiagnostic: IA1PR12MB6161:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: a/ipCyuTvIs42tdpaV4FF1wNz26+AVi3lSrKpul7NQAJtrsM2wUSkppzQVhqECCBC0kJKx1vkqfHRe1drYqLMMPOxs2LYxptZAaJhwF2lB/4JFDoHcyX/gSQfFLRqRpp18FZqMUG1C1uTpkVz9iCoWIyY1NjksO2MrJfnR279iNxROwk3BLz1nTkwvsLPWe5COUoS9eku9/rlDP1l/uM0xEA1fWIn3V9x6XSiUH0TLgd18zZbaHy/v6DmqvKfxZKhFeNbg5bJqJJI65rODDlGMfPhZ7bOGzGz82sGyL+ylDaozZXBOrLu4vBTw06Yto3Uib18AFEyUI+czj9plWU1u3r6W5OGz621tVA00mAxKj0KxQ/AH5u2CZ6LcL7T7jln4mu1gkg1Q0i1za//b1BPClwlaU71ivs7m7GDPLkyeVSghisv5iTd41c2ydNdW/rCHs9tcVPUorC2h9S/u0ohHqZ5UL2YUKCN89Wt1PLipgN9FmuMdhTZau2G2okEAYjphgbJlPAbT/PaMBX38aNsjr6SpAMjHliWFlKkzwW+639ldwYKuYp44P9GtJmHI01Vk8khGDdBbTStOfWsEww4dl0GjwRjGbn04a8wHnJAc72JcYUwjQYDyZmUrOGYEcteMtrv9TxbjvsAdjoz12qkzlKSPcLmuUmopFQUaF6eGYM3aaXcUa28E/yVoZmU8exwsE0A1X+TEbEZsmSHSA0xOmNaZKu2VdkwdSi5lP+wcJibEzJcO2Z9THotQ4S15SWT8uOImivkEn1edB47hTLRgUd6pRwxs8b+11NFAbRcksZpyKXl8BYl2QFbGWHcZ13Ep7GN6ZcXCDe5XOghUp+cw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(376002)(346002)(396003)(136003)(39860400002)(46966006)(40470700004)(36840700001)(82740400003)(30864003)(40460700003)(86362001)(5660300002)(316002)(70206006)(70586007)(8676002)(4326008)(356005)(8936002)(81166007)(110136005)(54906003)(40480700001)(26005)(36860700001)(336012)(426003)(47076005)(2616005)(36756003)(16526019)(186003)(1076003)(478600001)(83380400001)(82310400005)(6666004)(2906002)(7696005)(41300700001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:55.7919 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69eb26aa-6260-442f-bf33-08da74999e29 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT036.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6161 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org This feature has 3 modes quiet, balanced, performance The objective of this feature is to track the moving average of system power over the time period specified and switch to the subsequent mode. In order to do this, PMF driver will get the moving average of APU power from PMFW and power threshold, time constants, system config parameters from OEM inputs. System power as read by PMF driver from PMFW is the filtered value over the sampling window. Every sampling window, moving average of system power is computed. At the end of the monitoring window, the moving average is compared against the threshold for mode switch for decision making. With AMD managing the system config limits, any mode switch within auto-mode will result in limits of fPPT/sPPT/STAPM or STT being scaled down. When "auto mode" is enabled, the static slider control remains out of the PMF driver, so the platform_profile registration would not happen in PMF driver. The transition to auto-mode only happens when the APMF fn5 is enabled in BIOS, platform_profile set to "balanced" and a AMT (Auto Mode transition) is received. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/Makefile | 3 +- drivers/platform/x86/amd/pmf/acpi.c | 5 + drivers/platform/x86/amd/pmf/auto-mode.c | 263 +++++++++++++++++++++++ drivers/platform/x86/amd/pmf/core.c | 9 + drivers/platform/x86/amd/pmf/pmf.h | 113 ++++++++++ 5 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 drivers/platform/x86/amd/pmf/auto-mode.c diff --git a/drivers/platform/x86/amd/pmf/Makefile b/drivers/platform/x86/amd/pmf/Makefile index 557521a80427..ef2b08c9174d 100644 --- a/drivers/platform/x86/amd/pmf/Makefile +++ b/drivers/platform/x86/amd/pmf/Makefile @@ -5,4 +5,5 @@ # obj-$(CONFIG_AMD_PMF) += amd-pmf.o -amd-pmf-objs := core.o acpi.o sps.o +amd-pmf-objs := core.o acpi.o sps.o \ + auto-mode.o diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 1fc4d1400364..401fee381e90 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -144,6 +144,11 @@ int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx) return err; } +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)); +} + static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) { struct apmf_verify_interface output; diff --git a/drivers/platform/x86/amd/pmf/auto-mode.c b/drivers/platform/x86/amd/pmf/auto-mode.c new file mode 100644 index 000000000000..99f5a2396b0b --- /dev/null +++ b/drivers/platform/x86/amd/pmf/auto-mode.c @@ -0,0 +1,263 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * AMD Platform Management Framework Driver + * + * Copyright (c) 2022, Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Author: Shyam Sundar S K + */ + +#include +#include +#include "pmf.h" + +static struct auto_mode_mode_config config_store; +static const char *state_as_str(unsigned int state); + +static void amd_pmf_set_automode(struct amd_pmf_dev *dev, int idx, + struct auto_mode_mode_config *table) +{ + struct power_table_control *pwr_ctrl = &config_store.mode_set[idx].power_control; + + amd_pmf_send_cmd(dev, SET_SPL, false, pwr_ctrl->spl, NULL); + amd_pmf_send_cmd(dev, SET_FPPT, false, pwr_ctrl->fppt, NULL); + amd_pmf_send_cmd(dev, SET_SPPT, false, pwr_ctrl->sppt, NULL); + amd_pmf_send_cmd(dev, SET_SPPT_APU_ONLY, false, pwr_ctrl->sppt_apu_only, NULL); + amd_pmf_send_cmd(dev, SET_STT_MIN_LIMIT, false, pwr_ctrl->stt_min, NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_APU, false, + pwr_ctrl->stt_skin_temp[STT_TEMP_APU], NULL); + amd_pmf_send_cmd(dev, SET_STT_LIMIT_HS2, false, + pwr_ctrl->stt_skin_temp[STT_TEMP_HS2], NULL); + + if (is_apmf_func_supported(dev, APMF_FUNC_SET_FAN_IDX)) + apmf_update_fan_idx(dev, config_store.mode_set[idx].fan_control.manual, + config_store.mode_set[idx].fan_control.fan_id); +} + +static int amd_pmf_get_moving_avg(struct amd_pmf_dev *pdev, int socket_power) +{ + int i, total = 0; + + if (pdev->socket_power_history_idx == -1) { + for (i = 0; i < AVG_SAMPLE_SIZE; i++) + pdev->socket_power_history[i] = socket_power; + } + + pdev->socket_power_history_idx = (pdev->socket_power_history_idx + 1) % AVG_SAMPLE_SIZE; + pdev->socket_power_history[pdev->socket_power_history_idx] = socket_power; + + for (i = 0; i < AVG_SAMPLE_SIZE; i++) + total += pdev->socket_power_history[i]; + + return total / AVG_SAMPLE_SIZE; +} + +void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t time_elapsed_ms) +{ + int avg_power = 0; + bool update = false; + int i, j; + + /* Get the average moving average computed by auto mode algorithm */ + avg_power = amd_pmf_get_moving_avg(dev, socket_power); + + for (i = 0; i < AUTO_TRANSITION_MAX; i++) { + if ((config_store.transition[i].shifting_up && avg_power >= + config_store.transition[i].power_threshold) || + (!config_store.transition[i].shifting_up && avg_power <= + config_store.transition[i].power_threshold)) { + if (config_store.transition[i].timer < + config_store.transition[i].time_constant) + config_store.transition[i].timer += time_elapsed_ms; + } else { + config_store.transition[i].timer = 0; + } + + if (config_store.transition[i].timer >= + config_store.transition[i].time_constant && + !config_store.transition[i].applied) { + config_store.transition[i].applied = true; + update = true; + } else if (config_store.transition[i].timer <= + config_store.transition[i].time_constant && + config_store.transition[i].applied) { + config_store.transition[i].applied = false; + update = true; + } + } + + dev_dbg(dev->dev, "[AUTO_MODE] avg power: %u mW mode: %s\n", avg_power, + state_as_str(config_store.current_mode)); + + if (update) { + for (j = 0; j < AUTO_TRANSITION_MAX; j++) { + /* Apply the mode with highest priority indentified */ + if (config_store.transition[j].applied) { + if (config_store.current_mode != + config_store.transition[j].target_mode) { + config_store.current_mode = + config_store.transition[j].target_mode; + dev_dbg(dev->dev, "[AUTO_MODE] moving to mode:%s\n", + state_as_str(config_store.current_mode)); + amd_pmf_set_automode(dev, config_store.current_mode, NULL); + } + break; + } + } + } +} + +static void amd_pmf_get_power_threshold(void) +{ + config_store.transition[AUTO_TRANSITION_TO_QUIET].power_threshold = + config_store.mode_set[AUTO_BALANCE].power_floor - + config_store.transition[AUTO_TRANSITION_TO_QUIET].power_delta; + + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].power_threshold = + config_store.mode_set[AUTO_BALANCE].power_floor - + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].power_delta; + + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].power_threshold = + config_store.mode_set[AUTO_QUIET].power_floor - + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].power_delta; + + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].power_threshold = + config_store.mode_set[AUTO_PERFORMANCE].power_floor - + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].power_delta; +} + +static const char *state_as_str(unsigned int state) +{ + switch (state) { + case AUTO_QUIET: + return "QUIET"; + case AUTO_BALANCE: + return "BALANCED"; + case AUTO_PERFORMANCE_ON_LAP: + return "ON_LAP"; + case AUTO_PERFORMANCE: + return "PERFORMANCE"; + default: + return "Unknown Auto Mode State"; + } +} + +void amd_pmf_load_defaults_auto_mode(struct amd_pmf_dev *dev) +{ + struct apmf_auto_mode output; + struct power_table_control *pwr_ctrl; + int i; + + apmf_get_auto_mode_def(dev, &output); + /* time constant */ + config_store.transition[AUTO_TRANSITION_TO_QUIET].time_constant = + output.balanced_to_quiet; + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].time_constant = + output.balanced_to_perf; + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].time_constant = + output.quiet_to_balanced; + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].time_constant = + output.perf_to_balanced; + + /* power floor */ + config_store.mode_set[AUTO_QUIET].power_floor = output.pfloor_quiet; + config_store.mode_set[AUTO_BALANCE].power_floor = output.pfloor_balanced; + config_store.mode_set[AUTO_PERFORMANCE].power_floor = output.pfloor_perf; + config_store.mode_set[AUTO_PERFORMANCE_ON_LAP].power_floor = output.pfloor_perf; + + /* Power delta for mode change */ + config_store.transition[AUTO_TRANSITION_TO_QUIET].power_delta = + output.pd_balanced_to_quiet; + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].power_delta = + output.pd_balanced_to_perf; + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].power_delta = + output.pd_quiet_to_balanced; + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].power_delta = + output.pd_perf_to_balanced; + + /* Power threshold */ + amd_pmf_get_power_threshold(); + + /* skin temperature limits */ + pwr_ctrl = &config_store.mode_set[AUTO_QUIET].power_control; + pwr_ctrl->spl = output.spl_quiet; + pwr_ctrl->sppt = output.sppt_quiet; + pwr_ctrl->fppt = output.fppt_quiet; + pwr_ctrl->sppt_apu_only = output.sppt_apu_only_quiet; + pwr_ctrl->stt_min = output.stt_min_limit_quiet; + pwr_ctrl->stt_skin_temp[STT_TEMP_APU] = output.stt_apu_quiet; + pwr_ctrl->stt_skin_temp[STT_TEMP_HS2] = output.stt_hs2_quiet; + + pwr_ctrl = &config_store.mode_set[AUTO_BALANCE].power_control; + pwr_ctrl->spl = output.spl_balanced; + pwr_ctrl->sppt = output.sppt_balanced; + pwr_ctrl->fppt = output.fppt_balanced; + pwr_ctrl->sppt_apu_only = output.sppt_apu_only_balanced; + pwr_ctrl->stt_min = output.stt_min_limit_balanced; + pwr_ctrl->stt_skin_temp[STT_TEMP_APU] = output.stt_apu_balanced; + pwr_ctrl->stt_skin_temp[STT_TEMP_HS2] = output.stt_hs2_balanced; + + pwr_ctrl = &config_store.mode_set[AUTO_PERFORMANCE].power_control; + pwr_ctrl->spl = output.spl_perf; + pwr_ctrl->sppt = output.sppt_perf; + pwr_ctrl->fppt = output.fppt_perf; + pwr_ctrl->sppt_apu_only = output.sppt_apu_only_perf; + pwr_ctrl->stt_min = output.stt_min_limit_perf; + pwr_ctrl->stt_skin_temp[STT_TEMP_APU] = output.stt_apu_perf; + pwr_ctrl->stt_skin_temp[STT_TEMP_HS2] = output.stt_hs2_perf; + + pwr_ctrl = &config_store.mode_set[AUTO_PERFORMANCE_ON_LAP].power_control; + pwr_ctrl->spl = output.spl_perf_on_lap; + pwr_ctrl->sppt = output.sppt_perf_on_lap; + pwr_ctrl->fppt = output.fppt_perf_on_lap; + pwr_ctrl->sppt_apu_only = output.sppt_apu_only_perf_on_lap; + pwr_ctrl->stt_min = output.stt_min_limit_perf_on_lap; + pwr_ctrl->stt_skin_temp[STT_TEMP_APU] = output.stt_apu_perf_on_lap; + pwr_ctrl->stt_skin_temp[STT_TEMP_HS2] = output.stt_hs2_perf_on_lap; + + /* Fan ID */ + config_store.mode_set[AUTO_QUIET].fan_control.fan_id = output.fan_id_quiet; + config_store.mode_set[AUTO_BALANCE].fan_control.fan_id = output.fan_id_balanced; + config_store.mode_set[AUTO_PERFORMANCE].fan_control.fan_id = output.fan_id_perf; + config_store.mode_set[AUTO_PERFORMANCE_ON_LAP].fan_control.fan_id = + output.fan_id_perf; + + config_store.transition[AUTO_TRANSITION_TO_QUIET].target_mode = AUTO_QUIET; + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].target_mode = + AUTO_PERFORMANCE; + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].target_mode = + AUTO_BALANCE; + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].target_mode = + AUTO_BALANCE; + + config_store.transition[AUTO_TRANSITION_TO_QUIET].shifting_up = false; + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].shifting_up = true; + config_store.transition[AUTO_TRANSITION_FROM_QUIET_TO_BALANCE].shifting_up = true; + config_store.transition[AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE].shifting_up = + false; + + for (i = 0 ; i < AUTO_MODE_MAX ; i++) { + if (config_store.mode_set[i].fan_control.fan_id == FAN_INDEX_AUTO) + config_store.mode_set[i].fan_control.manual = false; + else + config_store.mode_set[i].fan_control.manual = true; + } + + /* set to initial default values */ + config_store.current_mode = AUTO_BALANCE; + dev->socket_power_history_idx = -1; +} + +void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev) +{ + cancel_delayed_work_sync(&dev->work_buffer); +} + +void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev) +{ + amd_pmf_load_defaults_auto_mode(dev); + /* update the thermal limits for Automode */ + amd_pmf_set_automode(dev, config_store.current_mode, NULL); + amd_pmf_init_metrics_table(dev); +} diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 762f769bf7ee..42d803b49d97 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -240,12 +240,21 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev) amd_pmf_init_sps(dev); dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n"); } + + /* Enable Auto Mode */ + if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) { + amd_pmf_init_auto_mode(dev); + dev_dbg(dev->dev, "Auto Mode Init done\n"); + } } static void amd_pmf_deinit_features(struct amd_pmf_dev *dev) { if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) amd_pmf_deinit_sps(dev); + + if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) + amd_pmf_deinit_auto_mode(dev); } static const struct acpi_device_id amd_pmf_acpi_ids[] = { diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index 42e4a5f512c0..ce092a529261 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -18,6 +18,7 @@ #define APMF_FUNC_VERIFY_INTERFACE 0 #define APMF_FUNC_GET_SYS_PARAMS 1 #define APMF_FUNC_SBIOS_HEARTBEAT 4 +#define APMF_FUNC_AUTO_MODE 5 #define APMF_FUNC_SET_FAN_IDX 7 #define APMF_FUNC_STATIC_SLIDER_GRANULAR 9 @@ -44,6 +45,7 @@ #define FAN_INDEX_AUTO 0xFFFFFFFF #define ARG_NONE 0 +#define AVG_SAMPLE_SIZE 3 /* AMD PMF BIOS interfaces */ struct apmf_verify_interface { @@ -143,6 +145,8 @@ struct amd_pmf_dev { struct smu_pmf_metrics m_table; struct delayed_work work_buffer; ktime_t start_time; + int socket_power_history[AVG_SAMPLE_SIZE]; + int socket_power_history_idx; }; struct apmf_sps_prop_granular { @@ -171,6 +175,107 @@ struct fan_table_control { unsigned long fan_id; }; +struct power_table_control { + u32 spl; + u32 sppt; + u32 fppt; + u32 sppt_apu_only; + u32 stt_min; + u32 stt_skin_temp[STT_TEMP_COUNT]; + u32 reserved[16]; +}; + +/* Auto Mode Layer */ +enum auto_mode_transition_priority { + AUTO_TRANSITION_TO_PERFORMANCE, /* Any other mode to Performance Mode */ + AUTO_TRANSITION_FROM_QUIET_TO_BALANCE, /* Quiet Mode to Balance Mode */ + AUTO_TRANSITION_TO_QUIET, /* Any other mode to Quiet Mode */ + AUTO_TRANSITION_FROM_PERFORMANCE_TO_BALANCE, /* Performance Mode to Balance Mode */ + AUTO_TRANSITION_MAX, +}; + +enum auto_mode_mode { + AUTO_QUIET, + AUTO_BALANCE, + AUTO_PERFORMANCE_ON_LAP, + AUTO_PERFORMANCE, + AUTO_MODE_MAX, +}; + +struct auto_mode_trans_params { + u32 time_constant; /* minimum time required to switch to next mode */ + u32 power_delta; /* delta power to shift mode */ + u32 power_threshold; + u32 timer; /* elapsed time. if timer > TimeThreshold, it will move to next mode */ + u32 applied; + enum auto_mode_mode target_mode; + u32 shifting_up; +}; + +struct auto_mode_mode_settings { + struct power_table_control power_control; + struct fan_table_control fan_control; + u32 power_floor; +}; + +struct auto_mode_mode_config { + struct auto_mode_trans_params transition[AUTO_TRANSITION_MAX]; + struct auto_mode_mode_settings mode_set[AUTO_MODE_MAX]; + enum auto_mode_mode current_mode; +}; + +struct apmf_auto_mode { + u16 size; + /* time constant */ + u32 balanced_to_perf; + u32 perf_to_balanced; + u32 quiet_to_balanced; + u32 balanced_to_quiet; + /* power floor */ + u32 pfloor_perf; + u32 pfloor_balanced; + u32 pfloor_quiet; + /* Power delta for mode change */ + u32 pd_balanced_to_perf; + u32 pd_perf_to_balanced; + u32 pd_quiet_to_balanced; + u32 pd_balanced_to_quiet; + /* skin temperature limits */ + u8 stt_apu_perf_on_lap; /* CQL ON */ + u8 stt_hs2_perf_on_lap; /* CQL ON */ + u8 stt_apu_perf; + u8 stt_hs2_perf; + u8 stt_apu_balanced; + u8 stt_hs2_balanced; + u8 stt_apu_quiet; + u8 stt_hs2_quiet; + u32 stt_min_limit_perf_on_lap; /* CQL ON */ + u32 stt_min_limit_perf; + u32 stt_min_limit_balanced; + u32 stt_min_limit_quiet; + /* SPL based */ + u32 fppt_perf_on_lap; /* CQL ON */ + u32 sppt_perf_on_lap; /* CQL ON */ + u32 spl_perf_on_lap; /* CQL ON */ + u32 sppt_apu_only_perf_on_lap; /* CQL ON */ + u32 fppt_perf; + u32 sppt_perf; + u32 spl_perf; + u32 sppt_apu_only_perf; + u32 fppt_balanced; + u32 sppt_balanced; + u32 spl_balanced; + u32 sppt_apu_only_balanced; + u32 fppt_quiet; + u32 sppt_quiet; + u32 spl_quiet; + u32 sppt_apu_only_quiet; + /* Fan ID */ + u32 fan_id_perf; + u32 fan_id_balanced; + u32 fan_id_quiet; +} __packed; + /* Core Layer */ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev); void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev); @@ -191,4 +296,12 @@ void amd_pmf_load_defaults_sps(struct amd_pmf_dev *dev); int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx); + +/* Auto Mode Layer */ +void amd_pmf_load_defaults_auto_mode(struct amd_pmf_dev *dev); +int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data); +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); + #endif /* PMF_H */ From patchwork Tue Aug 2 15:11:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934744 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 18B4CC00140 for ; Tue, 2 Aug 2022 15:14:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234624AbiHBPOE (ORCPT ); Tue, 2 Aug 2022 11:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234780AbiHBPOD (ORCPT ); Tue, 2 Aug 2022 11:14:03 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2053.outbound.protection.outlook.com [40.107.96.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73FB15A3C for ; Tue, 2 Aug 2022 08:14:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FfUtz2gtJY5LH7yrOTkbOgihw2VFFRK8bgbZ5GsTzFah9m7jtuA6P1eSB/13vmmoWBcDnYOPDdHXe2+3gyRvRQIBkfGUkkq4eVQrdZUUBbRSqfSdmAS8HatumQHCcWZxvv61nN9AWqCHd+4MniNCdNljBXVfdjQdYgD1b70TXopRuoB7EA07LjgFvY0uNae+KeZ4Uc6cgBx4lLxm4+YxNgQ9y9yXky2rucMn+8rf5U5zSnRmalM2dlizqdPugAPcb5Tk1CYTuu0hQ6Ie4oUPekEGm2Od9qwlCV3RBQz2/q01d0nAdXuB1vLbOuqF7HNKvBbSlWRhlqdR286LRhQFQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+ofW5aSOFfv9LFBelA88WEGf3WZJ/utmX1F3pEdlGPg=; b=V088yiPZTXHHLSJDLYZeMYDXEcU+PYLdqcx6jHM9FKxXtFLd+1dWLadFFhHt64QSZKKLicbt4GyaW4TtCOQXiDd5QzBGel8n+UwWpjr87IWURy9rZFEKcxaYZ0++TqzT0K4WCPex6rZQbEqlr17y+1MYekiWmRrGGfzimBBvRy2Abo6zaFtVlEu4t31urhdTPXWJTXZh36kS2Wh8C0KtL0upHE8VCJIKv1oY7Co8l6c0Xqes9BfmnAaP8J+HTkAwpcmi7tq+bQSGcnclYhgHYMbVHeGKEPLa8urntYqjC5b7d7uRosl8s7Wb7a9wZF/y2fFZCTimu5722SzOZGGgzA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+ofW5aSOFfv9LFBelA88WEGf3WZJ/utmX1F3pEdlGPg=; b=XcLx1EY+2a2RySjM73rz8whlxrJbCSiXBpEL3avz3tXwFvM0VYsoNUxSmG3doQnS0ZgXVCELwHB45j1Ns1J1qbRN6X1ygcnphA10YwtuJToL4P1xi6KveE+kjTk7SqVQpCVW99ZBjXpmAqBuTCHhgUCrXEdfbASnLYjKmH1EvbQ= Received: from BN9PR03CA0142.namprd03.prod.outlook.com (2603:10b6:408:fe::27) by SJ1PR12MB6099.namprd12.prod.outlook.com (2603:10b6:a03:45e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15; Tue, 2 Aug 2022 15:13:59 +0000 Received: from BN8NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::bb) by BN9PR03CA0142.outlook.office365.com (2603:10b6:408:fe::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.25 via Frontend Transport; Tue, 2 Aug 2022 15:13:59 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT013.mail.protection.outlook.com (10.13.176.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:13:59 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:55 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" , Mario Limonciello , Mark Pearson Subject: [PATCH v4 09/11] platform/x86/amd/pmf: Handle AMT and CQL events for Auto mode Date: Tue, 2 Aug 2022 20:41:47 +0530 Message-ID: <20220802151149.2123699-10-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9cbc5eeb-5633-4811-c798-08da7499a06a X-MS-TrafficTypeDiagnostic: SJ1PR12MB6099:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8xPeNGwFUaGFxEOlgHWCXxtp4LKKMCqbMJgTEPLp74xTh5VAsdlRwPq3nP0RKiSUEbkb3GxvKD19pL0zkYNAZb0yATOTro3/xqPnLlFh7GE9ydQIwlNOpKZcUmZeoSdN4NzFPm0pliDbVf54s7mYG6ZBVViXz5pqcsbO5bSr2bnLAkEv2hW2IgqsE2ESCdKONJX592fBgBwM/TlRZ4x0n6L7wmlHwbBjdUHC2A8w66V3AdHOhXfNAH0ZLaNY8sHIUHfJ3AaMG6XRnNqm896Hbq3j3kDfl8LmBx6t9WfKOjBCeL0VgDLGpSShlttaap/Ejf4uykAw2RWCEffm5CqpEeO7kdZVuFBVGhnl0IyoWZ6oaDv+kecMDK8YcMbb+LHG8gwlkHnu0KYiCPx1dH5zSt1D8BYJG8kfl63U7hOrZhy4QWHK6NrdludR0HwWmY8WwNrPgeoZiY/0FIAvHIdFvqHuXZJNQWd79NeC0VgR+uMC3Enl3VTKnc0bOHPf9jbrVeSV3nR6oZMoaDBHw9g+b5rehRtmklyp1qaI1u5a4GWUYcl0mHTojBp4DohqdgvqJRmC9mpFkrZzW2XqeKILi5KAtN2kWWd5WkJeS83w5gHv4bq/RkWfZc7HGNJwe2K0ZzovEuIukMaeDHNX8nIpBWMq2ww1pJLafdtDPy7JT+Mjs/nRN6qT94T77YcMGChtljaXY4xkNjOPxTERGXBKh4npWctfhu2LTBePK1ZyeeieYlPD60flQeh6ogJE8CbHQo1UL3CA4CgtkQQs8BPCXRbfbqImoQCY+Rw7Mi/1BcKwv5QQohFCKZsrHKFByRQkN/eKa6wJOgQEv7BPVIiRtc7krV1cHyd1fiXhNViH65Qmu0sJY9hPDbxRLnOoru66gO+1L/B0jp+9vcHr+h6FNQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(39860400002)(376002)(136003)(46966006)(36840700001)(40470700004)(54906003)(86362001)(2906002)(40460700003)(81166007)(356005)(966005)(478600001)(41300700001)(6666004)(7696005)(82310400005)(110136005)(82740400003)(316002)(70206006)(70586007)(4326008)(8676002)(40480700001)(5660300002)(83380400001)(36860700001)(2616005)(26005)(426003)(336012)(8936002)(47076005)(16526019)(186003)(1076003)(36756003)(36900700001)(309714004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:13:59.5892 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9cbc5eeb-5633-4811-c798-08da7499a06a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6099 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org The transition to auto-mode happens when the PMF driver receives AMT (Auto Mode transition) event. transition logic will reside in the PMF driver but the events would come from other supported drivers[1]. The thermal parameters would vary between when a performance "on-lap" mode is detected and versus when not. The CQL event would get triggered from other drivers, so that PMF driver would adjust the system thermal config based on the ACPI inputs. OEMs can control whether or not to enable AMT or CQL via other supported drivers[1] but the actual transition logic resides in the AMD PMF driver. When an AMT event is received the automatic mode transition RAPL algorithm will run. When a CQL event is received an performance "on-lap" mode will be enabled and thermal parameters will be adjusted accordingly. [1] Link: https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?h=review-hans&id=755b249250df1b612d982f3b702c831b26ecdf73 Cc: Mario Limonciello Cc: Mark Pearson Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/acpi.c | 66 ++++++++++++++++++++++++ drivers/platform/x86/amd/pmf/auto-mode.c | 38 ++++++++++++++ drivers/platform/x86/amd/pmf/core.c | 9 ++++ drivers/platform/x86/amd/pmf/pmf.h | 22 ++++++++ 4 files changed, 135 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/acpi.c b/drivers/platform/x86/amd/pmf/acpi.c index 401fee381e90..24d269bef92b 100644 --- a/drivers/platform/x86/amd/pmf/acpi.c +++ b/drivers/platform/x86/amd/pmf/acpi.c @@ -11,6 +11,9 @@ #include #include "pmf.h" +#define APMF_CQL_NOTIFICATION 2 +#define APMF_AMT_NOTIFICATION 3 + static union acpi_object *apmf_if_call(struct amd_pmf_dev *pdev, int fn, struct acpi_buffer *param) { struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; @@ -149,6 +152,47 @@ 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(struct amd_pmf_dev *pdev, struct apmf_sbios_req *req) +{ + return apmf_if_call_store_buffer(pdev, APMF_FUNC_SBIOS_REQUESTS, + req, sizeof(*req)); +} + +static void apmf_event_handler(acpi_handle handle, u32 event, void *data) +{ + struct amd_pmf_dev *pmf_dev = data; + struct apmf_sbios_req req; + int ret; + + mutex_lock(&pmf_dev->update_mutex); + ret = apmf_get_sbios_requests(pmf_dev, &req); + if (ret) { + dev_err(pmf_dev->dev, "Failed to get SBIOS requests:%d\n", ret); + return; + } + + if (req.pending_req & BIT(APMF_AMT_NOTIFICATION)) { + dev_dbg(pmf_dev->dev, "AMT is supported and notifications %s\n", + req.amt_event ? "Enabled" : "Disabled"); + pmf_dev->amt_enabled = !!req.amt_event; + + if (pmf_dev->amt_enabled) + amd_pmf_handle_amt(pmf_dev); + else + amd_pmf_reset_amt(pmf_dev); + } + + if (req.pending_req & BIT(APMF_CQL_NOTIFICATION)) { + dev_dbg(pmf_dev->dev, "CQL is supported and notifications %s\n", + req.cql_event ? "Enabled" : "Disabled"); + + /* update the target mode information */ + if (pmf_dev->amt_enabled) + amd_pmf_update_2_cql(pmf_dev, req.cql_event); + } + mutex_unlock(&pmf_dev->update_mutex); +} + static int apmf_if_verify_interface(struct amd_pmf_dev *pdev) { struct apmf_verify_interface output; @@ -190,12 +234,20 @@ static int apmf_get_system_params(struct amd_pmf_dev *dev) void apmf_acpi_deinit(struct amd_pmf_dev *pmf_dev) { + acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev); + if (pmf_dev->hb_interval) cancel_delayed_work_sync(&pmf_dev->heart_beat); + + if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) && + is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) + acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler); } int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) { + acpi_handle ahandle = ACPI_HANDLE(pmf_dev->dev); + acpi_status status; int ret; ret = apmf_if_verify_interface(pmf_dev); @@ -216,6 +268,20 @@ int apmf_acpi_init(struct amd_pmf_dev *pmf_dev) schedule_delayed_work(&pmf_dev->heart_beat, 0); } + /* Install the APMF Notify handler */ + if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) && + is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) { + status = acpi_install_notify_handler(ahandle, + ACPI_ALL_NOTIFY, + apmf_event_handler, pmf_dev); + if (ACPI_FAILURE(status)) { + dev_err(pmf_dev->dev, "failed to install notify handler\n"); + return -ENODEV; + } + /* Call the handler once manually to catch up with possibly missed notifies. */ + apmf_event_handler(ahandle, 0, pmf_dev); + } + out: return ret; } diff --git a/drivers/platform/x86/amd/pmf/auto-mode.c b/drivers/platform/x86/amd/pmf/auto-mode.c index 99f5a2396b0b..4e4ec6023525 100644 --- a/drivers/platform/x86/amd/pmf/auto-mode.c +++ b/drivers/platform/x86/amd/pmf/auto-mode.c @@ -108,6 +108,21 @@ void amd_pmf_trans_automode(struct amd_pmf_dev *dev, int socket_power, ktime_t t } } +void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event) +{ + int mode = config_store.current_mode; + + config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].target_mode = + is_cql_event ? AUTO_PERFORMANCE_ON_LAP : AUTO_PERFORMANCE; + + if ((mode == AUTO_PERFORMANCE || mode == AUTO_PERFORMANCE_ON_LAP) && + mode != config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].target_mode) { + mode = config_store.transition[AUTO_TRANSITION_TO_PERFORMANCE].target_mode; + amd_pmf_set_automode(dev, mode, NULL); + } + dev_dbg(dev->dev, "updated CQL thermals\n"); +} + static void amd_pmf_get_power_threshold(void) { config_store.transition[AUTO_TRANSITION_TO_QUIET].power_threshold = @@ -249,6 +264,29 @@ void amd_pmf_load_defaults_auto_mode(struct amd_pmf_dev *dev) dev->socket_power_history_idx = -1; } +void amd_pmf_reset_amt(struct amd_pmf_dev *dev) +{ + /* + * OEM BIOS implementation guide says that if the auto mode is enabled + * the platform_profile registration shall be done by the OEM driver. + * There could be cases where both static slider and auto mode BIOS + * functions are enabled, in that case enable static slider updates + * only if it advertised as supported. + */ + + if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) { + u8 mode = amd_pmf_get_pprof_modes(dev); + + dev_dbg(dev->dev, "resetting AMT thermals\n"); + amd_pmf_update_slider(dev, SLIDER_OP_SET, mode, NULL); + } +} + +void amd_pmf_handle_amt(struct amd_pmf_dev *dev) +{ + amd_pmf_set_automode(dev, config_store.current_mode, NULL); +} + void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev) { cancel_delayed_work_sync(&dev->work_buffer); diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 42d803b49d97..4467d682cd11 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -99,6 +99,7 @@ static void amd_pmf_get_metrics(struct work_struct *work) ktime_t time_elapsed_ms; int socket_power; + mutex_lock(&dev->update_mutex); /* Transfer table contents */ memset(dev->buf, 0, sizeof(dev->m_table)); amd_pmf_send_cmd(dev, SET_TRANSFER_TABLE, 0, 7, NULL); @@ -108,8 +109,14 @@ static void amd_pmf_get_metrics(struct work_struct *work) /* Calculate the avg SoC power consumption */ socket_power = dev->m_table.apu_power + dev->m_table.dgpu_power; + if (dev->amt_enabled) { + /* Apply the Auto Mode transition */ + amd_pmf_trans_automode(dev, socket_power, time_elapsed_ms); + } + dev->start_time = ktime_to_ms(ktime_get()); schedule_delayed_work(&dev->work_buffer, msecs_to_jiffies(metrics_table_loop_ms)); + mutex_unlock(&dev->update_mutex); } static inline u32 amd_pmf_reg_read(struct amd_pmf_dev *dev, int reg_offset) @@ -329,6 +336,7 @@ static int amd_pmf_probe(struct platform_device *pdev) amd_pmf_dbgfs_register(dev); mutex_init(&dev->lock); + mutex_init(&dev->update_mutex); dev_info(dev->dev, "registered PMF device successfully\n"); return 0; @@ -339,6 +347,7 @@ static int amd_pmf_remove(struct platform_device *pdev) struct amd_pmf_dev *dev = platform_get_drvdata(pdev); mutex_destroy(&dev->lock); + mutex_destroy(&dev->update_mutex); amd_pmf_deinit_features(dev); apmf_acpi_deinit(dev); amd_pmf_dbgfs_unregister(dev); diff --git a/drivers/platform/x86/amd/pmf/pmf.h b/drivers/platform/x86/amd/pmf/pmf.h index ce092a529261..4078665c8e06 100644 --- a/drivers/platform/x86/amd/pmf/pmf.h +++ b/drivers/platform/x86/amd/pmf/pmf.h @@ -17,6 +17,7 @@ /* APMF Functions */ #define APMF_FUNC_VERIFY_INTERFACE 0 #define APMF_FUNC_GET_SYS_PARAMS 1 +#define APMF_FUNC_SBIOS_REQUESTS 2 #define APMF_FUNC_SBIOS_HEARTBEAT 4 #define APMF_FUNC_AUTO_MODE 5 #define APMF_FUNC_SET_FAN_IDX 7 @@ -63,6 +64,21 @@ struct apmf_system_params { u32 heartbeat_int; } __packed; +struct apmf_sbios_req { + u16 size; + u32 pending_req; + u8 rsd; + u8 cql_event; + u8 amt_event; + u32 fppt; + u32 sppt; + u32 fppt_apu_only; + u32 spl; + u32 stt_min_limit; + u8 skin_temp_apu; + u8 skin_temp_hs2; +} __packed; + struct apmf_fan_idx { u16 size; u8 fan_ctl_mode; @@ -147,6 +163,8 @@ struct amd_pmf_dev { ktime_t start_time; int socket_power_history[AVG_SAMPLE_SIZE]; int socket_power_history_idx; + bool amt_enabled; + struct mutex update_mutex; /* protects race between ACPI handler and metrics thread */ }; struct apmf_sps_prop_granular { @@ -303,5 +321,9 @@ int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data 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); +void amd_pmf_update_2_cql(struct amd_pmf_dev *dev, bool is_cql_event); +void amd_pmf_reset_amt(struct amd_pmf_dev *dev); +void amd_pmf_handle_amt(struct amd_pmf_dev *dev); #endif /* PMF_H */ From patchwork Tue Aug 2 15:11:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934745 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 D4331C19F2D for ; Tue, 2 Aug 2022 15:14:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235174AbiHBPOG (ORCPT ); Tue, 2 Aug 2022 11:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234780AbiHBPOE (ORCPT ); Tue, 2 Aug 2022 11:14:04 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2046.outbound.protection.outlook.com [40.107.237.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E31F415A3C for ; Tue, 2 Aug 2022 08:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVx3/xpq25EuhYAnpoHUkACAM05rz6EnghthVz2OpvY86yo5JsF5MZpCkmOm68tyXH2upFUQS4ItzQyuadNwQL1SfDN99bofW/fjq3BW/HBPgljmCHIBHiacKJUylviTCgujdOWB/lp6XHX9AwGDkAbzB0YsQkAePu8kVBcTnbYoL5psnUxLBTjh/iBZQQ4WnByuicaH962yrbKSN5xVxfqhtEcRewtgIBnGTynhrRjmoznQBMiEhjcl26GfXh7pIxvcoAJdjIcdLtHwTcxFhMt9XlGJH6OuxIcgQa5MPoe0mCXXjqb9dcoaVifr3XzEyCTxTp7tzKjLrctzSfgi5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=smfUw0/1ajgXZd5jk6ml3rNLNmGLHg0cS4pFFjw35pw=; b=Xvnxj7++2waKoPMuL/8VZBwsPn1EB6svOMcbPxeemT32+3WBdeQx8tSa8uOKLHrUTpVkkZqVYZ85Zx9HqSmpgWOYnnZ0BQaje5iSmbi6gG3wt4xZqUfgMyvzi192FaBIBk/lB7HSzJhe2RWwyEnX5svfsoL+IHxDvOAa/YGM8gq/g2cFM35FJ4r5W0b2buOtQ18zS5LhSj+7oR36kwX4h0/uu1T6Ic35DRgeVO83p3Ie1yvg6XSw7jhY5RUl5gu5ObCUtU8jbygo7TV8JKX2csf7WiEzNoV6sJWlNyMd1ZUEDoDTAYiK5xqp6XG5J/40x62guqFA5PGxjSCAI0hyEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=smfUw0/1ajgXZd5jk6ml3rNLNmGLHg0cS4pFFjw35pw=; b=43997ZuMDV24e1RjvwWk3wzTRbzpKuUiwFml1HfMpQjnpzGHD92V0N+ACJnYEqQxygf9NgtSaebsmiDwIgyis+BhHyyeM1ZoLsnaAAJmXhdBHt51BsiyJo7nCayGBnPsbNWLlLhQ9nq8DQn2LRNwcKnDa/OoEguZWXF3ZxuZqtI= Received: from BN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:408:ee::33) by CH0PR12MB5265.namprd12.prod.outlook.com (2603:10b6:610:d0::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 2 Aug 2022 15:14:02 +0000 Received: from BN8NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ee:cafe::8c) by BN0PR04CA0028.outlook.office365.com (2603:10b6:408:ee::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.15 via Frontend Transport; Tue, 2 Aug 2022 15:14:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT052.mail.protection.outlook.com (10.13.177.210) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:14:01 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:13:59 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 10/11] platform/x86/amd/pmf: Force load driver on older supported platforms Date: Tue, 2 Aug 2022 20:41:48 +0530 Message-ID: <20220802151149.2123699-11-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 081fa85b-312d-4513-1e79-08da7499a1ce X-MS-TrafficTypeDiagnostic: CH0PR12MB5265:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LCZhqGJZdVmoNlq5dg3LjVFZeHNO4C/Q2XGsakbG8QGIOECwBgSPiC7FwrJlXYLwGFv2JWMLUr+J11YjmXUp5MjaO7rhfUHe4ZFwd05hZGgQ/8VPq+IUtfv35abc/F25aPMQgcNs0UnV6o3bJfvpLSAnxHKskqrXES5ywEM/6QtE05yfwyleM8Ip/qVjZPK6LATpFzcIdvvYqLE3DdCXZM8gItAydRRjGOAGpm1opvkEd7wOkNDZvOPtNPn7/vR1gC/j8G++2CVN0nmGtVDXrkHqdIgRUjtbWS7uA7JB46PJQsd1UQB9AJ5tBUkYF86+0hHheOQojKeUfDcKSH3QfFJgjad01SRlB/ljc2dii3hococ93kNKqkJyAqw3oq7/inIxyMm11rZzmbDfnF4CINruCRo4hlDyMEw2iLOaRELmvEmztOdRJDcjOuZ/gQm8EwSDX20I5vv2f5qDj/u1tB+G2veO3R0zEtE90eQddYTcXH2ZXkQ34f90LEvo3zS8P16hpqQPj4Vp2WmcRFuZAt7qg/AaMO1hMo7GdEQ5Uvxo7PHS3F0pq8JQWkp7nieQHxhyK6KrmmLTKsIHdQLVs8SDJWDukIiyNuasgxA8UKsHbdtiqh394Gi4rw+ti6yD5M00+ZQonSaT5ysTK7qPd/CztF5+a3G0yBtPyR7na6fbuG2yQIFmw2zHyt9EL3CJrwTkBFDuBebYVrMYwfzaP9mn0XQTmGXyV2dyfAKSdO3DwE1yzxTy0h4Too7D1Xt/GY1EUk+ULNa6ku4fG5sV5QyrElS1TzGPzIyGC2CRrqotPa1NYurOh3VI0Ei0I/xH9t47Kkcsox166tDc9GLr7Q== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(39860400002)(346002)(376002)(136003)(46966006)(36840700001)(40470700004)(36860700001)(2906002)(83380400001)(81166007)(356005)(82740400003)(40460700003)(8676002)(4326008)(70206006)(70586007)(110136005)(54906003)(316002)(26005)(5660300002)(2616005)(426003)(336012)(47076005)(1076003)(186003)(16526019)(478600001)(8936002)(7696005)(6666004)(41300700001)(40480700001)(36756003)(82310400005)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:14:01.9023 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 081fa85b-312d-4513-1e79-08da7499a1ce X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5265 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Some of the older platforms with _HID "AMDI0100" PMF driver can be force loaded by interested users but only for experimental purposes. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- drivers/platform/x86/amd/pmf/core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/platform/x86/amd/pmf/core.c b/drivers/platform/x86/amd/pmf/core.c index 4467d682cd11..dbca5d7c6311 100644 --- a/drivers/platform/x86/amd/pmf/core.c +++ b/drivers/platform/x86/amd/pmf/core.c @@ -39,6 +39,7 @@ #define AMD_PMF_RESULT_FAILED 0xFF /* List of supported CPU ids */ +#define AMD_CPU_ID_RMB 0x14b5 #define AMD_CPU_ID_PS 0x14e8 #define PMF_MSG_DELAY_MIN_US 50 @@ -52,6 +53,11 @@ static int metrics_table_loop_ms = 1000; module_param(metrics_table_loop_ms, int, 0644); MODULE_PARM_DESC(metrics_table_loop_ms, " Metrics Table sample size time (default = 1000ms) "); +/* Force load on supported older platforms */ +static bool force_load; +module_param(force_load, bool, 0444); +MODULE_PARM_DESC(force_load, " Force load this driver on supported older platforms (experimental) "); + static int current_power_limits_show(struct seq_file *seq, void *unused) { struct amd_pmf_dev *dev = seq->private; @@ -208,6 +214,7 @@ int amd_pmf_send_cmd(struct amd_pmf_dev *dev, u8 message, bool get, u32 arg, u32 } static const struct pci_device_id pmf_pci_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_RMB) }, { PCI_DEVICE(PCI_VENDOR_ID_AMD, AMD_CPU_ID_PS) }, { } }; @@ -265,6 +272,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev) } static const struct acpi_device_id amd_pmf_acpi_ids[] = { + {"AMDI0100", 0x100}, {"AMDI0102", 0}, { } }; @@ -272,6 +280,7 @@ MODULE_DEVICE_TABLE(acpi, amd_pmf_acpi_ids); static int amd_pmf_probe(struct platform_device *pdev) { + const struct acpi_device_id *id; struct amd_pmf_dev *dev; struct pci_dev *rdev; u32 base_addr_lo; @@ -280,6 +289,13 @@ static int amd_pmf_probe(struct platform_device *pdev) u32 val; int err; + id = acpi_match_device(amd_pmf_acpi_ids, &pdev->dev); + if (!id) + return -ENODEV; + + if (id->driver_data == 0x100 && !force_load) + return -ENODEV; + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; From patchwork Tue Aug 2 15:11:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shyam Sundar S K X-Patchwork-Id: 12934746 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 74C5FC19F28 for ; Tue, 2 Aug 2022 15:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237412AbiHBPOu (ORCPT ); Tue, 2 Aug 2022 11:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237414AbiHBPOm (ORCPT ); Tue, 2 Aug 2022 11:14:42 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2084.outbound.protection.outlook.com [40.107.223.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 526B123164 for ; Tue, 2 Aug 2022 08:14:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EJR4Sy64wDT2NT+yBtl4z+mNFlZgMIHJfpvxiGwP5WUOxOUHaJYIC9j++BxePR9nvouRn+9EmNJmYS/PGQ8YBngSfyb7QRy9heDj47+YAScXvs2FFiFk6csyMfkKojJ8/LFjQMu7xtmN8Ibxwj+Tu/4BGSAANEhiffVkKUCpUwL34/gFwf8FmoWqNSbgjPUeb9LpO7dbGYK3xMe9g3ijRD8Z8t/yPwoqhhpVB4zdaUpc5nYm2a9kxzxOwlhwyCw8JqJ8cLW2PnACvegM6OB6zjVBh1ia3jVd5Usg8av7dE5EuTwUKufmQ86FHcj6MI+f27PePlC9jW+rN0qW1AZh9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jRtQm2T7hI17ayPHw5m7xAZsZT2vxmfltbZDJZNx5xw=; b=hB6rxQ5D+sj1TezWtvdMldVoRk3CuzagEqQDKFApzL/MPuroXxUTAduesT1k4xkQi7Jjakyg2Y8V7I27jFxagEImev2gzs+D2D/blEV9vTJytS4B2uhTqFpEtHXYtoFqykokfIQyodkQDY3/3JHNHwVrfiZy0z3dvU/M9TA6oX32yPkz6cnGbn5st6SRZfTMzsF2IYYxcin7BGpHHHz/LhW6bDkKwKL4rXoY+LQPNVQf87wm0uTEJnxMXJ7PmXXMDcphI51bsKVyZDfp33mUTJzHzaLhrDIQd+oytat5yZFzmT4BGh9HHzgf0GQtqxVI+TQCdeOAZMoOhwO+NKf91A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jRtQm2T7hI17ayPHw5m7xAZsZT2vxmfltbZDJZNx5xw=; b=V37Yc+wfJS919/LY6A9C2DJJ04E5jbEBV9N+vs9t3vGuya7D/ao1bMz9Bf2MwXNFg3smqJPXmzH1ZX8VH4lIlY2ZdccALhXglaEQi8Dio312iUV811zp7AJoafG53YoHCcd8RtY9YcswWRz7oLY5sf2kTizZspFtYl0EljF40b8= Received: from BN9PR03CA0636.namprd03.prod.outlook.com (2603:10b6:408:13b::11) by DM5PR12MB1339.namprd12.prod.outlook.com (2603:10b6:3:70::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.11; Tue, 2 Aug 2022 15:14:21 +0000 Received: from BN8NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13b:cafe::b0) by BN9PR03CA0636.outlook.office365.com (2603:10b6:408:13b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.24 via Frontend Transport; Tue, 2 Aug 2022 15:14:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT007.mail.protection.outlook.com (10.13.177.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5482.10 via Frontend Transport; Tue, 2 Aug 2022 15:14:21 +0000 Received: from jatayu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 2 Aug 2022 10:14:01 -0500 From: Shyam Sundar S K To: , CC: , , "Shyam Sundar S K" Subject: [PATCH v4 11/11] MAINTAINERS: Add AMD PMF driver entry Date: Tue, 2 Aug 2022 20:41:49 +0530 Message-ID: <20220802151149.2123699-12-Shyam-sundar.S-k@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> References: <20220802151149.2123699-1-Shyam-sundar.S-k@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1162d501-ca72-4c56-2993-08da7499ad3b X-MS-TrafficTypeDiagnostic: DM5PR12MB1339:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P4mQAQCbIBXig9Ax3Xd1z2V2qtRQgc2aMtAUnl4dd60AQp7yhsNswGCwlppe1R/1K56vVYpvEaX2eKTzlb0Q3f5mEKwoUp0gQ2KHdQV8BUaRWEK2GKNhMpUcCNyEqdpAILIEsl/VedMd7mpKRGtNDDc9gbmbRT5glDJQP9V98PKHK/ASNgydXnW8/LUeCTcqqXIakSkSQma7CSKmTGem3Vj/fu1Hc80iifLwAPfEusLTo0VwRDbv/0omIdZKeGmRkdZ3XBwskucXtfK2FNKnPMcIKDplpvx00hcH609qL3ndYAfWN732ooFa70ZB8XEv10Aq1fomWQt15N1vEeURidlFFAbJVQtDNHumSPfEj94qnVz2D3o+fLW+dimzgiwnm7SUQFh8HIGXZHjPjEcMcdEJOy1YmTY7CvfOkl7jDwg3K4e2+N3/FbOnFohSNBx86jBKIqp/YF3TD3MOi2rmRyJRRGjeXCgLX3VGEZRMQoxVMInSPZbFKhwxKo64ZZZAx9xRoWgiyQoyCsAvsgBGbbkK3+sXbvYCC48zM6pO8cNRwRZXXM0NIxJQYDAX8CweE8oyf+l6oOOJ6TnKpWQGXPTO/X2LBW4QxOmVHMqYpJc6zaqGjOvsQk9MizWCTuTmPU4YNW3+9o7CuGoIUh9OkBBa82Oq9TWzXuGbqkRBrR8K6EuRQZArKtDPHmFAObswA58i9M9VooPM/uc/mV1SD+b6kx9pqkmWkGVXeJBdbdaAGwYkd/bFYDwEjV15vX9Omjc8oiwzW/L/SrSOMA6eEj7ej7snAjMJhNcSGwRVOJC306W54QvbMJmXicsHNdxcUoHgyZj7F0V9FbB/nxVcjw== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(396003)(376002)(136003)(39860400002)(346002)(40470700004)(46966006)(36840700001)(356005)(4744005)(82740400003)(81166007)(8936002)(7696005)(40460700003)(5660300002)(70586007)(70206006)(41300700001)(316002)(6666004)(40480700001)(54906003)(2906002)(8676002)(4326008)(426003)(336012)(16526019)(1076003)(47076005)(186003)(36756003)(83380400001)(36860700001)(82310400005)(2616005)(478600001)(26005)(110136005)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Aug 2022 15:14:21.0406 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1162d501-ca72-4c56-2993-08da7499ad3b X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1339 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Update the MAINTAINERS file with AMD PMF driver details. Reviewed-by: Hans de Goede Signed-off-by: Shyam Sundar S K --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index e01478062c56..d3f6cabcaab2 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -998,6 +998,13 @@ L: platform-driver-x86@vger.kernel.org S: Maintained F: drivers/platform/x86/amd/pmc.c +AMD PMF DRIVER +M: Shyam Sundar S K +L: platform-driver-x86@vger.kernel.org +S: Maintained +F: Documentation/ABI/testing/sysfs-amd-pmf +F: drivers/platform/x86/amd/pmf/ + AMD HSMP DRIVER M: Naveen Krishna Chatradhi R: Carlos Bilbao