Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp444803lqo; Wed, 8 May 2024 04:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXZqWfrIcPBV1ZCURMpCTBKB+dlMVliKEBe30rHJhW/Y8zDA7JAQiUDqbZd+t5mZ0J/YX20TtJOcTUXfEb1Q4QfeR1hvjmN+VX3E7tPNA== X-Google-Smtp-Source: AGHT+IEgp59c0qgD0hiEz/ftj50TcC9DfproVdWgb7dBXiX3hu3dDKPoYGPDg9ulRxkkZ3KXaCqZ X-Received: by 2002:a05:6808:3ce:b0:3c8:4dcb:3d34 with SMTP id 5614622812f47-3c9852985d7mr2447024b6e.7.1715169557625; Wed, 08 May 2024 04:59:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715169557; cv=pass; d=google.com; s=arc-20160816; b=TJtNd/lWWQd1lwI27lX9WAsm175QzpWjQzoLPY62CGEPfB3xI0fJ15XfhCOqDrWG0t Swi8vD37nSRZRnfLz4GPul6Evs4lX06tgVN1S3Npqbr+AebUOyXm88WbLzvX1xE6hZ1C Img6EPWNpagTlVNUsASJQI2JLKoVkye9DEc+fhAUZH+0M0Vy88UzaRacr9LrvmqfiWLu thAUhOP4+XJNrq8wf06U5ghpL6NJr7AGZr5ak++70dggicnvrjf9If8KD+ubHZwH6PPK Ak8WivDxkxfH3wbg/9nYy7QE9J38bmXPrwaHi/XfyfZ3BXGbpJh00j7ZpgeV/iV39H0L wOsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=6LjPd2OMZFyIOyQAZXgyAYOWGthMmf7cgFW/TreDtLw=; fh=XyZ2eRODiuJEPItZoqRxXp7PPw75xvqcm9RYovOopdE=; b=m5yBdJSfHXBG2G6zVONhTC5bL8Y2zeefpmMKqOc4iAbbaMTBJygzgWxtrpzmyQd5Bs BNAhTV5O4GfJxfFrOZ4NDw2KxHSYaytCGGg7u2Ij2t+M5k1r57spwhjXva2ThujmwxX0 02j7eB71QhPbnB8f3DGBk0xLvPA02dGaSo31e5S/gMJ1IX2tIOsSdwwba6iWwQLa860k V3936DhkkWpilgBJUyHvY8UxkRikLeovDHuLpjgqOoLklfXnIIqnK73kUPmqoEP94AOA Hhc0XORL8SahcUhNn5oi7yes4A2FcPKIWiY76AgzJrhgL8bjFF0Now74Y6UTsj7LBH3n x7qQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RY9FAj5O; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-173190-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id pt17-20020a056214049100b006a0d56e4b2dsi12643600qvb.380.2024.05.08.04.59.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 04:59:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173190-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RY9FAj5O; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-173190-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173190-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 488CB1C21E70 for ; Wed, 8 May 2024 11:59:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FFAB839E0; Wed, 8 May 2024 11:59:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RY9FAj5O" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3A7BF7D405; Wed, 8 May 2024 11:59:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715169548; cv=none; b=gyMyunG32vXpGy29xSUID3xMc9JORnxR46EHBbwqs3uOtmt3foxKrQGKW/Kd72x5jHNz+Erq2fbRD/jbqLSSk+lfsKe9iJCyqgeOvv/OLb69fWZsGK6Dq7wRJIk1RrfIvC04kCN6Lq0TR/dKFFh5SkjTFbUPSpOFFb1k0Ozh7ao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715169548; c=relaxed/simple; bh=T2T1c8P9LRlCkGtHutSW1xZfS0Ui+J7aHG0ayh6G03M=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=plDHC3psxgQtjgu6nU3xqNdVGoXdZbQo05XgIevHrXSZDvt1hpfIPUOVsIus54gD7oc4VpQG0Je7B9/o1fTrl9IQP/xqZboPAaNNVlOd5/T7wKeEjbqfWiFP2BL1hv8ictiSepBnCtKYGGLuT7rRqETeJbSTgBAELjeWTcmQGmk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RY9FAj5O; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB465C3277B; Wed, 8 May 2024 11:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715169547; bh=T2T1c8P9LRlCkGtHutSW1xZfS0Ui+J7aHG0ayh6G03M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=RY9FAj5OA1K4QOc1q0QtUajpwyO5O5RK/eCTyskaCKB3O8cAUqoIB7coFkpbZytda skOZ2cvjAGEmOTnknibL2reyTQ871KbI7dKy43c6X+b+FcrEC0VdBTA0hyNboHGpIg tvBZA0ufLS0ICDlGgEqHFQNqX6Mm3tPTukSo0m0DyEHLh/W2/Ds3+hoQdc9AEg1FIN GJQRpvDbY7Ntwe/GsAXGDMQkhki902P4hAJy3D/+7+qzPrDNuxSpynJYHzQlVjC+7j Vlb3ehCzf4c/5CHw4sTuEGHCsUwcKniqJf+tC+KN1ymAD6pIqiHZcuR47iYHDuUylW 8mnIOEskWvzqg== Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5ad288442bdso483390eaf.3; Wed, 08 May 2024 04:59:07 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW9zH4vIcTe+gWqo9n+Oq57btcLBq9ieXDHxIyeP3KBDBTkpQPOpzNC1usQwRG1ZIbu/mgWQiC/9Z1HvIyoMVn140isd9MZvHcHYfaPxw35JNDYW7zVHOX5Pc4ialxiu3T0a9nlmJs= X-Gm-Message-State: AOJu0Yyi63v4oJ9Mpv1OLQI8kgEwGnUdmg7oQfgyu+nipqmibwsd7A7t kDRqb0KfvsBKV3OB06Xpy7InqdNIiHG2stmD1k2qQaaKnDLG0CmmvEUQbZYU/3cfrr5Gb/89oSF T78DWowkeuJPwi0x31ICFR2/1d4A= X-Received: by 2002:a05:6820:b05:b0:5aa:3e4f:f01e with SMTP id 006d021491bc7-5b24d47d89fmr2171435eaf.1.1715169547045; Wed, 08 May 2024 04:59:07 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240508054703.3728337-1-perry.yuan@amd.com> In-Reply-To: <20240508054703.3728337-1-perry.yuan@amd.com> From: "Rafael J. Wysocki" Date: Wed, 8 May 2024 13:58:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] cpufreq: amd-pstate: fix the highest frequency issue which limit performance To: Perry Yuan Cc: rafael.j.wysocki@intel.com, Mario.Limonciello@amd.com, viresh.kumar@linaro.org, Ray.Huang@amd.com, gautham.shenoy@amd.com, Borislav.Petkov@amd.com, Alexander.Deucher@amd.com, Xinmei.Huang@amd.com, Xiaojian.Du@amd.com, Li.Meng@amd.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 8, 2024 at 7:47=E2=80=AFAM Perry Yuan wrot= e: > > To address the performance drop issue, an optimization has been > implemented. The incorrect highest performance value previously set by th= e > low-level power firmware for AMD CPUs with Family ID 0x19 and Model ID > ranging from 0x70 to 0x7F series has been identified as the cause. > > To resolve this, a check has been implemented to accurately determine the > CPU family and model ID. The correct highest performance value is now set > and the performance drop caused by the incorrect highest performance valu= e > are eliminated. > > Before the fix, the highest frequency was set to 4200MHz, now it is set > to 4971MHz which is correct. > > CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ MHZ > 0 0 0 0 0:0:0:0 yes 4971.0000 400.0000 400.0000 > 1 0 0 0 0:0:0:0 yes 4971.0000 400.0000 400.0000 > 2 0 0 1 1:1:1:0 yes 4971.0000 400.0000 4865.8140 > 3 0 0 1 1:1:1:0 yes 4971.0000 400.0000 400.0000 > > v1->v2: > * add test by flag from Gaha Bana This should go into the section below the tags. And if you send a v2 of a patch, please indicate that this is a v2 in the subject. > Fixes: f3a052391822 ("cpufreq: amd-pstate: Enable amd-pstate preferred co= re support") > Closes: https://bugzilla.kernel.org/show_bug.cgi?id=3D218759 > Signed-off-by: Perry Yuan > Co-developed-by: Mario Limonciello > Signed-off-by: Mario Limonciello > Tested-by: Gaha Bana > --- > drivers/cpufreq/amd-pstate.c | 22 +++++++++++++++++++--- > 1 file changed, 19 insertions(+), 3 deletions(-) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 2db095867d03..6a342b0c0140 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -50,7 +50,8 @@ > > #define AMD_PSTATE_TRANSITION_LATENCY 20000 > #define AMD_PSTATE_TRANSITION_DELAY 1000 > -#define AMD_PSTATE_PREFCORE_THRESHOLD 166 > +#define CPPC_HIGHEST_PERF_PERFORMANCE 196 > +#define CPPC_HIGHEST_PERF_DEFAULT 166 > > /* > * TODO: We need more time to fine tune processors with shared memory so= lution > @@ -326,6 +327,21 @@ static inline int amd_pstate_enable(bool enable) > return static_call(amd_pstate_enable)(enable); > } > > +static u32 amd_pstate_highest_perf_set(struct amd_cpudata *cpudata) > +{ > + struct cpuinfo_x86 *c =3D &cpu_data(0); > + > + /* > + * For AMD CPUs with Family ID 19H and Model ID range 0x70 to 0x7= f, > + * the highest performance level is set to 196. > + * https://bugzilla.kernel.org/show_bug.cgi?id=3D218759 > + */ > + if (c->x86 =3D=3D 0x19 && (c->x86_model >=3D 0x70 && c->x86_model= <=3D 0x7f)) > + return CPPC_HIGHEST_PERF_PERFORMANCE; > + > + return CPPC_HIGHEST_PERF_DEFAULT; > +} > + > static int pstate_init_perf(struct amd_cpudata *cpudata) > { > u64 cap1; > @@ -342,7 +358,7 @@ static int pstate_init_perf(struct amd_cpudata *cpuda= ta) > * the default max perf. > */ > if (cpudata->hw_prefcore) > - highest_perf =3D AMD_PSTATE_PREFCORE_THRESHOLD; > + highest_perf =3D amd_pstate_highest_perf_set(cpudata); > else > highest_perf =3D AMD_CPPC_HIGHEST_PERF(cap1); > > @@ -366,7 +382,7 @@ static int cppc_init_perf(struct amd_cpudata *cpudata= ) > return ret; > > if (cpudata->hw_prefcore) > - highest_perf =3D AMD_PSTATE_PREFCORE_THRESHOLD; > + highest_perf =3D amd_pstate_highest_perf_set(cpudata); > else > highest_perf =3D cppc_perf.highest_perf; > > -- Applied as 6.10 material, thanks!