mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wyes Karny <wyes.karny@amd.com>
To: <ray.huang@amd.com>, <rafael@kernel.org>, <viresh.kumar@linaro.org>
Cc: <linux-pm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<gautham.shenoy@amd.com>, Wyes Karny <wyes.karny@amd.com>
Subject: [PATCH v3 0/2] cpufreq/amd-pstate: Fix null pointer dereference when frequency invariance is disabled
Date: Mon, 15 May 2023 11:34:02 +0000	[thread overview]
Message-ID: <20230515113404.4259-1-wyes.karny@amd.com> (raw)

Currently, amd_pstate only uses `adjust_perf` and `target` callback
functions to get the frequency/effective utilization data from scaling
governors. But the governor can switch back to fast_switch callback when
frequency invariance is disabled. In that case, if the driver didn't set
fast_switch function pointer, null pointer dereference can happen and
kernel will crash.

Currently, frequency invariance is turned off when any anomaly is
detected with aperf/mperf readings. Which triggers this problem.

Fix this by adding `fast_switch` function in the amd_pstate driver. The
same problem could arise with intel_pstate driver when the driver is in
passive mode and the governor is schedutil.

Additionally, display a warning message if the scaling driver sets
fast_swich_possible flag but not fast_switch function pointer.

Changelog:
v2 -> v3
- Add fast_switch callback in amd_pstate and warn if any driver
  sets fast_swich_possible flag but not fast_switch function pointer.

v1 -> v2
- Remove fast_switch_enabled flag dependency for adjust_perf callback

v1: https://lore.kernel.org/linux-pm/20230410095045.14872-1-wyes.karny@amd.com/
v2: https://lore.kernel.org/linux-pm/20230509180503.739208-1-wyes.karny@amd.com/

Gautham R. Shenoy (1):
  amd_pstate: Add ->fast_switch() callback

Wyes Karny (1):
  cpufreq: Warn if fast_switch is not set

 drivers/cpufreq/amd-pstate.c | 35 +++++++++++++++++++++++++++++------
 drivers/cpufreq/cpufreq.c    | 18 ++++++++++++++++++
 include/linux/cpufreq.h      |  5 ++++-
 3 files changed, 51 insertions(+), 7 deletions(-)

-- 
2.34.1


             reply	other threads:[~2023-05-15 11:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-15 11:34 Wyes Karny [this message]
2023-05-15 11:34 ` [PATCH v3 1/2] amd_pstate: Add ->fast_switch() callback Wyes Karny
2023-05-15 11:34 ` [PATCH v3 2/2] cpufreq: Warn if fast_switch is not set Wyes Karny
2023-05-16  1:10   ` Viresh Kumar
2023-05-16  5:49     ` Wyes Karny
2023-05-16  5:52       ` Viresh Kumar

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=20230515113404.4259-1-wyes.karny@amd.com \
    --to=wyes.karny@amd.com \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=viresh.kumar@linaro.org \
    /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®