Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1319837pxb; Fri, 22 Jan 2021 12:31:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjVU2AfikR70D75OWnKz52/XOksq5KVPXHHOPdT3N5cN0VqB4KH9zV3T/7P+PSRRv2G62U X-Received: by 2002:a05:6402:404:: with SMTP id q4mr4708527edv.295.1611347509434; Fri, 22 Jan 2021 12:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611347509; cv=none; d=google.com; s=arc-20160816; b=CnIu7nJsOWz7Oru6wm4Z72jcX/v8157QgwEtL28WiZH97lCYyv3ThgJXBQQbVK/idS vspKpZis78EUyaBls5DajvMmwGndkj/QlZVpPg3I5vDxlOL3vFi6EaFqVcuRGmdnzwMX JRxFMHGKEZ0DeLGaQpudE3PX4dgDEyxTeGcukhB7FNlaZwqez26nqncgHtgJKvyg8iGH jWVUeUTMAbhjLHy0p6ZcmYI5lnb5cg9Hz1mx5DJyFxi4OLn6QCsGM9cXxEZkmIcFuebz h7xhAMScmdzV3my/fubX8FYL4aM5im08GVQ8fluJCccveXUoliMO2rwkls/vE9zj02kd k7+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=9zlW2lUUFq94a13H+Bafe0Un7K52KcvjGZoo5gL5FNQ=; b=KDpL03ozoRCn7DG1f8LVk6O5IVfj/Qw9MBmSFZPWZer1oRVg2FxUmR5k8/J/qoDAf8 SXw0FWGrIrr2oDK8Mm5S57LMVBtxa+ltf8mjRkmss2kG+XUrTZbJ/fA4IMU/ZJPUjpm6 z0NOLk5TYOg8P8xdzwR8VjjjperO9hzZAdcO+/X6XFNFqAtOGPkomr4UL3I0bLYsY5BL IPGNaGiSuCM6DlZm3RGbHSRCRAmabhVq65rs1vuz9DVmTUtFtzwtG3rNG3e0da99z7q2 3hVhdj7rgSSopztqCy6KAJ9LUwd94RqgYOiV7iBDSK8Qb3NG5XB6TaD4nxNZRimJfnAj wgOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b="DEcMA/aH"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si4060396edq.123.2021.01.22.12.31.24; Fri, 22 Jan 2021 12:31:49 -0800 (PST) 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=@linuxfoundation.org header.s=google header.b="DEcMA/aH"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730703AbhAVU34 (ORCPT + 99 others); Fri, 22 Jan 2021 15:29:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729912AbhAVU0b (ORCPT ); Fri, 22 Jan 2021 15:26:31 -0500 Received: from mail-io1-xd2d.google.com (mail-io1-xd2d.google.com [IPv6:2607:f8b0:4864:20::d2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50904C06174A for ; Fri, 22 Jan 2021 12:23:10 -0800 (PST) Received: by mail-io1-xd2d.google.com with SMTP id n2so13780336iom.7 for ; Fri, 22 Jan 2021 12:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=9zlW2lUUFq94a13H+Bafe0Un7K52KcvjGZoo5gL5FNQ=; b=DEcMA/aHIITXo2glOdJIFeUrpOemjBS4r4FO8QOL2msXtLnoofFI4wVgt5UIDcL4m7 d7olgXzRgwYuoYmlcH+/EFl39wMRVgFfH8k/CwWVcniw3/CTZvcCo3KU3/xcodqJo3vq Hd6aQc170oX51155kP7R5p03JpwS7m0Ke4fSQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9zlW2lUUFq94a13H+Bafe0Un7K52KcvjGZoo5gL5FNQ=; b=IjzhCkEFHldrlgMAyTq+aTA+RzBYcsDgL2L2Oh0q2ns+94r4t+Z9uWkqwgEirjQR0q Yi86zv1YYddIpvF5dMD1YYmtuNkJfb9FFbQF3NiLLMfaedqWOv7KwAb8P6R3kKPaEDd3 hJFcYrbojIIRN544UeKj+b4EwLgJU2aTXCsmODn1VrpTLZ58xt1f+u1rF9ASi223nPbU 3R18vi2guAtNOd9xYUC4ZATK+46Sy0GvZsMaKKo50YrJOOHRgciBYfw7PBFt8ZAFi5eS xyFaRqcsqfO121tFjQ1TQSrZeGFkwjUBoyT1kSdJfEKKOtBn4fY00fYBs3CjK7ZbySzr za9Q== X-Gm-Message-State: AOAM5333/it4Z/TQ3Wj2lzmjMY/scjclAgPsvtQBbI5CCROxATcUtY/K cpEQW71ttYVw+8pTFGERFVFNXg== X-Received: by 2002:a5d:8887:: with SMTP id d7mr4647810ioo.151.1611346989709; Fri, 22 Jan 2021 12:23:09 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id u3sm6684919ilg.48.2021.01.22.12.23.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Jan 2021 12:23:09 -0800 (PST) Subject: Re: [PATCH 3/8] cpupower: Add CPUPOWER_CAP_AMD_HW_PSTATE cpuid caps flag To: Nathan Fontenot , rrichter@amd.com, shuah@kernel.org, linux-kernel@vger.kernel.org, trenn@suse.com, linux-pm@vger.kernel.org, Shuah Khan References: <161133705833.59625.6935511700675018185.stgit@ethanol01c7-host.amd.com> <161133713035.59625.1577978944767511822.stgit@ethanol01c7-host.amd.com> From: Shuah Khan Message-ID: <512d7ad9-dac9-7e54-6afc-0bdf60eff8f2@linuxfoundation.org> Date: Fri, 22 Jan 2021 13:23:08 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <161133713035.59625.1577978944767511822.stgit@ethanol01c7-host.amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/22/21 10:38 AM, Nathan Fontenot wrote: > Add a check in get_cpu_info() for the ability to read frequencies > from hardware and set the CPUPOWER_CAP_AMD_HW_PSTATE cpuid flag. > The cpuid flag is set when CPUID_80000007_EDX[7] is set, > which is all families >= 10h. The check excludes family 14h > because HW pstate reporting was not implemented on family 14h. > > This is intended to reduce family checks in the main code paths. > > Signed-off-by: Nathan Fontenot > --- > tools/power/cpupower/utils/helpers/amd.c | 6 +----- > tools/power/cpupower/utils/helpers/cpuid.c | 12 +++++++++--- > tools/power/cpupower/utils/helpers/helpers.h | 1 + > 3 files changed, 11 insertions(+), 8 deletions(-) > > diff --git a/tools/power/cpupower/utils/helpers/amd.c b/tools/power/cpupower/utils/helpers/amd.c > index 34368436bbd6..496844a20fe2 100644 > --- a/tools/power/cpupower/utils/helpers/amd.c > +++ b/tools/power/cpupower/utils/helpers/amd.c > @@ -94,11 +94,7 @@ int decode_pstates(unsigned int cpu, unsigned int cpu_family, > union core_pstate pstate; > unsigned long long val; > > - /* Only read out frequencies from HW when CPU might be boostable > - to keep the code as short and clean as possible. > - Otherwise frequencies are exported via ACPI tables. > - */ Please update comment instead of deleting it. > - if (cpu_family < 0x10 || cpu_family == 0x14) > + if (!(cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_HW_PSTATE)) > return -1; > > if (read_msr(cpu, MSR_AMD_PSTATE_LIMIT, &val)) > diff --git a/tools/power/cpupower/utils/helpers/cpuid.c b/tools/power/cpupower/utils/helpers/cpuid.c > index f9a66a430b72..d577220a193b 100644 > --- a/tools/power/cpupower/utils/helpers/cpuid.c > +++ b/tools/power/cpupower/utils/helpers/cpuid.c > @@ -128,9 +128,15 @@ int get_cpu_info(struct cpupower_cpu_info *cpu_info) > /* AMD or Hygon Boost state enable/disable register */ > if (cpu_info->vendor == X86_VENDOR_AMD || > cpu_info->vendor == X86_VENDOR_HYGON) { > - if (ext_cpuid_level >= 0x80000007 && > - (cpuid_edx(0x80000007) & (1 << 9))) > - cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; > + if (ext_cpuid_level >= 0x80000007) { > + if (cpuid_edx(0x80000007) & (1 << 9)) > + cpu_info->caps |= CPUPOWER_CAP_AMD_CPB; > + > + if ((cpuid_edx(0x80000007) & (1 << 7)) && > + cpu_info->family != 0x14) > + /* HW pstate was not implemented in family 0x14 */ > + cpu_info->caps |= CPUPOWER_CAP_AMD_HW_PSTATE; > + } > > if (ext_cpuid_level >= 0x80000008 && > cpuid_ebx(0x80000008) & (1 << 4)) > diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h > index a84f85a9dbd2..5f61eefff5b2 100644 > --- a/tools/power/cpupower/utils/helpers/helpers.h > +++ b/tools/power/cpupower/utils/helpers/helpers.h > @@ -70,6 +70,7 @@ enum cpupower_cpu_vendor {X86_VENDOR_UNKNOWN = 0, X86_VENDOR_INTEL, > #define CPUPOWER_CAP_IS_SNB 0x00000020 > #define CPUPOWER_CAP_INTEL_IDA 0x00000040 > #define CPUPOWER_CAP_AMD_RDPRU 0x00000080 > +#define CPUPOWER_CAP_AMD_HW_PSTATE 0x00000100 > > #define CPUPOWER_AMD_CPBDIS 0x02000000 > > > thanks, -- Shuah