mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Zhang, Rui" <rui.zhang@intel.com>
To: "rafael@kernel.org" <rafael@kernel.org>
Cc: "srinivas.pandruvada@linux.intel.com"
	<srinivas.pandruvada@linux.intel.com>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] powercap: intel_rapl: Do not change CLAMPING bit if ENABLE bit cannot be changed
Date: Wed, 18 Jun 2025 23:33:17 +0000	[thread overview]
Message-ID: <d2f0b3fa448d11536c26b98067d400a44d9d3010.camel@intel.com> (raw)
In-Reply-To: <CAJZ5v0gY7Rp8C8AFzgRzMs+Gq-1rcgKmrG4+nJWB=bGpcKkU2A@mail.gmail.com>

On Wed, 2025-06-18 at 19:04 +0200, Rafael J. Wysocki wrote:
> On Wed, Jun 18, 2025 at 5:03 AM Zhang Rui <rui.zhang@intel.com> wrote:
> > 
> > PL1 cannot be disabled on some platforms. The ENABLE bit is still set
> > after software clears it. This behavior leads to a scenario where,
> > upon
> > user request to disable the Power Limit through the powercap sysfs,
> > the
> > ENABLE bit remains set while the CLAMPING bit is inadvertently
> > cleared.
> > 
> > According to the Intel Software Developer's Manual, the CLAMPING bit,
> > "When set, allows the processor to go below the OS requested P states
> > in
> > order to maintain the power below specified Platform Power Limit
> > value."
> > 
> > Thus this means the system may operate at higher power levels than
> > intended on such platforms.
> > 
> > Enhance the code to check ENABLE bit after writing to it, and stop
> > further processing if ENABLE bit cannot be changed.
> > 
> > Reported-by: Srinivas Pandruvada
> > <srinivas.pandruvada@linux.intel.com>
> 
> If this is a fix, I would appreciate a Fixes: tag.

The problem is always there since Day One, in this commit 2d281d8196e3
("PowerCap: Introduce Intel RAPL power capping driver").

I can use this commit in the Fixes tag. And I think this should be stable
candidate. Will send V2 soon.

thanks,
rui
> 
> > Signed-off-by: Zhang Rui <rui.zhang@intel.com>
> > ---
> >  drivers/powercap/intel_rapl_common.c | 17 ++++++++++++++++-
> >  1 file changed, 16 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/powercap/intel_rapl_common.c
> > b/drivers/powercap/intel_rapl_common.c
> > index e3be40adc0d7..602f540cbe15 100644
> > --- a/drivers/powercap/intel_rapl_common.c
> > +++ b/drivers/powercap/intel_rapl_common.c
> > @@ -341,12 +341,27 @@ static int set_domain_enable(struct
> > powercap_zone *power_zone, bool mode)
> >  {
> >         struct rapl_domain *rd =
> > power_zone_to_rapl_domain(power_zone);
> >         struct rapl_defaults *defaults = get_defaults(rd->rp);
> > +       u64 val;
> >         int ret;
> > 
> >         cpus_read_lock();
> >         ret = rapl_write_pl_data(rd, POWER_LIMIT1, PL_ENABLE, mode);
> > -       if (!ret && defaults->set_floor_freq)
> > +       if (ret)
> > +               goto end;
> > +
> > +       ret = rapl_read_pl_data(rd, POWER_LIMIT1, PL_ENABLE, false,
> > &val);
> > +       if (ret)
> > +               goto end;
> > +
> > +       if (mode != val) {
> > +               pr_debug("%s cannot be %s\n", power_zone->name, mode
> > ? "enabled" : "disabled");
> > +               goto end;
> > +       }
> > +
> > +       if (defaults->set_floor_freq)
> >                 defaults->set_floor_freq(rd, mode);
> > +
> > +end:
> >         cpus_read_unlock();
> > 
> >         return ret;
> > --
> > 2.43.0
> > 
> > 


      reply	other threads:[~2025-06-18 23:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18  3:03 Zhang Rui
2025-06-18 17:04 ` Rafael J. Wysocki
2025-06-18 23:33   ` Zhang, Rui [this message]

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=d2f0b3fa448d11536c26b98067d400a44d9d3010.camel@intel.com \
    --to=rui.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=srinivas.pandruvada@linux.intel.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

all inboxes | Powered by JetHome®