From nobody Sat Jul 25 04:53:32 2026 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11010062.outbound.protection.outlook.com [52.101.56.62]) (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 C793A3B19AE; Fri, 17 Jul 2026 21:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.62 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784325259; cv=fail; b=CYS049kpBE9D0+YmX7w1T9cPbdwWhWjlIOFhHO/BKnghihW8xabRV5+5KAaq8ffRhqAnCdrPXJxNbkeZ8J8UCeb7X+/Hp5gAmaV7PR1Mc+DoU5KdJu5+Q218mfZpZ4bIy8h71ig22J47Obetark/XQFlmqIyI7PqpvTAi5tbDRk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784325259; c=relaxed/simple; bh=q4F6LLNA9reK4cQuxxluc2cN0FuKp9nXdvKndx+bow0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YEGC1sOrDNeZP+8g+TgVuFPZRVqlPECxrv6nfkO9OlWGovV962MY9m8+donnVOaRyXQdvNJYY3IKUiqBMLBeZRS24wNOVXqs4SBQm32qLaxUkhdmRjGstnxPjxya6L6HYFMfwbkVK+CfVCc8RVQakREe/fc6uGyIHvMhsCheP/k= 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=Dtl1xvfl; arc=fail smtp.client-ip=52.101.56.62 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="Dtl1xvfl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lc9c3tudviiAnUDHLUZ3MuHL0mDUw+vuu3u7py0/UwFXUfH6u8WrYp5gwPM0wz5+ztK37lSesD1v3oexKZ2HEp14/V8FyjjKdzjhIm3mA8FbLw5fsEvy5gmcEWBeKRC+yyvKEGsCwNxIn8hgXMi//qevjPnt/lhhX+dJFDi1xNbBTq3anxrv4/Uz+ktyUlPxDrjt/6WD54TrMZoEi9ia2w8L9IF7MrB3GbF7f0hjDk8zzX2SmuwCllzOQIgahG99gm6rpvYU0DrO3nR0aaIruC9d+EbZgHxqZFyl4S9y2WaeY7DisrGDqeT1ZgmuU31Lk3ySugpTCjGCUvotVvQtlA== 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=UVSqziGQmIEgDo2DHoIdZaMOFqXs9tMYEbhanBkqopk=; b=MDpA5hHu2O4UH39DN9FKARNJr8Pt3m/ta0oSf7WKLvttyEbEUSSKPt3/P1zPxmkmDGjFHwWkJ02GyXt/YsMcb3L8D0S9lu3tkrwIRHLJq28JCYhnej4OVj8ozLftBbCEFBVs5fn6jstml3OmJlGYgxBM/hxXzdgJdDMaCxTFO1dQ9+dKs9hhu+tm2sy/HcquoEWqTop8BaMEExgq+iQ1CkHM4XC2mQ67lIr/sJdj0Y8+Uqaqp28VTzor791EGFgBeSeXt0gUZhG+wPcH4g7PXyynoBKUMSSVuAf0DS5AvUI83OEZMquAp8R8uk6oD9BCciVvKXhkO+2oqDrMoIsu6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=UVSqziGQmIEgDo2DHoIdZaMOFqXs9tMYEbhanBkqopk=; b=Dtl1xvfl/IRnvmbd1w4Sj63pohlKW/9sBcXCNHiplVy01hu9cMT62yk1Zu7T7cxp3vq7hMIH2XtQ7IYAG8gDI4W8Gb2Yc6OSgzDk4aYSHiN92q9anYU+1jP6hE4oepl/nlGUUpmidIJAPVQBW3THJSJv8tAU9gpQr54+5Du5updROvcoXRvt3MurYV3xpNOQoNABgrRsAXZPBaeVREfOV0bjJGa6cMGQQae9mvZv6PizqV233WAiJiTN4RuHMZOgX+5UJEUV6b1DXGfxryjg3PDIdjxiGLoCFL6qn53LwnLZ9RVOXB5sW/nfpP/SJWpr2GyqhhKxX5KC5ySe81lpUw== Received: from CH0PR03CA0191.namprd03.prod.outlook.com (2603:10b6:610:e4::16) by DS7PR12MB6189.namprd12.prod.outlook.com (2603:10b6:8:9a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 21:54:02 +0000 Received: from CH1PEPF0000AD77.namprd04.prod.outlook.com (2603:10b6:610:e4:cafe::74) by CH0PR03CA0191.outlook.office365.com (2603:10b6:610:e4::16) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 21:54:02 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by CH1PEPF0000AD77.mail.protection.outlook.com (10.167.244.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 21:54:01 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Fri, 17 Jul 2026 14:53:51 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 17 Jul 2026 14:53:50 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Fri, 17 Jul 2026 14:53:45 -0700 From: Sumit Gupta To: , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 1/2] ACPI: CPPC: Add ospm_nominal_perf support Date: Sat, 18 Jul 2026 03:23:29 +0530 Message-ID: <20260717215330.2215058-2-sumitg@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717215330.2215058-1-sumitg@nvidia.com> References: <20260717215330.2215058-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: CH1PEPF0000AD77:EE_|DS7PR12MB6189:EE_ X-MS-Office365-Filtering-Correlation-Id: 81e4f00a-8dcb-45c6-0b21-08dee44de9de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700016|376014|7416014|23010399003|1800799024|82310400026|921020|6133799003|56012099006|10067099003|11063799006|18002099003|22082099003; X-Microsoft-Antispam-Message-Info: xrAjxURH+Wqz2z5G80Up5ZgjgBZfy/t9iuHQyd9x5CY6bpzK64fWXOW5cHSwRBi89Nm5gsiKZF+UfKjhBZwQGjyyZHbQF5N9V8PHPrlhTLzGIvN42cg9wCoUa3nA+/Im1tJ3vWZOPvGHR7cjDWi01P1KxLuzztTWX/Zj1637OBGZzc1sMwVr1l4Mb5J9oqXM9VJEIFvgQZ7u8EaDIVNRlIR9GCRvRkrMUL4A41i5LQsnaDs49jWEjiZ1oiWMCZ3TlMsjKMdD2YfbGAH7S3GfJMXsjgQotc70v0GX1rqf/KAcWuZyOwJ+vRO1BEDPJ1GjVCqEr+HCnAbgwBrBWdpOwxA4cVwkIkZxaKmxt76O/x/zsH38APiXw5x0iDQyMZAZKwoa8m9CjgMz5SunzOMz5PevAtV6s+JX7R1WOTnPPuJWksqkfTLeD7i/kqqkQAi7RZcWOKsW+e9glXBZrRZ7asatu2RVxZjJMXfZEmR6QY64yCVj84CfDFqohHiZ1wQSWUgrG9NK1d2Q5l/IZYa5jZYtxsutSd3bwKvrGIOuttU+jFvjqTLe1AdhKsXVwUjimME4s1WWtPqfKMCxIPJubcbt4ZrAQiYtg+RlK0Ob+Io9G5R4U1xQuudgs8rgsp+S7JLLZRJqk0C53gyax4Yw4LDsnsXbHTga2DYm7pDdOnLTMijvrztTiFHtf1rTqbkO6MBHPDP0tZXs2oxVWjGYvQzV2ElBo6Q+u/7EKk9Fjtm4OFJLmGFsCDZEdjvJMIWZ X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230040)(36860700016)(376014)(7416014)(23010399003)(1800799024)(82310400026)(921020)(6133799003)(56012099006)(10067099003)(11063799006)(18002099003)(22082099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G6lUTuE1mSdHMf3e9yVGVb9NAN00vNo3Z/l/c08LfpgYnCHbTWLaQY3S9JHGyC2JavvBV3rYu0YLV6+UWI0H+MMZ4UYaJDrevtn4htUP/I1Kq3loAZmhmR3fM3irdeWTWQ8YIvc0XInfE9g/wki4xU0IKOEiK0meakN3aJgZqfCeoyexu+T2Uzmkya7NVEgvlyVisLeTgFmFsP0NLrpN9MP8lKHr9v02DepqZ+TVQMOEjtznR7kfqxJ/JOTTgcCIBEiixIyfYIuN+s/4OT2/kSuYPNHwlPPr8hcFu2hsoDAOjgnLYkNg/nxB5DERwoAe/6B2e8ow2vqJ2pslJoCeqVLfUZWOCqfYw6m4PSAiQjtAkzA0PdgcIsz7GCvL17xMGxD5/d3+zLcInzEvYxY8yCN78h/VgAf9mF9choiT+PBrgMvwoJ9FhEa3U90qzsjr X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 21:54:01.8985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 81e4f00a-8dcb-45c6-0b21-08dee44de9de X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH1PEPF0000AD77.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6189 Content-Type: text/plain; charset="utf-8" Expose the OSPM Nominal Performance register (ACPI 6.6, Section 8.4.6.1.2.6), which conveys the desired nominal performance level at which the platform may run. Unlike the existing read-only Nominal Performance register, it is writable and lets OSPM request a lower nominal level than the platform-reported nominal. The platform classifies performance above this level as boosted and below as throttled for its power/thermal decisions. It is exposed as a per-policy cpufreq sysfs attribute in kHz, to match the cpufreq sysfs unit convention: /sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq The attribute is documented in Documentation/ABI/testing/sysfs-devices-system-cpu. Writes are converted to perf via cppc_khz_to_perf(), validated against [Lowest Performance, Nominal Performance], and applied to the policy->cpu. The register is assumed shared across the policy->cpus. On read, the current register value is returned, or "" if the platform does not implement the register. Also add the register to the OSPM-set register save/restore table, so its value survives CPU hotplug and reverts to the firmware value on driver unload, like the other registers in the table. Signed-off-by: Sumit Gupta --- .../ABI/testing/sysfs-devices-system-cpu | 26 ++++++++++ drivers/acpi/cppc_acpi.c | 32 +++++++++++++ drivers/cpufreq/cppc_cpufreq.c | 47 +++++++++++++++++++ include/acpi/cppc_acpi.h | 10 ++++ 4 files changed, 115 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documenta= tion/ABI/testing/sysfs-devices-system-cpu index 82d10d556cc8..a8d592c08823 100644 --- a/Documentation/ABI/testing/sysfs-devices-system-cpu +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu @@ -346,6 +346,32 @@ Description: Performance Limited =20 This file is only present if the cppc-cpufreq driver is in use. =20 +What: /sys/devices/system/cpu/cpuX/cpufreq/ospm_nominal_freq +Date: May 2026 +Contact: linux-pm@vger.kernel.org +Description: OSPM Nominal Performance (kHz) + + OSPM uses this attribute to request a nominal performance + level lower than the platform-reported nominal. The + platform treats performance above this level as boost + and below as throttle for power and thermal decisions. + + Read returns the current value in kHz, or "" + if the platform does not implement the register. Write a + kHz value in the range [lowest_freq, nominal_freq]. + + Note that tasks may be migrated from one CPU to another + by the scheduler's load-balancing algorithm, and if + different OSPM Nominal Performance values are set for + those CPUs (through different cpufreq policies), that may + lead to undesirable outcomes. To avoid such issues it is + better to set the same value across all policies, or to + pin every task potentially sensitive to it to a specific + CPU. + + This file is only present if the cppc-cpufreq driver is + in use. + What: /sys/devices/system/cpu/cpu*/cache/index3/cache_disable_{0,1} Date: August 2008 KernelVersion: 2.6.27 diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index a7fec6c93178..681d4fd40c11 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -1685,6 +1685,38 @@ int cppc_set_epp(int cpu, u64 epp_val) } EXPORT_SYMBOL_GPL(cppc_set_epp); =20 +/** + * cppc_set_ospm_nominal_perf() - Write OSPM Nominal Performance register. + * @cpu: CPU on which to write register. + * @ospm_nominal_perf: Value to write to the OSPM Nominal Performance regi= ster. + * + * OSPM Nominal Performance conveys the desired nominal performance level + * at which the platform may run. Per ACPI 6.6, s8.4.6.1.2.6, the value + * must lie within [Lowest Performance, Nominal Performance] and may be + * set independently of Minimum, Maximum and Desired performance. The + * caller is responsible for validating the range. + * + * Return: 0 on success or negative error code. + */ +int cppc_set_ospm_nominal_perf(int cpu, u64 ospm_nominal_perf) +{ + return cppc_set_reg_val(cpu, OSPM_NOMINAL_PERF, ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL(cppc_set_ospm_nominal_perf); + +/** + * cppc_get_ospm_nominal_perf() - Read OSPM Nominal Performance register. + * @cpu: CPU from which to read register. + * @ospm_nominal_perf: Pointer to store the OSPM Nominal Performance value. + * + * Return: 0 on success or negative error code. + */ +int cppc_get_ospm_nominal_perf(int cpu, u64 *ospm_nominal_perf) +{ + return cppc_get_reg_val(cpu, OSPM_NOMINAL_PERF, ospm_nominal_perf); +} +EXPORT_SYMBOL_GPL(cppc_get_ospm_nominal_perf); + /** * cppc_get_auto_act_window() - Read autonomous activity window register. * @cpu: CPU from which to read register. diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 9c88512d635c..eb6746810fa6 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -37,6 +37,7 @@ enum cppc_saved_reg_id { CPPC_SAVED_AUTO_SEL, CPPC_SAVED_EPP, CPPC_SAVED_AUTO_ACT_WINDOW, + CPPC_SAVED_OSPM_NOMINAL_PERF, CPPC_NR_SAVED_REGS, }; =20 @@ -55,6 +56,9 @@ static const struct cppc_saved_reg cppc_saved_regs[CPPC_N= R_SAVED_REGS] =3D { [CPPC_SAVED_AUTO_ACT_WINDOW] =3D { cppc_get_auto_act_window, cppc_set_auto_act_window, }, + [CPPC_SAVED_OSPM_NOMINAL_PERF] =3D { + cppc_get_ospm_nominal_perf, cppc_set_ospm_nominal_perf, + }, }; =20 /* @@ -1166,11 +1170,53 @@ static int cppc_get_perf_limited_filtered(int cpu, = u64 *perf_limited) CPPC_CPUFREQ_ATTR_RW_U64(perf_limited, cppc_get_perf_limited_filtered, cppc_set_perf_limited) =20 +static ssize_t show_ospm_nominal_freq(struct cpufreq_policy *policy, char = *buf) +{ + struct cppc_cpudata *cpu_data =3D policy->driver_data; + u64 perf; + int ret; + + ret =3D cppc_get_ospm_nominal_perf(policy->cpu, &perf); + if (ret =3D=3D -EOPNOTSUPP) + return sysfs_emit(buf, "\n"); + if (ret) + return ret; + + return sysfs_emit(buf, "%u\n", + cppc_perf_to_khz(&cpu_data->perf_caps, perf)); +} + +static ssize_t store_ospm_nominal_freq(struct cpufreq_policy *policy, + const char *buf, size_t count) +{ + struct cppc_cpudata *cpu_data =3D policy->driver_data; + unsigned int freq_khz; + u32 perf; + int ret; + + ret =3D kstrtouint(buf, 0, &freq_khz); + if (ret) + return ret; + + perf =3D cppc_khz_to_perf(&cpu_data->perf_caps, freq_khz); + if (perf < cpu_data->perf_caps.lowest_perf || + perf > cpu_data->perf_caps.nominal_perf) + return -EINVAL; + + /* The register is assumed shared across the policy's CPUs. */ + ret =3D cppc_set_ospm_nominal_perf(policy->cpu, perf); + if (ret) + return ret; + + return count; +} + 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(perf_limited); +cpufreq_freq_attr_rw(ospm_nominal_freq); =20 static struct freq_attr *cppc_cpufreq_attr[] =3D { &freqdomain_cpus, @@ -1178,6 +1224,7 @@ static struct freq_attr *cppc_cpufreq_attr[] =3D { &auto_act_window, &energy_performance_preference_val, &perf_limited, + &ospm_nominal_freq, NULL, }; =20 diff --git a/include/acpi/cppc_acpi.h b/include/acpi/cppc_acpi.h index cd07e1e92bf4..4c9e59643cc0 100644 --- a/include/acpi/cppc_acpi.h +++ b/include/acpi/cppc_acpi.h @@ -180,6 +180,8 @@ extern int cpc_write_ffh(int cpunum, struct cpc_reg *re= g, u64 val); extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf); extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, = bool enable); extern int cppc_set_epp(int cpu, u64 epp_val); +extern int cppc_set_ospm_nominal_perf(int cpu, u64 ospm_nominal_perf); +extern int cppc_get_ospm_nominal_perf(int cpu, u64 *ospm_nominal_perf); extern int cppc_get_auto_act_window(int cpu, u64 *auto_act_window); extern int cppc_set_auto_act_window(int cpu, u64 auto_act_window); extern int cppc_get_auto_sel(int cpu, bool *enable); @@ -268,6 +270,14 @@ static inline int cppc_set_epp(int cpu, u64 epp_val) { return -EOPNOTSUPP; } +static inline int cppc_set_ospm_nominal_perf(int cpu, u64 ospm_nominal_per= f) +{ + return -EOPNOTSUPP; +} +static inline int cppc_get_ospm_nominal_perf(int cpu, u64 *ospm_nominal_pe= rf) +{ + return -EOPNOTSUPP; +} static inline int cppc_get_auto_act_window(int cpu, u64 *auto_act_window) { return -EOPNOTSUPP; --=20 2.34.1 From nobody Sat Jul 25 04:53:32 2026 Received: from BN8PR05CU002.outbound.protection.outlook.com (mail-eastus2azon11011068.outbound.protection.outlook.com [52.101.57.68]) (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 E65943B14D4; Fri, 17 Jul 2026 21:54:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.57.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784325277; cv=fail; b=VHVNLaGK6Q1GjvooO15AdH3E3ewT0TF7dNTaBSo7X032L0+9du1FUayNlq0dWDQljtIr3WusuCvvoux01YkJR0oanjNxhK2JSeIetaagDGzACg+4dKm9nZAiC/RLIFxBFteYpC6fOq5BWNB5bSEVJoyiSy0Rq4SmXFqqYd6cMks= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784325277; c=relaxed/simple; bh=EANHh8/R9Mq/oysjEYutOD5yHaxJUWLMyD+fjBTAqGk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gyA9Olph20OnLY6qbpTF4a9dLTAKWF0lANNwJyB33cMNAv3kjctX8zOfZd2LjZjnsDH/C+eqetYsRxx4xB0vuvG7coqknG7bRALFlpj7U/GU5GmybHel5w61MBpDodjaxqB9v2i4UU5DzWEw9IoCMWyO9B17DUH/EqC9XTmqPzo= 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=kGFbyG62; arc=fail smtp.client-ip=52.101.57.68 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="kGFbyG62" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tQAprv2hzBLW9ZqoyRkGCC0AqcKrpZ2UlwuXoJHb0XqerQu3Z9AkT/9RwdSbvQSh5yYpstSSEHeEA+vtSyBU7Cpu03q6U0GJYcSbwOOYGYtL0uPQ62xopYoMbM0kdueMwi9CN3If8WBGPQKMZR4e3v/39xdwwz/oruTq2u5KHqCm6stmC91LcM2o8amk5w+3kDC9iop9RpimMHN2mrGMFBT3Ilz8ao86gwVW+/cb6WQgaalQAtjnWw5w/VGSTEMynyKG5d/DCCDRNJNL4k4fvZdx7OeCZkGb51N4nqaoTTchj6CnIdOUcV2qkRHu7C3igk2rvbnvvpDSTbcqYMpa+A== 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=53uPTuVYjXEexomO5YjnYKjkvrDNkErHJ+5Y/yjPuNk=; b=WBVS/yC9MJhLmJK+u0pFEH8Q65QAZnrI68dDlhCJ72hrrq4qTd5WwPMrP7L4e8fMOUzQD2fYyTFqB4U63oNVTcZ7GFfS36Wrw/68Gpljf0GIZX2t/bDZPVR2p1eH4YKKVg/4Lie0x610rAjlZf6J17IfVCqnGDhKWCjtucRKjWgw31Q3hqi7B9HsU0q70tSKoUDZqWFvugI0iXVOTVYNedc5K/AsFXqwEd7UghZYbDaec82ziCssUvZkel8XmbxSy553UCsNhD8rhgSbZR2ml1y79+oepjSLTSSLU+QTMfc3Ca/rEDoE1suBRedQCaZz+PvyK5fG6pibCuQWuOmD5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=53uPTuVYjXEexomO5YjnYKjkvrDNkErHJ+5Y/yjPuNk=; b=kGFbyG62ZSvFu9A3n557f4he+e3nQ9ywqprXejUfDdJgDnaOFe4T15MS9xhMiHCI6fw31nbKXdZfLLvvvbqLigCNk1pBxp1H7tqMvVGL5wOw73fabcCI3nppNLqQERFeRJ2S5GladpkUBaZo+rBrDiu2equ2DpICNvalend/i71E3ynTmHSPfllPSgR6Rg5iroHUgJcihLYY01VAv/9DoF1wIWlbTFmXLLBAvQdRqGQgdnKLLgy5OF2i0RJ+83R1N3GwGYbgHZY7iCASQuIzvMpEq+Crerxg2gh398vhspVQ+ilRYw7JsB/lDEcMAS6BnH9gS7gDV5RvtDNl39udQA== Received: from MW4P223CA0007.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::12) by MW5PR12MB5651.namprd12.prod.outlook.com (2603:10b6:303:19f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.223.12; Fri, 17 Jul 2026 21:54:15 +0000 Received: from MWH0EPF000A6732.namprd04.prod.outlook.com (2603:10b6:303:80:cafe::63) by MW4P223CA0007.outlook.office365.com (2603:10b6:303:80::12) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.223.13 via Frontend Transport; Fri, 17 Jul 2026 21:54:15 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by MWH0EPF000A6732.mail.protection.outlook.com (10.167.249.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.245.5 via Frontend Transport; Fri, 17 Jul 2026 21:54:15 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 17 Jul 2026 14:54:01 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Fri, 17 Jul 2026 14:54:00 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.14) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.2562.20 via Frontend Transport; Fri, 17 Jul 2026 14:53:55 -0700 From: Sumit Gupta To: , , , , , , , , , , , , , CC: , , , , , , , Subject: [PATCH v6 2/2] cpufreq: CPPC: Reflect ospm_nominal_perf in boost and limits Date: Sat, 18 Jul 2026 03:23:30 +0530 Message-ID: <20260717215330.2215058-3-sumitg@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260717215330.2215058-1-sumitg@nvidia.com> References: <20260717215330.2215058-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: MWH0EPF000A6732:EE_|MW5PR12MB5651:EE_ X-MS-Office365-Filtering-Correlation-Id: e2dccf1c-3c98-4d0a-7e1d-08dee44df1d2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|82310400026|23010399003|1800799024|36860700016|921020|18002099003|22082099003|3023799007|11063799006|6133799003|10067099003|56012099006; X-Microsoft-Antispam-Message-Info: bn6VXGNCPZtxCfkIp/ZhgVEHUrYqDEQV9v06moQmCuK/qS4kH+fL03zbi0Imo2qLzN3L/YOGWrPbqptNx/EOcRJJvUb1pDh1TT7OQ4xxzwlDJ3RK41jlh9bw4In8EUdF/yHeSo51V2D/mNXpKvp4kSGNstTv2l1omdNF/1/dC8sunlqizQjs2BsZtB8Q6ljNZSPeU8TfdrnLtzqxDzTVlilIlRFQAUzgTfjJvb3h0oSPcEw40pkJvZrpNvSZt30yn6kM+pFD3fco8n6dCi+Rh0JBrlhXO0LkLIrmYw+drmIvx5pb/JTDNHinJ39oUr1V0iHvcDfx1qI62eho4o+abPuiTEDA2gCRpzCRfp33AeRcWTwoeSX3b/AAz0cz7yV4vL9GdrsrYEw1XTBFBRT6gB1dU9phoyCyLDvInzh4w6WCrTguRsGqp11rO6bL1gxC5/g98gnJPcLcRaxeL5Xa45cvExJIZG1R23TfCZ0EeyAVLeThiM384hCA376pROhVkuGvh3JgXjugm1NSCK5vFCYP2Jkh1ZlFqAeBHihpW+9rQDYaKAiRHJYEhh7HTqyaE/4aXzPSStcvWdwFaEGjjprttu4ecCZ+0PZb5tIuZrhwnIygYgbmyEC7WtU5ggtkrhOwsPrfQBAsZ4ChFLhIrlOZ3l8WlcZvCyvn4O5ARr375+jGn45hqE0pVg6zDrDYxVbxUatgH9d0bwnaSmMmccQSCAwJqH6AIlcyh4SLFHqOr9zD+SRxx8Dq45IiDbPN X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230040)(7416014)(376014)(82310400026)(23010399003)(1800799024)(36860700016)(921020)(18002099003)(22082099003)(3023799007)(11063799006)(6133799003)(10067099003)(56012099006);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GurUrBGbpvKk0vlHl2g+X++ou9DtaSY15fY7Qq+RK4gkUNNn4xtwF4cFOpjBYzOLGKeCpgkch/z75tWV5URe1wQyzvC745W6Vyql5cD5AIXRkmtgxKHCQgbMG2bIVB1Ro8smhLmfo6PvaQhHXlX6rFq7LbUgg1Jfl/F+h8Lm0JBpYlZw4NLyF1XyzL/34JgmucF2Fvtzxpgqx8p3QQSziaQ5sb0UeF+6JKfpSG54kKYX1ZtcxpB831RjgQ2/brQaroFvo0cid339mfjw22JrZNjlazGtDpY2AjXmEBDOGzDLJSahAwSPoHNEpNDVR7MaCd9GSRJJvz0TNbYBctvGVk8i/orNXrzzFXEwashokWKTRVLLMqZSag0jporr6kerGRDbgfdBk6fqlU6I04r/tB7zevlNbV/KsNI22RVUsLJuAtBHpqRJLG95n9mv4paL X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2026 21:54:15.2762 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2dccf1c-3c98-4d0a-7e1d-08dee44df1d2 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000A6732.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR12MB5651 Content-Type: text/plain; charset="utf-8" OSPM Nominal Performance lets OSPM request a nominal level below the platform-reported nominal. Since boost is the range above nominal, lowering the nominal enlarges the boost range and drops the non-boost ceiling. cppc_cpufreq currently uses the platform nominal as the non-boost ceiling. Changing the OSPM nominal then leaves the policy limits unchanged, so the boost and non-boost ranges no longer match the register. Reflect the OSPM nominal in the cpufreq policy so that boost and the frequency limits stay consistent with the register: - Add cppc_cpufreq_get_effective_nominal(), which yields the OSPM Nominal Performance when set and the platform nominal otherwise. - Use it to derive cpuinfo.max_freq for the non-boost ceiling in init() and in set_boost() while boost is disabled. The cpufreq core includes a per-policy boost QoS request among the constraints that cap scaling_max_freq. It updates that request to match cpuinfo.max_freq, but only when boost is toggled. Writing ospm_nominal_freq changes cpuinfo.max_freq without toggling boost, so the request (boost_freq_req) is left stale and keeps scaling_max_freq at the old nominal. cppc_cpufreq_reflect_nominal() therefore updates the request directly when the nominal changes while boost is disabled. At boot, when highest_perf =3D=3D nominal_perf there is no boost range, but lowering the OSPM nominal later from sysfs can create one if highest_perf > lowest_perf. Since the core registers its boost FREQ_QOS_MAX request at policy setup only when boost_supported is already set, set boost_supported in init() when the OSPM register is supported and such a range is possible. Boost can then be enabled once the nominal is lowered. Signed-off-by: Sumit Gupta --- drivers/cpufreq/cppc_cpufreq.c | 119 ++++++++++++++++++++++++++++++--- 1 file changed, 111 insertions(+), 8 deletions(-) diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index eb6746810fa6..048bb567ec45 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -761,11 +761,63 @@ static void cppc_cpufreq_put_cpu_data(struct cpufreq_= policy *policy) policy->driver_data =3D NULL; } =20 +/** + * cppc_cpufreq_get_effective_nominal() - Get the effective nominal perfor= mance + * @policy: cpufreq policy associated with the CPU + * @nominal: Updated with the effective nominal performance + * @supported: Updated with whether OSPM Nominal Performance is supported. + * Pass NULL if not needed + * + * Use the OSPM Nominal Performance value when the register is supported a= nd + * contains a nonzero value. Otherwise, use the platform-reported Nominal + * Performance. The resulting value is the non-boost performance ceiling. + * + * Return: 0 on success, or a negative error code if the register cannot be + * read or contains a value outside the supported performance range. + */ +static int cppc_cpufreq_get_effective_nominal(struct cpufreq_policy *polic= y, + u32 *nominal, bool *supported) +{ + struct cppc_cpudata *cpu_data =3D policy->driver_data; + struct cppc_perf_caps *caps =3D &cpu_data->perf_caps; + u32 effective_nominal =3D caps->nominal_perf; + bool ospm_supported =3D false; + u64 ospm_nominal; + int ret; + + ret =3D cppc_get_ospm_nominal_perf(policy->cpu, &ospm_nominal); + if (ret =3D=3D -EOPNOTSUPP) + goto out; + if (ret) + return ret; + + ospm_supported =3D true; + + /* A zero value means OSPM has not selected a nominal level. */ + if (!ospm_nominal) + goto out; + + if (ospm_nominal < caps->lowest_perf || + ospm_nominal > caps->nominal_perf) + return -EINVAL; + + effective_nominal =3D (u32)ospm_nominal; + +out: + *nominal =3D effective_nominal; + if (supported) + *supported =3D ospm_supported; + + return 0; +} + static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) { unsigned int cpu =3D policy->cpu; struct cppc_cpudata *cpu_data; struct cppc_perf_caps *caps; + bool ospm_supported; + u32 nominal, perf; int ret; =20 cpu_data =3D cppc_cpufreq_get_cpu_data(cpu); @@ -788,8 +840,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy= *policy) * nonlinear perf */ policy->cpuinfo.min_freq =3D cppc_perf_to_khz(caps, caps->lowest_perf); - policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, policy->boost_enabled= ? - caps->highest_perf : caps->nominal_perf); + + ret =3D cppc_cpufreq_get_effective_nominal(policy, &nominal, + &ospm_supported); + if (ret) { + pr_debug("CPU%u: failed to get effective nominal: %d\n", + cpu, ret); + goto out; + } + + perf =3D policy->boost_enabled ? caps->highest_perf : nominal; + policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, perf); =20 policy->transition_delay_us =3D cppc_cpufreq_get_transition_delay_us(cpu); policy->shared_type =3D cpu_data->shared_type; @@ -819,9 +880,13 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy= *policy) =20 /* * If 'highest_perf' is greater than 'nominal_perf', we assume CPU Boost - * is supported. + * is supported. A writable OSPM Nominal Performance register can also + * open a boost range at runtime by lowering the nominal, so assume + * boost is supported in that case too, letting the core register its + * QoS request up front. */ - if (caps->highest_perf > caps->nominal_perf) + if (caps->highest_perf > caps->nominal_perf || + (ospm_supported && caps->highest_perf > caps->lowest_perf)) policy->boost_supported =3D true; =20 /* Set policy->cur to max now. The governors will adjust later. */ @@ -992,11 +1057,16 @@ static int cppc_cpufreq_set_boost(struct cpufreq_pol= icy *policy, int state) { struct cppc_cpudata *cpu_data =3D policy->driver_data; struct cppc_perf_caps *caps =3D &cpu_data->perf_caps; + u32 perf =3D caps->highest_perf; + int ret; =20 - if (state) - policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, caps->highest_perf); - else - policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, caps->nominal_perf); + if (!state) { + ret =3D cppc_cpufreq_get_effective_nominal(policy, &perf, NULL); + if (ret) + return ret; + } + + policy->cpuinfo.max_freq =3D cppc_perf_to_khz(caps, perf); =20 return 0; } @@ -1025,6 +1095,35 @@ static ssize_t show_auto_select(struct cpufreq_polic= y *policy, char *buf) return sysfs_emit(buf, "%d\n", val); } =20 +static int cppc_cpufreq_reflect_nominal(struct cpufreq_policy *policy, + u32 nominal) +{ + struct cppc_cpudata *cpu_data =3D policy->driver_data; + int ret; + + /* + * While boost is disabled, the nominal is the ceiling. Set + * cpuinfo.max_freq to it and update the core's boost_freq_req to + * match. The core only syncs boost_freq_req when boost is enabled or + * disabled, so a plain nominal change must update it here. + */ + if (!policy->boost_enabled) { + policy->cpuinfo.max_freq =3D + cppc_perf_to_khz(&cpu_data->perf_caps, nominal); + + if (freq_qos_request_active(&policy->boost_freq_req)) { + ret =3D freq_qos_update_request(&policy->boost_freq_req, + policy->cpuinfo.max_freq); + if (ret < 0) + return ret; + } + } + + refresh_frequency_limits(policy); + + return 0; +} + static ssize_t store_auto_select(struct cpufreq_policy *policy, const char *buf, size_t count) { @@ -1208,6 +1307,10 @@ static ssize_t store_ospm_nominal_freq(struct cpufre= q_policy *policy, if (ret) return ret; =20 + ret =3D cppc_cpufreq_reflect_nominal(policy, perf); + if (ret) + return ret; + return count; } =20 --=20 2.34.1