From nobody Mon Feb 9 14:31:15 2026 Received: from CH5PR02CU005.outbound.protection.outlook.com (mail-northcentralusazon11012003.outbound.protection.outlook.com [40.107.200.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3BB8472795; Tue, 20 Jan 2026 14:58:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.200.3 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768921117; cv=fail; b=b5YFLSxMtr7gI62/tdASrK8Hzb2PGg+QkVFYE9nPRtM4IuiTEVETxlTtleczHgFnLbmgCNHM162kDn2ljB7RFx1tvbv3up/bDCRL4HlMdR6iTGH4o/a5SRjtQHoWspYwSxN3V50fyPtSxS/aKgIrLC+iuS4hDUsiuJJ72zqOZU0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768921117; c=relaxed/simple; bh=37PwC5sDJBFH2LuAIPL6Z9FzC4Id2EtYQ9pibycQRFo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uLQiIea0KnItP88GVP8O12WoB/slbWZPIASwzJ669MepGqJZqP/9lf4AhR/JR+JHfdmPwYwaarBBGk7C0d7LHTTgTBqWUbCcVo3qgBuXPEmrk4iFy+e81ECFZwlGXQMNfpSO189m5YOSYvfCimhE0OKe80/1whhcdhHcUheXp50= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=pwlzGW2G; arc=fail smtp.client-ip=40.107.200.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="pwlzGW2G" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=evxSIL6kxEeXPMjItVdzDB+TIeI+EuY6wFeRlO1HIbhYeDFTsq7eJBEAiyHklfR1ny03CrxSDs8vqPvJ+vRabm7QsX5Kt3EIQnIEYe2Zq3HtU66ZU27M2S1BoIcEtc+F49fAblUDFDNHkAbFTALjTqBmMVrOjwidMYjfa3H1FqhV9aB96Nsh8sMVoXRLt6YqPWDzLG1Kp5T3xj+I9CDCAnq6cj+Z0i8Ba01Y54wmYer0gs728nDTeRTj3H34A4Him3nbKe2qFT8bf04lBsBZHfR7zD4JH/eI1Zj9hvupeSVDnOXLQ5/x27b9jpQN6DdZTeQ/FvFxsn/xx94DaWiyjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=AhlCLkmgEAzheLtL7tNHBT/Dd6YdlRgiNt9Ek2T38Ko=; b=kjFXNBAXJuTi/RevN3SbUi60YAGP4KLq9jCfi+K3exCTWhra8kwS3Ssvx46We2Sp6EH/iMFrzp+lcE3WfNCH9YEq8e+c06MoYtYSkrEZYAvPdw1mcjogdcRnKon/1+MgamI32aLXTirgML15w5ArYMApGycB1HPt7AV59cth2SbZPW12uJzqK7ooTG4+fcYmmFU1c8qG3xgO1RFVDvw8Kg/Tm0utYMtThV21YRKb1wWVBIQWgR+RceCy9oA1JVdPLWrXuBhCFY1Y3Mh4xttFfqExc9g+GClnmQJIoVIRoYwh/2kBh4mYYvnQeaYdM8sT6hRKu3OkW6BbOgRCpVSQpw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AhlCLkmgEAzheLtL7tNHBT/Dd6YdlRgiNt9Ek2T38Ko=; b=pwlzGW2GEa+VVjcCcnOXb7ksD3bKSa1ywsPsJq+VMQl3xsyyvPKLTv+ACHKu1PsUcUKLjA/jNF/eDTnQ4Wrdi6GnnInBf2aeV2JrfTGQa8tnZOexwdCkns7s9bqSSLXRgyJ9ZXrjJ7BG4wy9aBvDC0dcBRQECRiM5SItD/1m/RGb05mzxEDMLXL81eUe4ZU1UmqwXi6tMXMm5Tcc6iPMHvIWFXSYtnKP9LRcEm4B6tPUa+RaP9mvl2FWuW+0aaseHhIJO9DgAM8ml3slOHkbYFjroUNEc5aYMSyPFnAE7iV0u5KB90HZxLWlSvsle0g158TnB+q6jwS412atfUfqRQ== Received: from PH7P220CA0114.NAMP220.PROD.OUTLOOK.COM (2603:10b6:510:32d::8) by DS0PR12MB8293.namprd12.prod.outlook.com (2603:10b6:8:f3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9520.12; Tue, 20 Jan 2026 14:58:31 +0000 Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:510:32d:cafe::8d) by PH7P220CA0114.outlook.office365.com (2603:10b6:510:32d::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9542.8 via Frontend Transport; Tue, 20 Jan 2026 14:58:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9542.4 via Frontend Transport; Tue, 20 Jan 2026 14:58:30 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 20 Jan 2026 06:58:02 -0800 Received: from rnnvmail205.nvidia.com (10.129.68.10) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Tue, 20 Jan 2026 06:58:01 -0800 Received: from sumitg-l4t.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.10) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Tue, 20 Jan 2026 06:57:54 -0800 From: Sumit Gupta To: , , , , , , , , , , , , , , , , , , CC: , , , , , , , , Subject: [PATCH v6 7/9] ACPI: CPPC: add APIs and sysfs interface for perf_limited Date: Tue, 20 Jan 2026 20:26:21 +0530 Message-ID: <20260120145623.2959636-8-sumitg@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260120145623.2959636-1-sumitg@nvidia.com> References: <20260120145623.2959636-1-sumitg@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D6:EE_|DS0PR12MB8293:EE_ X-MS-Office365-Filtering-Correlation-Id: 3502bd1d-014b-4653-23c7-08de58345ff7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|7416014|36860700013|1800799024|82310400026|921020; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?lCrzMV01ecarOJGr916gXrfizkNXz//lp85LAxJFEopxw7l6zt5kqjar1+iW?= =?us-ascii?Q?GGENyvNUqvVSdVEyLBNoZPBtecZCw/RIDlDv3HvYkhlUEBP/Ouprl7NCBm3N?= =?us-ascii?Q?RMF9ABT/7VwFFSFx4/ROKCRQ0z4c2gKGWzL/3NfkB5ebuSztV2sVE5Xx1/WM?= =?us-ascii?Q?ScfajSeTAKGFCwZ5+HOw8Sz5hz3KvnoUtZVSeBSgI4++5DYTjYWJMrvnwH7Y?= =?us-ascii?Q?pXDzS2TWtr/YKSe7O0nwLLrgb0UIeXpWbUoHBsmCElkWWbddW/qFrefSsZye?= =?us-ascii?Q?X9OdICJ/4tivK4xQYfkQpb7yA357ZvZPaTF07slw0sm3ftdIg/7AnSg/elNE?= =?us-ascii?Q?JipZezGk6x7/Zy856WNl7K3rfPAueRRD4uWHtqjtL07cSMEBMlEFtIGjX8/V?= =?us-ascii?Q?bVcv1jzF4ZaSHPact4iCV+4FU7jOr3R2qvaKQCYcdWGuq7mr3Iv3GHg7DV0Y?= =?us-ascii?Q?BRN9L0VCI0v0XH8zGj255axnmyUdbAd3agdM0zUQk3ngwI2U3Ku6WT8JPf2Z?= =?us-ascii?Q?+aHH2IH4+oZWGnOdNI5b800RtJNksUrR8h1HXilBqXGxuVWSDANv6HOXa5K4?= =?us-ascii?Q?s0ikvj7b6xnX8AOmyTesQ/5aVRn/zDvNyX476ls+yYJcqILdlfkXHzKt/JEZ?= =?us-ascii?Q?oOzHOUBiGUGDi2QLWXqe1unafhrDDjTRP2Y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oukhkF2QElU9GZNpyy//LoOYDaZc4o0nnPRs6yfwm/wz5mFAFdHk0l9u?= =?us-ascii?Q?kdq4PqW4W7lNTgyEeYUi1aMe6OhOn2/JEcEaRsaoeBmNgGDIIjJZ8HlbXaxU?= =?us-ascii?Q?szeQDXs95I+RzLVnVfWxtyTq7kE=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(376014)(7416014)(36860700013)(1800799024)(82310400026)(921020);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2026 14:58:30.3440 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3502bd1d-014b-4653-23c7-08de58345ff7 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8293 Content-Type: text/plain; charset="utf-8" Add sysfs interface to read/write the Performance Limited register. The Performance Limited register indicates to the OS that an unpredictable event (like thermal throttling) has limited processor performance. It contains two sticky bits set by the platform: - Bit 0 (Desired_Excursion): Set when delivered performance is constrained below desired performance. Not used when Autonomous Selection is enabled. - Bit 1 (Minimum_Excursion): Set when delivered performance is constrained below minimum performance. These bits remain set until OSPM explicitly clears them. The write operation accepts a bitmask of bits to clear: - Write 0x1 to clear bit 0 - Write 0x2 to clear bit 1 - Write 0x3 to clear both bits This enables users to detect if platform throttling impacted a workload. Users clear the register before execution, run the workload, then check afterward - if set, hardware throttling occurred during that time window. The interface is exposed as: /sys/devices/system/cpu/cpuX/cpufreq/perf_limited Signed-off-by: Sumit Gupta --- drivers/acpi/cppc_acpi.c | 56 ++++++++++++++++++++++++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 5 +++ include/acpi/cppc_acpi.h | 15 +++++++++ 3 files changed, 76 insertions(+) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 46bf45f8b0f3..b46f22f58f56 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1787,6 +1787,62 @@ int cppc_set_max_perf(int cpu, u32 max_perf) } EXPORT_SYMBOL_GPL(cppc_set_max_perf); =20 +/** + * cppc_get_perf_limited - Get the Performance Limited register value. + * @cpu: CPU from which to get Performance Limited register. + * @perf_limited: Pointer to store the Performance Limited value. + * + * The returned value contains sticky status bits indicating platform-impo= sed + * performance limitations. + * + * Return: 0 for success, -EIO on failure, -EOPNOTSUPP if not supported. + */ +int cppc_get_perf_limited(int cpu, u64 *perf_limited) +{ + return cppc_get_reg_val(cpu, PERF_LIMITED, perf_limited); +} +EXPORT_SYMBOL_GPL(cppc_get_perf_limited); + +/** + * cppc_set_perf_limited() - Clear bits in the Performance Limited registe= r. + * @cpu: CPU on which to write register. + * @bits_to_clear: Bitmask of bits to clear in the perf_limited register. + * + * The Performance Limited register contains two sticky bits set by platfo= rm: + * - Bit 0 (Desired_Excursion): Set when delivered performance is constr= ained + * below desired performance. Not used when Autonomous Selection is en= abled. + * - Bit 1 (Minimum_Excursion): Set when delivered performance is constr= ained + * below minimum performance. + * + * These bits are sticky and remain set until OSPM explicitly clears them. + * This function only allows clearing bits (the platform sets them). + * + * Return: 0 for success, -EINVAL for invalid bits, -EIO on register + * access failure, -EOPNOTSUPP if not supported. + */ +int cppc_set_perf_limited(int cpu, u64 bits_to_clear) +{ + u64 current_val, new_val; + int ret; + + /* Only bits 0 and 1 are valid */ + if (bits_to_clear & ~CPPC_PERF_LIMITED_MASK) + return -EINVAL; + + if (!bits_to_clear) + return 0; + + ret =3D cppc_get_perf_limited(cpu, ¤t_val); + if (ret) + return ret; + + /* Clear the specified bits */ + new_val =3D current_val & ~bits_to_clear; + + return cppc_set_reg_val(cpu, PERF_LIMITED, new_val); +} +EXPORT_SYMBOL_GPL(cppc_set_perf_limited); + /** * cppc_set_enable - Set to enable CPPC on the processor by writing the * Continuous Performance Control package EnableRegister field. diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 66e183b45fb0..afb2cdb67a2f 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -1071,12 +1071,16 @@ static ssize_t store_max_perf(struct cpufreq_policy= *policy, const char *buf, return count; } =20 +CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited, + cppc_set_perf_limited) + cpufreq_freq_attr_ro(freqdomain_cpus); cpufreq_freq_attr_rw(auto_select); cpufreq_freq_attr_rw(auto_act_window); cpufreq_freq_attr_rw(energy_performance_preference_val); cpufreq_freq_attr_rw(min_perf); cpufreq_freq_attr_rw(max_perf); +cpufreq_freq_attr_rw(perf_limited); =20 static struct freq_attr *cppc_cpufreq_attr[] =3D { &freqdomain_cpus, @@ -1085,6 +1089,7 @@ static struct freq_attr *cppc_cpufreq_attr[] =3D { &energy_performance_preference_val, &min_perf, &max_perf, + &perf_limited, NULL, }; =20 diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index b358440cd0e2..f3a04ccd10b7 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -42,6 +42,11 @@ #define CPPC_EPP_PERFORMANCE_PREF 0x00 #define CPPC_EPP_ENERGY_EFFICIENCY_PREF 0xFF =20 +#define CPPC_PERF_LIMITED_DESIRED_EXCURSION BIT(0) +#define CPPC_PERF_LIMITED_MINIMUM_EXCURSION BIT(1) +#define CPPC_PERF_LIMITED_MASK (CPPC_PERF_LIMITED_DESIRED_EXCURSION | \ + CPPC_PERF_LIMITED_MINIMUM_EXCURSION) + /* Each register has the folowing format. */ struct cpc_reg { u8 descriptor; @@ -178,6 +183,8 @@ extern int cppc_get_min_perf(int cpu, u64 *min_perf); extern int cppc_set_min_perf(int cpu, u32 min_perf); extern int cppc_get_max_perf(int cpu, u64 *max_perf); extern int cppc_set_max_perf(int cpu, u32 max_perf); +extern int cppc_get_perf_limited(int cpu, u64 *perf_limited); +extern int cppc_set_perf_limited(int cpu, u64 perf_limited); extern int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf); extern int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator); extern int amd_detect_prefcore(bool *detected); @@ -290,6 +297,14 @@ static inline int cppc_set_max_perf(int cpu, u32 max_p= erf) { return -EOPNOTSUPP; } +static inline int cppc_get_perf_limited(int cpu, u64 *perf_limited) +{ + return -EOPNOTSUPP; +} +static inline int cppc_set_perf_limited(int cpu, u64 perf_limited) +{ + return -EOPNOTSUPP; +} static inline int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf) { return -ENODEV; --=20 2.34.1