linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wyes Karny <wyes.karny@amd.com>
To: "Yuan, Perry" <Perry.Yuan@amd.com>
Cc: "trenn@suse.com" <trenn@suse.com>,
	"shuah@kernel.org" <shuah@kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"rafael@kernel.org" <rafael@kernel.org>,
	"Shenoy, Gautham Ranjal" <gautham.shenoy@amd.com>,
	"Limonciello, Mario" <Mario.Limonciello@amd.com>,
	"Huang, Ray" <Ray.Huang@amd.com>
Subject: Re: [PATCH v3 5/5] cpupower: Add turbo-boost support in cpupower
Date: Tue, 20 Jun 2023 10:19:23 +0530	[thread overview]
Message-ID: <ZJEv05RNDS07x7VI@BLR-5CG13462PL.amd.com> (raw)
In-Reply-To: <CYYPR12MB865590E3567FC552308B75549C5CA@CYYPR12MB8655.namprd12.prod.outlook.com>

On 20 Jun 08:37, Yuan, Perry wrote:
> [AMD Official Use Only - General]
> 
>  Hi Wyes.
> 
> > -----Original Message-----
> > From: Karny, Wyes <Wyes.Karny@amd.com>
> > Sent: Tuesday, June 20, 2023 3:05 AM
> > To: trenn@suse.com; shuah@kernel.org
> > Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; rafael@kernel.org;
> > Shenoy, Gautham Ranjal <gautham.shenoy@amd.com>; Limonciello, Mario
> > <Mario.Limonciello@amd.com>; Huang, Ray <Ray.Huang@amd.com>; Yuan,
> > Perry <Perry.Yuan@amd.com>; Karny, Wyes <Wyes.Karny@amd.com>; Huang,
> > Ray <Ray.Huang@amd.com>; Limonciello, Mario
> > <Mario.Limonciello@amd.com>
> > Subject: [PATCH v3 5/5] cpupower: Add turbo-boost support in cpupower
> >
> > If boost sysfs (/sys/devices/system/cpu/cpufreq/boost) file is present turbo-
> > boost is feature is supported in the hardware. By default this feature should be
> > enabled. But to disable/enable it write to the sysfs file. Use the same to control
> > this feature via cpupower.
> >
> > To enable:
> > cpupower set --turbo-boost 1
> >
> > To disable:
> > cpupower set --turbo-boost 0
> >
> > Acked-by: Huang Rui <ray.huang@amd.com>
> > Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
> > Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
> > Signed-off-by: Wyes Karny <wyes.karny@amd.com>
> > ---
> >  tools/power/cpupower/utils/cpupower-set.c    | 22 +++++++++++++++++++-
> >  tools/power/cpupower/utils/helpers/helpers.h |  3 +++
> >  tools/power/cpupower/utils/helpers/misc.c    | 18 ++++++++++++++++
> >  3 files changed, 42 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/power/cpupower/utils/cpupower-set.c
> > b/tools/power/cpupower/utils/cpupower-set.c
> > index c2ba69b7ea54..0677b58374ab 100644
> > --- a/tools/power/cpupower/utils/cpupower-set.c
> > +++ b/tools/power/cpupower/utils/cpupower-set.c
> > @@ -20,6 +20,7 @@ static struct option set_opts[] = {
> >       {"perf-bias", required_argument, NULL, 'b'},
> >       {"epp", required_argument, NULL, 'e'},
> >       {"amd-pstate-mode", required_argument, NULL, 'm'},
> > +     {"turbo-boost", required_argument, NULL, 't'},
> >       { },
> >  };
> >
> > @@ -41,10 +42,11 @@ int cmd_set(int argc, char **argv)
> >                       int perf_bias:1;
> >                       int epp:1;
> >                       int mode:1;
> > +                     int turbo_boost:1;
> >               };
> >               int params;
> >       } params;
> > -     int perf_bias = 0;
> > +     int perf_bias = 0, turbo_boost = 1;
> >       int ret = 0;
> >       char epp[30], mode[20];
> >
> > @@ -94,6 +96,18 @@ int cmd_set(int argc, char **argv)
> >                       }
> >                       params.mode = 1;
> >                       break;
> > +             case 't':
> > +                     if (params.turbo_boost)
> > +                             print_wrong_arg_exit();
> > +                     turbo_boost = atoi(optarg);
> > +                     if (turbo_boost < 0 || turbo_boost > 1) {
> > +                             printf("--turbo-boost param out of range [0-
> > 1]\n");
> > +                             print_wrong_arg_exit();
> > +                     }
> > +                     params.turbo_boost = 1;
> > +                     break;
> > +
> > +
> >               default:
> >                       print_wrong_arg_exit();
> >               }
> > @@ -108,6 +122,12 @@ int cmd_set(int argc, char **argv)
> >                       fprintf(stderr, "Error setting mode\n");
> >       }
> >
> > +     if (params.turbo_boost) {
> > +             ret = cpupower_set_turbo_boost(turbo_boost);
> > +             if (ret)
> > +                     fprintf(stderr, "Error setting turbo-boost\n");
> > +     }
> > +
> >       /* Default is: set all CPUs */
> >       if (bitmask_isallclear(cpus_chosen))
> >               bitmask_setall(cpus_chosen);
> > diff --git a/tools/power/cpupower/utils/helpers/helpers.h
> > b/tools/power/cpupower/utils/helpers/helpers.h
> > index d35596631eef..95749b8ee475 100644
> > --- a/tools/power/cpupower/utils/helpers/helpers.h
> > +++ b/tools/power/cpupower/utils/helpers/helpers.h
> > @@ -118,6 +118,7 @@ extern unsigned long long
> > msr_intel_get_turbo_ratio(unsigned int cpu);
> >
> >  extern int cpupower_set_epp(unsigned int cpu, char *epp);  extern int
> > cpupower_set_amd_pstate_mode(char *mode);
> > +extern int cpupower_set_turbo_boost(int turbo_boost);
> >
> >  /* Read/Write msr ****************************/
> >
> > @@ -180,6 +181,8 @@ static inline int cpupower_set_epp(unsigned int cpu,
> > char *epp)  { return -1; };  static inline int
> > cpupower_set_amd_pstate_mode(char *mode)  { return -1; };
> > +static inline int cpupower_set_turbo_boost(int turbo_boost) { return
> > +-1; };
> >
> >  /* Read/Write msr ****************************/
> >
> > diff --git a/tools/power/cpupower/utils/helpers/misc.c
> > b/tools/power/cpupower/utils/helpers/misc.c
> > index 075c136a100c..76e461ff4f74 100644
> > --- a/tools/power/cpupower/utils/helpers/misc.c
> > +++ b/tools/power/cpupower/utils/helpers/misc.c
> > @@ -124,6 +124,24 @@ int cpupower_set_amd_pstate_mode(char *mode)
> >       return 0;
> >  }
> >
> > +int cpupower_set_turbo_boost(int turbo_boost) {
> > +     char path[SYSFS_PATH_MAX];
> > +     char linebuf[2] = {};
> > +
> > +     snprintf(path, sizeof(path), PATH_TO_CPU "cpufreq/boost");
> > +
> > +     if (!is_valid_path(path))
> > +             return -1;
> > +
> > +     snprintf(linebuf, sizeof(linebuf), "%d", turbo_boost);
> > +
> > +     if (cpupower_write_sysfs(path, linebuf, 2) <= 0)
> > +             return -1;
> > +
> > +     return 0;
> > +}
> > +
> >  bool cpupower_amd_pstate_enabled(void)
> >  {
> >       char *driver = cpufreq_get_driver(0);
> > --
> > 2.34.1
> 
> Thanks for the  new commands for pstate driver
> 
> Tested-by: Perry Yuan <Perry.Yuan@amd.com>

Thanks Perry for the tested-by.

Regards,
Wyes

  reply	other threads:[~2023-06-20  4:49 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 19:04 [PATCH v3 0/5] cpupower: Add various feature control support for amd_pstate Wyes Karny
2023-06-19 19:04 ` [PATCH v3 1/5] cpupower: Recognise amd-pstate active mode driver Wyes Karny
2023-06-19 19:08   ` Limonciello, Mario
2023-06-20  3:10   ` Yuan, Perry
2023-06-20 12:49   ` Huang Rui
2023-06-19 19:05 ` [PATCH v3 2/5] cpupower: Add is_valid_path API Wyes Karny
2023-06-20  3:09   ` Yuan, Perry
2023-06-20 12:59   ` Huang Rui
2023-06-19 19:05 ` [PATCH v3 3/5] cpupower: Add EPP value change support Wyes Karny
2023-06-20  3:08   ` Yuan, Perry
2023-06-20 12:59   ` Huang Rui
2023-06-19 19:05 ` [PATCH v3 4/5] cpupower: Add support for amd_pstate mode change Wyes Karny
2023-06-20  3:08   ` Yuan, Perry
2023-06-19 19:05 ` [PATCH v3 5/5] cpupower: Add turbo-boost support in cpupower Wyes Karny
2023-06-20  3:07   ` Yuan, Perry
2023-06-20  4:49     ` Wyes Karny [this message]
2023-07-14 11:19 ` [PATCH v3 0/5] cpupower: Add various feature control support for amd_pstate Thomas Renninger
2023-07-18 22:17   ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZJEv05RNDS07x7VI@BLR-5CG13462PL.amd.com \
    --to=wyes.karny@amd.com \
    --cc=Mario.Limonciello@amd.com \
    --cc=Perry.Yuan@amd.com \
    --cc=Ray.Huang@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=shuah@kernel.org \
    --cc=trenn@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).