Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp385945pxb; Thu, 9 Sep 2021 03:15:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcrEA5bwEZ6MkwBX860MwtbtL19nMaZtxEfLOJjEkHUp587CTiB3K4njMTilBCqMkK2PS6 X-Received: by 2002:a92:d752:: with SMTP id e18mr1840424ilq.254.1631182502902; Thu, 09 Sep 2021 03:15:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1631182502; cv=pass; d=google.com; s=arc-20160816; b=05rJO18GxQG8e7s9nq1X3uYX4CUY0UUTFF65lc0Fw3ec9As/ABc/T5f1VRNpkgsTFa QbqxDKuKjzfwKjtiuxTpdZ9OtXA+kIYtVGs5rc3o4G/oCbjTe5h4tZtXOzKG6xU3oSM1 gDQlS1XVZvf4DRQhO7f+oztEBbvhX0daPs9WNn6qxzFHvRiZ7NxShdw6Vs2YWU53FbDY HaU522tIH/2p2oI9h0H8IDjFPFNnI5HF4aDvnMd6A2Sl9srWK4t2l6MfyOFImhLm5SMo YmTFgKxoe/XIrOVU7l95cin0VZZ5UIj9Kqrku/T/HpXnECuP5twdcUFLsxapGMuSDZND fNKw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w508ZaL1ZoIpEhRxkDCJ4Yu40WkhzNdXVU+J9ivvXaA=; b=g95Vo/Ea0Yjc79OWwZXGEKqaGEzZjzRSSLRVJgpUIE+XdauHLhSGCk6wzQUhqNHwGa dBQ7AEz6/m2+LpQnU9WPmw/ZJYnM7THjBi5nSccygIt/UhFods2qsYbDYQj9jLssPk2h tvTz9Y0L+0B3OXvuGGBlAfQVlNhFG3KakaYucT1QS+x9vj9p7NkLdA3W1fSMuMOBWjW4 hZsvoJNrl6GFN2CqxobJJ8LRqOZo+B4+sIB5rdLFGvfYcibbM9hC7rUh0m+UCnunok8x NNDLq84cFBTtHbIdM42r3vPb8KLvbB/i5JqPONBfTmXiaDH4bmnEAfCbe+6Y7EHlvesi Lz1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=DqP6xztI; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i62si1166982iof.83.2021.09.09.03.14.51; Thu, 09 Sep 2021 03:15:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=DqP6xztI; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbhIIKO7 (ORCPT + 99 others); Thu, 9 Sep 2021 06:14:59 -0400 Received: from mail-dm6nam11on2082.outbound.protection.outlook.com ([40.107.223.82]:52929 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229980AbhIIKO5 (ORCPT ); Thu, 9 Sep 2021 06:14:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FOYOhFLVoekUFXeusZb0cXysqEUI+znZuUrm88KUM29HE2KU7FpB4hqYsb1ZLZj7CKHsN+lhs3KAj4v+HIgSn1mEBv1xQDvNYqPTRwg7Aa34Tp6hA4zxekPPY+0er92VFkBBD4MSEg2zYvPpLnvqiAHwu+DvWzsVS4QMV55dlx/fiB7sMt07Gl14AXNyiATNyS/LJwnOaBjY+gjQSjsRPMe4fiYfGkyMmZeK3t9To0txzT8U9rtCP/oEADvjW2yLiocKYkMZoOs0LT8/HGD58FYupllK99zKALwg2NYXHkR+RFjRPN1YKqDEGImMG0KFZPtgVEppctd98TKPfy7OJQ== 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; bh=w508ZaL1ZoIpEhRxkDCJ4Yu40WkhzNdXVU+J9ivvXaA=; b=bPQROX1UoZBXP+OUEqUE5f/m4rj3H5Xd0IHKkIu6IONF9SEc5fv6/0SIQAFrqc5JdZD4DcbMiYk56bC3TjVnMc5elU0SDf4fi2ICb5H3GmqtlYOXbT7umX+LGF2xidDIkJ59vojhWxPK83yfp6gbQf4/UqhJug828tbopUQ3Z1wXix+xZZYAyU080siLDz3tLAQu/Po1MAvI22VQmj/0kxYOGt355oqs39tJfyNiNpr700taFV05174jFDAi53UlcsZy2O0tfG6ezdMhAe2tJ9r5MWit6FmQI+jg2azjSEWTCzjhbmLZr3sDTE08oO1iHiuWjtvBMTyRIqNojWbAcg== 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 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=w508ZaL1ZoIpEhRxkDCJ4Yu40WkhzNdXVU+J9ivvXaA=; b=DqP6xztIcORwrwOb/8t2MvwEFnvRJD+5dhKctegR2U2zH7mcPCrMENTURiVErwe6jlrnAQXSbKUdF/Jm6ypvX1rDsLqjGDeM5aUxlcZ6hUi48g5n0X3eew47FELNBzYfYk0HAvOT9MTr8vE3r6qRe/kgQyJeNDz9YncUzDNfIHU= Received: from DS7PR03CA0024.namprd03.prod.outlook.com (2603:10b6:5:3b8::29) by DM5PR12MB1338.namprd12.prod.outlook.com (2603:10b6:3:71::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4478.22; Thu, 9 Sep 2021 10:13:47 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b8:cafe::f1) by DS7PR03CA0024.outlook.office365.com (2603:10b6:5:3b8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16 via Frontend Transport; Thu, 9 Sep 2021 10:13:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; intel.com; dkim=none (message not signed) header.d=none;intel.com; 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; Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 10:13:47 +0000 Received: from hr-amd (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.2308.8; Thu, 9 Sep 2021 05:13:43 -0500 Date: Thu, 9 Sep 2021 18:12:48 +0800 From: Huang Rui To: "Fontenot, Nathan" CC: "Rafael J . Wysocki" , Viresh Kumar , Shuah Khan , "Borislav Petkov" , Ingo Molnar , "linux-pm@vger.kernel.org" , "Sharma, Deepak" , "Deucher, Alexander" , "Limonciello, Mario" , "Su, Jinzhou (Joe)" , "Du, Xiaojian" , "linux-kernel@vger.kernel.org" , "x86@kernel.org" Subject: Re: [PATCH 08/19] cpufreq: amd: add boost mode support for amd-pstate Message-ID: <20210909101248.GE3702717@hr-amd> References: <20210908150001.3702552-1-ray.huang@amd.com> <20210908150001.3702552-9-ray.huang@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Originating-IP: [10.180.168.240] 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-Office365-Filtering-Correlation-Id: 520be7cd-dafa-4b79-acd1-08d9737a832d X-MS-TrafficTypeDiagnostic: DM5PR12MB1338: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IZ3Hb5wPH43w01HWNjfBkiVnuPDNSYGspv44i9fFYiP1gW6yA/mlaTy6SRYXOUqkzA/mVY4F8tD3G/IWomo89T0TjXHmv9M/Ku+HeXyfo60PFGLKg1le5lHtH7WV7Yllhr44HXJcPLnKvje/WFYyI3lWz5L6gzSkKgCiD/02ObPM3RpBYo2UZfFs/BoYigoldLaQLwIsZeej/LIlAqTjChQkRWGh6STRCCdVxvgIHaJM1E6IwbTT6RueUiSpz0LwbUM5W0TF6Kraj9Uu26yBmi3okqR4qz/qMHMi2aWFjIO/QYQtgrUYYaz5y1q+v499dbCHgUv0RaKF5W8uaRIO91TNZzLPJbehJmmYzhAcJfVpJ6zs6WLWeFqadNBrE3Gi9kkZhYmFCUEHRsSvcBn558hYnZl0M8IBtNb5kdpK/fZAGg2EXB7mpbXJ08isfLzTT898MPPo6OoYo2qSGHg8bmL1H56Q0S+NoiEVOPiHLe0zoMlenbg54R9qvjVLWbxBmOmIxcVYU4KiEoMpmsgEyfHV/ZUdBddMfZ02gKfBcCZP4bi5+ntr3bC2PUx7FLtZnAKCJYB/F4HQ3xvzmkOoRso6FONnwywEeTQszu/pfTFm222GFCNfHBt/nKV9e42SjUctHFdGO675SwP+bbkuLI0sBXBMdYDrqpfslPS+8nhmF/aVjypoWNmW3RgjHZXpC1gQj3GGLPqTAO3YbTd04WrEQqGjJ7tpKK4Tzz6KZP8= 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:(4636009)(346002)(39860400002)(376002)(136003)(396003)(36840700001)(46966006)(86362001)(33656002)(356005)(81166007)(2906002)(55016002)(36860700001)(8936002)(82740400003)(8676002)(426003)(336012)(1076003)(47076005)(316002)(33716001)(9686003)(54906003)(4326008)(6862004)(70586007)(82310400003)(70206006)(53546011)(16526019)(186003)(478600001)(6636002)(83380400001)(5660300002)(26005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 10:13:47.2729 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 520be7cd-dafa-4b79-acd1-08d9737a832d 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1338 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 02:24:54AM +0800, Fontenot, Nathan wrote: > On 9/8/2021 9:59 AM, Huang Rui wrote: > > If the sbios supports the boost mode of amd-pstate, let's switch to > > boost enabled by default. > > > > Signed-off-by: Huang Rui > > --- > > drivers/cpufreq/amd-pstate.c | 50 ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 50 insertions(+) > > > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > > index ea965a122431..67a9a117f524 100644 > > --- a/drivers/cpufreq/amd-pstate.c > > +++ b/drivers/cpufreq/amd-pstate.c > > @@ -75,6 +75,8 @@ struct amd_cpudata { > > u32 min_freq; > > u32 nominal_freq; > > u32 lowest_nonlinear_freq; > > + > > + bool boost_supported; > > }; > > > > struct amd_pstate_perf_funcs { > > @@ -229,6 +231,19 @@ amd_pstate_update(struct amd_cpudata *cpudata, u32 min_perf, > > max_perf, fast_switch); > > } > > > > +static bool amd_pstate_boost_supported(struct amd_cpudata *cpudata) > > +{ > > + u32 highest_perf, nominal_perf; > > + > > + highest_perf = READ_ONCE(cpudata->highest_perf); > > + nominal_perf = READ_ONCE(cpudata->nominal_perf); > > + > > + if (highest_perf > nominal_perf) > > + return true; > > + > > + return false; > > +} > > + > > static int amd_pstate_verify(struct cpufreq_policy_data *policy) > > { > > cpufreq_verify_within_cpu_limits(policy); > > @@ -402,6 +417,37 @@ static int amd_get_lowest_nonlinear_freq(struct amd_cpudata *cpudata) > > return lowest_nonlinear_freq * 1000; > > } > > > > +static int amd_pstate_set_boost(struct cpufreq_policy *policy, int state) > > +{ > > + struct amd_cpudata *cpudata = policy->driver_data; > > + int ret; > > + > > + if (!cpudata->boost_supported) { > > + pr_err("Boost mode is not supported by this processor or SBIOS\n"); > > + return -EINVAL; > > + } > > + > > + if (state) > > + policy->cpuinfo.max_freq = cpudata->max_freq; > > + else > > + policy->cpuinfo.max_freq = cpudata->nominal_freq; > > + > > + policy->max = policy->cpuinfo.max_freq; > > + > > + ret = freq_qos_update_request(&cpudata->req[1], > > + policy->cpuinfo.max_freq); > > + if (ret < 0) > > + return ret; > > + > > + return 0; > > +} > > + > > +static void amd_pstate_boost_init(struct amd_cpudata *cpudata) > > +{ > > + cpudata->boost_supported = true; > > + amd_pstate_driver.boost_enabled = true; > > +} > > + > > static int amd_pstate_init_freqs_in_cpudata(struct amd_cpudata *cpudata, > > u32 max_freq, u32 min_freq, > > u32 nominal_freq, > > @@ -504,6 +550,9 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) > > > > policy->driver_data = cpudata; > > > > + if (amd_pstate_boost_supported(cpudata)) > > + amd_pstate_boost_init(cpudata); > > Is there any reason to not merge amd_pstate_boost_supported() and > amd_pstate_boost_init() into a single function? I don't see that > amd_pstate_boost_supported() is called anywhere else. > Sounds reasonable. Will update it in V2 as well. Thanks, Ray