From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Darren Powell <darren.powell@amd.com>,
Kenneth Feng <kenneth.feng@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Sasha Levin <sashal@kernel.org>,
evan.quan@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com,
airlied@linux.ie, daniel@ffwll.ch, lijo.lazar@amd.com,
Hawking.Zhang@amd.com, guchun.chen@amd.com, kevin1.wang@amd.com,
lang.yu@amd.com, luben.tuikov@amd.com, Stanley.Yang@amd.com,
tao.zhou1@amd.com, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 5.19 045/105] amdgpu/pm: Fix possible array out-of-bounds if SCLK levels != 2
Date: Thu, 11 Aug 2022 11:27:29 -0400 [thread overview]
Message-ID: <20220811152851.1520029-45-sashal@kernel.org> (raw)
In-Reply-To: <20220811152851.1520029-1-sashal@kernel.org>
From: Darren Powell <darren.powell@amd.com>
[ Upstream commit ceb180361e3851007547c55035cd1de03f108f75 ]
[v2]
simplified fix after Lijo's feedback
removed clocks.num_levels from calculation of loop count
removed unsafe accesses to shim table freq_values
retained corner case output only min,now if
clocks.num_levels == 1 && now > min
[v1]
added a check to populate and use SCLK shim table freq_values only
if using dpm_level == AMD_DPM_FORCED_LEVEL_MANUAL or
AMD_DPM_FORCED_LEVEL_PERF_DETERMINISM
removed clocks.num_levels from calculation of shim table size
removed unsafe accesses to shim table freq_values
output gfx_table values if using other dpm levels
added check for freq_match when using freq_values for when now == min_clk
== Test ==
LOGFILE=aldebaran-sclk.test.log
AMDGPU_PCI_ADDR=`lspci -nn | grep "VGA\|Display" | cut -d " " -f 1`
AMDGPU_HWMON=`ls -la /sys/class/hwmon | grep $AMDGPU_PCI_ADDR | awk '{print $9}'`
HWMON_DIR=/sys/class/hwmon/${AMDGPU_HWMON}
lspci -nn | grep "VGA\|Display" > $LOGFILE
FILES="pp_od_clk_voltage
pp_dpm_sclk"
for f in $FILES
do
echo === $f === >> $LOGFILE
cat $HWMON_DIR/device/$f >> $LOGFILE
done
cat $LOGFILE
Signed-off-by: Darren Powell <darren.powell@amd.com>
Reviewed-by: Kenneth Feng <kenneth.feng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
.../drm/amd/pm/swsmu/smu13/aldebaran_ppt.c | 34 +++++++------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
index fb130409309c..f6ff7942e1b7 100644
--- a/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
+++ b/drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
@@ -739,7 +739,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
struct smu_13_0_dpm_table *single_dpm_table;
struct smu_dpm_context *smu_dpm = &smu->smu_dpm;
struct smu_13_0_dpm_context *dpm_context = NULL;
- uint32_t display_levels;
+ int display_levels;
uint32_t freq_values[3] = {0};
uint32_t min_clk, max_clk;
@@ -771,7 +771,7 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
return ret;
}
- display_levels = clocks.num_levels;
+ display_levels = (clocks.num_levels == 1) ? 1 : 2;
min_clk = pstate_table->gfxclk_pstate.curr.min;
max_clk = pstate_table->gfxclk_pstate.curr.max;
@@ -781,30 +781,20 @@ static int aldebaran_print_clk_levels(struct smu_context *smu,
/* fine-grained dpm has only 2 levels */
if (now > min_clk && now < max_clk) {
- display_levels = clocks.num_levels + 1;
+ display_levels++;
freq_values[2] = max_clk;
freq_values[1] = now;
}
- /*
- * For DPM disabled case, there will be only one clock level.
- * And it's safe to assume that is always the current clock.
- */
- if (display_levels == clocks.num_levels) {
- for (i = 0; i < clocks.num_levels; i++)
- size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i,
- freq_values[i],
- (clocks.num_levels == 1) ?
- "*" :
- (aldebaran_freqs_in_same_level(
- freq_values[i], now) ?
- "*" :
- ""));
- } else {
- for (i = 0; i < display_levels; i++)
- size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i,
- freq_values[i], i == 1 ? "*" : "");
- }
+ for (i = 0; i < display_levels; i++)
+ size += sysfs_emit_at(buf, size, "%d: %uMhz %s\n", i,
+ freq_values[i],
+ (display_levels == 1) ?
+ "*" :
+ (aldebaran_freqs_in_same_level(
+ freq_values[i], now) ?
+ "*" :
+ ""));
break;
--
2.35.1
next prev parent reply other threads:[~2022-08-11 15:37 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-11 15:26 [PATCH AUTOSEL 5.19 001/105] fbdev: Restart conflicting fb removal loop when unregistering devices Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 002/105] drm/r128: Fix undefined behavior due to shift overflowing the constant Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 003/105] ath10k: htt_tx: do not interpret Eth frames as WiFi Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 004/105] ath10k: fix misreported tx bandwidth for 160Mhz Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 005/105] drm/nouveau: clear output poll workers before nouveau_fbcon_destroy() Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 006/105] drm/panfrost: Handle HW_ISSUE_TTRX_2968_TTRX_3162 Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 007/105] drm/panfrost: Don't set L2_MMU_CONFIG quirks Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 008/105] drm/panfrost: Add arm,mali-valhall-jm compatible Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 009/105] ath10k: fix regdomain info of iw reg set/get Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 010/105] bpf, sockmap: Fix sk->sk_forward_alloc warn_on in sk_stream_kill_queues Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 011/105] drm/amd/display: fix system hang when PSR exits Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 012/105] drm/amd/display: Detect dpcd_rev when hotplug mst monitor Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 013/105] drm/probe-helper: Default to 640x480 if no EDID on DP Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 014/105] libbpf: Fix an error in 64bit relocation value computation Sasha Levin
2022-08-11 15:26 ` [PATCH AUTOSEL 5.19 015/105] iavf: Add waiting for response from PF in set mac Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 016/105] drm/amd/display: Correct min comp buffer size Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 017/105] drm/amd/display: Fix dpp dto for disabled pipes Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 018/105] drm/amd/display: Reduce frame size in the bouding box for DCN20 Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 019/105] drm/radeon: integer overflow in radeon_mode_dumb_create() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 020/105] drm/radeon: Initialize fences array entries in radeon_sa_bo_next_hole Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 021/105] udmabuf: Set the DMA mask for the udmabuf device (v2) Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 022/105] crypto: octeontx2 - fix potential null pointer access Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 023/105] net/mlx5: Add HW definitions of vport debug counters Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 024/105] selftests/bpf: Avoid skipping certain subtests Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 025/105] drm/amd/display: Fix monitor flash issue Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 026/105] net: phy: marvell-88x2222: set proper phydev->port Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 027/105] selftests: mlxsw: resource_scale: Allow skipping a test Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 028/105] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Sasha Levin
2022-08-11 15:38 ` Russell King (Oracle)
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 029/105] net: stmmac: make mdio register skips PHY scanning for fixed-link Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 030/105] net: dsa: ar9331: fix potential dead lock on mdio access Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 031/105] media: davinci: vpif: add missing of_node_put() in vpif_probe() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 032/105] media: mediatek: vcodec: prevent kernel crash when scp ipi timeout Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 033/105] media: airspy: respect the DMA coherency rules Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 034/105] media: pvrusb2: fix memory leak in pvr_probe Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 035/105] rcu: Apply noinstr to rcu_idle_enter() and rcu_idle_exit() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 036/105] tools/nolibc/stdlib: Support overflow checking for older compiler versions Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 037/105] tools/nolibc: fix the makefile to also work as "make -C tools ..." Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 038/105] drm/bridge/tc358775: Fix DSI clock division for vsync delay calculation Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 039/105] uprobe: gate bpf call behind BPF_EVENTS Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 040/105] rcutorture: Fix memory leak in rcu_test_debug_objects() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 041/105] rcuscale: Fix smp_processor_id()-in-preemptible warnings Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 042/105] refscale: Convert test_lock spinlock to raw_spinlock Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 043/105] mlxsw: cmd: Increase 'config_profile.flood_mode' length Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 044/105] drm/amdkfd: Free queue after unmap queue success Sasha Levin
2022-08-11 15:27 ` Sasha Levin [this message]
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 046/105] drm/ast: Fixed the casting issue reported by sparse Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 047/105] media: mediatek: vcodec: return EINVAL if plane is too small Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 048/105] media: atmel: atmel-isc-base: allow wb ctrls to be changed when isc is not configured Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 049/105] media: mediatek: vcodec: Report supported bitrate modes Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 050/105] kselftests: Enable the echo command to print newlines in Makefile Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 051/105] ipv6/addrconf: fix timing bug in tempaddr regen Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 052/105] drm/amdgpu/display/dc: Fix null pointer exception Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 053/105] libbpf: fix up few libbpf.map problems Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 054/105] iomap: skip pages past eof in iomap_do_writepage() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 055/105] scripts: get_feat.pl: use /usr/bin/env to find perl Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 056/105] octeontx2-af: fix operand size in bitwise operation Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 057/105] drm/amdgpu: skip whole ras bad page framework on sriov Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 058/105] drm/amd/display: Guard against ddc_pin being NULL for AUX Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 059/105] drm/amd/display: Fix dmub soft hang for PSR 1 Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 060/105] drm/amd/display: disable otg toggle w/a on boot Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 061/105] iov_iter_get_pages{,_alloc}(): cap the maxsize with MAX_RW_COUNT Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 062/105] drm/msm/gem: Drop obj lock in msm_gem_free_object() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 063/105] scripts: sphinx-pre-install: fix venv version check logic Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 064/105] drm/amdgpu: Fix one list corruption when create queue fails Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 065/105] crypto: vmx - Fix warning on p8_ghash_alg Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 066/105] octeontx2-af: Don't reset previous pfc config Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 067/105] libbpf: Disable SEC pragma macro on GCC Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 068/105] bpf: Make non-preallocated allocation low priority Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 069/105] drm/nouveau/nvkm: use list_add_tail() when building object tree Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 070/105] drm/amdgpu: fix file permissions on some files Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 071/105] selftests/bpf: Do not attach kprobe_multi bench to bpf_dispatcher_xdp_func Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 072/105] crypto: ccree - Add missing clk_disable_unprepare() in cc_pm_resume() Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 073/105] bpf: Fix check against plain integer v 'NULL' Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 074/105] media: rkisp1: Disable runtime PM in probe error path Sasha Levin
2022-08-11 15:27 ` [PATCH AUTOSEL 5.19 075/105] drm/amdgpu: Call trace info was found in dmesg when loading amdgpu Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 076/105] net: devlink: avoid false DEADLOCK warning reported by lockdep Sasha Levin
2022-08-11 15:56 ` Jakub Kicinski
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 077/105] bpf: Don't redirect packets with invalid pkt_len Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 078/105] rcu: Avoid tracing a few functions executed in stop machine Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 079/105] can: sja1000: Add Quirk for RZ/N1 SJA1000 CAN controller Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 080/105] net/cdc_ncm: Increase NTB max RX/TX values to 64kb Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 081/105] Bluetooth: hci_bcm: Add BCM4349B1 variant Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 082/105] Bluetooth: use memset avoid memory leaks Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 083/105] Bluetooth: Collect kcov coverage from hci_rx_work Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 084/105] Bluetooth: btusb: Set HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN for MTK Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 085/105] Bluetooth: hci_sync: Check LMP feature bit instead of quirk Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 086/105] Bluetooth: btusb: Remove HCI_QUIRK_BROKEN_ERR_DATA_REPORTING for QCA Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 087/105] Bluetooth: btusb: Remove HCI_QUIRK_BROKEN_ERR_DATA_REPORTING for fake CSR Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 088/105] Bluetooth: hci_sync: Remove HCI_QUIRK_BROKEN_ERR_DATA_REPORTING Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 089/105] Bluetooth: mgmt: Fix using hci_conn_abort Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 090/105] bpf/selftests: Fix couldn't retrieve pinned program in xdp veth test Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 091/105] drm/amdkfd: Correct mmu_notifier_get failure handling Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 092/105] drm/amdkfd: Process notifier release callback don't take mutex Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 093/105] btrfs: output mirror number for bad metadata Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 094/105] btrfs: repair all known bad mirrors Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 095/105] net: ethernet: stmicro: stmmac: first disable all queues and disconnect in release Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 096/105] net: devlink: make sure that devlink_try_get() works with valid pointer during xarray iteration Sasha Levin
2022-08-11 15:54 ` Jakub Kicinski
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 097/105] Revert "ath11k: add support for hardware rfkill for QCA6390" Sasha Levin
2022-08-11 15:28 ` [PATCH AUTOSEL 5.19 098/105] wifi: rtl8xxxu: Fix the error handling of the probe function Sasha Levin
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=20220811152851.1520029-45-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Hawking.Zhang@amd.com \
--cc=Stanley.Yang@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=daniel@ffwll.ch \
--cc=darren.powell@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=evan.quan@amd.com \
--cc=guchun.chen@amd.com \
--cc=kenneth.feng@amd.com \
--cc=kevin1.wang@amd.com \
--cc=lang.yu@amd.com \
--cc=lijo.lazar@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luben.tuikov@amd.com \
--cc=stable@vger.kernel.org \
--cc=tao.zhou1@amd.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