From patchwork Wed Mar 13 09:59:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 780253 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2059.outbound.protection.outlook.com [40.107.212.59]) (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 A3DAE3A1B5; Wed, 13 Mar 2024 10:00:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.59 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324056; cv=fail; b=L9WsRl9v12cNGDdz+bAh1pVPc7lVwMuLIRdPPjffVA3wsU192oXbTZBjmT3g+O6ApCR0QLt0tZU3vJElZBA0Z7QlKn0jjhy/iX6oLj0KrYafhXJgad/s+xGx1p4s6KOiK1pFKv2wkTu9OHenugay9SStUZbJK42LP0RsPESct9w= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324056; c=relaxed/simple; bh=fFaC2eFGT3VvaloNNsoODFmvoI3Kzd31hKTJAA69Odw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Oe8gcoIIN6/JluT+yshY0NgTFH8IKQkLuFfo9ejkfTQMMO6V7H2S5pM4VeURmcfVOcyXytrthYZkGVSp8GZIIwnDuFgjGHU/hqUiIByKfktrSKFNVk9xa32wpqdQdWDYUyVVGsjDhy+q95bJNJODzAdM13dlKCyBZr1bnR1CcT4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=t3J11eM4; arc=fail smtp.client-ip=40.107.212.59 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="t3J11eM4" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UHXS88v3bMV5pub8HLQ/8HKiIm5O+tVhwXXesYGVj0aIWwE9vkA4GkOrJBs9S/amzubH8bBaC26UhUY4NSfEbuSjbQY74sjfQwU1QhaXhFzdZ4iYmf+1KGcyOBloDaiJQox5zQ9/78yD6psbOSfF7R6WfpmHHHHxJfgjgXHfAzSgmOilRoowfZlDZyH3cpS2Pan4Rr3hljwjYGgsM4VvbMs1hWSehVKGqCpCLYX8x9UViFxkcvDwL8fFNDPzf/5zlbxEb7N9kyS4ONMhRe/IOwL9TiNhuSrDYaYTUj2tFbJNgy4gTu8OUb4kARj8fq8IfSygIXsuyRcvkPX8QBk5hQ== 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=K/FaF+4lx0lXVkGTv7YAAWX3CSKxQR1KBoBVBpr7wts=; b=MJcLpB594vbMKUL/7gHRpW8vDAGwXmBMpcUd7eQ+dqcQDjswLL+i05mRrsCol9kCvtCXVW+ReXxLifK0Dzzr4lyfzByu06Gun+NZkoRSMNh0h/8a9Yr3u8vanP4BFn3fnmaKeQav+WSYPYRyd2JRLuVIbqMDiPtH10OiRFtXpwHaRu2kdAl8P9v8t3AyRfs/kXqwA9YGsSL2ewwtnJXyVFTkAaXZ4MlfNhYSc6TUuS4ODXz1hiEHiWwFKziIhGA/pZNnq0kwFZ9KWhi/yv2aQ8te+K6+7DpFPVIYe02Z8mw5Br8YvIfgyKJ0tYVkRbqnnxWzAKzuNjPkq2T6I6FEKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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 (0) 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=K/FaF+4lx0lXVkGTv7YAAWX3CSKxQR1KBoBVBpr7wts=; b=t3J11eM4oFwxa82oFrZguAJngQBrQFTNR4SKyY/u5aaiglIOWhXwFFbCEbBi5FLQIo2lIDLVpldqZzOKt+DPdwNF+TiZWcJQ+8PbvZzxXbFgYp+SGG1agwv5EkO3Es5+7ZAyYAdp93vQrYYgLqnGWqmdANbt2GmSiJqOSXYpJnY= Received: from SJ0PR05CA0071.namprd05.prod.outlook.com (2603:10b6:a03:332::16) by DM6PR12MB4299.namprd12.prod.outlook.com (2603:10b6:5:223::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.36; Wed, 13 Mar 2024 10:00:49 +0000 Received: from CO1PEPF000066E9.namprd05.prod.outlook.com (2603:10b6:a03:332:cafe::fb) by SJ0PR05CA0071.outlook.office365.com (2603:10b6:a03:332::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.18 via Frontend Transport; Wed, 13 Mar 2024 10:00: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 CO1PEPF000066E9.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7386.12 via Frontend Transport; Wed, 13 Mar 2024 10:00:48 +0000 Received: from pyuan-Chachani-VN.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.2507.35; Wed, 13 Mar 2024 05:00:42 -0500 From: Perry Yuan To: , , , , , CC: , , , , , Subject: [PATCH v7 2/6] cpufreq:amd-pstate: initialize nominal_freq of each cpudata Date: Wed, 13 Mar 2024 17:59:14 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E9:EE_|DM6PR12MB4299:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b0468f7-8752-4e09-ec55-08dc4344757e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EwsjtZ+MdT6W5U3U8SIPTS6ny5OpjzLJ4FFb8bRIJMhpAeN8l9Y7Nb4h7kUs3xaPXt9EsbneXr2dYHVW4Z5yl5xoSQTsWfsJieY1OafPUz4WRfyScF6PDDY1vK0OzhizjdyCmUem5+W8frt4Wd1RhpVqXLnLtq9T3E16Wki9r8fVw/7rgom6nf0KLpqkzY1XKYsUUjXdYK3tsgLCVUCmvK6ooK2TOrtL+/nzH4M2mNorlEreiyskSwnwMfRR0ZxCZWB16A1VflZ9QvH28+tBBx8B+8i1sT0RWHbRmoVKTxSkn6rRB6MmzvGP31KJKU5LxGNCG00Vuw632fVEsewst/uIYVQ9G99l99WOWG0mwRZVUfG10VzUfZfnr47OXjzCEQfBMQzFnEWmSLK0zAoXp9jfVFpSsecO6vhT1cNWpNh0S5nKjX61J077D1rhfHmTcyucpq6N0PdHRwVOlUnxUsCTpAPFoFcW0sAtndswAtMpQ1a/qtkgtMWmWpD0fZhAcXNgHqml9tM9Prs65ag8pWx1TBRhYtTPMCe6dpYEH67KaHpTSuSBcMPnsaqq8GPHjRPG2a3+UW2q9JeJ9bUroWk29tKf1r/iLpAMO9EXvAaHJ1H8BYuiQrkSn0r1nZxbdcunreOapZMNt7ixEz+o6kpDCzAWhA6cL4BTyLG6FihzgGDQCUxVDQzEvGBQLCdpCH2OhRlNihZf1c401t/JTnlpR6JVS8tPQszGGSZ8rNaTr9scJvUyQsOxfqTfJc/2 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:(13230031)(82310400014)(1800799015)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2024 10:00:48.5513 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9b0468f7-8752-4e09-ec55-08dc4344757e 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: CO1PEPF000066E9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4299 Optimizes the process of retrieving the nominal frequency by utilizing 'cpudata->nominal_freq' instead of repeatedly accessing the cppc_acpi interface. To enhance efficiency and reduce the CPU load, shifted to using 'cpudata->nominal_freq'. It allows for the nominal frequency to be accessed directly from the cached data in 'cpudata' of each CPU. It will also slightly reduce the frequency change latency while using pstate driver passive mode. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 3faa895b77b7..6db9256f42c0 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -626,7 +626,7 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) if (ret) return ret; - nominal_freq = cppc_perf.nominal_freq; + nominal_freq = READ_ONCE(cpudata->nominal_freq); nominal_perf = READ_ONCE(cpudata->nominal_perf); max_perf = READ_ONCE(cpudata->highest_perf); @@ -661,7 +661,7 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) if (ret) return ret; - nominal_freq = cppc_perf.nominal_freq; + nominal_freq = READ_ONCE(cpudata->nominal_freq); nominal_perf = READ_ONCE(cpudata->nominal_perf); lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; @@ -855,13 +855,14 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; min_freq = amd_get_min_freq(cpudata); - max_freq = amd_get_max_freq(cpudata); nominal_freq = amd_get_nominal_freq(cpudata); + cpudata->nominal_freq = nominal_freq; + max_freq = amd_get_max_freq(cpudata); lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq < 0 || max_freq < 0 || min_freq > max_freq || nominal_freq == 0) { + dev_err(dev, "min_freq(%d) or max_freq(%d) or nominal_freq(%d) is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } @@ -900,7 +901,6 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) cpudata->min_freq = min_freq; cpudata->max_limit_freq = max_freq; cpudata->min_limit_freq = min_freq; - cpudata->nominal_freq = nominal_freq; cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; policy->driver_data = cpudata; @@ -1317,12 +1317,13 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) goto free_cpudata1; min_freq = amd_get_min_freq(cpudata); - max_freq = amd_get_max_freq(cpudata); nominal_freq = amd_get_nominal_freq(cpudata); + cpudata->nominal_freq = nominal_freq; + max_freq = amd_get_max_freq(cpudata); lowest_nonlinear_freq = amd_get_lowest_nonlinear_freq(cpudata); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq < 0 || max_freq < 0 || min_freq > max_freq || nominal_freq == 0) { + dev_err(dev, "min_freq(%d) or max_freq(%d) or nominal_freq(%d) is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } @@ -1335,7 +1336,6 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) /* Initial processor data capability frequencies */ cpudata->max_freq = max_freq; cpudata->min_freq = min_freq; - cpudata->nominal_freq = nominal_freq; cpudata->lowest_nonlinear_freq = lowest_nonlinear_freq; policy->driver_data = cpudata; From patchwork Wed Mar 13 09:59:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 780252 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) (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 AC26F3B789; Wed, 13 Mar 2024 10:00:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324060; cv=fail; b=kiJe8IbHNgPK8FiWo0etPKvTU/PEuHqPabKDCgTfHnr533N2BaZoSf7Swy/Fxv4TNvK7zVaz6gIedaQ9DVKLIe6OLSyH3ZHNWEZ0G8RQm2oz4bt4zSJd+sVUawdSXwRBExsnWKIZ4EyXqEKXzmpc9jogD83/ofwcTbdeiFjYGCc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324060; c=relaxed/simple; bh=9YoPGWYOTq1y6dA1LU0T/TdhYJ48Ig5mU6lWLRZEGb8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kzqW4MdrBOD+QSbZMczONCXbEInVPaNmcbDEN/O93sqhhSUGAnRD2xpyChBil6aDOvZr65SshzGBErfyfPtgz5Drjreynt0WqYz60kQav0cCJ8Ck42aQXENKWdI6Yac5duM4plH6V7nUdjpWUiIDT4zl9O+3dfO49NzGgRsZCk8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=4Dcgo7pD; arc=fail smtp.client-ip=40.107.236.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="4Dcgo7pD" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVKjg+t8SAz2MUEo/ghW0YiN6klm4eGCb56WnspI41SzNqpRbq+8wKom8FC8zYySqGjDtW41ZeNlMkyntk3JTA/N3dVeb53b2dbSyolhZWOaeEL0Ea/ZqzC9pUHONk/vQzmBvy7DelRPKnbHBaDoWaJCRX4dMak83J8GLIbB6EF5v17q/VTh830SJEhyjxmyxViPnohciYYmZYVl9c80VZKl1DqoUuluDG5C+ppFznmH2HPVz47QBSxPwX3+XBebUIugft4xDqjG+k30lIHQOFoI4xp5I73oJixdQQuxljkZgjqhKZDAkXtpGfAfetjwa95o2VBPVzmKVNvGkUFfGA== 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=TiAzKpGfOKUUmWTICLDcNebWFXhmKkI5ls4Zx1iHmcQ=; b=WJdjDXj2GWceFo+N0+dWIvYn7/aP3KrBEzfvU+BR0Y2rGWFHVXhRhHctrvV+Ui4rQ9ZRQA7LwPR6JYBG3jOC4By9Dc/7kWYb4jMhGP8ub5lb39CBMARh/6xaWfOVNxcjjiXOwSwzBqKJC7XlcLiSFQxPZlBpAepOSF4vGhNfIGF4bhuBAW5YA687uPYAewg+PA4AFlIW70kwZ+jG535ZFkYPsIWhyPUuNioun73zh1r07oYVLknKhsOrKRYQCz2BplLyVRu+J3xx8yvKcid1LP2i4oKH5s/T/4pSYnoRUk7pS0CmIu6WMxdiEf/js/vd/429Z8gB846JN7yVPih/VQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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 (0) 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=TiAzKpGfOKUUmWTICLDcNebWFXhmKkI5ls4Zx1iHmcQ=; b=4Dcgo7pDutmMFFjfGlMJ7xd7qtmb3jJz/7h/sqLKpvYV9DaRtggpGRR+xM4YXYxbcG+d0LyuyfzBx/YOQGt1dvbLM6YKqbS67Z4WpIiWZXYMzyGvIz1DcZH/flbQ9Ftbq7NRcih8o7IsU4G1w8El+OEJyO1rIkrbHooYSx/mLLg= Received: from MW4PR04CA0078.namprd04.prod.outlook.com (2603:10b6:303:6b::23) by MN2PR12MB4407.namprd12.prod.outlook.com (2603:10b6:208:260::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.19; Wed, 13 Mar 2024 10:00:53 +0000 Received: from CO1PEPF000066ED.namprd05.prod.outlook.com (2603:10b6:303:6b:cafe::44) by MW4PR04CA0078.outlook.office365.com (2603:10b6:303:6b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.36 via Frontend Transport; Wed, 13 Mar 2024 10:00: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 CO1PEPF000066ED.mail.protection.outlook.com (10.167.249.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7386.12 via Frontend Transport; Wed, 13 Mar 2024 10:00:52 +0000 Received: from pyuan-Chachani-VN.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.2507.35; Wed, 13 Mar 2024 05:00:48 -0500 From: Perry Yuan To: , , , , , CC: , , , , , Subject: [PATCH v7 4/6] cppc_acpi: print error message if CPPC is unsupported Date: Wed, 13 Mar 2024 17:59:16 +0800 Message-ID: <4bb45bd64bfdf3a8f5a3bffdd8b5475474d9609e.1710323410.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066ED:EE_|MN2PR12MB4407:EE_ X-MS-Office365-Filtering-Correlation-Id: d4b20645-7bb6-4cc8-7088-08dc434477ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z7sREojZoxKunMTVilBH5bQPXLErFoUwyn5nxPUR3sVaeS0tLUHlrrKRePDJsWR0zMvG0iVx32ngkL3ms7F3KI5MeICn/cnTNaOdsIto5cHKaAyCN8IfzDPZM+8lKUJak1nlIKtqPFd541KLbiMwNM0yWXM3ItvMT/N+TT6xJqc44ubwQVKNN0HI4UC1l0VGVSGKlrX9kyNU604PPSc3Lq5Bs6RxDQErhUSswJ2QHaineUqqJ38HS1tBa2lF+//nu1AW+FXalgyoaMzQmcKn9hq3bIfyueh1IpVge6GNABDow7cl7UOcaOWzmtlqsYfsb32s/DyvmRUvFsEB/7r9Z/VN96/piAkry2LPrzsXQ9WsVb7dOypSf84bab8cirPPAXdGLHxfGWAb0PV4QWfy//rMyQ/PoqqdybUdDnFqJPeD//uehABNpfa5BXW/t/bi9og5mqP4//gO+OlNrUQworV/9rnYtvgQkcWX6Cyg+aL5joFMlhz8D3aFU+LIYq02GYDNbmlHHqkW6D5XtsL6XVHoEzt+ww5+UaibMBoMzCHsWUjyn3pLN43S8sKf6hlUzDOOZjVu9KgCjjJfh7KwCoZ9nQmlKBkT2EMvEEQLh80x4IDHWTJ1l3Tymu76MSxP6RUGRYbM7v5YGSiboz9A5h7FSJTb5lhkeZS2c7K6ciD/V8NugciyQVr8ivF1cxqY9P72VTJWgZ76Q75N//llxPvAFvAl9lBYjZdBupAOQM/iIAmBP0jxP+Zb1PPuTZtp 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:(13230031)(36860700004)(1800799015)(376005)(82310400014); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2024 10:00:52.7313 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d4b20645-7bb6-4cc8-7088-08dc434477ee 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: CO1PEPF000066ED.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4407 to be more clear what is wrong with CPPC when pstate driver failed to load which has dependency on the CPPC capabilities. Add one more debug message to notify user if CPPC is not supported by the CPU, then it will be easy to find out what need to fix for pstate driver loading issue. [ 0.477523] amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled Above message is not clear enough to verify whether CPPC is not supported. Reviewed-by: Mario Limonciello Signed-off-by: Perry Yuan Reviewed-by: Gautham R. Shenoy --- drivers/acpi/cppc_acpi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 4bfbe55553f4..3134101f31b6 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -686,8 +686,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) if (!osc_sb_cppc2_support_acked) { pr_debug("CPPC v2 _OSC not acked\n"); - if (!cpc_supported_by_cpu()) + if (!cpc_supported_by_cpu()) { + pr_debug("CPPC is not supported by the CPU\n"); return -ENODEV; + } } /* Parse the ACPI _CPC table for this CPU. */ From patchwork Wed Mar 13 09:59:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yuan, Perry" X-Patchwork-Id: 780251 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060.outbound.protection.outlook.com [40.107.93.60]) (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 D57B23D571; Wed, 13 Mar 2024 10:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.93.60 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324068; cv=fail; b=oQDA+0eABukBDyFVaI9CeWkt5ggQ4HDtk7eV0cCBdr0QFlc1wYhXohG/wIJIUG1yKeZYQSLUqtXNPzuJDIMXI0NHjNwNFOY2ZmdhLJFM0ygtvd2+25meUpkNElZme7VBTfqNnP7DXmArmkQL8OaLwgpJ+uzMnSIfpZT/3h+PDm4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710324068; c=relaxed/simple; bh=bQhlkKcYhkceLwUzWDfLmD6GX6DT4B6UCe1dUkh3TQs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YWIBcZLCOKQAlDIJhL9xO7Gs6aydAArgqJuFttxlI0OTV1ZUTm3UoY4qztVBjhWC4/67yTw0h1TqPli6jEEtha+naBdLLW/6cgETE6uZE6M0wimXt5eFG3QezLpLoqAxPZXN2Iy/liEsgnFA265Ux4AUe6t21ojI3MhMW80Ajq8= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=zlghowS+; arc=fail smtp.client-ip=40.107.93.60 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="zlghowS+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H2H0FXuiEaZSctbR5XkW8IsCXBVN3X+gSY/7ANDqYRknxhnky6DupvUJsIdo7LDcnQ17zYkL+0ivwkQeGqHnxsnzLi5Ljm8inJSMsWtC/Mes2lN1bX9IFqq+qji7mIzZ93vrlTMqx4e6eq/CbCtZvOsE77STVoJ2L1T3CbYc2BNaJaMqPJ2u/S01bO415/PIhQsbFUgHf0SKjxV0lSzT8c/2QJXUaw9AqwEvSCzEucVXEwZThunXOXdGbhzu6y1kw6JD0cNi1XBzEzqWceIFtOg+wDAx/qehhYahABncBlAcwEtbFBm+hPiEuMbjk30opsVeZ6/HnOKlOcI89qN+Mw== 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=zrfKU3COTqI7EOlleWGjCbqooBmav3KdLe2pBzvHwTs=; b=McLPLnN/ALUOiRvkzU0l2n3uDrI/ot0JiWDCGdBbDkhRJO6VSejH0rbPx0aXkBWyACRQCUKm4ugYAEDEQoXiq7/TpYWSHUj9Oynr745zejjxOyZJgFC18N3Hb6yPwc68vnLM9AKMUiji8ZRdaf3yhEhDY1UsjhuEaPhG9fDAKXQZsfINRh8rLh5WXmb6nzqdcIChThDgI/SaiSarnbZU0TO8p6FOr/M2jZic6+TmnHnBoIUGt2rU+3QchstrwvebX494NbDBJJbZ0yue5NC3pvfFTvr1I1sKTiE2HaMqWiNyzvuJJu4EiwiXgl3+XzrdNptQmmo7CvsOrtoc+ZVzdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=intel.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 (0) 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=zrfKU3COTqI7EOlleWGjCbqooBmav3KdLe2pBzvHwTs=; b=zlghowS+JrOf7JAa6dhf2YK3V2uzLVJu4RyR4KbhKkFJtwSGfQLqiI1Rzs5UphU8SQ2gMJox8L9a49j1eBCt8z2BXDZDkGOpsDoUMCRrdZBYii/JBtFaXbpGzAFgKh99jbNjXX6RBFJt/EzwwFZE0Vq2pB+FDQqsUqgb6ogksS4= Received: from MW4PR03CA0253.namprd03.prod.outlook.com (2603:10b6:303:b4::18) by DS7PR12MB5813.namprd12.prod.outlook.com (2603:10b6:8:75::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.18; Wed, 13 Mar 2024 10:01:01 +0000 Received: from CO1PEPF000066EB.namprd05.prod.outlook.com (2603:10b6:303:b4:cafe::ff) by MW4PR03CA0253.outlook.office365.com (2603:10b6:303:b4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.35 via Frontend Transport; Wed, 13 Mar 2024 10:01:01 +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 CO1PEPF000066EB.mail.protection.outlook.com (10.167.249.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7386.12 via Frontend Transport; Wed, 13 Mar 2024 10:01:00 +0000 Received: from pyuan-Chachani-VN.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.2507.35; Wed, 13 Mar 2024 05:00:55 -0500 From: Perry Yuan To: , , , , , CC: , , , , , Subject: [PATCH v7 6/6] cpufreq:amd-pstate: initialize capabilities in amd_pstate_init_perf Date: Wed, 13 Mar 2024 17:59:18 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066EB:EE_|DS7PR12MB5813:EE_ X-MS-Office365-Filtering-Correlation-Id: c2064b59-b79b-447c-ab1d-08dc43447cbf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k2lXNNxNuJv70yRHjZhxKyy3wuXTR+iuqPdVyQBr2TqGWx+lG9NZ6Ff8HUIYD9RlCCyqtsSkM3ammMJ4k+YT0WCEW0S8MVI6RiHKOOym35idI5/t6zNQf/a5WtgS9ssxEfMJvQPWBMu6IjCtWxBV6Z4RAogKO2z/6HaxnrOW8Ytbxb8dZOmEZfZGyWraxi0eQWNSTnqyArz6bD2lKkuyQWw3t8MdBDioZ4rhTRGSjVrkVBHz3j3CsImtxNAIip1At4+7z/yQQNv7vIThietSISxsWBx3bEPzGTMo2ZQasVRmObvclPm6jcSpUhbbzJB5iFuay+qUvL2+oNkLiRVuxbfvf3B0L/zcC+Y+PZmaeAVcOxXfXbLScd/HoJZwCN6z9E7gh6ihocwvNz5L+x1nP/tbOpWCbdsArUQ/biJdYMhcrFCPwbqIv+x7YzWzuYc+og3ZqHB41zGMG7bin4yWghNMDCiG0FYV9fvTD4auyV4vsLQdW5knEw33WBLRqgPpglIdeS7LWxczGvRgXbZPD6MBw+dMcLp9PDiay05QY7xOBmPf0PBR4fSWO3kvS9FN0QQmSAdi8xDnzjLlVHCRIJ/hb/3m673Jgt9yRp5E+BewzBaYMrER6TbgkDM84C4KBMBg+9SDEyLaJCScZIsmtdvYyy7ebeCN5z/7tw011zEX7l5txGGHLcUyHpvcB5FIl1+aTVgh83g2pAVfzCMrFcG+4DwYELqE6y5eWvoKiKzNNU6Az+GTDJExJy+DucDo 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:(13230031)(1800799015)(82310400014)(36860700004)(376005); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2024 10:01:00.7978 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c2064b59-b79b-447c-ab1d-08dc43447cbf 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: CO1PEPF000066EB.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5813 Moved the initialization of some perf and frequency values related to cpudata to the amd_pstate_init_perf and cppc_init_perf functions. It can avoid duplicate calls to cppc_get_perf_caps function. Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 43 ++++++++++++++---------------------- include/linux/amd-pstate.h | 1 + 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 59bcdf829c93..3877d4ecb5d4 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -330,12 +330,18 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) { u64 cap1; u32 highest_perf; + struct cppc_perf_caps cppc_perf; + int ret; - int ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, + ret = rdmsrl_safe_on_cpu(cpudata->cpu, MSR_AMD_CPPC_CAP1, &cap1); if (ret) return ret; + ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + if (ret) + return ret; + /* For platforms that do not support the preferred core feature, the * highest_pef may be configured with 166 or 255, to avoid max frequency * calculated wrongly. we take the AMD_CPPC_HIGHEST_PERF(cap1) value as @@ -353,6 +359,9 @@ static int pstate_init_perf(struct amd_cpudata *cpudata) WRITE_ONCE(cpudata->lowest_perf, AMD_CPPC_LOWEST_PERF(cap1)); WRITE_ONCE(cpudata->prefcore_ranking, AMD_CPPC_HIGHEST_PERF(cap1)); WRITE_ONCE(cpudata->min_limit_perf, AMD_CPPC_LOWEST_PERF(cap1)); + WRITE_ONCE(cpudata->lowest_freq, cppc_perf.lowest_freq); + WRITE_ONCE(cpudata->nominal_freq, cppc_perf.nominal_freq); + return 0; } @@ -360,8 +369,9 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) { struct cppc_perf_caps cppc_perf; u32 highest_perf; + int ret; - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); + ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); if (ret) return ret; @@ -378,6 +388,8 @@ static int cppc_init_perf(struct amd_cpudata *cpudata) WRITE_ONCE(cpudata->lowest_perf, cppc_perf.lowest_perf); WRITE_ONCE(cpudata->prefcore_ranking, cppc_perf.highest_perf); WRITE_ONCE(cpudata->min_limit_perf, cppc_perf.lowest_perf); + WRITE_ONCE(cpudata->lowest_freq, cppc_perf.lowest_freq); + WRITE_ONCE(cpudata->nominal_freq, cppc_perf.nominal_freq); if (cppc_state == AMD_PSTATE_ACTIVE) return 0; @@ -642,17 +654,12 @@ static void amd_pstate_adjust_perf(unsigned int cpu, static int amd_get_min_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; u32 lowest_freq; - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - if (quirks && quirks->lowest_freq) lowest_freq = quirks->lowest_freq; else - lowest_freq = cppc_perf.lowest_freq; + lowest_freq = READ_ONCE(cpudata->lowest_freq); /* Switch to khz */ return lowest_freq * 1000; @@ -660,14 +667,9 @@ static int amd_get_min_freq(struct amd_cpudata *cpudata) static int amd_get_max_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; u32 max_perf, max_freq, nominal_freq, nominal_perf; u64 boost_ratio; - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - nominal_freq = READ_ONCE(cpudata->nominal_freq); nominal_perf = READ_ONCE(cpudata->nominal_perf); max_perf = READ_ONCE(cpudata->highest_perf); @@ -683,36 +685,25 @@ static int amd_get_max_freq(struct amd_cpudata *cpudata) static int amd_get_nominal_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; u32 nominal_freq; - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - if (quirks && quirks->nominal_freq) nominal_freq = quirks->nominal_freq; else - nominal_freq = cppc_perf.nominal_freq; + nominal_freq = READ_ONCE(cpudata->nominal_freq); return nominal_freq; } static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) { - struct cppc_perf_caps cppc_perf; u32 lowest_nonlinear_freq, lowest_nonlinear_perf, nominal_freq, nominal_perf; u64 lowest_nonlinear_ratio; - int ret = cppc_get_perf_caps(cpudata->cpu, &cppc_perf); - if (ret) - return ret; - nominal_freq = READ_ONCE(cpudata->nominal_freq); nominal_perf = READ_ONCE(cpudata->nominal_perf); - - lowest_nonlinear_perf = cppc_perf.lowest_nonlinear_perf; + lowest_nonlinear_perf = READ_ONCE(cpudata->lowest_nonlinear_perf); lowest_nonlinear_ratio = div_u64(lowest_nonlinear_perf << SCHED_CAPACITY_SHIFT, nominal_perf); diff --git a/include/linux/amd-pstate.h b/include/linux/amd-pstate.h index 7b2cbb892fd9..1fbbe75c3dcc 100644 --- a/include/linux/amd-pstate.h +++ b/include/linux/amd-pstate.h @@ -88,6 +88,7 @@ struct amd_cpudata { u32 min_freq; u32 nominal_freq; u32 lowest_nonlinear_freq; + u32 lowest_freq; struct amd_aperf_mperf cur; struct amd_aperf_mperf prev;