Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp209725lqp; Tue, 11 Jun 2024 01:57:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBmAhdoauPgBG3ZeGa+w3ZKjve5q5uESLnUeznXol42+8bI0BZL5xu+xkbqNwfRdaaNeYX6/UlipMbSqrhPEhv1lWrSwy/hYytqF+2Bg== X-Google-Smtp-Source: AGHT+IHXqG8Ix4iy79G9a0nS29S+tAVctkw1+HMmeGtKfFO/XziAHsadGROUjrHjBit6pKnFSNKJ X-Received: by 2002:a05:6a21:3294:b0:1af:86da:3f7 with SMTP id adf61e73a8af0-1b2f969ed9bmr11724786637.4.1718096234149; Tue, 11 Jun 2024 01:57:14 -0700 (PDT) Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f723f2e59esi17428065ad.372.2024.06.11.01.57.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 01:57:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=oblhHj9t; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-209525-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209525-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E3F4E28B1D1 for ; Tue, 11 Jun 2024 08:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6FBBB176ACA; Tue, 11 Jun 2024 08:53:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="oblhHj9t" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) (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 B72D1176ABE; Tue, 11 Jun 2024 08:53:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.85 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718096001; cv=fail; b=K6GBNYkq3+pUh7pEkSbpR9foPXuOrC/GKywXqgHIdxAff5peNI50bYfzjbM+DM85l1f1TTJWzpuRXgIZpvB9L80zxC9LNaWKkdvRL9ap1zsoM9tEWzQV25EvqzIMs+esARiuPVwjWx3g78EsTkhA97WLUzjOUIJxp2Xu0JOUoQU= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718096001; c=relaxed/simple; bh=5FiSM+uQeOZpz8v498h6TTQvnoVU4ruREKDIyzmEzCg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n66ILshhZkxVS2TSZGh61x0im4409wVM7hQRpeNFf0OT0ddJR+KNYzVUvYnAKuh7/7xEXljbLFUiiFw7I9box14/zVzAVNQ9sk4j6BPMoSOJv1T6/+Ju0atH0XkCwbSoi4TUXLGEpGPQnJrB78K5RZavs5dQ1PBrQiwdS05/hoc= 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=oblhHj9t; arc=fail smtp.client-ip=40.107.244.85 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aYWf/0BcmdA2R17Kx6NSk/qMZ9RYyD70TjJu+sY9mQb2TatiqSab3BoXk+eVc8iqqprQbOznh9PRHfMcKzM1agQmWRNTyuN/YM7kJRnRX+SzA5jgNfi/qAQSrT7kaiwTUFhKlr3+Y771M+UWQW96tNPYQb55jbjvZBN6wbvXY/vH978t52G72zIsNgkK3ySvuIBXL3Eh/6eJpbIO516b9THbmdeKbbudQtrnK/Zqq/XzBqw4kouhwbiF9qrHwCLG5FWfheWvnzUGaUZtjZLb7xxnqUrjpwUClw+dg61gmVqj33qRk65jytZSdSuJMGyxldGFE7Vv3jVqFLFj1W7Sgw== 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=sQyzJaOne+We6n1n2nOcSNThxpN75QCZB9oSmSOaKKg=; b=cRbfxRYdc+3D/vmQTO3y92174chcpOL2oRmaRUUmU14QDsLtqEMAR8vDRJuyXdfz6hOHO+Wb8UeFjQFnStouJQCpYjd8gmlrimvcjwxx9hgfoBDPHDREnzdzXwpht8+dYO2QftQOf6SSsdnak2RQGQfmuSNfA4dk1xtUdQgC75+s9M7CcEqgCDyzF7CKA2bCXllESyALULYb7hvgySbxk8e1K8xbpCnMo9oUaIKTUblgbx+N68Hm7F/4krWm/iuLBe1CoLo8bkG2/Ddx4WS37bhrtsRC682rWZ2qY7FARI4+Wk9TZwODGVgTfVUnZkzmQTbmjVwM/2PJL0OvUGqrXw== 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=sQyzJaOne+We6n1n2nOcSNThxpN75QCZB9oSmSOaKKg=; b=oblhHj9tCVBOyjFNPyNvFuiV+l1DhWVwY+2XMbUcYS72PdOKyYgf+6B2keFRi7KFThx1JU3UbE2W0Gbri0vW/Av7rJjcCeTBIbByHVqTHbCOk1cPjXuPydaczQQsAfMs1pN3lkXhxmln4PdWtnZmYcGi/ikFfhURT861ivCxjIs= Received: from SN7PR04CA0169.namprd04.prod.outlook.com (2603:10b6:806:125::24) by DM6PR12MB4105.namprd12.prod.outlook.com (2603:10b6:5:217::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.36; Tue, 11 Jun 2024 08:53:17 +0000 Received: from SN1PEPF000397B0.namprd05.prod.outlook.com (2603:10b6:806:125:cafe::b7) by SN7PR04CA0169.outlook.office365.com (2603:10b6:806:125::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.17 via Frontend Transport; Tue, 11 Jun 2024 08:53:17 +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 SN1PEPF000397B0.mail.protection.outlook.com (10.167.248.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7677.15 via Frontend Transport; Tue, 11 Jun 2024 08:53:17 +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.39; Tue, 11 Jun 2024 03:53:13 -0500 From: Perry Yuan To: , CC: , , , , , , , , , Subject: [PATCH v3 10/10] cpufreq: amd-pstate: automatically load pstate driver by default Date: Tue, 11 Jun 2024 16:52:26 +0800 Message-ID: <39b55abeb278d9ae1688c0b87cb7ec8a3e37932a.1718095377.git.perry.yuan@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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-TrafficTypeDiagnostic: SN1PEPF000397B0:EE_|DM6PR12MB4105:EE_ X-MS-Office365-Filtering-Correlation-Id: b6ebc321-1c81-4239-1339-08dc89f3effb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|36860700004|1800799015|82310400017; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?pQmjp36itnK94Lcc42GJ5krlSqcBSqFq1y9KAR5FhMi4PxBqdDhvBTHHU+t5?= =?us-ascii?Q?25SzsqekraIbfZ6CrifPiUNE6+Rkcb49QW2mRuGisDVvEhqjNo8tsZ8XqjWE?= =?us-ascii?Q?M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AV+Ab6sk1ipbx4kxkOMfF0XkMq+nL?= =?us-ascii?Q?NiNQpLA9hUwg/Y1Nxob2HMQqSWDDiT3JpG7Bo8Ce+5HK+0jeiu9w5/fUUlGE?= =?us-ascii?Q?EKmiZi+Jle2O5wMO7AapcgFUzL01tGnZwJvBrCp5Mlw7FUeFDUgrIxu/eoAN?= =?us-ascii?Q?RrW6narOG1JNQxQQfygWY1q0LhPEsSb+Kg5GibPxaFRqnGPYXiS5UzHYWvNL?= =?us-ascii?Q?xAgboDtmvTHkG8i4ZgVGjfPqr/PBnYh0J2SKjHbonqh1KI3rURnRTVm6+W2Y?= =?us-ascii?Q?K8BajzgK9OnBOIGgfeS920I41R4INO/RQb7gAud9bB0jy+qOv34kkXkUSGfY?= =?us-ascii?Q?jQmGcFk307XV/rPFFdIpODmw4Trm/gZzY7HlP/pvJThHetvuoA0UyU+0QteO?= =?us-ascii?Q?zWEpvHE=3D?= 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)(376005)(36860700004)(1800799015)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jun 2024 08:53:17.5253 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6ebc321-1c81-4239-1339-08dc89f3effb 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: SN1PEPF000397B0.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4105 If the `amd-pstate` driver is not loaded automatically by default, it is because the kernel command line parameter has not been added. To resolve this issue, it is necessary to call the `amd_pstate_set_driver()` function to enable the desired mode (passive/active/guided) before registering the driver instance. This ensures that the driver is loaded correctly without relying on the kernel command line parameter. Meanwhle, user can add driver mode in command line which will override the kernel config default option. [ 0.917789] usb usb6: Manufacturer: Linux 6.9.0-rc6-amd-pstate-new-fix-v1 xhci-hcd [ 0.982579] amd_pstate: failed to register with return -22 Reported-by: Andrei Amuraritei Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218705 Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index fa486dfaa7e8..6e5c398810bf 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1841,28 +1841,37 @@ static int __init amd_pstate_init(void) /* check if this machine need CPPC quirks */ dmi_check_system(amd_pstate_quirks_table); - switch (cppc_state) { - case AMD_PSTATE_UNDEFINED: + /* + * get driver mode for loading from command line choice or kernel config + * cppc_state will be AMD_PSTATE_UNDEFINED if no command line input + * command line choice will override the kconfig option + */ + if (cppc_state == AMD_PSTATE_UNDEFINED) { + pr_err("pyuan cppc_state == AMD_PSTATE_UNDEFINED \n"); /* Disable on the following configs by default: * 1. Undefined platforms * 2. Server platforms * 3. Shared memory designs */ if (amd_pstate_acpi_pm_profile_undefined() || - amd_pstate_acpi_pm_profile_server() || - !cpu_feature_enabled(X86_FEATURE_CPPC)) { + amd_pstate_acpi_pm_profile_server()) { pr_info("driver load is disabled, boot with specific mode to enable this\n"); return -ENODEV; } - ret = amd_pstate_set_driver(CONFIG_X86_AMD_PSTATE_DEFAULT_MODE); - if (ret) - return ret; - break; + /* get driver mode from kernel config option [1:4] */ + cppc_state = CONFIG_X86_AMD_PSTATE_DEFAULT_MODE; + } + + switch (cppc_state) { case AMD_PSTATE_DISABLE: + pr_info("driver load is disabled, boot with specific mode to enable this\n"); return -ENODEV; case AMD_PSTATE_PASSIVE: case AMD_PSTATE_ACTIVE: case AMD_PSTATE_GUIDED: + ret = amd_pstate_set_driver(cppc_state); + if (ret) + return ret; break; default: return -EINVAL; @@ -1883,7 +1892,7 @@ static int __init amd_pstate_init(void) /* enable amd pstate feature */ ret = amd_pstate_enable(true); if (ret) { - pr_err("failed to enable with return %d\n", ret); + pr_err("failed to enable driver mode(%d)\n", cppc_state); return ret; } -- 2.34.1