[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/3] x86/cpufreq: Clean up powernow registration
- To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Mon, 15 Nov 2021 10:27:11 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- 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=pmS1lMnLnUdt7WXPvc818TlVi0YYLZq2TWXqSjbGlSk=; b=cVSV0D/ENIo3QAPQ+P9Zoz1PzuUHlwagTPkEkRM5OBs2JgAzPDao4S1B4vl4y1pNMBH7G/B64kIzrmUnTlyxNJaCkhvC3CCvY0mzpaA31QKcyIscu5Ww29aUK2kaHqpoah5dMbJo0tI7FtP9jHOWOqDJDdCLsEVebp61WSxuF/dMvIsIxSPxYdHEBlh2VhKR0juSJXHcu2G1y8nzvi2hYyWG/cI+sA+BTXwd31P5w6QHwkLyw6LmYAP0tMTREdW4v292YqOawKxIn++Q+RL3R3YJC42awZgyBHWpsu+nKULw8Vvpq7kC+XYCOInXefwfOF0AeqcSVpsucTRHX8gabw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HZ4SmuAddvNms+TYQJu5zZUPcmAGhHv8f6zFEHOKbY7i9bBc97AtHbghQM15WlLocX/dGZjSZN6zrhxs5EviTbsbLBtW814OiBDlOqFjYVq677Ch3LPJ+TDWXhS+xh3twCsccJ4NqBH3Hy+4zy+RnvhC/EL+4uWftF4b1H4HkP6g86729NVuZfeO6Ae8tosA9IVE2YHX2ODNvmvpf0PDxdoJ8qPs6sIZ8XV4CZ6h7oKYKBx49xzB3Koe26y05sXL1hMTRYOGYzwvbYg/Adjr2RovHn6qUGLI6fQdfDpOOwJg8k+FH35qrXMsVK/0VObUwXGItIZFbR44dHyE1V/76A==
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 15 Nov 2021 09:27:32 +0000
- Ironport-data: A9a23:PcDk76CfGy4tpRVW//jkw5YqxClBgxIJ4kV8jS/XYbTApG8hhGMAm jBKCGiPOK2MYzehe48lb4XioxwGsZSBn4JmQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLGs1hxZH1c+EX540E87wobVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/zGyousJv2 eh2sd+xWzUFDq/jyPUtTEwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHvqVuoMBhW9YasZmAKqPP OQBWyJWazuaTAZiHg8oEak1pbL97pX4W2IB8w/EzUYt2EDMyCRh3b6rN8DaEvSob8hImkeTp krd4n/0RBodMbS32TeDt36hmOLLtSf6Q54JUq218OZwh1+ezXBVDwcZPWZXutHg1BT4AYgGb RVJpGx+9sDe6XBHUPG6BjydsmCVgyUYGNtCIcEK6i7d25rLtlPx6nc/chZNb9kvtckTTDMs1 0OUk96BOQGDoIF5WlrGqO7K8Gra1Tw9aDZbOHRaFVdtD8zL+dlr1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dzM4dtmGg+eOuIPtYBYACRJiwA6SjQmw4Lq/NxSDxB8RXx5G3L9nqA H+4kDEz5Tml8v+5g7X1mfV4ZgTsNz9yuFbDMjJrsQOMD3jhiuheYwkcbyfuzIepv2p9T8R4Z TxiiZlG/42x2Laf2mzrxeo8w780Aw243un8lOciWuLm72xeBsKT+56wa5JeBrQ7EQt+Ptm1r hQ4m6fv51LSTvdgSXU/bHzJlBXv3vxhUBnvf8YjnRZX4dbQqRWt5Yj8ERcF4pFND7m6bogDP JlAKjnlbhrmGuhHjPkV1RUsZ6RtixZJGbCfqFCgL3b79FupgE486NCr/Zv2kvp9/oGOu95Dq r/Q+NVfYp1P70rhJRGdZA8qPuMex/wqC33QRevyHTcZek60iH22tXKCItc3pDfRHVP9up1pK j8
- Ironport-sdr: NpEGXB/rX/yWRBv+l7j7N/OgQ0xQ1hB1IDvuYTnPzvDfJsSVXwaaqkKwkDgEXEHSYgRWtCsUqb UZi0p2P0wxZ7e/pDhTo9B4tKDf4jqIg0UkHVvXBhcTA+uSQEiiyCOZa881kIdBNtIl3h4uoPhQ 8O0FoiXuOYZqERepbu1fkSjx/NPKftwvBgOTKyWOYvxjPiQBdWLrkOZPlEMHfpFiv6f2KFCzto 3jnBUWPbp+vnN2DkLgCiYuDgpajBu/bC9ybY+jQhFcbNv7kLDlefgKAJK6E1uG+0Q/wtSTxyxm LHvfLlGgLtQj9roPw3IGHung
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Fri, Nov 12, 2021 at 06:28:16PM +0000, Andrew Cooper wrote:
> powernow_register_driver() is currently written with a K&R type definition;
> I'm surprised that compilers don't object to a mismatch with its declaration,
> which is written in an ANSI-C compatible way.
>
> Furthermore, its sole caller is cpufreq_driver_init() which is a pre-smp
> initcall. There are no other online CPUs, and even if there were, checking
> the BSP's CPUID data $N times is pointless. Simplify registration to only
> look at the BSP.
I guess an extra safety would be to add some check for the cpuid bit
in the AP boot path if the cpufreq driver is enabled.
>
> While at it, drop obviously unused includes. Also rewrite the expression in
> cpufreq_driver_init() for clarity.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> CC: Wei Liu <wl@xxxxxxx>
> ---
> xen/arch/x86/acpi/cpufreq/cpufreq.c | 20 +++++++++++++-------
> xen/arch/x86/acpi/cpufreq/powernow.c | 28 ++++++----------------------
> 2 files changed, 19 insertions(+), 29 deletions(-)
>
> diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c
> b/xen/arch/x86/acpi/cpufreq/cpufreq.c
> index f1f3c6923fb3..2251c87f9e42 100644
> --- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
> +++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
> @@ -640,13 +640,19 @@ static int __init cpufreq_driver_init(void)
> {
> int ret = 0;
>
> - if ((cpufreq_controller == FREQCTL_xen) &&
> - (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL))
> - ret = cpufreq_register_driver(&acpi_cpufreq_driver);
> - else if ((cpufreq_controller == FREQCTL_xen) &&
> - (boot_cpu_data.x86_vendor &
> - (X86_VENDOR_AMD | X86_VENDOR_HYGON)))
> - ret = powernow_register_driver();
> + if ( cpufreq_controller == FREQCTL_xen )
> + {
> + switch ( boot_cpu_data.x86_vendor )
> + {
> + case X86_VENDOR_INTEL:
> + ret = cpufreq_register_driver(&acpi_cpufreq_driver);
> + break;
> +
> + case X86_VENDOR_AMD | X86_VENDOR_HYGON:
This should be two separate case statements.
With this fixed:
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
One rant below about getting rid of powernow_register_driver.
> + ret = powernow_register_driver();
> + break;
> + }
> + }
>
> return ret;
> }
> diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c
> b/xen/arch/x86/acpi/cpufreq/powernow.c
> index f620bebc7e91..80095dfd14b4 100644
> --- a/xen/arch/x86/acpi/cpufreq/powernow.c
> +++ b/xen/arch/x86/acpi/cpufreq/powernow.c
> @@ -24,13 +24,9 @@
> #include <xen/types.h>
> #include <xen/errno.h>
> #include <xen/init.h>
> -#include <xen/delay.h>
> #include <xen/cpumask.h>
> -#include <xen/timer.h>
> #include <xen/xmalloc.h>
> -#include <asm/bug.h>
> #include <asm/msr.h>
> -#include <asm/io.h>
> #include <asm/processor.h>
> #include <asm/cpufeature.h>
> #include <acpi/acpi.h>
> @@ -353,25 +349,13 @@ static const struct cpufreq_driver __initconstrel
> powernow_cpufreq_driver = {
> .update = powernow_cpufreq_update
> };
>
> -unsigned int __init powernow_register_driver()
> +unsigned int __init powernow_register_driver(void)
> {
> - unsigned int i, ret = 0;
> + if ( !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
> + return -ENODEV;
>
> - for_each_online_cpu(i) {
> - struct cpuinfo_x86 *c = &cpu_data[i];
> - if (!(c->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)))
> - ret = -ENODEV;
> - else
> - {
> - u32 eax, ebx, ecx, edx;
> - cpuid(CPUID_FREQ_VOLT_CAPABILITIES, &eax, &ebx, &ecx, &edx);
> - if ((edx & USE_HW_PSTATE) != USE_HW_PSTATE)
> - ret = -ENODEV;
> - }
> - if (ret)
> - return ret;
> - }
> + if ( !(cpuid_edx(CPUID_FREQ_VOLT_CAPABILITIES) & USE_HW_PSTATE) )
> + return -ENODEV;
I wonder if we could move this check into cpufreq_driver_init and get
rid of powernow_register_driver.
Thanks, Roger.
|