From: srinivas pandruvada <srinivas.pandruvada@linux.intel.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>, Xi Ruoyao <xry111@xry111.site>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Linux PM <linux-pm@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 2/6] cpufreq: intel_pstate: Do not update global.turbo_disabled after initialization
Date: Mon, 03 Jun 2024 21:31:05 -0700 [thread overview]
Message-ID: <1da736da33a61de92314934ecf7fa0420d6d6b81.camel@linux.intel.com> (raw)
In-Reply-To: <f34c20ae3feac0e3570125f124e440d51c5e4d9b.camel@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3783 bytes --]
On Mon, 2024-06-03 at 11:47 -0700, srinivas pandruvada wrote:
> On Mon, 2024-06-03 at 20:32 +0200, Rafael J. Wysocki wrote:
> > On Mon, Jun 3, 2024 at 7:44 PM Xi Ruoyao <xry111@xry111.site>
> > wrote:
> > >
> > > On Mon, 2024-06-03 at 10:11 -0700, srinivas pandruvada wrote:
> > > > On Mon, 2024-06-03 at 21:12 +0800, Xi Ruoyao wrote:
> > > > > On Sun, 2024-06-02 at 16:11 -0700, srinivas pandruvada wrote:
> > > > >
> > > > > /* snip */
> > > > >
> > > > > > What is the output of:
> > > > > > grep . /sys/devices/system/cpu/intel_pstate/*
> > > > > >
> > > > > > Also
> > > > > > rdmsr 0x771
> > > > > > rdmsr 0x774
> > > > > >
> > > > > >
> > > > > > Try these three patches. Don't worry about the commit
> > > > > > description
> > > > > > for
> > > > > > this issue.
> > > > >
> > > > > Unfortunately they still do not fix the issue for me.
> > > > >
> > > > > The outputs of grep and rdmsr commands are initially:
> > > > >
> > > > > /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost:0
> > > > > /sys/devices/system/cpu/intel_pstate/max_perf_pct:100
> > > > > /sys/devices/system/cpu/intel_pstate/min_perf_pct:9
> > > > > /sys/devices/system/cpu/intel_pstate/no_turbo:1
> > > > > /sys/devices/system/cpu/intel_pstate/num_pstates:41
> > > > > /sys/devices/system/cpu/intel_pstate/status:active
> > > > > /sys/devices/system/cpu/intel_pstate/turbo_pct:33
> > > > > rdmsr 0x771: 10d1f2c
> > > > > rdmsr 0x774: 1f04
> > > > >
> > > > > But it then changes to:
> > > > >
> > > > > /sys/devices/system/cpu/intel_pstate/hwp_dynamic_boost:0
> > > > > /sys/devices/system/cpu/intel_pstate/max_perf_pct:100
> > > > > /sys/devices/system/cpu/intel_pstate/min_perf_pct:9
> > > > > /sys/devices/system/cpu/intel_pstate/no_turbo:1
> > > > > /sys/devices/system/cpu/intel_pstate/num_pstates:41
> > > > > /sys/devices/system/cpu/intel_pstate/status:active
> > > > > /sys/devices/system/cpu/intel_pstate/turbo_pct:33
> > > > > rdmsr 0x771: 10c1f2c
> > > > > rdmsr 0x774: 1f04
> > > > >
> > > > > It seems only the output of rdmsr 0x771 has changed. And if
> > > > > I
> > > > > read
> > > > > the
> > > > > SDM correctly it's a "Most_Efficient_Performance" change.
> > > > That is fine.
> > > >
> > > > We don't have any notifications either via ACPI or via HWP
> > > > interrupt.
> > > > I think it was working by chance before this change as by the
> > > > cpufreq
> > > > core is trying to set policy, the turbo is enabled by the
> > > > firmware.
> > > >
> > > > What is this laptop make and model?
> > >
> > > It's a Hasee X5-2021S5H.
> > >
> > > Hasee is known for producing some laptops very cheap but often
> > > having
> > > "minor" issues. So I guess the firmware is doing some stupid
> > > thing.
> > >
> > > But turbo works just fine on Windows 11 so it'd be better if we
> > > could
> > > make it work for Linux too.
> >
> > In principle, there are two things that can be done about this.
> >
> > First, MSR_IA32_MISC_ENABLE_TURBO_DISABLE on this system can be
> > ignored altogether, but that would require adding a quirk.
> >
> > Second, a delayed work can be added to check the MSR long enough
> > after
> > initialization and update global.turbo_disabled if it is 1.
> > However,
> > that would require some code surgery.
>
Something like the attached which does same way as user space no_turbo
update.
Thanks,
Srinivas
> I was about to send this suggestion.
>
> For the first one we can always program the HWP_REQ.max to
> HWP_CAP.max
> and let hardware do the clipping. But this is not friendly to
> passive
> mode. But display of scalig_max_freq still should reflect the
> reality.
>
>
> Thanks,
> Srinivas
>
> >
>
>
[-- Attachment #2: delayed_turbo_check.diff --]
[-- Type: text/x-patch, Size: 2202 bytes --]
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c
index 65d3f79104bd..8d61ff261c61 100644
--- a/drivers/cpufreq/intel_pstate.c
+++ b/drivers/cpufreq/intel_pstate.c
@@ -1305,7 +1305,7 @@ static ssize_t store_no_turbo(struct kobject *a, struct kobj_attribute *b,
if (no_turbo == global.no_turbo)
goto unlock_driver;
- if (global.turbo_disabled) {
+ if (READ_ONCE(global.turbo_disabled)) {
pr_notice_once("Turbo disabled by BIOS or unavailable on processor\n");
count = -EPERM;
goto unlock_driver;
@@ -1762,7 +1762,7 @@ static u64 atom_get_val(struct cpudata *cpudata, int pstate)
u32 vid;
val = (u64)pstate << 8;
- if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
+ if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))
val |= (u64)1 << 32;
vid_fp = cpudata->vid.min + mul_fp(
@@ -1927,7 +1927,7 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate)
u64 val;
val = (u64)pstate << 8;
- if (READ_ONCE(global.no_turbo) && !global.turbo_disabled)
+ if (READ_ONCE(global.no_turbo) && !READ_ONCE(global.turbo_disabled))
val |= (u64)1 << 32;
return val;
@@ -3102,6 +3102,29 @@ static void intel_pstate_driver_cleanup(void)
intel_pstate_driver = NULL;
}
+static void check_turbo_work_handler(struct work_struct *work)
+{
+ bool no_turbo;
+
+ no_turbo = turbo_is_disabled();
+
+ if (no_turbo)
+ return;
+
+ /* Same processing as sysfs no_turbo update */
+ mutex_lock(&intel_pstate_driver_lock);
+
+ WRITE_ONCE(global.turbo_disabled, no_turbo);
+ WRITE_ONCE(global.no_turbo, no_turbo);
+
+ intel_pstate_update_limits_for_all();
+ arch_set_max_freq_ratio(false);
+
+ mutex_unlock(&intel_pstate_driver_lock);
+}
+
+DECLARE_DELAYED_WORK(turbo_work, check_turbo_work_handler);
+
static int intel_pstate_register_driver(struct cpufreq_driver *driver)
{
int ret;
@@ -3114,6 +3137,9 @@ static int intel_pstate_register_driver(struct cpufreq_driver *driver)
global.turbo_disabled = turbo_is_disabled();
global.no_turbo = global.turbo_disabled;
+ if (global.turbo_disabled)
+ schedule_delayed_work(&turbo_work, HZ);
+
arch_set_max_freq_ratio(global.turbo_disabled);
intel_pstate_driver = driver;
next prev parent reply other threads:[~2024-06-04 4:31 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-25 17:00 [PATCH v1 0/6] intel_pstate: Turbo disabled handling rework Rafael J. Wysocki
2024-03-25 17:01 ` [PATCH v1 1/6] cpufreq: intel_pstate: Fold intel_pstate_max_within_limits() into caller Rafael J. Wysocki
2024-04-01 20:06 ` srinivas pandruvada
2024-03-25 17:02 ` [PATCH v1 2/6] cpufreq: intel_pstate: Do not update global.turbo_disabled after initialization Rafael J. Wysocki
2024-06-02 3:21 ` Xi Ruoyao
2024-06-02 4:03 ` srinivas pandruvada
2024-06-02 4:25 ` Xi Ruoyao
2024-06-02 13:40 ` srinivas pandruvada
2024-06-02 16:07 ` Xi Ruoyao
2024-06-02 23:11 ` srinivas pandruvada
2024-06-03 13:12 ` Xi Ruoyao
2024-06-03 17:11 ` srinivas pandruvada
2024-06-03 17:44 ` Xi Ruoyao
2024-06-03 18:32 ` Rafael J. Wysocki
2024-06-03 18:47 ` srinivas pandruvada
2024-06-04 4:10 ` srinivas pandruvada
2024-06-04 4:31 ` srinivas pandruvada [this message]
2024-06-04 9:30 ` Xi Ruoyao
2024-06-04 10:29 ` srinivas pandruvada
2024-06-04 10:32 ` Xi Ruoyao
2024-06-04 16:41 ` srinivas pandruvada
2024-06-04 16:46 ` Rafael J. Wysocki
2024-06-04 16:56 ` srinivas pandruvada
2024-06-05 5:21 ` Xi Ruoyao
2024-06-05 12:05 ` srinivas pandruvada
2024-06-07 15:04 ` Rafael J. Wysocki
2024-06-07 15:18 ` srinivas pandruvada
2024-06-08 9:30 ` Xi Ruoyao
2024-03-25 17:03 ` [PATCH v1 3/6] cpufreq: intel_pstate: Rearrange show_no_turbo() and store_no_turbo() Rafael J. Wysocki
2024-03-25 17:04 ` [PATCH v1 4/6] cpufreq: intel_pstate: Read global.no_turbo under READ_ONCE() Rafael J. Wysocki
2024-03-25 17:05 ` [PATCH v1 5/6] cpufreq: intel_pstate: Replace three global.turbo_disabled checks Rafael J. Wysocki
2024-03-25 17:06 ` [PATCH v1 6/6] cpufreq: intel_pstate: Update the maximum CPU frequency consistently Rafael J. Wysocki
2024-03-27 18:08 ` srinivas pandruvada
2024-03-28 11:26 ` Rafael J. Wysocki
2024-03-28 19:02 ` [PATCH v1.1 " Rafael J. Wysocki
2024-04-02 8:46 ` [PATCH v1 0/6] intel_pstate: Turbo disabled handling rework srinivas pandruvada
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=1da736da33a61de92314934ecf7fa0420d6d6b81.camel@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=xry111@xry111.site \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.