Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp915422pxb; Thu, 9 Sep 2021 15:18:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwESxZJrVgcMJ/cQsuc0NV3jv7iE1MUwqcS5x5vk0W7cQPfE+6Qi6MQ6cYf40OmzsMvs8/V X-Received: by 2002:a6b:e012:: with SMTP id z18mr4399912iog.26.1631225879905; Thu, 09 Sep 2021 15:17:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631225879; cv=none; d=google.com; s=arc-20160816; b=J5RHuGzOwlvAT4GYtFytBfbSQv9A1RxZDDiwCBBd/5Q5cIlhmGqeDd3bR2eue3ilIM JYTvX2AJ3ifLyEwjmAa4l9M9u2aFslq6ZKvnE2QwctMqLzkM61qfdmpjQfevAlnvgoES JxS4P5cR1jfZs9kkb6Mlc+0tTcsN7en1HkjhYypxDY1yOz/qzwyvWYdjY8X0BXFnS8xN AcBzJYSpXIFM4XvOwQhlq9oMSOOLWpALmMvVw54p7Qq51L4vO6Kw35ncVRVh6ivTMIgh TBKUu3eLBv/fsgGJmnsDbeZnvhtvZzhm1tJsHbmEGOgr6OxCHlHgPC80oty2yhF1+PlP WiEg== 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 :cc:to:subject:dkim-signature; bh=zM0IXLI05yVZi63Lak4d4tbjRWxjsfvz5YtFG0Gz+D8=; b=TCcf51BT2vqj4plPjp8M1geLy6MdHOCexYiZWcGn5PsZhA9Tze9cr5qlClPnTn9xWY M1jbAug+9OrcVjcSReDTmM6E4dby7V11Yd4WH3QeAcTEQz56bjidI7COcyy44bjYEbBK r429BCnvv//3ZydkBn2hfKzkU0MGbDpSwKVIWFKMs8s0PwOKmRy9VI9epH3bVeaJR/64 UyBiiY9Ws6IWTTxLidKc7VI7my0bG+5fQB1JnPn/jgBPPgcoOECG0wADP3Gm1zZeGvlR tt1S02AbwjRCWt0TdLqbkbWqiw8Fg6yDFzKBB/2zutoGFGg1dYcSaVCUcgw3yjkuOJ1R V5bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Klq23GFl; 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 d8si3216591ila.45.2021.09.09.15.17.47; Thu, 09 Sep 2021 15:17:59 -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=@linuxfoundation.org header.s=google header.b=Klq23GFl; 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 S232273AbhIIWRe (ORCPT + 99 others); Thu, 9 Sep 2021 18:17:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343920AbhIIWRd (ORCPT ); Thu, 9 Sep 2021 18:17:33 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D75CCC061575 for ; Thu, 9 Sep 2021 15:16:23 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id b4so3565266ilr.11 for ; Thu, 09 Sep 2021 15:16:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=zM0IXLI05yVZi63Lak4d4tbjRWxjsfvz5YtFG0Gz+D8=; b=Klq23GFlF4B4Y5HCGn+DgkvtGBGsBjnEbsQnRQ/RRIpOlGNqGJZRa4rs0KRwaBu5fG GiY+fkfvWlriXkhiqXGrVy6nGM9+olox9Mlmhl/X9GlX4Fxd+h356qCcvDF4TJiZUfnF KkggHo5WpqhZDM/J0d7ef8l8qGeNiIsXAXEPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zM0IXLI05yVZi63Lak4d4tbjRWxjsfvz5YtFG0Gz+D8=; b=KIhbavynsPHnE2hsqPlCJQU1cWEgifOnyF5hMT/g4zeFcSZpXhjQyRldqogepb+pQo pKO9kLWKzYpXLL2kSxFDFQYCwsxHlEPFVmGrsBCIR2Lvx2QBN8gqloSwb9GwrKjG1Lsg JT/71upiNlYm3DX07cShKsFmHFZgOAahek4XxbOTPMtIU/6U/f8nUk/JAx4VfAaN+qge p4nutXy4ayUtydwIocW12OEU4ruKElEdjN7bnHFGt9QIRydcBK98Q1qeCEv92CdlAW+0 vuXtatTp2fOe4LnFVX4I//lCBgXFGICQmnmcK/kF3worCLngFZjsf0L3KzxG85lbChce 5AFA== X-Gm-Message-State: AOAM531dFnkr6T9q/0XLzoUW5zdOpqmI6FCfCaT+h3lzVVG0J7R9Z7iC H2A5TvEZfm4X8FVlgkucDR5QJfndbFxXKQ== X-Received: by 2002:a05:6e02:5a3:: with SMTP id k3mr3856271ils.283.1631225783245; Thu, 09 Sep 2021 15:16:23 -0700 (PDT) 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 b19sm1543257ile.88.2021.09.09.15.16.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Sep 2021 15:16:22 -0700 (PDT) Subject: Re: [PATCH 13/19] cpupower: add the function to check amd-pstate enabled To: Huang Rui , "Rafael J . Wysocki" , Viresh Kumar , Borislav Petkov , Ingo Molnar , linux-pm@vger.kernel.org Cc: Deepak Sharma , Alex Deucher , Mario Limonciello , Nathan Fontenot , Jinzhou Su , Xiaojian Du , linux-kernel@vger.kernel.org, x86@kernel.org, Shuah Khan References: <20210908150001.3702552-1-ray.huang@amd.com> <20210908150001.3702552-14-ray.huang@amd.com> From: Shuah Khan Message-ID: <50412248-179d-3548-aeb0-d912a14a152f@linuxfoundation.org> Date: Thu, 9 Sep 2021 16:16:21 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210908150001.3702552-14-ray.huang@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 9/8/21 8:59 AM, Huang Rui wrote: > Introduce the cpupower_amd_pstate_enabled() to check whether the kernel > mode enables amd-pstate. > What does "kernel mode" mean? Are you referring to kernel vs. firmware mode? > Signed-off-by: Huang Rui > --- > tools/power/cpupower/utils/helpers/helpers.h | 5 +++++ > tools/power/cpupower/utils/helpers/misc.c | 20 ++++++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/tools/power/cpupower/utils/helpers/helpers.h b/tools/power/cpupower/utils/helpers/helpers.h > index b4813efdfb00..eb43c14d1728 100644 > --- a/tools/power/cpupower/utils/helpers/helpers.h > +++ b/tools/power/cpupower/utils/helpers/helpers.h > @@ -136,6 +136,11 @@ extern int decode_pstates(unsigned int cpu, int boost_states, > > extern int cpufreq_has_boost_support(unsigned int cpu, int *support, > int *active, int * states); > + > +/* AMD PSTATE enabling **************************/ > + > +extern unsigned long cpupower_amd_pstate_enabled(unsigned int cpu); > + > /* > * CPUID functions returning a single datum > */ > diff --git a/tools/power/cpupower/utils/helpers/misc.c b/tools/power/cpupower/utils/helpers/misc.c > index fc6e34511721..07d80775fb68 100644 > --- a/tools/power/cpupower/utils/helpers/misc.c > +++ b/tools/power/cpupower/utils/helpers/misc.c > @@ -83,6 +83,26 @@ int cpupower_intel_set_perf_bias(unsigned int cpu, unsigned int val) > return 0; > } > > +unsigned long cpupower_amd_pstate_enabled(unsigned int cpu) > +{ > + char linebuf[MAX_LINE_LEN]; > + char path[SYSFS_PATH_MAX]; > + unsigned long val; > + char *endp; > + > + snprintf(path, sizeof(path), > + PATH_TO_CPU "cpu%u/cpufreq/is_amd_pstate_enabled", cpu); > + > + if (cpupower_read_sysfs(path, linebuf, MAX_LINE_LEN) == 0) > + return 0; > + > + val = strtoul(linebuf, &endp, 0); > + if (endp == linebuf || errno == ERANGE) > + return 0; > + > + return val; > +} > + > #endif /* #if defined(__i386__) || defined(__x86_64__) */ > > /* get_cpustate >