Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2782620lqt; Tue, 23 Apr 2024 01:02:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW03ZRvqmWiOw057f4KbzRscqtxypqNg9nZIGbTnp6aSihY8szHTIKzsZewPbBfIl9A22hk37sq+ydaZjbSJO+0lzhy+JTtZboythnu9Q== X-Google-Smtp-Source: AGHT+IF/TFf96HdvapgtDR8MsGnZd3Ay4KrA5oGvlsblVX2QGWNXHkBt3gLd32M1O4O0uvGpTH60 X-Received: by 2002:a17:906:eb4f:b0:a58:725b:9fea with SMTP id mc15-20020a170906eb4f00b00a58725b9feamr2071868ejb.21.1713859342456; Tue, 23 Apr 2024 01:02:22 -0700 (PDT) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x23-20020a1709065ad700b00a5235631222si6617616ejs.240.2024.04.23.01.02.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 01:02:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=rYxJTddu; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-154646-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154646-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 am.mirrors.kernel.org (Postfix) with ESMTPS id F28F91F2457A for ; Tue, 23 Apr 2024 08:02:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C4EB755C29; Tue, 23 Apr 2024 07:59:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="rYxJTddu" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2065.outbound.protection.outlook.com [40.107.236.65]) (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 4D01C54BFE; Tue, 23 Apr 2024 07:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.236.65 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859144; cv=fail; b=DFjl0saH0HxJwGGikBS4VmcKGlB9hOnM8X6dE6PV6RJPZR5JSPgVajEkfiwNEKScII0mZpzSNBTB6NjHirNtT0IvD7icUT4UEnZcdY156Ku7/J0B5x+Zd7EwE1P0xHpegdmducVVIgmqmCxXPlcU/qfptC1sTkFZWEz6JBaVPpc= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713859144; c=relaxed/simple; bh=OLudeT+1gijlMUi7TFfWkAzoR9bs8ojKSeLEe4FVrk0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bJst2oNIlrZzwrGwL99lv3q7iIfQsEXdPg/dO+++kopgrue6IeD+eGOPM++mgHBysyR3nH12sxhmHmgxRF7LOs9FM4l6J2PQFiyudA/rxlVKyj3PjJFeETvG+1GfwdxE9rzXhoGfEoWKFCGpt/XxGoZAVH81d25rouq3A0NdtSE= 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=rYxJTddu; arc=fail smtp.client-ip=40.107.236.65 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=L3sMrbUobNQnfSVIZJA3Qw6PDYiTXG9iHoSKGu0qJakyQlqR/vyPM9+loVI3SDKoTUBe4XdRRuUiSTu5/+IjuYJXpQmZqnFUYVM5sMi9EDrwgOqNrZr9Yyo2fUcKPYl3ghuHvkep33vNxLDfgbCKOel7jnA8lIKgAAkILil73giPU49WU1PdlLv7pPb68jFDPCWugGz5PzMBF1qD5uOrh4v0zeeG+1njMd+UfCAXnQcoTyHJaWPiW+efOBhl4f4evakB1elpCbL64wF69iFq90YqC0qIfVlRroDPoUMsbNr+EYiiZ3HgwGx2mja3PBDwlqx1V2MtJEeMkKUWYpqG4w== 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=0+TC2KATw7Hqz4WMVGydK+FfXr1FbAtVbdW2gRVy1Mw=; b=Miyoply3gTq5ALkBIHllc5SJeQkPIGPzrcaU9MHBJAdjwXCTKoL/eY1ltDgm0AihJ9UQuQeWRUAO8lnwrYQadMxitdPQRDt8aq07nplqABGu0NpiEgTLX+ShCbBV7qaUoZc/50vVvIpCJS73jhNDLOs8L4hYwT9wz4yCug3AIlx89BXVnPrmfuc4Rdch/RSyWqtknEEb/1xVL+aERRlnC7/cSj3vOWW3fyTfXqewzVzMxWo2yWGG0Z+NuBR9y6piQjY5lyIciUInOp5qKenMcFeS3xYJHY2UkSKZcXrzZIz/dN/rhmAD2zmUxfXq9PkiqtlR0c5mC/lR7RDFONDIKA== 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=0+TC2KATw7Hqz4WMVGydK+FfXr1FbAtVbdW2gRVy1Mw=; b=rYxJTddu4m+CVSq/txKJFKHY3XH51H3wYy/sF+vkjYTxXh+UiZTP5ZEbIsg8Nxf/ZfYQYxG1Vp+Ud00MX9jJ8HwOnxbIyJ1p1vIkVj4h+lOC22fERzxo//B4/EA9ncPwl+r+fMgFFqZ2TJLeBTL8ekEzoEItWN4nHRlLhAkTW2w= Received: from CH0PR04CA0108.namprd04.prod.outlook.com (2603:10b6:610:75::23) by CH3PR12MB8356.namprd12.prod.outlook.com (2603:10b6:610:130::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Tue, 23 Apr 2024 07:59:00 +0000 Received: from CH2PEPF00000140.namprd02.prod.outlook.com (2603:10b6:610:75:cafe::1c) by CH0PR04CA0108.outlook.office365.com (2603:10b6:610:75::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Tue, 23 Apr 2024 07:59:00 +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 CH2PEPF00000140.mail.protection.outlook.com (10.167.244.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Tue, 23 Apr 2024 07:59: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; Tue, 23 Apr 2024 02:58:55 -0500 From: Perry Yuan To: , , , , , , CC: , , , , , Subject: [PATCH v11 5/8] cpufreq: amd-pstate: Bail out if min/max/nominal_freq is 0 Date: Tue, 23 Apr 2024 15:58:21 +0800 Message-ID: <6f016bc90debb6fb590db105c32ac9456c6ce490.1713858800.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: 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: CH2PEPF00000140:EE_|CH3PR12MB8356:EE_ X-MS-Office365-Filtering-Correlation-Id: 02ede79f-8af4-4dc1-7295-08dc636b3c25 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?uhzQIVfrcVUNv9A/xIyNA4MAzXg1BYfCFZKGzXnZKQFqtvv017o3nmNR78hT?= =?us-ascii?Q?KXKgpTEWgpAFVgC7kNzsfNhlcRfcgENx8rNaQEBFL7TDpZ7WY9oM5ezfWteC?= =?us-ascii?Q?neAXl28alEG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6h0Nb1QVW?= =?us-ascii?Q?XsEBDZrvEBIMnj4O6Vw8r1+sLricJA1RIMWqi7PMlK56qpdTovEZzdOW1DoE?= =?us-ascii?Q?Ud4xzi6T+gh8Pbjo3UQb9twYzYfqWI8fkhp0gp0r36ZgPkh8w7slehPNFxYr?= =?us-ascii?Q?gXH6VfkNNzBtmnCRlcbmf72Oq7XHrPi2JasXCf+QAY2ur/uMWB07L+Ya5V9I?= =?us-ascii?Q?Ck0uM0wXnV9WNFgX49D2e18Jgz9NpCbcbzP0a7wvdmnd1opKcOqjU2gHQ6Zv?= =?us-ascii?Q?4+AuvXTW01jDoKf4CEAMbPbCqoEFnIg46XZgTEitF/2gnfH8ycwychkJyt+E?= =?us-ascii?Q?fjDT+nrkT2+XePMXibjb1Zivb+zubWQFwx7bw+xL33ZCNuXsOYph2eWAy1gf?= =?us-ascii?Q?M+YveF4=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)(82310400014)(376005)(1800799015)(36860700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Apr 2024 07:59:00.0880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02ede79f-8af4-4dc1-7295-08dc636b3c25 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: CH2PEPF00000140.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB8356 The amd-pstate driver cannot work when the min_freq, nominal_freq or the max_freq is zero. When this happens it is prudent to error out early on rather than waiting failing at the time of the governor initialization. Acked-by: Huang Rui Reviewed-by: Gautham R. Shenoy Tested-by: Dhananjay Ugwekar Signed-off-by: Perry Yuan --- drivers/cpufreq/amd-pstate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 3836d62b54ef..960fead0b83e 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -839,9 +839,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - 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 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq (%d) value is incorrect, check _CPC in ACPI tables\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } @@ -1299,9 +1301,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) max_freq = READ_ONCE(cpudata->max_freq); nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - 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 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect, check _CPC in ACPI tables\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } -- 2.34.1