The new SW SMU driver of amdgpu
Subsystems (3)
cover The new SW SMU driver of amdgpu
Hi all,
The series of patches are to implement a new SW SMU driver for future asics.
Background:
The powerplay driver will be retired. The final version is for vega20 with SMU11. However, the future asic will use the new swSMU framework to implement as well. Here is the first version of new sw smu driver that is basing on vega20.
Purpose:
We would like to do re-arch for linux power codes to use a new sw SMU ip block for future asics. We hope to write a simple and readable framework for Linux.
Currently, the default path is still with powerplay on vega20. So far we don’t plan to switch default path to new swSMU design for vega20. And we can use the module parameter amdgpu_dpm to switch it to new SW SMU design (modprobe amdgpu dpm=1).
Development Items:
- Setup new SMU IP block skeleton.
- Implement SMC firmware loading function.
- Implement SMC table data structure.
- Implement SMU v11 indirect register (MP1) read/write and SMC message sending helpers.
- Implement SMU v11 SMC table initialization (read from vbios, parse, populate, and write back to smc).
- Implement SMU v11 memory pool location function.
- Enable DPM feature for SMU v11 and implement DPM control callback function.
- Enable interfaces for starting tools.
- Implement SMU v11 power control and power containment functions.
- Implement and enable SMU v11 thermal/fan control function.
- Implement SMU interfaces placeholder for DC, VCN, and KFD driver.
- Enable and align sys interface in the amdgpu_pm.c.
So far, Kevin, Likun, Jack, and I have enabled features such as dpm, od, thermal, and etc. with new sw smu driver. (Thanks to Kevin, Likun and Jack's great effort!)
Any comments are warm for us.
Thanks & Best Regards!
Ray
Chengming Gui (14):
drm/amd/powerplay: implement power_dpm_state sys interface for SMU11 drm/amd/powerplay: add watermarks related data structs and function
for SMU11.
drm/amd/powerplay: implement pp_power_profile_mode sys inerface for
SMU11
drm/amd/powerplay: add display_config to handle display config for
SMU11.
drm/amd/powerplay: add mclk_latency_table struct and smu_clocks struct
for SMU11
drm/amd/powerplay: add enable_umd_pstate functions for SMU11
drm/amd/powerplay: add get_profiling_clk_mask functions for SMU11
drm/amd/powerplay: add set_uclk_to_highest_level for SMU11
drm/amd/powerplay: add display_config_changed for SMU11.
drm/amd/powerplay: add apply_clock_adjust_rules for SMU11.
drm/amd/powerplay: add vega20_notify_smc_display_config functions for
SMU11
drm/amd/powerplay: add vega20_find/force_higest/lowest_dpm for SMU11
drm/amd/powerplay: add vega20_unforce_dpm_levels for SMU11.
drm/amd/powerplay: implement power_dpm_force_performance_level for
SMU11Huang Rui (53):
drm/amd/powerplay: add new smu ip block drm/amd/powerplay: add smu11 sub block for SMU IP drm/amd/powerplay: add firmware loading interface drm/amd/powerplay: add fw load checking interface drm/amd/powerplay: add interface to read pptable from vbios drm/amd/powerplay: add placeholder of smu_initialize_pptable drm/amd/powerplay: add interface to init smc tables (v2) drm/amd/powerplay: add interface to init power (v2) drm/amd/powerplay: add interface to get vbios bootup values (v2) drm/amd/powerplay: add interface to check pptable (v2) drm/amd/powerplay: add interface to init fb allocations (v2) drm/amd/powerplay: add interface to parse pptable (v2) drm/amd/powerplay: add interface to populate smc pptable (v2) drm/amd/powerplay: add interface to check fw version (v2) drm/amd/powerplay: add interface to write pptable (v2) drm/amd/powerplay: add interface to set min dcef deep sleep (v2) drm/amd/powerplay: add interface to set tool table location (v2) drm/amd/powerplay: add interface to allocate memory pool (v2) drm/amd/powerplay: add interface to notify memory pool location (v2) drm/amd/powerplay: add interfaces for smu resume drm/amd/powerplay: add resume sequence placeholder for smu ip block drm/amdgpu: enable new smu ip block for vega20 drm/amd/powerplay: add new ppsmc header for smu11 (v2) drm/amd/powerplay: add pptable header for smu11 drm/amdgpu: update atomfirmware header for smu11 drm/amdgpu: update new members in atomfirmware drm/amd/powerplay: add smu table context structure drm/amd/powerplay: add get atom data table helper drm/amdgpu: move get_index_into_master_table macro into atomfirmware
header
drm/amd/powerplay: implement read_pptable_from_vbios function for
smu11
drm/amd/powerplay: update pptable header for smu11
drm/amd/powerplay: add data structure of bootup values
drm/amd/powerplay: implement get_vbios_bootup_values function for
smu11 (v2)
drm/amd/powerplay: implement get_clk_info_from_vbios function for
smu11 (v2) drm/amd/powerplay: add vega20 pptable function file drm/amd/powerplay: add append_powerplay_table function drm/amd/powerplay: add get_max_sustainable_clock function drm/amd/powerplay: add the function to set deep sleep dcefclk drm/amd/powerplay: add two interfaces to set_active_display_count and
store_cc6_data
drm/amd/powerplay: add smu display configuration change function drm/amd/powerplay: add get_clock_by_type interface for display drm/amd/powerplay: add interface to get max high clocks for display drm/amd/powerplay: add interface to get clock by type with latency for
display (v2)
drm/amd/powerplay: add interface to get clock by type with voltage for
display
drm/amd/powerplay: add interface to request display clock voltage drm/amd/powerplay: add interface to get dal power level drm/amd/powerplay: add interface to get performance level drm/amd/powerplay: add interface to get current shallow sleep clocks drm/amd/powerplay: add interface to get current clocks for display drm/amd/powerplay: add interface to notify smu enable pme restore
register
drm/amd/powerplay: implement interface to set watermarks for clock
ranges
drm/amd/powerplay: remove unnecessary checking in smu_hw_fini drm/amd/powerplay: don't check hwmgr while using the sw smu
Kevin Wang (38):
drm/amd/powerplay: implement smu send message functions for smu11 (v3) drm/amd/powerplay: implement check_fw_status function for smu11 drm/amd/powerplay: implement check_fw_version function for smu11 drm/amd/powerplay: implement smu_init[fini]_smc_tables for smu11 drm/amd/powerplay: implement smu dpm context functions for smu11 drm/amd/powerplay: implement smu_init[fini]_power function for smu11 drm/amd/powerplay: implement smu_init(fini)_fb_allocations function drm/amd/powerplay: remove header of smu_v11_0_pptable drm/amd/powerplay: implement smu_alloc[free]_memory pool function drm/amd/powerplay: implement notify_memory_pool_location function for
smu11
drm/amd/powerplay: add enum smu_msg_type to header
drm/amd/powerplay: implement smu vega20_message_map for vega20
drm/amd/powerplay: use virtual msg index to replace asic-related msg
index
drm/amd/powerplay: replace SMU_MSG_XXX with PPSMC_MSG_XXX message
index for smu11 (v2)
drm/amd/powerplay: implement smu_init_display for smu11
drm/amd/powerplay: implement smu_run_afll_btc function
drm/amd/powerplay: implement smu feature functions
drm/amd/powerplay: implement feature get&set functions
drm/amd/powerplay: implement smu_notify_display_change function for
smu11
drm/amd/powerplay: implement get_current_clk_freq for smu11
drm/amd/powerplay: implement smu update table function
drm/amd/powerplay: implement is_support_sw_smu function for new smu
drm/amd/powerplay: implement sysfs of amdgpu_get_busy_percent for
smu11
drm/amd/powerplay: implement sysfs of pp_table for smu11
drm/amd/powerplay: implement sensor of SCLK and MCLK for smu11
drm/amd/powerplay: implement sensor of thermal_get_temperature for
smu11
drm/amd/powerplay: implement sensor of get_gpu_power for smu11
drm/amd/powerplay: implement sensor of get_gfx_vdd for smu11
drm/amd/powerplay: implement sensor of get feature mask
drm/amd/powerplay: implement sysfs of get num states function
drm/amd/powerplay: implement sysfs of pp_cur_state function
drm/amd/powerplay: implement sysfs of pp_force_state for sw-smu
drm/amd/powerplay: implement update enabled feature state to smc for
smu11drm/amd/powerplay: hwmon don't check powerplay when sw smu is enabled drm/amd/powerplay: implement uvd & vce dpm enable functions drm/amd/powerplay: implement sensor of uvd & vce power state for smu11 drm/amd/powerplay: implement dpm enable functions of uvd & vce for smu drm/amd/powerplay: enable amdgpu dpm for smu
Likun Gao (33):
drm/amd/powerplay: init microcode for smu11 drm/amd/powerplay: add function to parse pptable for smu11 drm/amd/powerplay: add function to check pptable for smu11 drm/amd/powerplay: update hw fini function to relase some memory drm/amd/powerplay: add function to populate smc pptable for smu11 drm/amd/powerplay: add function to write pptable for smu11 (v2) drm/amd/powerplay: add function to set min dcef deep sleep for smu11
(v2)
drm/amd/powerplay: add function to set tool table location for smu11
(v2)
drm/amd/powerplay: expose the function of smu read argument
drm/amd/powerplay: Change the allocate method of dpm context for
smu11.
drm/amd/powerplay: set defalut dpm table for smu
drm/amd/powerplay: add function to populate umd state clk.
drm/amd/powerplay: add function to get power limit for smu11 (v2)
drm/amd/powerplay: print clock levels for smu11 (v2)
drm/amd/powerplay: add function to get thermal range
drm/amd/powerplay: add function to set thermal range
drm/amd/powerplay: add function to enable thermal alert
drm/amd/powerplay: add function to set fan table to control thermal
drm/amd/powerplay: add function to start thermal control
drm/amd/powerplay: upload dpm level for smu11
drm/amd/powerplay: force clock levels for smu11
drm/amd/powerplay: add function to store overdrive information for
smu11 drm/amd/powerplay: add function to set default overdrive settings drm/amd/powerplay: add golden dpm table to backup default DPM table drm/amd/powerplay: print overdrive percentage information for smu11 drm/amd/powerplay: get overdrive clock and voltage information drm/amd/powerplay: add sys interface for pcie for smu drm/amd/powerplay: add function to update overdrive settings drm/amd/powerplay: add sys interface for set sclk_od/mclk_od for smu drm/amd/powerplay: add sys interface to set pp_od_clk_voltage for smu drm/amd/powerplay: adjust power state when set od_clk drm/amd/powerplay: dpm clk can be set only when performance level is
manual
drm/amd/powerplay: Unify smu handle task function
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 + drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 12 +- drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | 2 + drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 +- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 11 +- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 364 ++-- drivers/gpu/drm/amd/amdgpu/soc15.c | 9 +- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 99 +- drivers/gpu/drm/amd/include/amd_shared.h | 3 + drivers/gpu/drm/amd/include/atomfirmware.h | 44 +- drivers/gpu/drm/amd/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1198 +++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 732 +++++++ drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 89 + .../gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h | 128 ++ .../gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h | 147 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 1683 +++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 2146 ++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 129 ++ 19 files changed, 6624 insertions(+), 185 deletions(-) create mode 100644 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c create mode 100644 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h create mode 100644 drivers/gpu/drm/amd/powerplay/smu_v11_0.c create mode 100644 drivers/gpu/drm/amd/powerplay/vega20_ppt.c create mode 100644 drivers/gpu/drm/amd/powerplay/vega20_ppt.h
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1548411945-12396-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org
PATCH 1/138 drm/amd/powerplay: add new smu ip block
This patch add amdgpu_smu ip block skeleton as placeholder. We plan use new smu ip block from Vega20.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 + drivers/gpu/drm/amd/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 166 +++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 45 +++++++ 4 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/powerplay/amdgpu_smu.c create mode 100644 drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -83,6 +83,7 @@#include "amdgpu_gem.h" #include "amdgpu_doorbell.h" #include "amdgpu_amdkfd.h" +#include "amdgpu_smu.h" #define MAX_GPU_INSTANCE 16
@@ -843,6 +844,9 @@ struct amdgpu_device {struct amd_powerplay powerplay;bool pp_force_state_enabled; +/* smu */ +struct smu_context smu; +/* dpm */ struct amdgpu_pm pm;u32 cg_flags;
drivers/gpu/drm/amd/powerplay/Makefile +1 -1
@@ -35,7 +35,7 @@ AMD_POWERPLAY = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/powerplay/,$( include $(AMD_POWERPLAY) -POWER_MGR = amd_powerplay.o +POWER_MGR = amd_powerplay.o amdgpu_smu.o AMD_PP_POWER = $(addprefix $(AMD_PP_PATH)/,$(POWER_MGR))
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c new file +166 -0
166 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h new file +45 -0
45 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/138 drm/amd/powerplay: add smu11 sub block for SMU IP
In reply to a message not in the archiveThis patch add smu11 sub ip block skeleton as placeholder
--- drivers/gpu/drm/amd/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 20 ++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 30 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 42 ++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h create mode 100644 drivers/gpu/drm/amd/powerplay/smu_v11_0.c
drivers/gpu/drm/amd/powerplay/Makefile +1 -1
@@ -35,7 +35,7 @@ AMD_POWERPLAY = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/powerplay/,$( include $(AMD_POWERPLAY) -POWER_MGR = amd_powerplay.o amdgpu_smu.o +POWER_MGR = amd_powerplay.o amdgpu_smu.o smu_v11_0.o AMD_PP_POWER = $(addprefix $(AMD_PP_PATH)/,$(POWER_MGR))
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +20 -0
@@ -26,9 +26,20 @@#include "amdgpu.h" #include "amdgpu_smu.h" #include "soc15_common.h" +#include "smu_v11_0.h" static int smu_set_funcs (struct amdgpu_device *adev) { +struct smu_context *smu = &adev->smu; + +switch (adev->asic_type) { +case CHIP_VEGA20 : +smu_v11_0_set_smu_funcs (smu); +break ; +default : +return -EINVAL ; + } +return 0 ; }
@@ -164,3 +175,12 @@ const struct amd_ip_funcs smu_ip_funcs = { .set_clockgating_state = smu_set_clockgating_state, .set_powergating_state = smu_set_powergating_state, }; + +const struct amdgpu_ip_block_version smu_v11_0_ip_block = +{ + .type =AMD_IP_BLOCK_TYPE_SMC , + .major =11 , + .minor =0 , + .rev =0 , + .funcs = &smu_ip_funcs, +};
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -42,4 +42,6 @@ struct smu_funcsextern const struct amd_ip_funcs smu_ip_funcs; +extern const struct amdgpu_ip_block_version smu_v11_0_ip_block; +#endif
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright 2019 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __SMU_V11_0_H__ +#define __SMU_V11_0_H__ + +#include "amdgpu_smu.h" + +void smu_v11_0_set_smu_funcs (struct smu_context *smu); + +#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c new file +42 -0
42 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/138 drm/amd/powerplay: add firmware loading interface
In reply to a message not in the archiveThis patch adds firmware loading interface for smu.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 ++++++ 3 files changed, 15 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -0
@@ -96,6 +96,12 @@ static int smu_hw_init(void *handle)if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) { + ret =smu_load_microcode (smu); +if (ret) +return ret; + } +mutex_lock (&smu->mutex);/* TODO */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -35,10 +35,13 @@ struct smu_contextstruct smu_funcs {int (*init_microcode)(struct smu_context *smu); +int (*load_microcode)(struct smu_context *smu); };#define smu_init_microcode (smu) \ ((smu)->funcs->init_microcode ? (smu)->funcs->init_microcode((smu)) : 0) +#define smu_load_microcode (smu) \ + ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +6 -0
@@ -32,8 +32,14 @@ static int smu_v11_0_init_microcode(struct smu_context *smu)return 0 ; } +static int smu_v11_0_load_microcode (struct smu_context *smu) +{ +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, + .load_microcode = smu_v11_0_load_microcode, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/138 drm/amd/powerplay: add fw load checking interface
In reply to a message not in the archiveThis patch adds fw load checking interface for smu.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 7 +++++++ 3 files changed, 16 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -0
@@ -102,6 +102,12 @@ static int smu_hw_init(void *handle)return ret; } + ret =smu_check_fw_status (smu); +if (ret) { +pr_err ("SMC firmware status is not correct\n" ); +return ret; + } +mutex_lock (&smu->mutex);/* TODO */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -36,12 +36,15 @@ struct smu_funcs {int (*init_microcode)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu); +int (*check_fw_status)(struct smu_context *smu); };#define smu_init_microcode (smu) \ ((smu)->funcs->init_microcode ? (smu)->funcs->init_microcode((smu)) : 0)#define smu_load_microcode (smu) \ ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0) +#define smu_check_fw_status (smu) \ + ((smu)->funcs->check_fw_status ? (smu)->funcs->check_fw_status((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +7 -0
@@ -24,6 +24,7 @@#include <linux/firmware.h> #include "amdgpu.h" #include "amdgpu_smu.h" +#include "smu_v11_0.h" static int smu_v11_0_init_microcode (struct smu_context *smu) {
@@ -37,9 +38,15 @@ static int smu_v11_0_load_microcode(struct smu_context *smu)return 0 ; } +static int smu_v11_0_check_fw_status (struct smu_context *smu) +{ +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode, + .check_fw_status = smu_v11_0_check_fw_status, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/138 drm/amd/powerplay: add interface to read pptable from vbios
In reply to a message not in the archiveThis patch adds interface to read pptable from vbios for smu.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 ++++++++++++++++++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +18 -1
@@ -87,6 +87,17 @@ static int smu_sw_fini(void *handle)return 0 ; } +static int smu_smc_table_hw_init (struct smu_context *smu) +{ +int ret; + + ret =smu_read_pptable_from_vbios (smu); +if (ret) +return ret; + +return 0 ; +} +static int smu_hw_init (void *handle) {int ret;
@@ -110,13 +121,19 @@ static int smu_hw_init(void *handle)mutex_lock (&smu->mutex); -/* TODO */ + ret =smu_smc_table_hw_init (smu); +if (ret) + goto failed;mutex_unlock (&smu->mutex);pr_info ("SMU is initialized successfully!\n" );return 0 ; + +failed: +mutex_unlock (&smu->mutex); +return ret; }static int smu_hw_fini (void *handle)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -37,6 +37,7 @@ struct smu_funcsint (*init_microcode)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu); +int (*read_pptable_from_vbios)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -45,6 +46,8 @@ struct smu_funcs ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)#define smu_check_fw_status (smu) \ ((smu)->funcs->check_fw_status ? (smu)->funcs->check_fw_status((smu)) : 0) +#define smu_read_pptable_from_vbios (smu) \ + ((smu)->funcs->read_pptable_from_vbios ? (smu)->funcs->read_pptable_from_vbios((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/138 drm/amd/powerplay: add placeholder of smu_initialize_pptable
In reply to a message not in the archiveThis patch adds placeholder of smu_initialize_pptable for smu.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +25 -0
@@ -59,6 +59,25 @@ static int smu_early_init(void *handle)return 0 ; } +static int smu_initialize_pptable (struct smu_context *smu) +{ +/* TODO */ +return 0 ; +} + +static int smu_smc_table_sw_init (struct smu_context *smu) +{ +int ret; + + ret =smu_initialize_pptable (smu); +if (ret) { +pr_err ("Failed to init smu_initialize_pptable!\n" ); +return ret; + } + +return 0 ; +} +static int smu_sw_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -74,6 +93,12 @@ static int smu_sw_init(void *handle)return ret; } + ret =smu_smc_table_sw_init (smu); +if (ret) { +pr_err ("Failed to sw init smc table!\n" ); +return ret; + } +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/138 drm/amd/powerplay: add interface to init smc tables (v2)
In reply to a message not in the archiveThis patch adds interface to init smc tables for smu. It is to create smu_table structure, and init smc tables such as TABLE_PPTABLE, TABLE_WATERMARKS, TABLE_SMU_METRICS, and etc.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +10 -0
@@ -75,6 +75,16 @@ static int smu_smc_table_sw_init(struct smu_context *smu)return ret; } +/** +* Create smu_table structure, and init smc tables such as +* TABLE_PPTABLE, TABLE_WATERMARKS, TABLE_SMU_METRICS, and etc. +*/ + ret =smu_init_smc_tables (smu); +if (ret) { +pr_err ("Failed to init smc tables!\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -35,6 +35,7 @@ struct smu_contextstruct smu_funcs {int (*init_microcode)(struct smu_context *smu); +int (*init_smc_tables)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu);
@@ -42,6 +43,8 @@ struct smu_funcs#define smu_init_microcode (smu) \ ((smu)->funcs->init_microcode ? (smu)->funcs->init_microcode((smu)) : 0) +#define smu_init_smc_tables (smu) \ + ((smu)->funcs->init_smc_tables ? (smu)->funcs->init_smc_tables((smu)) : 0)#define smu_load_microcode (smu) \ ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)#define smu_check_fw_status (smu) \
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 8/138 drm/amd/powerplay: add interface to init power (v2)
In reply to a message not in the archiveThis patch adds interface to init power function for smu.
It's to create smu_power_context structure, and allocate smu_dpm_context and context size to fill the smu_power_context data.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 10 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +10 -0
@@ -85,6 +85,16 @@ static int smu_smc_table_sw_init(struct smu_context *smu)return ret; } +/** +* Create smu_power_context structure, and allocate smu_dpm_context and +* context size to fill the smu_power_context data. +*/ + ret =smu_init_power (smu); +if (ret) { +pr_err ("Failed to init smu_init_power!\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -36,6 +36,7 @@ struct smu_funcs {int (*init_microcode)(struct smu_context *smu);int (*init_smc_tables)(struct smu_context *smu); +int (*init_power)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu);
@@ -45,6 +46,8 @@ struct smu_funcs ((smu)->funcs->init_microcode ? (smu)->funcs->init_microcode((smu)) : 0)#define smu_init_smc_tables (smu) \ ((smu)->funcs->init_smc_tables ? (smu)->funcs->init_smc_tables((smu)) : 0) +#define smu_init_power (smu) \ + ((smu)->funcs->init_power ? (smu)->funcs->init_power((smu)) : 0)#define smu_load_microcode (smu) \ ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)#define smu_check_fw_status (smu) \
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 9/138 drm/amd/powerplay: add interface to get vbios bootup values (v2)
In reply to a message not in the archiveThis patch adds interface to get vbios bootup values for smu. It's to get boot_values from vbios to set revision, gfxclk, and etc.
v2: add detailed info to describe this function.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 5 +++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +5 -0
@@ -140,6 +140,11 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* get boot_values from vbios to set revision, gfxclk, and etc. */ + ret =smu_get_vbios_bootup_values (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -40,6 +40,7 @@ struct smu_funcsint (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu); +int (*get_vbios_bootup_values)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -54,6 +55,8 @@ struct smu_funcs ((smu)->funcs->check_fw_status ? (smu)->funcs->check_fw_status((smu)) : 0)#define smu_read_pptable_from_vbios (smu) \ ((smu)->funcs->read_pptable_from_vbios ? (smu)->funcs->read_pptable_from_vbios((smu)) : 0) +#define smu_get_vbios_bootup_values (smu) \ + ((smu)->funcs->get_vbios_bootup_values ? (smu)->funcs->get_vbios_bootup_values((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 10/138 drm/amd/powerplay: add interface to check pptable (v2)
In reply to a message not in the archiveThis patch adds interface to check pptable function for smu.
It's to check if the format_revision in vbios is up to pptable header version, and the structure size is not 0.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -145,6 +145,14 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* check if the format_revision in vbios is up to pptable header +* version, and the structure size is not 0. +*/ + ret =smu_check_pptable (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -41,6 +41,7 @@ struct smu_funcsint (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu);int (*get_vbios_bootup_values)(struct smu_context *smu); +int (*check_pptable)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -57,6 +58,8 @@ struct smu_funcs ((smu)->funcs->read_pptable_from_vbios ? (smu)->funcs->read_pptable_from_vbios((smu)) : 0)#define smu_get_vbios_bootup_values (smu) \ ((smu)->funcs->get_vbios_bootup_values ? (smu)->funcs->get_vbios_bootup_values((smu)) : 0) +#define smu_check_pptable (smu) \ + ((smu)->funcs->check_pptable ? (smu)->funcs->check_pptable((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 11/138 drm/amd/powerplay: add interface to init fb allocations (v2)
In reply to a message not in the archiveThis patch adds interface to init fb allocations for smu. It's to allocate vram bos to store smc table contents.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +13 -0
@@ -132,6 +132,12 @@ static int smu_sw_fini(void *handle)return 0 ; } +static int smu_init_fb_allocations (struct smu_context *smu) +{ +/* TODO */ +return 0 ; +} +static int smu_smc_table_hw_init (struct smu_context *smu) {int ret;
@@ -153,6 +159,13 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* allocate vram bos to store smc table contents. +*/ + ret =smu_init_fb_allocations (smu); +if (ret) +return ret; +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 12/138 drm/amd/powerplay: add interface to parse pptable (v2)
In reply to a message not in the archiveThis patch adds interface to parse pptable for smu.
It's to parse pptable format and fill PPTable_t smc_pptable to smu_table_context structure. And read the smc_dpm_table from vbios, then fill it into smc_pptable.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 9 +++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ 2 files changed, 13 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +9 -0
@@ -166,6 +166,15 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* Parse pptable format and fill PPTable_t smc_pptable to +* smu_table_context structure. And read the smc_dpm_table from vbios, +* then fill it into smc_pptable. +*/ + ret =smu_parse_pptable (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -42,6 +42,7 @@ struct smu_funcsint (*read_pptable_from_vbios)(struct smu_context *smu);int (*get_vbios_bootup_values)(struct smu_context *smu);int (*check_pptable)(struct smu_context *smu); +int (*parse_pptable)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -60,6 +61,9 @@ struct smu_funcs ((smu)->funcs->get_vbios_bootup_values ? (smu)->funcs->get_vbios_bootup_values((smu)) : 0)#define smu_check_pptable (smu) \ ((smu)->funcs->check_pptable ? (smu)->funcs->check_pptable((smu)) : 0) +#define smu_parse_pptable (smu) \ + ((smu)->funcs->parse_pptable ? (smu)->funcs->parse_pptable((smu)) : 0) +extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 13/138 drm/amd/powerplay: add interface to populate smc pptable (v2)
In reply to a message not in the archiveThis patch adds interface to populate smc pptable for smu.
It's to set initialized values (get from vbios) to dpm tables context such as gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each type of clks.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 9 +++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 12 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +9 -0
@@ -175,6 +175,15 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* Set initialized values (get from vbios) to dpm tables context such as +* gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each +* type of clks. +*/ + ret =smu_populate_smc_pptable (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -43,6 +43,7 @@ struct smu_funcsint (*get_vbios_bootup_values)(struct smu_context *smu);int (*check_pptable)(struct smu_context *smu);int (*parse_pptable)(struct smu_context *smu); +int (*populate_smc_pptable)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -63,6 +64,8 @@ struct smu_funcs ((smu)->funcs->check_pptable ? (smu)->funcs->check_pptable((smu)) : 0)#define smu_parse_pptable (smu) \ ((smu)->funcs->parse_pptable ? (smu)->funcs->parse_pptable((smu)) : 0) +#define smu_populate_smc_pptable (smu) \ + ((smu)->funcs->populate_smc_pptable ? (smu)->funcs->populate_smc_pptable((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 14/138 drm/amd/powerplay: add interface to check fw version (v2)
In reply to a message not in the archiveThis patch adds interface to check fw version for smu.
It's to send msg GetDriverIfVersion to check if the return value is equal with DRIVER_IF_VERSION of smc header.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -184,6 +184,14 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* Send msg GetDriverIfVersion to check if the return value is equal +* with DRIVER_IF_VERSION of smc header. +*/ + ret =smu_check_fw_version (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -44,6 +44,7 @@ struct smu_funcsint (*check_pptable)(struct smu_context *smu);int (*parse_pptable)(struct smu_context *smu);int (*populate_smc_pptable)(struct smu_context *smu); +int (*check_fw_version)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -66,6 +67,8 @@ struct smu_funcs ((smu)->funcs->parse_pptable ? (smu)->funcs->parse_pptable((smu)) : 0)#define smu_populate_smc_pptable (smu) \ ((smu)->funcs->populate_smc_pptable ? (smu)->funcs->populate_smc_pptable((smu)) : 0) +#define smu_check_fw_version (smu) \ + ((smu)->funcs->check_fw_version ? (smu)->funcs->check_fw_version((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 15/138 drm/amd/powerplay: add interface to write pptable (v2)
In reply to a message not in the archiveThis patch adds interface to write pptable for smu. It's to copy pptable bo in the vram to smc with SMU MSGs such as SetDriverDramAddr and TransferTableDram2Smu.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -192,6 +192,14 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* Copy pptable bo in the vram to smc with SMU MSGs such as +* SetDriverDramAddr and TransferTableDram2Smu. +*/ + ret =smu_write_pptable (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -45,6 +45,7 @@ struct smu_funcsint (*parse_pptable)(struct smu_context *smu);int (*populate_smc_pptable)(struct smu_context *smu);int (*check_fw_version)(struct smu_context *smu); +int (*write_pptable)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -69,6 +70,8 @@ struct smu_funcs ((smu)->funcs->populate_smc_pptable ? (smu)->funcs->populate_smc_pptable((smu)) : 0)#define smu_check_fw_version (smu) \ ((smu)->funcs->check_fw_version ? (smu)->funcs->check_fw_version((smu)) : 0) +#define smu_write_pptable (smu) \ + ((smu)->funcs->write_pptable ? (smu)->funcs->write_pptable((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 16/138 drm/amd/powerplay: add interface to set min dcef deep sleep (v2)
In reply to a message not in the archiveThis patch adds interface to set min dcef deep sleep for smu. It's to set min deep sleep dce fclk with bootup value from vbios via SetMinDeepSleepDcefclk MSG.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -200,6 +200,14 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* +* Set min deep sleep dce fclk with bootup value from vbios via +* SetMinDeepSleepDcefclk MSG. +*/ + ret =smu_set_min_dcef_deep_sleep (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -46,6 +46,7 @@ struct smu_funcsint (*populate_smc_pptable)(struct smu_context *smu);int (*check_fw_version)(struct smu_context *smu);int (*write_pptable)(struct smu_context *smu); +int (*set_min_dcef_deep_sleep)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -72,6 +73,8 @@ struct smu_funcs ((smu)->funcs->check_fw_version ? (smu)->funcs->check_fw_version((smu)) : 0)#define smu_write_pptable (smu) \ ((smu)->funcs->write_pptable ? (smu)->funcs->write_pptable((smu)) : 0) +#define smu_set_min_dcef_deep_sleep (smu) \ + ((smu)->funcs->set_min_dcef_deep_sleep ? (smu)->funcs->set_min_dcef_deep_sleep((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 17/138 drm/amd/powerplay: add interface to set tool table location (v2)
In reply to a message not in the archiveThis patch adds interface to set tool table location for smu. Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 7 ++++++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -1
@@ -208,7 +208,12 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; -return 0 ; +/* +* Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. +*/ + ret =smu_set_tool_table_location (smu); + +return ret; }static int smu_hw_init (void *handle)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -47,6 +47,7 @@ struct smu_funcsint (*check_fw_version)(struct smu_context *smu);int (*write_pptable)(struct smu_context *smu);int (*set_min_dcef_deep_sleep)(struct smu_context *smu); +int (*set_tool_table_location)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -75,6 +76,8 @@ struct smu_funcs ((smu)->funcs->write_pptable ? (smu)->funcs->write_pptable((smu)) : 0)#define smu_set_min_dcef_deep_sleep (smu) \ ((smu)->funcs->set_min_dcef_deep_sleep ? (smu)->funcs->set_min_dcef_deep_sleep((smu)) : 0) +#define smu_set_tool_table_location (smu) \ + ((smu)->funcs->set_tool_table_location ? (smu)->funcs->set_tool_table_location((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 18/138 drm/amd/powerplay: add interface to allocate memory pool (v2)
In reply to a message not in the archiveThis patch adds interface to allocate memory pool for smu.
This memory pool will be used for SMC use and msg SetSystemVirtualDramAddr and DramLogSetDramAddr can notify it changed.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +19 -0
@@ -216,6 +216,21 @@ static int smu_smc_table_hw_init(struct smu_context *smu)return ret; } +/** +* smu_alloc_memory_pool - allocate memory pool in the system memory +* +* @smu: amdgpu_device pointer +* +* This memory pool will be used for SMC use and msg SetSystemVirtualDramAddr +* and DramLogSetDramAddr can notify it changed. +* +* Returns 0 on success, error on failure. +*/ +static int smu_alloc_memory_pool (struct smu_context *smu) +{ +return 0 ; +} +static int smu_hw_init (void *handle) {int ret;
@@ -243,6 +258,10 @@ static int smu_hw_init(void *handle)if (ret) goto failed; + ret =smu_alloc_memory_pool (smu); +if (ret) + goto failed; +mutex_unlock (&smu->mutex);pr_info ("SMU is initialized successfully!\n" );
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 19/138 drm/amd/powerplay: add interface to notify memory pool location (v2)
In reply to a message not in the archiveThis patch adds interface to notify memory pool location for smu. It's to use msg SetSystemVirtualDramAddr and DramLogSetDramAddr can notify pool location.
v2: add detailed info to describe this function
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -262,6 +262,14 @@ static int smu_hw_init(void *handle)if (ret) goto failed; +/* +* Use msg SetSystemVirtualDramAddr and DramLogSetDramAddr can notify +* pool location. +*/ + ret =smu_notify_memory_pool_location (smu); +if (ret) + goto failed; +mutex_unlock (&smu->mutex);pr_info ("SMU is initialized successfully!\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -48,6 +48,7 @@ struct smu_funcsint (*write_pptable)(struct smu_context *smu);int (*set_min_dcef_deep_sleep)(struct smu_context *smu);int (*set_tool_table_location)(struct smu_context *smu); +int (*notify_memory_pool_location)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -78,6 +79,8 @@ struct smu_funcs ((smu)->funcs->set_min_dcef_deep_sleep ? (smu)->funcs->set_min_dcef_deep_sleep((smu)) : 0)#define smu_set_tool_table_location (smu) \ ((smu)->funcs->set_tool_table_location ? (smu)->funcs->set_tool_table_location((smu)) : 0) +#define smu_notify_memory_pool_location (smu) \ + ((smu)->funcs->notify_memory_pool_location ? (smu)->funcs->notify_memory_pool_location((smu)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 20/138 drm/amd/powerplay: add interfaces for smu resume
In reply to a message not in the archiveSMU resume needs three more interfaces such as write_watermarks_table, set_last_dcef_min_deep_sleep_clk, and system_features_control.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +9 -0
@@ -49,6 +49,9 @@ struct smu_funcsint (*set_min_dcef_deep_sleep)(struct smu_context *smu);int (*set_tool_table_location)(struct smu_context *smu);int (*notify_memory_pool_location)(struct smu_context *smu); +int (*write_watermarks_table)(struct smu_context *smu); +int (*set_last_dcef_min_deep_sleep_clk)(struct smu_context *smu); +int (*system_features_control)(struct smu_context *smu,bool en); };#define smu_init_microcode (smu) \
@@ -81,6 +84,12 @@ struct smu_funcs ((smu)->funcs->set_tool_table_location ? (smu)->funcs->set_tool_table_location((smu)) : 0)#define smu_notify_memory_pool_location (smu) \ ((smu)->funcs->notify_memory_pool_location ? (smu)->funcs->notify_memory_pool_location((smu)) : 0) +#define smu_write_watermarks_table (smu) \ + ((smu)->funcs->write_watermarks_table ? (smu)->funcs->write_watermarks_table((smu)) : 0) +#define smu_set_last_dcef_min_deep_sleep_clk (smu) \ + ((smu)->funcs->set_last_dcef_min_deep_sleep_clk ? (smu)->funcs->set_last_dcef_min_deep_sleep_clk((smu)) : 0) +#define smu_system_features_control (smu, en) \ + ((smu)->funcs->system_features_control ? (smu)->funcs->system_features_control((smu), (en)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 21/138 drm/amd/powerplay: add resume sequence placeholder for smu ip block
In reply to a message not in the archiveThis patch adds resume sequence placeholder for smu ip block.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 39 +++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +38 -1
@@ -311,13 +311,50 @@ static int smu_resume(void *handle)if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; +pr_info ("SMU is resuming...\n" ); + +if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) { + ret =smu_load_microcode (smu); +if (ret) +return ret; + } + + ret =smu_check_fw_status (smu); +if (ret) { +pr_err ("SMC firmware status is not correct\n" ); +return ret; + } +mutex_lock (&smu->mutex); -/* TODO */ + ret =smu_set_tool_table_location (smu); +if (ret) + goto failed; + + ret =smu_write_pptable (smu); +if (ret) + goto failed; + + ret =smu_write_watermarks_table (smu); +if (ret) + goto failed; + + ret =smu_set_last_dcef_min_deep_sleep_clk (smu); +if (ret) + goto failed; + + ret =smu_system_features_control (smu, true); +if (ret) + goto failed;mutex_unlock (&smu->mutex); +pr_info ("SMU is resumed successfully!\n" ); +return 0 ; +failed: +mutex_unlock (&smu->mutex); +return ret; } static int smu_set_clockgating_state(void *handle,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 22/138 drm/amdgpu: enable new smu ip block for vega20
In reply to a message not in the archiveSwitch to new smu ip block since vega20.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +7 -2
@@ -63,6 +63,7 @@#include "vcn_v1_0.h" #include "dce_virtual.h" #include "mxgpu_ai.h" +#include "amdgpu_smu.h" #define mmMP0_MISC_CGTT_CTRL0 0x01b9#define mmMP0_MISC_CGTT_CTRL0_BASE_IDX 0
@@ -603,8 +604,12 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev) }amdgpu_device_ip_block_add (adev, &gfx_v9_0_ip_block);amdgpu_device_ip_block_add (adev, &sdma_v4_0_ip_block); -if (!amdgpu_sriov_vf (adev)) -amdgpu_device_ip_block_add (adev, &pp_smu_ip_block); +if (!amdgpu_sriov_vf (adev)) { +if (amdgpu_dpm ==1 && adev->asic_type >=CHIP_VEGA20 ) +amdgpu_device_ip_block_add (adev, &smu_v11_0_ip_block); +else +amdgpu_device_ip_block_add (adev, &pp_smu_ip_block); + }if (adev->enable_virtual_display ||amdgpu_sriov_vf (adev))amdgpu_device_ip_block_add (adev, &dce_virtual_ip_block);#if defined(CONFIG_DRM_AMD_DC )
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 23/138 drm/amd/powerplay: init microcode for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function of init mircrocode for smu11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +46 -1
@@ -26,11 +26,56 @@#include "amdgpu_smu.h" #include "smu_v11_0.h" +MODULE_FIRMWARE ("amdgpu/vega20_smc.bin" ); +static int smu_v11_0_init_microcode (struct smu_context *smu) {struct amdgpu_device *adev = smu->adev; +const char *chip_name; +char fw_name[30 ]; +int err =0 ; +const struct smc_firmware_header_v1_0 *hdr; +const struct common_firmware_header *header; +struct amdgpu_firmware_info *ucode =NULL ; -return 0 ; +switch (adev->asic_type) { +case CHIP_VEGA20 : + chip_name ="vega20" ; +break ; +default : +BUG (); + } + +snprintf (fw_name,sizeof (fw_name),"amdgpu/%s_smc.bin" , chip_name); + + err =request_firmware (&adev->pm.fw, fw_name, adev->dev); +if (err) + goto out; + err =amdgpu_ucode_validate (adev->pm.fw); +if (err) + goto out; + + hdr = (const struct smc_firmware_header_v1_0 *) adev->pm.fw->data; +amdgpu_ucode_print_smc_hdr (&hdr->header); + adev->pm.fw_version =le32_to_cpu (hdr->header.ucode_version); + +if (adev->firmware.load_type ==AMDGPU_FW_LOAD_PSP ) { + ucode = &adev->firmware.ucode[AMDGPU_UCODE_ID_SMC ]; + ucode->ucode_id =AMDGPU_UCODE_ID_SMC ; + ucode->fw = adev->pm.fw; + header = (const struct common_firmware_header *)ucode->fw->data; + adev->firmware.fw_size += +ALIGN (le32_to_cpu (header->ucode_size_bytes),PAGE_SIZE ); + } + +out: +if (err) { +DRM_ERROR ("smu_v11_0: Failed to load firmware \"%s\"\n" , + fw_name); +release_firmware (adev->pm.fw); + adev->pm.fw =NULL ; + } +return err; }static int smu_v11_0_load_microcode (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 24/138 drm/amd/powerplay: add new ppsmc header for smu11 (v2)
In reply to a message not in the archiveThis header will be used for smc message handling.
v2: add a license to the top of the header file (Alex)
--- .../gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h | 128 +++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 1 + 2 files changed, 129 insertions(+) create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_ppsmc.h new file +128 -0
@@ -0,0 +1,128 @@ +/* +* Copyright 2018 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ + +#ifndef SMU_V11_0_PPSMC_H +#define SMU_V11_0_PPSMC_H + +// SMU Response Codes: +#define PPSMC_Result_OK 0x1 +#define PPSMC_Result_Failed 0xFF +#define PPSMC_Result_UnknownCmd 0xFE +#define PPSMC_Result_CmdRejectedPrereq 0xFD +#define PPSMC_Result_CmdRejectedBusy 0xFC + +// Message Definitions: +// BASIC +#define PPSMC_MSG_TestMessage 0x1 +#define PPSMC_MSG_GetSmuVersion 0x2 +#define PPSMC_MSG_GetDriverIfVersion 0x3 +#define PPSMC_MSG_SetAllowedFeaturesMaskLow 0x4 +#define PPSMC_MSG_SetAllowedFeaturesMaskHigh 0x5 +#define PPSMC_MSG_EnableAllSmuFeatures 0x6 +#define PPSMC_MSG_DisableAllSmuFeatures 0x7 +#define PPSMC_MSG_EnableSmuFeaturesLow 0x8 +#define PPSMC_MSG_EnableSmuFeaturesHigh 0x9 +#define PPSMC_MSG_DisableSmuFeaturesLow 0xA +#define PPSMC_MSG_DisableSmuFeaturesHigh 0xB +#define PPSMC_MSG_GetEnabledSmuFeaturesLow 0xC +#define PPSMC_MSG_GetEnabledSmuFeaturesHigh 0xD +#define PPSMC_MSG_SetDriverDramAddrHigh 0xE +#define PPSMC_MSG_SetDriverDramAddrLow 0xF +#define PPSMC_MSG_SetToolsDramAddrHigh 0x10 +#define PPSMC_MSG_SetToolsDramAddrLow 0x11 +#define PPSMC_MSG_TransferTableSmu2Dram 0x12 +#define PPSMC_MSG_TransferTableDram2Smu 0x13 +#define PPSMC_MSG_UseDefaultPPTable 0x14 +#define PPSMC_MSG_UseBackupPPTable 0x15 +#define PPSMC_MSG_SetSystemVirtualDramAddrHigh 0x16 +#define PPSMC_MSG_SetSystemVirtualDramAddrLow 0x17 + +//BACO/BAMACO/BOMACO +#define PPSMC_MSG_EnterBaco 0x18 +#define PPSMC_MSG_ExitBaco 0x19 + +//DPM +#define PPSMC_MSG_SetSoftMinByFreq 0x1A +#define PPSMC_MSG_SetSoftMaxByFreq 0x1B +#define PPSMC_MSG_SetHardMinByFreq 0x1C +#define PPSMC_MSG_SetHardMaxByFreq 0x1D +#define PPSMC_MSG_GetMinDpmFreq 0x1E +#define PPSMC_MSG_GetMaxDpmFreq 0x1F +#define PPSMC_MSG_GetDpmFreqByIndex 0x20 +#define PPSMC_MSG_OverridePcieParameters 0x21 +#define PPSMC_MSG_SetMinDeepSleepDcefclk 0x22 +#define PPSMC_MSG_SetWorkloadMask 0x23 +#define PPSMC_MSG_SetUclkFastSwitch 0x24 +#define PPSMC_MSG_GetAvfsVoltageByDpm 0x25 +#define PPSMC_MSG_SetVideoFps 0x26 +#define PPSMC_MSG_GetDcModeMaxDpmFreq 0x27 + +//Power Gating +#define PPSMC_MSG_AllowGfxOff 0x28 +#define PPSMC_MSG_DisallowGfxOff 0x29 +#define PPSMC_MSG_PowerUpVcn 0x2A +#define PPSMC_MSG_PowerDownVcn 0x2B +#define PPSMC_MSG_PowerUpJpeg 0x2C +#define PPSMC_MSG_PowerDownJpeg 0x2D +//reserve 0x2A to 0x2F for PG harvesting TBD + +//I2C Interface +#define PPSMC_RequestI2cTransaction 0x30 + +//Resets +#define PPSMC_MSG_SoftReset 0x31 //FIXME Need confirmation from driver +#define PPSMC_MSG_PrepareMp1ForUnload 0x32 +#define PPSMC_MSG_PrepareMp1ForReset 0x33 +#define PPSMC_MSG_PrepareMp1ForShutdown 0x34 + +//ACDC Power Source +#define PPSMC_MSG_SetPptLimit 0x35 +#define PPSMC_MSG_GetPptLimit 0x36 +#define PPSMC_MSG_ReenableAcDcInterrupt 0x37 +#define PPSMC_MSG_NotifyPowerSource 0x38 +//#define PPSMC_MSG_GfxDeviceDriverReset 0x39 //FIXME mode1 and 2 resets will go directly go PSP + +//BTC +#define PPSMC_MSG_RunBtc 0x3A + +//Debug +#define PPSMC_MSG_DramLogSetDramAddrHigh 0x3B +#define PPSMC_MSG_DramLogSetDramAddrLow 0x3C +#define PPSMC_MSG_DramLogSetDramSize 0x3D +#define PPSMC_MSG_GetDebugData 0x3E + +//Others +#define PPSMC_MSG_ConfigureGfxDidt 0x3F +#define PPSMC_MSG_NumOfDisplays 0x40 + +#define PPSMC_MSG_SetMemoryChannelConfig 0x41 +#define PPSMC_MSG_SetGeminiMode 0x42 +#define PPSMC_MSG_SetGeminiApertureHigh 0x43 +#define PPSMC_MSG_SetGeminiApertureLow 0x44 + +#define PPSMC_Message_Count 0x45 + +typedef uint32_t PPSMC_Result ; +typedef uint32_t PPSMC_Msg ; + +#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
@@ -25,6 +25,7 @@#include "amdgpu.h" #include "amdgpu_smu.h" #include "smu_v11_0.h" +#include "smu_v11_0_ppsmc.h" MODULE_FIRMWARE ("amdgpu/vega20_smc.bin" );
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 25/138 drm/amd/powerplay: implement smu send message functions for smu11 (v3)
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Add function of smu send message for smu11
v2: fix the missing ) in define of smu_send_smc_msg_with_param
v3: Use adev usec timeout for smu as well, the origin time 10 us is not enough. (Ray)
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 8 ++- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 84 ++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +7 -1
@@ -52,6 +52,9 @@ struct smu_funcsint (*write_watermarks_table)(struct smu_context *smu);int (*set_last_dcef_min_deep_sleep_clk)(struct smu_context *smu);int (*system_features_control)(struct smu_context *smu,bool en); +int (*send_smc_msg)(struct smu_context *smu,uint16_t msg); +int (*send_smc_msg_with_param)(struct smu_context *smu,uint16_t msg,uint32_t param); + };#define smu_init_microcode (smu) \
@@ -90,7 +93,10 @@ struct smu_funcs ((smu)->funcs->set_last_dcef_min_deep_sleep_clk ? (smu)->funcs->set_last_dcef_min_deep_sleep_clk((smu)) : 0)#define smu_system_features_control (smu, en) \ ((smu)->funcs->system_features_control ? (smu)->funcs->system_features_control((smu), (en)) : 0) - +#define smu_send_smc_msg (smu, msg) \ + ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0) +#define smu_send_smc_msg_with_param (smu, msg, param) \ + ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0)extern const struct amd_ip_funcs smu_ip_funcs;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +84 -0
99 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 26/138 drm/amd/powerplay: implement check_fw_status function for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Add function of check firmware status funtions for smu11
--- drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 11 +++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 13 ++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +11 -0
@@ -25,6 +25,17 @@#include "amdgpu_smu.h" +/* MP Apertures */ +#define MP0_Public 0x03800000 +#define MP0_SRAM 0x03900000 +#define MP1_Public 0x03b00000 +#define MP1_SRAM 0x03c00004 + +/* address block */ +#define smnMP1_FIRMWARE_FLAGS 0x3010024 +#define smnMP0_FW_INTF 0x30101c0 +#define smnMP1_PUB_CTRL 0x3010b14 +void smu_v11_0_set_smu_funcs (struct smu_context *smu);#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +12 -1
@@ -168,7 +168,18 @@ static int smu_v11_0_load_microcode(struct smu_context *smu)static int smu_v11_0_check_fw_status (struct smu_context *smu) { -return 0 ; +struct amdgpu_device *adev = smu->adev; +uint32_t mp1_fw_flags; + +WREG32_SOC15 (NBIF ,0 , mmPCIE_INDEX2, + (MP1_Public | (smnMP1_FIRMWARE_FLAGS &0xffffffff ))); + + mp1_fw_flags =RREG32_SOC15 (NBIF ,0 , mmPCIE_DATA2); + +if ((mp1_fw_flags &MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK ) >> +MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED__SHIFT ) +return 0 ; +return -EIO ; }static const struct smu_funcs smu_v11_0_funcs = {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 27/138 drm/amd/powerplay: implement check_fw_version function for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Add function of check firmware version for smu11
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +29 -0
@@ -26,6 +26,7 @@#include "amdgpu_smu.h" #include "smu_v11_0.h" #include "smu_v11_0_ppsmc.h" +#include "smu11_driver_if.h" #include "soc15_common.h" #include "asic_reg/thm/thm_11_0_2_offset.h"
@@ -44,6 +45,14 @@ static int smu_v11_0_send_msg_without_waiting(struct smu_context *smu,return 0 ; } +static int smu_v11_0_read_arg (struct smu_context *smu,uint32_t *arg) +{ +struct amdgpu_device *adev = smu->adev; + + *arg =RREG32_SOC15 (MP1 ,0 , mmMP1_SMN_C2PMSG_82); +return 0 ; +} +static int smu_v11_0_wait_for_response (struct smu_context *smu) {struct amdgpu_device *adev = smu->adev;
@@ -182,10 +191,30 @@ static int smu_v11_0_check_fw_status(struct smu_context *smu)return -EIO ; } +static int smu_v11_0_check_fw_version (struct smu_context *smu) +{ +uint32_t smu_version =0xff ; +int ret =0 ; + + ret =smu_send_smc_msg (smu, PPSMC_MSG_GetDriverIfVersion); +if (ret) + goto err; + + ret =smu_v11_0_read_arg (smu, &smu_version); +if (ret) + goto err; + +if (smu_version ==SMU11_DRIVER_IF_VERSION ) +return 0 ; +err: +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode, .check_fw_status = smu_v11_0_check_fw_status, + .check_fw_version = smu_v11_0_check_fw_version, .send_smc_msg = smu_v11_0_send_msg, .send_smc_msg_with_param = smu_v11_0_send_msg_with_param, };
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 28/138 drm/amd/powerplay: add pptable header for smu11
In reply to a message not in the archiveThis patch adds the pptable header for smu11.
--- .../gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h | 147 +++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 1 + 2 files changed, 148 insertions(+) create mode 100644 drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h new file +147 -0
@@ -0,0 +1,147 @@ +/* +* Copyright 2018 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef SMU_11_0_PPTABLE_H +#define SMU_11_0_PPTABLE_H + + +#define SMU_11_0_TABLE_FORMAT_REVISION 12 + +//// POWERPLAYTABLE::ulPlatformCaps +#define SMU_11_0_PP_PLATFORM_CAP_POWERPLAY 0x1 +#define SMU_11_0_PP_PLATFORM_CAP_SBIOSPOWERSOURCE 0x2 +#define SMU_11_0_PP_PLATFORM_CAP_HARDWAREDC 0x4 +#define SMU_11_0_PP_PLATFORM_CAP_BACO 0x8 +#define SMU_11_0_PP_PLATFORM_CAP_MACO 0x10 +#define SMU_11_0_PP_PLATFORM_CAP_SHADOWPSTATE 0x20 + +// SMU_11_0_PP_THERMALCONTROLLER - Thermal Controller Type +#define SMU_11_0_PP_THERMALCONTROLLER_NONE 0 + +#define SMU_11_0_PP_OVERDRIVE_VERSION 0x0800 +#define SMU_11_0_PP_POWERSAVINGCLOCK_VERSION 0x0100 + +enum SMU_11_0_ODFEATURE_ID { +SMU_11_0_ODFEATURE_GFXCLK_LIMITS =0 ,//GFXCLK Limit feature +SMU_11_0_ODFEATURE_GFXCLK_CURVE ,//GFXCLK Curve feature +SMU_11_0_ODFEATURE_UCLK_MAX ,//UCLK Limit feature +SMU_11_0_ODFEATURE_POWER_LIMIT ,//Power Limit feature +SMU_11_0_ODFEATURE_FAN_ACOUSTIC_LIMIT ,//Fan Acoustic RPM feature +SMU_11_0_ODFEATURE_FAN_SPEED_MIN ,//Minimum Fan Speed feature +SMU_11_0_ODFEATURE_TEMPERATURE_FAN ,//Fan Target Temperature Limit feature +SMU_11_0_ODFEATURE_TEMPERATURE_SYSTEM ,//Operating Temperature Limit feature +SMU_11_0_ODFEATURE_MEMORY_TIMING_TUNE ,//AC Timing Tuning feature +SMU_11_0_ODFEATURE_FAN_ZERO_RPM_CONTROL ,//Zero RPM feature +SMU_11_0_ODFEATURE_AUTO_UV_ENGINE ,//Auto Under Volt GFXCLK feature +SMU_11_0_ODFEATURE_AUTO_OC_ENGINE ,//Auto Over Clock GFXCLK feature +SMU_11_0_ODFEATURE_AUTO_OC_MEMORY ,//Auto Over Clock MCLK feature +SMU_11_0_ODFEATURE_COUNT , +}; +#define SMU_11_0_MAX_ODFEATURE 32 //Maximum Number of OD Features + +enum SMU_11_0_ODSETTING_ID { +SMU_11_0_ODSETTING_GFXCLKFMAX =0 , +SMU_11_0_ODSETTING_GFXCLKFMIN , +SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P1 , +SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P1 , +SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P2 , +SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P2 , +SMU_11_0_ODSETTING_VDDGFXCURVEFREQ_P3 , +SMU_11_0_ODSETTING_VDDGFXCURVEVOLTAGE_P3 , +SMU_11_0_ODSETTING_UCLKFMAX , +SMU_11_0_ODSETTING_POWERPERCENTAGE , +SMU_11_0_ODSETTING_FANRPMMIN , +SMU_11_0_ODSETTING_FANRPMACOUSTICLIMIT , +SMU_11_0_ODSETTING_FANTARGETTEMPERATURE , +SMU_11_0_ODSETTING_OPERATINGTEMPMAX , +SMU_11_0_ODSETTING_ACTIMING , +SMU_11_0_ODSETTING_FAN_ZERO_RPM_CONTROL , +SMU_11_0_ODSETTING_AUTOUVENGINE , +SMU_11_0_ODSETTING_AUTOOCENGINE , +SMU_11_0_ODSETTING_AUTOOCMEMORY , +SMU_11_0_ODSETTING_COUNT , +}; +#define SMU_11_0_MAX_ODSETTING 32 //Maximum Number of ODSettings + +struct smu_11_0_overdrive_table +{ +uint8_t revision;//Revision = SMU_11_0_PP_OVERDRIVE_VERSION +uint8_t reserve[3 ];//Zero filled field reserved for future use +uint32_t feature_count;//Total number of supported features +uint32_t setting_count;//Total number of supported settings +uint8_t cap[SMU_11_0_MAX_ODFEATURE ];//OD feature support flags +uint32_t max[SMU_11_0_MAX_ODSETTING ];//default maximum settings +uint32_t min[SMU_11_0_MAX_ODSETTING ];//default minimum settings +}; + +enum SMU_11_0_PPCLOCK_ID { +SMU_11_0_PPCLOCK_GFXCLK =0 , +SMU_11_0_PPCLOCK_VCLK , +SMU_11_0_PPCLOCK_DCLK , +SMU_11_0_PPCLOCK_ECLK , +SMU_11_0_PPCLOCK_SOCCLK , +SMU_11_0_PPCLOCK_UCLK , +SMU_11_0_PPCLOCK_DCEFCLK , +SMU_11_0_PPCLOCK_DISPCLK , +SMU_11_0_PPCLOCK_PIXCLK , +SMU_11_0_PPCLOCK_PHYCLK , +SMU_11_0_PPCLOCK_COUNT , +}; +#define SMU_11_0_MAX_PPCLOCK 16 //Maximum Number of PP Clocks + +struct smu_11_0_power_saving_clock_table +{ +uint8_t revision;//Revision = SMU_11_0_PP_POWERSAVINGCLOCK_VERSION +uint8_t reserve[3 ];//Zero filled field reserved for future use +uint32_t count;//power_saving_clock_count = SMU_11_0_PPCLOCK_COUNT +uint32_t max[SMU_11_0_MAX_PPCLOCK ];//PowerSavingClock Mode Clock Maximum array In MHz +uint32_t min[SMU_11_0_MAX_PPCLOCK ];//PowerSavingClock Mode Clock Minimum array In MHz +}; + +struct smu_11_0_powerplay_table +{ +struct atom_common_table_header header; +uint8_t table_revision; +uint32_t table_size;//Driver portion table size. The offset to smc_pptable including header size +uint32_t golden_pp_id; +uint32_t golden_revision; +uint16_t format_id; +uint32_t platform_caps;//POWERPLAYABLE::ulPlatformCaps + +uint8_t thermal_controller_type;//one of SMU_11_0_PP_THERMALCONTROLLER + +uint16_t small_power_limit1; +uint16_t small_power_limit2; +uint16_t boost_power_limit; +uint16_t od_turbo_power_limit;//Power limit setting for Turbo mode in Performance UI Tuning. +uint16_t od_power_save_power_limit;//Power limit setting for PowerSave/Optimal mode in Performance UI Tuning. +uint16_t software_shutdown_temp; + +uint16_t reserve[6 ];//Zero filled field reserved for future use + +struct smu_11_0_power_saving_clock_table power_saving_clock; +struct smu_11_0_overdrive_table overdrive_table; + +PPTable_t smc_pptable;//PPTable_t in smu11_driver_if.h +}; + +#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
@@ -28,6 +28,7 @@#include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h" #include "soc15_common.h" +#include "smu_v11_0_pptable.h" #include "asic_reg/thm/thm_11_0_2_offset.h" #include "asic_reg/thm/thm_11_0_2_sh_mask.h"
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 29/138 drm/amdgpu: update atomfirmware header for smu11
In reply to a message not in the archiveThis patch updates atomfirmware header on smu11 for future use.
--- drivers/gpu/drm/amd/include/atomfirmware.h | 44 +++++++++++++++++++++++++----- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 1 + 2 files changed, 38 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/include/atomfirmware.h +37 -7
@@ -528,6 +528,35 @@ struct atom_firmware_info_v3_2 {uint32_t reserved2[3 ]; }; +struct atom_firmware_info_v3_3 +{ +struct atom_common_table_header table_header; +uint32_t firmware_revision; +uint32_t bootup_sclk_in10khz; +uint32_t bootup_mclk_in10khz; +uint32_t firmware_capability;// enum atombios_firmware_capability +uint32_t main_call_parser_entry;/* direct address of main parser call in VBIOS binary. */ +uint32_t bios_scratch_reg_startaddr;// 1st bios scratch register dword address +uint16_t bootup_vddc_mv; +uint16_t bootup_vddci_mv; +uint16_t bootup_mvddc_mv; +uint16_t bootup_vddgfx_mv; +uint8_t mem_module_id; +uint8_t coolingsolution_id;/*0: Air cooling; 1: Liquid cooling ... */ +uint8_t reserved1[2 ]; +uint32_t mc_baseaddr_high; +uint32_t mc_baseaddr_low; +uint8_t board_i2c_feature_id;// enum of atom_board_i2c_feature_id_def +uint8_t board_i2c_feature_gpio_id;// i2c id find in gpio_lut data table gpio_id +uint8_t board_i2c_feature_slave_addr; +uint8_t reserved3; +uint16_t bootup_mvddq_mv; +uint16_t bootup_mvpp_mv; +uint32_t zfbstartaddrin16mb; +uint32_t pplib_pptable_id;// if pplib_pptable_id!=0, pplib get powerplay table inside driver instead of from VBIOS +uint32_t reserved2[2 ]; +}; +/* *************************************************************************** Data Table lcd_info structure
@@ -1226,16 +1255,17 @@ struct atom_gfx_info_v2_3 {uint32_t rm21_sram_vmin_value; }; -struct atom_gfx_info_v2_4 { +struct atom_gfx_info_v2_4 +{struct atom_common_table_header table_header;uint8_t gfxip_min_ver;uint8_t gfxip_max_ver; -uint8_t gc_num_se; -uint8_t max_tile_pipes; -uint8_t gc_num_cu_per_sh; -uint8_t gc_num_sh_per_se; -uint8_t gc_num_rb_per_se; -uint8_t gc_num_tccs; +uint8_t max_shader_engines; +uint8_t reserved; +uint8_t max_cu_per_sh; +uint8_t max_sh_per_se; +uint8_t max_backends_per_se; +uint8_t max_texture_channel_caches;uint32_t regaddr_cp_dma_src_addr;uint32_t regaddr_cp_dma_src_addr_hi;uint32_t regaddr_cp_dma_dst_addr;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
@@ -24,6 +24,7 @@#include <linux/firmware.h> #include "amdgpu.h" #include "amdgpu_smu.h" +#include "atomfirmware.h" #include "smu_v11_0.h" #include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h"
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 30/138 drm/amdgpu: update new members in atomfirmware
In reply to a message not in the archiveThis patch updates new members for fields to meet new atomfirmware header.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +5 -5
@@ -346,11 +346,11 @@ int amdgpu_atomfirmware_get_gfx_info(struct amdgpu_device *adev) (mode_info->atom_context->bios + data_offset);switch (crev) {case 4 : - adev->gfx.config.max_shader_engines = gfx_info->v24.gc_num_se; - adev->gfx.config.max_cu_per_sh = gfx_info->v24.gc_num_cu_per_sh; - adev->gfx.config.max_sh_per_se = gfx_info->v24.gc_num_sh_per_se; - adev->gfx.config.max_backends_per_se = gfx_info->v24.gc_num_rb_per_se; - adev->gfx.config.max_texture_channel_caches = gfx_info->v24.gc_num_tccs; + adev->gfx.config.max_shader_engines = gfx_info->v24.max_shader_engines; + adev->gfx.config.max_cu_per_sh = gfx_info->v24.max_cu_per_sh; + adev->gfx.config.max_sh_per_se = gfx_info->v24.max_sh_per_se; + adev->gfx.config.max_backends_per_se = gfx_info->v24.max_backends_per_se; + adev->gfx.config.max_texture_channel_caches = gfx_info->v24.max_texture_channel_caches; adev->gfx.config.max_gprs =le16_to_cpu (gfx_info->v24.gc_num_gprs); adev->gfx.config.max_gs_threads = gfx_info->v24.gc_num_max_gs_thds; adev->gfx.config.gs_vgt_table_depth = gfx_info->v24.gc_gs_table_depth;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 31/138 drm/amd/powerplay: add smu table context structure
In reply to a message not in the archiveThis patch adds smu table context.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +8 -0
@@ -24,12 +24,20 @@#include "amdgpu.h" +struct smu_table_context +{ +void *power_play_table; +uint32_t power_play_table_size; +}; +struct smu_context {struct amdgpu_device *adev;const struct smu_funcs *funcs;struct mutex mutex; + +struct smu_table_context smu_table; };struct smu_funcs
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 32/138 drm/amd/powerplay: add get atom data table helper
In reply to a message not in the archiveThis patch adds get atom data table helper for smu future use.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 17 +++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ 2 files changed, 21 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +17 -0
@@ -27,6 +27,7 @@#include "amdgpu_smu.h" #include "soc15_common.h" #include "smu_v11_0.h" +#include "atom.h" static int smu_set_funcs (struct amdgpu_device *adev) {
@@ -59,6 +60,22 @@ static int smu_early_init(void *handle)return 0 ; } +int smu_get_atom_data_table (struct smu_context *smu,uint32_t table, +uint16_t *size,uint8_t *frev,uint8_t *crev, +uint8_t **addr) +{ +struct amdgpu_device *adev = smu->adev; +uint16_t data_start; + +if (!amdgpu_atom_parse_data_header (adev->mode_info.atom_context, table, + size, frev, crev, &data_start)) +return -EINVAL ; + + *addr = (uint8_t *)adev->mode_info.atom_context->bios + data_start; + +return 0 ; +} +static int smu_initialize_pptable (struct smu_context *smu) {/* TODO */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -106,6 +106,10 @@ struct smu_funcs#define smu_send_smc_msg_with_param (smu, msg, param) \ ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0) +extern int smu_get_atom_data_table (struct smu_context *smu,uint32_t table, +uint16_t *size,uint8_t *frev,uint8_t *crev, +uint8_t **addr); +extern const struct amd_ip_funcs smu_ip_funcs;extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 33/138 drm/amdgpu: move get_index_into_master_table macro into atomfirmware header
In reply to a message not in the archiveThis patchs move get_index_into_master_table macro into atomfirmware header for future use on smu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +0 -2
@@ -28,8 +28,6 @@#include "atom.h" #include "atombios.h" -#define get_index_into_master_table (master_table, table_name) (offsetof(struct master_table, table_name) / sizeof(uint16_t)) -bool amdgpu_atomfirmware_gpu_supports_virtualization (struct amdgpu_device *adev) { int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h +2 -0
@@ -24,6 +24,8 @@#ifndef __AMDGPU_ATOMFIRMWARE_H__#define __AMDGPU_ATOMFIRMWARE_H__ +#define get_index_into_master_table (master_table, table_name) (offsetof(struct master_table, table_name) / sizeof(uint16_t)) +bool amdgpu_atomfirmware_gpu_supports_virtualization (struct amdgpu_device *adev);void amdgpu_atomfirmware_scratch_regs_init (struct amdgpu_device *adev);int amdgpu_atomfirmware_allocate_fb_scratch (struct amdgpu_device *adev);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 34/138 drm/amd/powerplay: implement read_pptable_from_vbios function for smu11
In reply to a message not in the archiveThis patch implements the function of read_pptable_from_vbios for smu11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +23 -0
@@ -25,6 +25,7 @@#include "amdgpu.h" #include "amdgpu_smu.h" #include "atomfirmware.h" +#include "amdgpu_atomfirmware.h" #include "smu_v11_0.h" #include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h"
@@ -212,6 +213,27 @@ static int smu_v11_0_check_fw_version(struct smu_context *smu)return ret; } +static int smu_v11_0_read_pptable_from_vbios (struct smu_context *smu) +{ +int ret, index; +uint16_t size; +uint8_t frev, crev; +struct smu_11_0_powerplay_table *table; + + index =get_index_into_master_table (atom_master_list_of_data_tables_v2_1, + powerplayinfo); + + ret =smu_get_atom_data_table (smu, index, &size, &frev, &crev, + (uint8_t **)&table); +if (ret) +return ret; + + smu->smu_table.power_play_table = table; + smu->smu_table.power_play_table_size = size; + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -219,6 +241,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .check_fw_version = smu_v11_0_check_fw_version, .send_smc_msg = smu_v11_0_send_msg, .send_smc_msg_with_param = smu_v11_0_send_msg_with_param, + .read_pptable_from_vbios = smu_v11_0_read_pptable_from_vbios, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 35/138 drm/amd/powerplay: implement smu_init[fini]_smc_tables for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Each SMU IP may have a different number of SMU tables, so these tables are allocated using dynamic memory
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 21 +++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 22 +++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 43 ++++++++++++++++++++++++++ 3 files changed, 86 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +21 -0
@@ -115,6 +115,19 @@ static int smu_smc_table_sw_init(struct smu_context *smu)return 0 ; } +static int smu_smc_table_sw_fini (struct smu_context *smu) +{ +int ret; + + ret =smu_fini_smc_tables (smu); +if (ret) { +pr_err ("Failed to smu_fini_smc_tables!\n" ); +return ret; + } + +return 0 ; +} +static int smu_sw_init (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
@@ -142,10 +155,18 @@ static int smu_sw_init(void *handle)static int smu_sw_fini (void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +struct smu_context *smu = &adev->smu; +int ret;if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; + ret =smu_smc_table_sw_fini (smu); +if (ret) { +pr_err ("Failed to sw fini smc table!\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +22 -0
@@ -24,10 +24,29 @@#include "amdgpu.h" +#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ + do { \ + tables[table_id].size = s; \ + tables[table_id].align = a; \ + tables[table_id].domain = d; \ + } while (0) + +struct smu_table { +uint64_t size; +uint32_t align; +uint8_t domain; +uint64_t mc_address; +void *cpu_addr; +struct amdgpu_bo *bo; + +}; +struct smu_table_context {void *power_play_table;uint32_t power_play_table_size; +struct smu_table *tables; +uint32_t table_count; };struct smu_context
@@ -44,6 +63,7 @@ struct smu_funcs {int (*init_microcode)(struct smu_context *smu);int (*init_smc_tables)(struct smu_context *smu); +int (*fini_smc_tables)(struct smu_context *smu);int (*init_power)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu);
@@ -69,6 +89,8 @@ struct smu_funcs ((smu)->funcs->init_microcode ? (smu)->funcs->init_microcode((smu)) : 0)#define smu_init_smc_tables (smu) \ ((smu)->funcs->init_smc_tables ? (smu)->funcs->init_smc_tables((smu)) : 0) +#define smu_fini_smc_tables (smu) \ + ((smu)->funcs->fini_smc_tables ? (smu)->funcs->fini_smc_tables((smu)) : 0)#define smu_init_power (smu) \ ((smu)->funcs->init_power ? (smu)->funcs->init_power((smu)) : 0)#define smu_load_microcode (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +43 -0
55 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 36/138 drm/amd/powerplay: implement smu dpm context functions for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements smu dpm context functions for smu v11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++++ drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 26 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 38 ++++++++++++++++++++++++++ 3 files changed, 70 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -0
@@ -49,6 +49,11 @@ struct smu_table_contextuint32_t table_count; }; +struct smu_dpm_context { +void *dpm_context; +uint32_t dpm_context_size; +}; +struct smu_context {struct amdgpu_device *adev;
@@ -57,6 +62,7 @@ struct smu_contextstruct mutex mutex;struct smu_table_context smu_table; +struct smu_dpm_context smu_dpm; };struct smu_funcs
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +26 -0
@@ -36,6 +36,32 @@#define smnMP0_FW_INTF 0x30101c0#define smnMP1_PUB_CTRL 0x3010b14 + +struct smu_11_0_dpm_table { +uint32_t min;/* MHz */ +uint32_t max;/* MHz */ +}; + +struct smu_11_0_dpm_tables { +struct smu_11_0_dpm_table soc_table; +struct smu_11_0_dpm_table gfx_table; +struct smu_11_0_dpm_table uclk_table; +struct smu_11_0_dpm_table eclk_table; +struct smu_11_0_dpm_table vclk_table; +struct smu_11_0_dpm_table dclk_table; +struct smu_11_0_dpm_table dcef_table; +struct smu_11_0_dpm_table pixel_table; +struct smu_11_0_dpm_table display_table; +struct smu_11_0_dpm_table phy_table; +struct smu_11_0_dpm_table fclk_table; +}; + +struct smu_11_0_dpm_context { +struct smu_11_0_dpm_tables dpm_tables; +uint32_t workload_policy_mask; +uint32_t dcef_min_ds_clk; +}; +void smu_v11_0_set_smu_funcs (struct smu_context *smu);#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +38 -0
@@ -234,10 +234,40 @@ static int smu_v11_0_read_pptable_from_vbios(struct smu_context *smu)return 0 ; } +static int smu_v11_0_init_dpm_context (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; + +if (smu_dpm->dpm_context || smu_dpm->dpm_context_size !=0 ) +return -EINVAL ; + + smu_dpm->dpm_context =kzalloc (sizeof (struct smu_11_0_dpm_context ),GFP_KERNEL ); +if (!smu_dpm->dpm_context) +return -ENOMEM ; + smu_dpm->dpm_context_size =sizeof (struct smu_11_0_dpm_context ); + +return 0 ; +} + +static int smu_v11_0_fini_dpm_context (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; + +if (!smu_dpm->dpm_context || smu_dpm->dpm_context_size ==0 ) +return -EINVAL ; + +kfree (smu_dpm->dpm_context); + smu_dpm->dpm_context =NULL ; + smu_dpm->dpm_context_size =0 ; + +return 0 ; +} +static int smu_v11_0_init_smc_tables (struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table;struct smu_table *tables =NULL ; +int ret =0 ;if (smu_table->tables || smu_table->table_count !=0 )return -EINVAL ;
@@ -258,12 +288,17 @@ static int smu_v11_0_init_smc_tables(struct smu_context *smu)SMU_TABLE_INIT (tables,TABLE_OVERDRIVE ,sizeof (OverDriveTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); + ret =smu_v11_0_init_dpm_context (smu); +if (ret) +return ret; +return 0 ; }static int smu_v11_0_fini_smc_tables (struct smu_context *smu) {struct smu_table_context *smu_table = &smu->smu_table; +int ret =0 ;if (!smu_table->tables || smu_table->table_count ==0 )return -EINVAL ;
@@ -272,6 +307,9 @@ static int smu_v11_0_fini_smc_tables(struct smu_context *smu) smu_table->tables =NULL ; smu_table->table_count =0 ; + ret =smu_v11_0_fini_dpm_context (smu); +if (ret) +return ret;return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 37/138 drm/amd/powerplay: implement smu_init[fini]_power function for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements smu_init[fini]_power function for smu v11.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 +++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 +++++++ drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 14 +++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 33 ++++++++++++++++++++++++++ 4 files changed, 62 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -0
@@ -167,6 +167,12 @@ static int smu_sw_fini(void *handle)return ret; } + ret =smu_fini_power (smu); +if (ret) { +pr_err ("Failed to init smu_fini_power!\n" ); +return ret; + } +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +9 -0
@@ -54,6 +54,11 @@ struct smu_dpm_context {uint32_t dpm_context_size; }; +struct smu_power_context { +void *power_context; +uint32_t power_context_size; +}; +struct smu_context {struct amdgpu_device *adev;
@@ -63,6 +68,7 @@ struct smu_contextstruct smu_table_context smu_table;struct smu_dpm_context smu_dpm; +struct smu_power_context smu_power; };struct smu_funcs
@@ -71,6 +77,7 @@ struct smu_funcsint (*init_smc_tables)(struct smu_context *smu);int (*fini_smc_tables)(struct smu_context *smu);int (*init_power)(struct smu_context *smu); +int (*fini_power)(struct smu_context *smu);int (*load_microcode)(struct smu_context *smu);int (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu);
@@ -99,6 +106,8 @@ struct smu_funcs ((smu)->funcs->fini_smc_tables ? (smu)->funcs->fini_smc_tables((smu)) : 0)#define smu_init_power (smu) \ ((smu)->funcs->init_power ? (smu)->funcs->init_power((smu)) : 0) +#define smu_fini_power (smu) \ + ((smu)->funcs->fini_power ? (smu)->funcs->fini_power((smu)) : 0)#define smu_load_microcode (smu) \ ((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)#define smu_check_fw_status (smu) \
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +14 -0
@@ -62,6 +62,20 @@ struct smu_11_0_dpm_context { uint32_t dcef_min_ds_clk; }; +enum smu_11_0_power_state { +SMU_11_0_POWER_STATE__D0 =0 , +SMU_11_0_POWER_STATE__D1 , +SMU_11_0_POWER_STATE__D3 ,/* Sleep*/ +SMU_11_0_POWER_STATE__D4 ,/* Hibernate*/ +SMU_11_0_POWER_STATE__D5 ,/* Power off*/ +}; + +struct smu_11_0_power_context { +uint32_t power_source; +uint8_t in_power_limit_boost_mode; +enum smu_11_0_power_state power_state; +}; +void smu_v11_0_set_smu_funcs (struct smu_context *smu);#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +33 -0
@@ -313,6 +313,37 @@ static int smu_v11_0_fini_smc_tables(struct smu_context *smu)return 0 ; } + +static int smu_v11_0_init_power (struct smu_context *smu) +{ +struct smu_power_context *smu_power = &smu->smu_power; + +if (smu_power->power_context || smu_power->power_context_size !=0 ) +return -EINVAL ; + + smu_power->power_context =kzalloc (sizeof (struct smu_11_0_dpm_context ), +GFP_KERNEL ); +if (!smu_power->power_context) +return -ENOMEM ; + smu_power->power_context_size =sizeof (struct smu_11_0_dpm_context ); + +return 0 ; +} + +static int smu_v11_0_fini_power (struct smu_context *smu) +{ +struct smu_power_context *smu_power = &smu->smu_power; + +if (!smu_power->power_context || smu_power->power_context_size ==0 ) +return -EINVAL ; + +kfree (smu_power->power_context); + smu_power->power_context =NULL ; + smu_power->power_context_size =0 ; + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -323,6 +354,8 @@ static const struct smu_funcs smu_v11_0_funcs = { .read_pptable_from_vbios = smu_v11_0_read_pptable_from_vbios, .init_smc_tables = smu_v11_0_init_smc_tables, .fini_smc_tables = smu_v11_0_fini_smc_tables, + .init_power = smu_v11_0_init_power, + .fini_power = smu_v11_0_fini_power, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 38/138 drm/amd/powerplay: implement smu_init(fini)_fb_allocations function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements smu_init_fb_allocations/smu_fini_fb_allocations function for smu to reserve the BOs for smc tables.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 60 +++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +59 -1
@@ -178,10 +178,63 @@ static int smu_sw_fini(void *handle)static int smu_init_fb_allocations (struct smu_context *smu) { -/* TODO */ +struct amdgpu_device *adev = smu->adev; +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *tables = smu_table->tables; +uint32_t table_count = smu_table->table_count; +uint32_t i =0 ; +int32_t ret =0 ; + +if (table_count <=0 ) +return -EINVAL ; + +for (i =0 ; i < table_count; i++) { +if (tables[i].size ==0 ) +continue ; + ret =amdgpu_bo_create_kernel (adev, + tables[i].size, + tables[i].align, + tables[i].domain, + &tables[i].bo, + &tables[i].mc_address, + &tables[i].cpu_addr); +if (ret) + goto failed; + } +return 0 ; +failed: +for (; i >0 ; i--) { +if (tables[i].size ==0 ) +continue ; +amdgpu_bo_free_kernel (&tables[i].bo, + &tables[i].mc_address, + &tables[i].cpu_addr); + + } +return ret; } +static int smu_fini_fb_allocations (struct smu_context *smu) +{ +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *tables = smu_table->tables; +uint32_t table_count = smu_table->table_count; +uint32_t i =0 ; + +if (table_count ==0 || tables ==NULL ) +return -EINVAL ; + +for (i =0 ; i < table_count; i++) { +if (tables[i].size ==0 ) +continue ; +amdgpu_bo_free_kernel (&tables[i].bo, + &tables[i].mc_address, + &tables[i].cpu_addr); + } + +return 0 ; +}static int smu_smc_table_hw_init (struct smu_context *smu) {int ret;
@@ -329,10 +382,15 @@ static int smu_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu; +int ret =0 ;if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; + ret =smu_fini_fb_allocations (smu); +if (ret) +return ret; +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 39/138 drm/amd/powerplay: remove header of smu_v11_0_pptable
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
different ASICs have different pptables, so the header will move to asic source code to implement.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -2
@@ -30,7 +30,6 @@#include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h" #include "soc15_common.h" -#include "smu_v11_0_pptable.h" #include "asic_reg/thm/thm_11_0_2_offset.h" #include "asic_reg/thm/thm_11_0_2_sh_mask.h"
@@ -218,7 +217,7 @@ static int smu_v11_0_read_pptable_from_vbios(struct smu_context *smu)int ret, index;uint16_t size;uint8_t frev, crev; -struct smu_11_0_powerplay_table *table; +void *table; index =get_index_into_master_table (atom_master_list_of_data_tables_v2_1, powerplayinfo);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 40/138 drm/amd/powerplay: update pptable header for smu11
In reply to a message not in the archiveThis patch updates pptable header for smu v11.
--- .../gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0_pptable.h +15 -15
@@ -18,7 +18,6 @@* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. -* */ #ifndef SMU_11_0_PPTABLE_H #define SMU_11_0_PPTABLE_H
@@ -41,20 +40,21 @@#define SMU_11_0_PP_POWERSAVINGCLOCK_VERSION 0x0100enum SMU_11_0_ODFEATURE_ID { -SMU_11_0_ODFEATURE_GFXCLK_LIMITS =0 ,//GFXCLK Limit feature -SMU_11_0_ODFEATURE_GFXCLK_CURVE ,//GFXCLK Curve feature -SMU_11_0_ODFEATURE_UCLK_MAX ,//UCLK Limit feature -SMU_11_0_ODFEATURE_POWER_LIMIT ,//Power Limit feature -SMU_11_0_ODFEATURE_FAN_ACOUSTIC_LIMIT ,//Fan Acoustic RPM feature -SMU_11_0_ODFEATURE_FAN_SPEED_MIN ,//Minimum Fan Speed feature -SMU_11_0_ODFEATURE_TEMPERATURE_FAN ,//Fan Target Temperature Limit feature -SMU_11_0_ODFEATURE_TEMPERATURE_SYSTEM ,//Operating Temperature Limit feature -SMU_11_0_ODFEATURE_MEMORY_TIMING_TUNE ,//AC Timing Tuning feature -SMU_11_0_ODFEATURE_FAN_ZERO_RPM_CONTROL ,//Zero RPM feature -SMU_11_0_ODFEATURE_AUTO_UV_ENGINE ,//Auto Under Volt GFXCLK feature -SMU_11_0_ODFEATURE_AUTO_OC_ENGINE ,//Auto Over Clock GFXCLK feature -SMU_11_0_ODFEATURE_AUTO_OC_MEMORY ,//Auto Over Clock MCLK feature -SMU_11_0_ODFEATURE_COUNT , +SMU_11_0_ODFEATURE_GFXCLK_LIMITS =1 <<0 ,//GFXCLK Limit feature +SMU_11_0_ODFEATURE_GFXCLK_CURVE =1 <<1 ,//GFXCLK Curve feature +SMU_11_0_ODFEATURE_UCLK_MAX =1 <<2 ,//UCLK Limit feature +SMU_11_0_ODFEATURE_POWER_LIMIT =1 <<3 ,//Power Limit feature +SMU_11_0_ODFEATURE_FAN_ACOUSTIC_LIMIT =1 <<4 ,//Fan Acoustic RPM feature +SMU_11_0_ODFEATURE_FAN_SPEED_MIN =1 <<5 ,//Minimum Fan Speed feature +SMU_11_0_ODFEATURE_TEMPERATURE_FAN =1 <<6 ,//Fan Target Temperature Limit feature +SMU_11_0_ODFEATURE_TEMPERATURE_SYSTEM =1 <<7 ,//Operating Temperature Limit feature +SMU_11_0_ODFEATURE_MEMORY_TIMING_TUNE =1 <<8 ,//AC Timing Tuning feature +SMU_11_0_ODFEATURE_FAN_ZERO_RPM_CONTROL =1 <<9 ,//Zero RPM feature +SMU_11_0_ODFEATURE_AUTO_UV_ENGINE =1 <<10 ,//Auto Under Volt GFXCLK feature +SMU_11_0_ODFEATURE_AUTO_OC_ENGINE =1 <<11 ,//Auto Over Clock GFXCLK feature +SMU_11_0_ODFEATURE_AUTO_OC_MEMORY =1 <<12 ,//Auto Over Clock MCLK feature +SMU_11_0_ODFEATURE_FAN_CURVE =1 <<13 ,//VICTOR TODO +SMU_11_0_ODFEATURE_COUNT =14 , };#define SMU_11_0_MAX_ODFEATURE 32 //Maximum Number of OD Features
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 41/138 drm/amd/powerplay: add data structure of bootup values
In reply to a message not in the archiveThis patch adds data structures for bootup values.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +16 -0
@@ -38,13 +38,29 @@ struct smu_table {uint64_t mc_address;void *cpu_addr;struct amdgpu_bo *bo; +}; +struct smu_bios_boot_up_values +{ +uint32_t revision; +uint32_t gfxclk; +uint32_t uclk; +uint32_t socclk; +uint32_t dcefclk; +uint16_t vddc; +uint16_t vddci; +uint16_t mvddc; +uint16_t vdd_gfx; +uint8_t cooling_id; +uint32_t pp_table_id; };struct smu_table_context {void *power_play_table;uint32_t power_play_table_size; + +struct smu_bios_boot_up_values boot_values;struct smu_table *tables;uint32_t table_count; };
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 42/138 drm/amd/powerplay: implement get_vbios_bootup_values function for smu11 (v2)
In reply to a message not in the archiveThis patch implements get_vbios_bootup_values function for smu11 to fetach firmwareinfo member from atombios.
v2: use switch statement based on the content revision (Alex)
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 59 +++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +59 -0
@@ -343,6 +343,64 @@ static int smu_v11_0_fini_power(struct smu_context *smu)return 0 ; } +int smu_v11_0_get_vbios_bootup_values (struct smu_context *smu) +{ +int ret, index; +uint16_t size; +uint8_t frev, crev; +struct atom_common_table_header *header; +struct atom_firmware_info_v3_3 *v_3_3; +struct atom_firmware_info_v3_1 *v_3_1; + + index =get_index_into_master_table (atom_master_list_of_data_tables_v2_1, + firmwareinfo); + + ret =smu_get_atom_data_table (smu, index, &size, &frev, &crev, + (uint8_t **)&header); +if (ret) +return ret; + +if (header->format_revision !=3 ) { +pr_err ("unknown atom_firmware_info version! for smu11\n" ); +return -EINVAL ; + } + +switch (header->content_revision) { +case 0 : +case 1 : +case 2 : + v_3_1 = (struct atom_firmware_info_v3_1 *)header; + smu->smu_table.boot_values.revision = v_3_1->firmware_revision; + smu->smu_table.boot_values.gfxclk = v_3_1->bootup_sclk_in10khz; + smu->smu_table.boot_values.uclk = v_3_1->bootup_mclk_in10khz; + smu->smu_table.boot_values.socclk =0 ; + smu->smu_table.boot_values.dcefclk =0 ; + smu->smu_table.boot_values.vddc = v_3_1->bootup_vddc_mv; + smu->smu_table.boot_values.vddci = v_3_1->bootup_vddci_mv; + smu->smu_table.boot_values.mvddc = v_3_1->bootup_mvddc_mv; + smu->smu_table.boot_values.vdd_gfx = v_3_1->bootup_vddgfx_mv; + smu->smu_table.boot_values.cooling_id = v_3_1->coolingsolution_id; + smu->smu_table.boot_values.pp_table_id =0 ; +break ; +case 3 : +default : + v_3_3 = (struct atom_firmware_info_v3_3 *)header; + smu->smu_table.boot_values.revision = v_3_3->firmware_revision; + smu->smu_table.boot_values.gfxclk = v_3_3->bootup_sclk_in10khz; + smu->smu_table.boot_values.uclk = v_3_3->bootup_mclk_in10khz; + smu->smu_table.boot_values.socclk =0 ; + smu->smu_table.boot_values.dcefclk =0 ; + smu->smu_table.boot_values.vddc = v_3_3->bootup_vddc_mv; + smu->smu_table.boot_values.vddci = v_3_3->bootup_vddci_mv; + smu->smu_table.boot_values.mvddc = v_3_3->bootup_mvddc_mv; + smu->smu_table.boot_values.vdd_gfx = v_3_3->bootup_vddgfx_mv; + smu->smu_table.boot_values.cooling_id = v_3_3->coolingsolution_id; + smu->smu_table.boot_values.pp_table_id = v_3_3->pplib_pptable_id; + } + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -355,6 +413,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .fini_smc_tables = smu_v11_0_fini_smc_tables, .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, + .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 43/138 drm/amd/powerplay: implement get_clk_info_from_vbios function for smu11 (v2)
In reply to a message not in the archiveThis patch implements the get_clk_info_from_vbios function for smu11. We can do execute_vbios_cmd_table to fetch the clk value from vbios.
v2: use the proper cpu_to_le[32|16]() and le[32|16]_to_cpu() macros to handle endianness. (Alex)
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 8 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 39 ++++++++++++++++++++++++++ 3 files changed, 50 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +8 -0
@@ -248,10 +248,18 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_get_clk_info_from_vbios (smu); +if (ret) +return ret; +/* * check if the format_revision in vbios is up to pptable header * version, and the structure size is not 0. */ + ret =smu_get_clk_info_from_vbios (smu); +if (ret) +return ret; + ret =smu_check_pptable (smu);if (ret)return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -98,6 +98,7 @@ struct smu_funcsint (*check_fw_status)(struct smu_context *smu);int (*read_pptable_from_vbios)(struct smu_context *smu);int (*get_vbios_bootup_values)(struct smu_context *smu); +int (*get_clk_info_from_vbios)(struct smu_context *smu);int (*check_pptable)(struct smu_context *smu);int (*parse_pptable)(struct smu_context *smu);int (*populate_smc_pptable)(struct smu_context *smu);
@@ -132,6 +133,8 @@ struct smu_funcs ((smu)->funcs->read_pptable_from_vbios ? (smu)->funcs->read_pptable_from_vbios((smu)) : 0)#define smu_get_vbios_bootup_values (smu) \ ((smu)->funcs->get_vbios_bootup_values ? (smu)->funcs->get_vbios_bootup_values((smu)) : 0) +#define smu_get_clk_info_from_vbios (smu) \ + ((smu)->funcs->get_clk_info_from_vbios ? (smu)->funcs->get_clk_info_from_vbios((smu)) : 0)#define smu_check_pptable (smu) \ ((smu)->funcs->check_pptable ? (smu)->funcs->check_pptable((smu)) : 0)#define smu_parse_pptable (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +39 -0
@@ -30,6 +30,7 @@#include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h" #include "soc15_common.h" +#include "atom.h" #include "asic_reg/thm/thm_11_0_2_offset.h" #include "asic_reg/thm/thm_11_0_2_sh_mask.h"
@@ -401,6 +402,43 @@ int smu_v11_0_get_vbios_bootup_values(struct smu_context *smu)return 0 ; } +static int smu_v11_0_get_clk_info_from_vbios (struct smu_context *smu) +{ +int ret, index; +struct amdgpu_device *adev = smu->adev; +struct atom_get_smu_clock_info_parameters_v3_1 input = {0 }; +struct atom_get_smu_clock_info_output_parameters_v3_1 *output; + + input.clk_id =SMU11_SYSPLL0_SOCCLK_ID ; + input.command =GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ ; + index =get_index_into_master_table (atom_master_list_of_command_functions_v2_1, + getsmuclockinfo); + + ret =amdgpu_atom_execute_table (adev->mode_info.atom_context, index, + (uint32_t *)&input); +if (ret) +return -EINVAL ; + + output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&input; + smu->smu_table.boot_values.socclk =le32_to_cpu (output->atom_smu_outputclkfreq.smu_clock_freq_hz) /10000 ; + +memset (&input,0 ,sizeof (input)); + input.clk_id =SMU11_SYSPLL0_DCEFCLK_ID ; + input.command =GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ ; + index =get_index_into_master_table (atom_master_list_of_command_functions_v2_1, + getsmuclockinfo); + + ret =amdgpu_atom_execute_table (adev->mode_info.atom_context, index, + (uint32_t *)&input); +if (ret) +return -EINVAL ; + + output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&input; + smu->smu_table.boot_values.dcefclk =le32_to_cpu (output->atom_smu_outputclkfreq.smu_clock_freq_hz) /10000 ; + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -414,6 +452,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .init_power = smu_v11_0_init_power, .fini_power = smu_v11_0_fini_power, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, + .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 44/138 drm/amd/powerplay: implement smu_alloc[free]_memory pool function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements smu_alloc[free]_memory pool function to reserve the memory pool bo.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 55 +++++++++++++++++++++++++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 11 ++++++ 2 files changed, 65 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +54 -1
@@ -137,6 +137,8 @@ static int smu_sw_init(void *handle)if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; + smu->pool_size = adev->pm.smu_prv_buffer_size; + ret =smu_init_microcode (smu);if (ret) {pr_err ("Failed to load smu firmware!\n" );
@@ -333,9 +335,56 @@ static int smu_smc_table_hw_init(struct smu_context *smu)*/ static int smu_alloc_memory_pool (struct smu_context *smu) { -return 0 ; +struct amdgpu_device *adev = smu->adev; +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *memory_pool = &smu_table->memory_pool; +uint64_t pool_size = smu->pool_size; +int ret =0 ; + +if (pool_size ==SMU_MEMORY_POOL_SIZE_ZERO ) +return ret; + + memory_pool->size = pool_size; + memory_pool->align =PAGE_SIZE ; + memory_pool->domain =AMDGPU_GEM_DOMAIN_GTT ; + +switch (pool_size) { +case SMU_MEMORY_POOL_SIZE_256_MB : +case SMU_MEMORY_POOL_SIZE_512_MB : +case SMU_MEMORY_POOL_SIZE_1_GB : +case SMU_MEMORY_POOL_SIZE_2_GB : + ret =amdgpu_bo_create_kernel (adev, + memory_pool->size, + memory_pool->align, + memory_pool->domain, + &memory_pool->bo, + &memory_pool->mc_address, + &memory_pool->cpu_addr); +break ; +default : +break ; + } + +return ret; } +static int smu_free_memory_pool (struct smu_context *smu) +{ +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *memory_pool = &smu_table->memory_pool; +int ret =0 ; + +if (memory_pool->size ==SMU_MEMORY_POOL_SIZE_ZERO ) +return ret; + +amdgpu_bo_free_kernel (&memory_pool->bo, + &memory_pool->mc_address, + &memory_pool->cpu_addr); + +memset (memory_pool,0 ,sizeof (struct smu_table )); + +return ret; +}static int smu_hw_init (void *handle) {int ret;
@@ -399,6 +448,10 @@ static int smu_hw_fini(void *handle)if (ret)return ret; + ret =smu_free_memory_pool (smu); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +11 -0
@@ -24,6 +24,15 @@#include "amdgpu.h" +enum smu_memory_pool_size +{ +SMU_MEMORY_POOL_SIZE_ZERO =0 , +SMU_MEMORY_POOL_SIZE_256_MB =0x10000000 , +SMU_MEMORY_POOL_SIZE_512_MB =0x20000000 , +SMU_MEMORY_POOL_SIZE_1_GB =0x40000000 , +SMU_MEMORY_POOL_SIZE_2_GB =0x80000000 , +}; +#define SMU_TABLE_INIT (tables, table_id, s, a, d) \ do { \ tables[table_id].size = s; \
@@ -63,6 +72,7 @@ struct smu_table_contextstruct smu_bios_boot_up_values boot_values;struct smu_table *tables;uint32_t table_count; +struct smu_table memory_pool; };struct smu_dpm_context {
@@ -81,6 +91,7 @@ struct smu_contextconst struct smu_funcs *funcs;struct mutex mutex; +uint64_t pool_size;struct smu_table_context smu_table;struct smu_dpm_context smu_dpm;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 45/138 drm/amd/powerplay: implement notify_memory_pool_location function for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements the notify_memory_pool_location function to send memory address to smc for dram logging.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +47 -0
@@ -439,6 +439,52 @@ static int smu_v11_0_get_clk_info_from_vbios(struct smu_context *smu)return 0 ; } +static int smu_v11_0_notify_memory_pool_location (struct smu_context *smu) +{ +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *memory_pool = &smu_table->memory_pool; +int ret =0 ; +uint64_t address; +uint32_t address_low, address_high; + +if (memory_pool->size ==0 || memory_pool->cpu_addr ==NULL ) +return ret; + + address = (uint64_t )memory_pool->cpu_addr; + address_high = (uint32_t )upper_32_bits (address); + address_low = (uint32_t )lower_32_bits (address); + + ret =smu_send_smc_msg_with_param (smu, + PPSMC_MSG_SetSystemVirtualDramAddrHigh, + address_high); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, + PPSMC_MSG_SetSystemVirtualDramAddrLow, + address_low); +if (ret) +return ret; + + address = memory_pool->mc_address; + address_high = (uint32_t )upper_32_bits (address); + address_low = (uint32_t )lower_32_bits (address); + + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramAddrHigh, + address_high); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramAddrLow, + address_low); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramSize, + (uint32_t )memory_pool->size); +if (ret) +return ret; + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -453,6 +499,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .fini_power = smu_v11_0_fini_power, .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios, + .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 46/138 drm/amd/powerplay: add vega20 pptable function file
In reply to a message not in the archiveThis patch adds the vega20_ppt.c to support ATOM_Vega20_POWERPLAYTABLE format for vega20 on smu11. It will be used to implement to asic specific pptable helpers.
--- drivers/gpu/drm/amd/powerplay/Makefile | 2 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 7 +--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 11 ++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 51 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 28 ++++++++++++++ 6 files changed, 97 insertions(+), 7 deletions(-) create mode 100644 drivers/gpu/drm/amd/powerplay/vega20_ppt.c create mode 100644 drivers/gpu/drm/amd/powerplay/vega20_ppt.h
drivers/gpu/drm/amd/powerplay/Makefile +1 -1
@@ -35,7 +35,7 @@ AMD_POWERPLAY = $(addsuffix /Makefile,$(addprefix $(FULL_AMD_PATH)/powerplay/,$( include $(AMD_POWERPLAY) -POWER_MGR = amd_powerplay.o amdgpu_smu.o smu_v11_0.o +POWER_MGR = amd_powerplay.o amdgpu_smu.o smu_v11_0.o vega20_ppt.o AMD_PP_POWER = $(addprefix $(AMD_PP_PATH)/,$(POWER_MGR))
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -6
@@ -48,16 +48,11 @@ static int smu_early_init(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu; -int ret; - - ret =smu_set_funcs (adev); -if (ret) -return ret; smu->adev = adev;mutex_init (&smu->mutex); -return 0 ; +return smu_set_funcs (adev); } int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -90,6 +90,7 @@ struct smu_contextstruct amdgpu_device *adev;const struct smu_funcs *funcs; +const struct pptable_funcs *ppt_funcs;struct mutex mutex;uint64_t pool_size;
@@ -98,6 +99,10 @@ struct smu_contextstruct smu_power_context smu_power; }; +struct pptable_funcs { +int (*store_powerplay_table)(struct smu_context *smu); +}; +struct smu_funcs {int (*init_microcode)(struct smu_context *smu);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +11 -0
@@ -31,6 +31,7 @@#include "smu11_driver_if.h" #include "soc15_common.h" #include "atom.h" +#include "vega20_ppt.h" #include "asic_reg/thm/thm_11_0_2_offset.h" #include "asic_reg/thm/thm_11_0_2_sh_mask.h"
@@ -504,5 +505,15 @@ static const struct smu_funcs smu_v11_0_funcs = {void smu_v11_0_set_smu_funcs (struct smu_context *smu) { +struct amdgpu_device *adev = smu->adev; + smu->funcs = &smu_v11_0_funcs; + +switch (adev->asic_type) { +case CHIP_VEGA20 : +vega20_set_ppt_funcs (smu); +break ; +default : +pr_warn ("Unknow asic for smu11\n" ); + } }
drivers/gpu/drm/amd/powerplay/vega20_ppt.c new file +51 -0
51 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/vega20_ppt.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright 2019 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +*/ +#ifndef __VEGA20_PPT_H__ +#define __VEGA20_PPT_H__ + +extern void vega20_set_ppt_funcs (struct smu_context *smu); + +#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 47/138 drm/amd/powerplay: add function to parse pptable for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_parse_pptable function for smu11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 20 ++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 11 +++++++++++ 3 files changed, 34 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -70,6 +70,7 @@ struct smu_table_contextuint32_t power_play_table_size;struct smu_bios_boot_up_values boot_values; +void *driver_pptable;struct smu_table *tables;uint32_t table_count;struct smu_table memory_pool;
@@ -177,6 +178,8 @@ struct smu_funcs ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)#define smu_send_smc_msg_with_param (smu, msg, param) \ ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0) +#define smu_store_powerplay_table (smu) \ + ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +20 -0
@@ -486,6 +486,25 @@ static int smu_v11_0_notify_memory_pool_location(struct smu_context *smu)return ret; } +static int smu_v11_0_parse_pptable (struct smu_context *smu) +{ +int ret; + +struct smu_table_context *table_context = &smu->smu_table; + +if (table_context->driver_pptable) +return -EINVAL ; + + table_context->driver_pptable =kzalloc (sizeof (PPTable_t),GFP_KERNEL ); + +if (!table_context->driver_pptable) +return -ENOMEM ; + + ret =smu_store_powerplay_table (smu); + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -501,6 +520,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, + .parse_pptable = smu_v11_0_parse_pptable, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +11 -0
@@ -38,6 +38,17 @@static int vega20_store_powerplay_table (struct smu_context *smu) { +ATOM_Vega20_POWERPLAYTABLE *powerplay_table =NULL ; +struct smu_table_context *table_context = &smu->smu_table; + +if (!table_context->power_play_table) +return -EINVAL ; + + powerplay_table = table_context->power_play_table; + +memcpy (table_context->driver_pptable, &powerplay_table->smcPPTable, +sizeof (PPTable_t)); +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 48/138 drm/amd/powerplay: add function to check pptable for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_check_pptable function for smu11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 9 +++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -102,6 +102,7 @@ struct smu_contextstruct pptable_funcs {int (*store_powerplay_table)(struct smu_context *smu); +int (*check_powerplay_table)(struct smu_context *smu); };struct smu_funcs
@@ -180,6 +181,8 @@ struct smu_funcs ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0)#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0) +#define smu_check_powerplay_table (smu) \ + ((smu)->ppt_funcs->check_powerplay_table ? (smu)->ppt_funcs->check_powerplay_table((smu)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +9 -0
@@ -486,6 +486,14 @@ static int smu_v11_0_notify_memory_pool_location(struct smu_context *smu)return ret; } +static int smu_v11_0_check_pptable (struct smu_context *smu) +{ +int ret; + + ret =smu_check_powerplay_table (smu); +return ret; +} +static int smu_v11_0_parse_pptable (struct smu_context *smu) {int ret;
@@ -520,6 +528,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_vbios_bootup_values = smu_v11_0_get_vbios_bootup_values, .get_clk_info_from_vbios = smu_v11_0_get_clk_info_from_vbios, .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, + .check_pptable = smu_v11_0_check_pptable, .parse_pptable = smu_v11_0_parse_pptable, };
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +21 -0
@@ -52,8 +52,29 @@ static int vega20_store_powerplay_table(struct smu_context *smu)return 0 ; } +static int vega20_check_powerplay_table (struct smu_context *smu) +{ +ATOM_Vega20_POWERPLAYTABLE *powerplay_table =NULL ; +struct smu_table_context *table_context = &smu->smu_table; + + powerplay_table = table_context->power_play_table; + +if (powerplay_table->sHeader.format_revision <ATOM_VEGA20_TABLE_REVISION_VEGA20 ) { +pr_err ("Unsupported PPTable format!" ); +return -EINVAL ; + } + +if (!powerplay_table->sHeader.structuresize) { +pr_err ("Invalid PowerPlay Table!" ); +return -EINVAL ; + } + +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .store_powerplay_table = vega20_store_powerplay_table, + .check_powerplay_table = vega20_check_powerplay_table, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 49/138 drm/amd/powerplay: update hw fini function to relase some memory
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Release memory of table_context->driver_pptable and table_context->ppt_information when smu hw fini.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +5 -0
@@ -434,11 +434,16 @@ static int smu_hw_fini(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu; +struct smu_table_context *table_context = &smu->smu_table;int ret =0 ;if (adev->asic_type <CHIP_VEGA20 )return -EINVAL ; +if (!table_context->driver_pptable) +return -EINVAL ; +kfree (table_context->driver_pptable); + ret =smu_fini_fb_allocations (smu);if (ret)return ret;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 50/138 drm/amd/powerplay: add function to populate smc pptable for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_populate_smc_pptable function for smu11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +42 -0
@@ -513,6 +513,47 @@ static int smu_v11_0_parse_pptable(struct smu_context *smu)return ret; } +static int smu_v11_0_populate_smc_pptable (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; + +PPTable_t *driver_ppt = (PPTable_t *)&(smu->smu_table.tables[TABLE_PPTABLE ]); +struct smu_11_0_dpm_context *dpm_context = (struct smu_11_0_dpm_context *)smu_dpm->dpm_context; + +if (dpm_context && driver_ppt) { + dpm_context->dpm_tables.soc_table.min = driver_ppt->FreqTableSocclk[0 ]; + dpm_context->dpm_tables.soc_table.max = driver_ppt->FreqTableSocclk[NUM_SOCCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.gfx_table.min = driver_ppt->FreqTableGfx[0 ]; + dpm_context->dpm_tables.gfx_table.max = driver_ppt->FreqTableGfx[NUM_GFXCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.uclk_table.min = driver_ppt->FreqTableUclk[0 ]; + dpm_context->dpm_tables.uclk_table.max = driver_ppt->FreqTableUclk[NUM_UCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.vclk_table.min = driver_ppt->FreqTableVclk[0 ]; + dpm_context->dpm_tables.vclk_table.max = driver_ppt->FreqTableVclk[NUM_VCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.dclk_table.min = driver_ppt->FreqTableDclk[0 ]; + dpm_context->dpm_tables.dclk_table.max = driver_ppt->FreqTableDclk[NUM_DCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.dcef_table.min = driver_ppt->FreqTableDcefclk[0 ]; + dpm_context->dpm_tables.dcef_table.max = driver_ppt->FreqTableDcefclk[NUM_DCEFCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.pixel_table.min = driver_ppt->FreqTablePixclk[0 ]; + dpm_context->dpm_tables.pixel_table.max = driver_ppt->FreqTablePixclk[NUM_PIXCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.display_table.min = driver_ppt->FreqTableDispclk[0 ]; + dpm_context->dpm_tables.display_table.max = driver_ppt->FreqTableDispclk[NUM_DISPCLK_DPM_LEVELS -1 ]; + + dpm_context->dpm_tables.phy_table.min = driver_ppt->FreqTablePhyclk[0 ]; + dpm_context->dpm_tables.phy_table.max = driver_ppt->FreqTablePhyclk[NUM_PHYCLK_DPM_LEVELS -1 ]; + +return 0 ; + } + +return -EINVAL ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -530,6 +571,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .notify_memory_pool_location = smu_v11_0_notify_memory_pool_location, .check_pptable = smu_v11_0_check_pptable, .parse_pptable = smu_v11_0_parse_pptable, + .populate_smc_pptable = smu_v11_0_populate_smc_pptable, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 51/138 drm/amd/powerplay: add function to write pptable for smu11 (v2)
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_write_pptable and smu_v11_0_copy_table_to_smc function for smu11.
v2: fix the build warning. (Ray)
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 60 +++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +60 -0
@@ -554,6 +554,65 @@ static int smu_v11_0_populate_smc_pptable(struct smu_context *smu)return -EINVAL ; } +static int smu_v11_0_copy_table_to_smc (struct smu_context *smu, +uint32_t table_id) +{ +struct smu_table_context *table_context = &smu->smu_table; +struct smu_table *driver_pptable = &smu->smu_table.tables[table_id]; +int ret =0 ; + +if (table_id >=TABLE_COUNT ) { +pr_err ("Invalid SMU Table ID for smu11!" ); +return -EINVAL ; + } + +if (!driver_pptable->cpu_addr) { +pr_err ("Invalid virtual address for smu11!" ); +return -EINVAL ; + } +if (!driver_pptable->mc_address) { +pr_err ("Invalid MC address for smu11!" ); +return -EINVAL ; + } +if (!driver_pptable->size) { +pr_err ("Invalid SMU Table size for smu11!" ); +return -EINVAL ; + } + +memcpy (driver_pptable->cpu_addr, table_context->driver_pptable, + driver_pptable->size); + + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_SetDriverDramAddrHigh, +upper_32_bits (driver_pptable->mc_address)); +if (ret) { +pr_err ("[CopyTableToSMC] Attempt to Set Dram Addr High Failed!" ); +return ret; + } + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_SetDriverDramAddrLow, +lower_32_bits (driver_pptable->mc_address)); +if (ret) { +pr_err ("[CopyTableToSMC] Attempt to Set Dram Addr Low Failed!" ); +return ret; + } + ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_TransferTableDram2Smu, + table_id); +if (ret) { +pr_err ("[CopyTableToSMC] Attempt to Transfer Table To SMU Failed!" ); +return ret; + } + +return 0 ; +} + +static int smu_v11_0_write_pptable (struct smu_context *smu) +{ +int ret =0 ; + + ret =smu_v11_0_copy_table_to_smc (smu,TABLE_PPTABLE ); + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -572,6 +631,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .check_pptable = smu_v11_0_check_pptable, .parse_pptable = smu_v11_0_parse_pptable, .populate_smc_pptable = smu_v11_0_populate_smc_pptable, + .write_pptable = smu_v11_0_write_pptable, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 52/138 drm/amd/powerplay: add function to set min dcef deep sleep for smu11 (v2)
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_set_min_dcef_deep_sleep function for smu11.
v2: fix coding error about set_min_dcef_deep_sleep (Kevin)
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +18 -0
@@ -613,6 +613,23 @@ static int smu_v11_0_write_pptable(struct smu_context *smu)return ret; } +static int smu_v11_0_set_min_dcef_deep_sleep (struct smu_context *smu) +{ +int ret =0 ; +struct smu_table_context *table_context = &smu->smu_table; + +if (!table_context) +return -EINVAL ; + + ret =smu_send_smc_msg_with_param (smu, + PPSMC_MSG_SetMinDeepSleepDcefclk, + table_context->boot_values.dcefclk /100 ); +if (ret) +pr_err ("SMU11 attempt to set divider for DCEFCLK Failed!" ); + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -632,6 +649,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .parse_pptable = smu_v11_0_parse_pptable, .populate_smc_pptable = smu_v11_0_populate_smc_pptable, .write_pptable = smu_v11_0_write_pptable, + .set_min_dcef_deep_sleep = smu_v11_0_set_min_dcef_deep_sleep, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 53/138 drm/amd/powerplay: add function to set tool table location for smu11 (v2)
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_set_tool_table_location function for smu11.
v2: fix the missed TABLE_PMSTATUSLOG bo creation which caused AGM hung. (Ray)
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +23 -0
@@ -41,6 +41,8 @@MODULE_FIRMWARE ("amdgpu/vega20_smc.bin" ); +#define SMU11_TOOL_SIZE 0x19000 +static int smu_v11_0_send_msg_without_waiting (struct smu_context *smu,uint16_t msg) {
@@ -288,6 +290,8 @@ static int smu_v11_0_init_smc_tables(struct smu_context *smu) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM);SMU_TABLE_INIT (tables,TABLE_OVERDRIVE ,sizeof (OverDriveTable_t),PAGE_SIZE ,AMDGPU_GEM_DOMAIN_VRAM ); +SMU_TABLE_INIT (tables,TABLE_PMSTATUSLOG ,SMU11_TOOL_SIZE ,PAGE_SIZE , +AMDGPU_GEM_DOMAIN_VRAM ); ret =smu_v11_0_init_dpm_context (smu);if (ret)
@@ -630,6 +634,24 @@ static int smu_v11_0_set_min_dcef_deep_sleep(struct smu_context *smu)return ret; } +static int smu_v11_0_set_tool_table_location (struct smu_context *smu) +{ +int ret =0 ; +struct smu_table *tool_table = &smu->smu_table.tables[TABLE_PMSTATUSLOG ]; + +if (tool_table->mc_address) { + ret =smu_send_smc_msg_with_param (smu, + PPSMC_MSG_SetToolsDramAddrHigh, +upper_32_bits (tool_table->mc_address)); +if (!ret) + ret =smu_send_smc_msg_with_param (smu, + PPSMC_MSG_SetToolsDramAddrLow, +lower_32_bits (tool_table->mc_address)); + } + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -650,6 +672,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .populate_smc_pptable = smu_v11_0_populate_smc_pptable, .write_pptable = smu_v11_0_write_pptable, .set_min_dcef_deep_sleep = smu_v11_0_set_min_dcef_deep_sleep, + .set_tool_table_location = smu_v11_0_set_tool_table_location, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 54/138 drm/amd/powerplay: add enum smu_msg_type to header
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
each asic with different message index,
add this header to help top level smu code to send message.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 89 ++++++++++++++++++++++++++ 1 file changed, 89 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +89 -0
@@ -24,6 +24,95 @@#include "amdgpu.h" +enum smu_message_type +{ + SMU_MSG_TestMessage =0 , + SMU_MSG_GetSmuVersion, + SMU_MSG_GetDriverIfVersion, + SMU_MSG_SetAllowedFeaturesMaskLow, + SMU_MSG_SetAllowedFeaturesMaskHigh, + SMU_MSG_EnableAllSmuFeatures, + SMU_MSG_DisableAllSmuFeatures, + SMU_MSG_EnableSmuFeaturesLow, + SMU_MSG_EnableSmuFeaturesHigh, + SMU_MSG_DisableSmuFeaturesLow, + SMU_MSG_DisableSmuFeaturesHigh, + SMU_MSG_GetEnabledSmuFeaturesLow, + SMU_MSG_GetEnabledSmuFeaturesHigh, + SMU_MSG_SetWorkloadMask, + SMU_MSG_SetPptLimit, + SMU_MSG_SetDriverDramAddrHigh, + SMU_MSG_SetDriverDramAddrLow, + SMU_MSG_SetToolsDramAddrHigh, + SMU_MSG_SetToolsDramAddrLow, + SMU_MSG_TransferTableSmu2Dram, + SMU_MSG_TransferTableDram2Smu, + SMU_MSG_UseDefaultPPTable, + SMU_MSG_UseBackupPPTable, + SMU_MSG_RunBtc, + SMU_MSG_RequestI2CBus, + SMU_MSG_ReleaseI2CBus, + SMU_MSG_SetFloorSocVoltage, + SMU_MSG_SoftReset, + SMU_MSG_StartBacoMonitor, + SMU_MSG_CancelBacoMonitor, + SMU_MSG_EnterBaco, + SMU_MSG_SetSoftMinByFreq, + SMU_MSG_SetSoftMaxByFreq, + SMU_MSG_SetHardMinByFreq, + SMU_MSG_SetHardMaxByFreq, + SMU_MSG_GetMinDpmFreq, + SMU_MSG_GetMaxDpmFreq, + SMU_MSG_GetDpmFreqByIndex, + SMU_MSG_GetDpmClockFreq, + SMU_MSG_GetSsVoltageByDpm, + SMU_MSG_SetMemoryChannelConfig, + SMU_MSG_SetGeminiMode, + SMU_MSG_SetGeminiApertureHigh, + SMU_MSG_SetGeminiApertureLow, + SMU_MSG_SetMinLinkDpmByIndex, + SMU_MSG_OverridePcieParameters, + SMU_MSG_OverDriveSetPercentage, + SMU_MSG_SetMinDeepSleepDcefclk, + SMU_MSG_ReenableAcDcInterrupt, + SMU_MSG_NotifyPowerSource, + SMU_MSG_SetUclkFastSwitch, + SMU_MSG_SetUclkDownHyst, + SMU_MSG_GfxDeviceDriverReset, + SMU_MSG_GetCurrentRpm, + SMU_MSG_SetVideoFps, + SMU_MSG_SetTjMax, + SMU_MSG_SetFanTemperatureTarget, + SMU_MSG_PrepareMp1ForUnload, + SMU_MSG_DramLogSetDramAddrHigh, + SMU_MSG_DramLogSetDramAddrLow, + SMU_MSG_DramLogSetDramSize, + SMU_MSG_SetFanMaxRpm, + SMU_MSG_SetFanMinPwm, + SMU_MSG_ConfigureGfxDidt, + SMU_MSG_NumOfDisplays, + SMU_MSG_RemoveMargins, + SMU_MSG_ReadSerialNumTop32, + SMU_MSG_ReadSerialNumBottom32, + SMU_MSG_SetSystemVirtualDramAddrHigh, + SMU_MSG_SetSystemVirtualDramAddrLow, + SMU_MSG_WaflTest, + SMU_MSG_SetFclkGfxClkRatio, + SMU_MSG_AllowGfxOff, + SMU_MSG_DisallowGfxOff, + SMU_MSG_GetPptLimit, + SMU_MSG_GetDcModeMaxDpmFreq, + SMU_MSG_GetDebugData, + SMU_MSG_SetXgmiMode, + SMU_MSG_RunAfllBtc, + SMU_MSG_ExitBaco, + SMU_MSG_PrepareMp1ForReset, + SMU_MSG_PrepareMp1ForShutdown, + SMU_MSG_SetMGpuFanBoostLimitRpm, + SMU_MSG_GetAVFSVoltageByDpm, +SMU_MSG_MAX_COUNT , +}; +enum smu_memory_pool_size {SMU_MEMORY_POOL_SIZE_ZERO =0 ,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 55/138 drm/amd/powerplay: implement smu vega20_message_map for vega20
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements smu vega20_message_map to map the PPSMC messages from smu11 to specific asic.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 101 ++++++++++++++++++++++++- 2 files changed, 103 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -192,6 +192,7 @@ struct smu_contextstruct pptable_funcs {int (*store_powerplay_table)(struct smu_context *smu);int (*check_powerplay_table)(struct smu_context *smu); +int (*get_smu_msg_index)(struct smu_context *smu,uint32_t index); };struct smu_funcs
@@ -273,6 +274,9 @@ struct smu_funcs#define smu_check_powerplay_table (smu) \ ((smu)->ppt_funcs->check_powerplay_table ? (smu)->ppt_funcs->check_powerplay_table((smu)) : 0) +#define smu_msg_get_index (smu, msg) \ + ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL) +extern int smu_get_atom_data_table (struct smu_context *smu,uint32_t table,uint16_t *size,uint8_t *frev,uint8_t *crev,uint8_t **addr);
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +99 -2
118 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 56/138 drm/amd/powerplay: use virtual msg index to replace asic-related msg index
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Using virtual msg index is able to support all ASIC specific message values on one smu upper layer.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +12 -4
@@ -81,13 +81,17 @@ static int smu_v11_0_wait_for_response(struct smu_context *smu)static int smu_v11_0_send_msg (struct smu_context *smu,uint16_t msg) {struct amdgpu_device *adev = smu->adev; -int ret =0 ; +int ret =0 , index =0 ; + + index =smu_msg_get_index (smu, msg); +if (index <0 ) +return index;smu_v11_0_wait_for_response (smu);WREG32_SOC15 (MP1 ,0 , mmMP1_SMN_C2PMSG_90,0 ); -smu_v11_0_send_msg_without_waiting (smu, msg); +smu_v11_0_send_msg_without_waiting (smu, (uint16_t )index); ret =smu_v11_0_wait_for_response (smu);
@@ -105,7 +109,11 @@ smu_v11_0_send_msg_with_param(struct smu_context *smu, uint16_t msg, {struct amdgpu_device *adev = smu->adev; -int ret =0 ; +int ret =0 , index =0 ; + + index =smu_msg_get_index (smu, msg); +if (index <0 ) +return index; ret =smu_v11_0_wait_for_response (smu);if (ret)
@@ -116,7 +124,7 @@ smu_v11_0_send_msg_with_param(struct smu_context *smu, uint16_t msg,WREG32_SOC15 (MP1 ,0 , mmMP1_SMN_C2PMSG_82, param); -smu_v11_0_send_msg_without_waiting (smu, msg); +smu_v11_0_send_msg_without_waiting (smu, (uint16_t )index); ret =smu_v11_0_wait_for_response (smu);if (ret)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 57/138 drm/amd/powerplay: replace SMU_MSG_XXX with PPSMC_MSG_XXX message index for smu11 (v2)
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch is to setup a common SMU_MSGs for smu11. We can support common MSG definitions for each asics under smu11.
v2: move smu_v11_0_ppsmc.h to xxx_ppt.c level, because it depends on specific asic.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +13 -14
@@ -27,7 +27,6 @@#include "atomfirmware.h" #include "amdgpu_atomfirmware.h" #include "smu_v11_0.h" -#include "smu_v11_0_ppsmc.h" #include "smu11_driver_if.h" #include "soc15_common.h" #include "atom.h"
@@ -75,7 +74,7 @@ static int smu_v11_0_wait_for_response(struct smu_context *smu)if (i == adev->usec_timeout)return -ETIME ; -return RREG32_SOC15 (MP1 ,0 , mmMP1_SMN_C2PMSG_90) == PPSMC_Result_OK ?0 :-EIO ; +return RREG32_SOC15 (MP1 ,0 , mmMP1_SMN_C2PMSG_90) ==0x1 ?0 : -EIO ; }static int smu_v11_0_send_msg (struct smu_context *smu,uint16_t msg)
@@ -210,7 +209,7 @@ static int smu_v11_0_check_fw_version(struct smu_context *smu)uint32_t smu_version =0xff ;int ret =0 ; - ret =smu_send_smc_msg (smu, PPSMC_MSG_GetDriverIfVersion); + ret =smu_send_smc_msg (smu, SMU_MSG_GetDriverIfVersion);if (ret) goto err;
@@ -468,12 +467,12 @@ static int smu_v11_0_notify_memory_pool_location(struct smu_context *smu) address_low = (uint32_t )lower_32_bits (address); ret =smu_send_smc_msg_with_param (smu, - PPSMC_MSG_SetSystemVirtualDramAddrHigh, + SMU_MSG_SetSystemVirtualDramAddrHigh, address_high);if (ret)return ret; ret =smu_send_smc_msg_with_param (smu, - PPSMC_MSG_SetSystemVirtualDramAddrLow, + SMU_MSG_SetSystemVirtualDramAddrLow, address_low);if (ret)return ret;
@@ -482,15 +481,15 @@ static int smu_v11_0_notify_memory_pool_location(struct smu_context *smu) address_high = (uint32_t )upper_32_bits (address); address_low = (uint32_t )lower_32_bits (address); - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramAddrHigh, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DramLogSetDramAddrHigh, address_high);if (ret)return ret; - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramAddrLow, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DramLogSetDramAddrLow, address_low);if (ret)return ret; - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_DramLogSetDramSize, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_DramLogSetDramSize, (uint32_t )memory_pool->size);if (ret)return ret;
@@ -594,19 +593,19 @@ static int smu_v11_0_copy_table_to_smc(struct smu_context *smu,memcpy (driver_pptable->cpu_addr, table_context->driver_pptable, driver_pptable->size); - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_SetDriverDramAddrHigh, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetDriverDramAddrHigh,upper_32_bits (driver_pptable->mc_address));if (ret) {pr_err ("[CopyTableToSMC] Attempt to Set Dram Addr High Failed!" );return ret; } - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_SetDriverDramAddrLow, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetDriverDramAddrLow,lower_32_bits (driver_pptable->mc_address));if (ret) {pr_err ("[CopyTableToSMC] Attempt to Set Dram Addr Low Failed!" );return ret; } - ret =smu_send_smc_msg_with_param (smu, PPSMC_MSG_TransferTableDram2Smu, + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_TransferTableDram2Smu, table_id);if (ret) {pr_err ("[CopyTableToSMC] Attempt to Transfer Table To SMU Failed!" );
@@ -634,7 +633,7 @@ static int smu_v11_0_set_min_dcef_deep_sleep(struct smu_context *smu)return -EINVAL ; ret =smu_send_smc_msg_with_param (smu, - PPSMC_MSG_SetMinDeepSleepDcefclk, + SMU_MSG_SetMinDeepSleepDcefclk, table_context->boot_values.dcefclk /100 );if (ret)pr_err ("SMU11 attempt to set divider for DCEFCLK Failed!" );
@@ -649,11 +648,11 @@ static int smu_v11_0_set_tool_table_location(struct smu_context *smu)if (tool_table->mc_address) { ret =smu_send_smc_msg_with_param (smu, - PPSMC_MSG_SetToolsDramAddrHigh, + SMU_MSG_SetToolsDramAddrHigh,upper_32_bits (tool_table->mc_address));if (!ret) ret =smu_send_smc_msg_with_param (smu, - PPSMC_MSG_SetToolsDramAddrLow, + SMU_MSG_SetToolsDramAddrLow,lower_32_bits (tool_table->mc_address)); }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 58/138 drm/amd/powerplay: add append_powerplay_table function
In reply to a message not in the archiveIt needs to add append_powerplay_table function to program the smc_dpm_table for PPTable_t.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 4 ++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 92 ++++++++++++++++++++++++++ 3 files changed, 99 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -192,6 +192,7 @@ struct smu_contextstruct pptable_funcs {int (*store_powerplay_table)(struct smu_context *smu);int (*check_powerplay_table)(struct smu_context *smu); +int (*append_powerplay_table)(struct smu_context *smu);int (*get_smu_msg_index)(struct smu_context *smu,uint32_t index); };
@@ -273,6 +274,8 @@ struct smu_funcs ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \ ((smu)->ppt_funcs->check_powerplay_table ? (smu)->ppt_funcs->check_powerplay_table((smu)) : 0) +#define smu_append_powerplay_table (smu) \ + ((smu)->ppt_funcs->append_powerplay_table ? (smu)->ppt_funcs->append_powerplay_table((smu)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +4 -0
@@ -520,6 +520,10 @@ static int smu_v11_0_parse_pptable(struct smu_context *smu)return -ENOMEM ; ret =smu_store_powerplay_table (smu); +if (ret) +return -EINVAL ; + + ret =smu_append_powerplay_table (smu);return ret; }
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +92 -0
104 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 59/138 drm/amd/powerplay: expose the function of smu read argument
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Expose the function of smu_read_smc_arg to get argument value from SMU11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -221,6 +221,7 @@ struct smu_funcsint (*system_features_control)(struct smu_context *smu,bool en);int (*send_smc_msg)(struct smu_context *smu,uint16_t msg);int (*send_smc_msg_with_param)(struct smu_context *smu,uint16_t msg,uint32_t param); +int (*read_smc_arg)(struct smu_context *smu,uint32_t *arg); };
@@ -270,6 +271,8 @@ struct smu_funcs ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)#define smu_send_smc_msg_with_param (smu, msg, param) \ ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0) +#define smu_read_smc_arg (smu, arg) \ + ((smu)->funcs->read_smc_arg? (smu)->funcs->read_smc_arg((smu), (arg)) : 0)#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +2 -1
@@ -213,7 +213,7 @@ static int smu_v11_0_check_fw_version(struct smu_context *smu)if (ret) goto err; - ret =smu_v11_0_read_arg (smu, &smu_version); + ret =smu_read_smc_arg (smu, &smu_version);if (ret) goto err;
@@ -670,6 +670,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .check_fw_version = smu_v11_0_check_fw_version, .send_smc_msg = smu_v11_0_send_msg, .send_smc_msg_with_param = smu_v11_0_send_msg_with_param, + .read_smc_arg = smu_v11_0_read_arg, .read_pptable_from_vbios = smu_v11_0_read_pptable_from_vbios, .init_smc_tables = smu_v11_0_init_smc_tables, .fini_smc_tables = smu_v11_0_fini_smc_tables,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 60/138 drm/amd/powerplay: Change the allocate method of dpm context for smu11.
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Change the allocate method of dpm context as dpm_table is different bewteen vega20 and smu11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 7 +--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 15 +++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 44 ++++++++++++++++++++++++++ 4 files changed, 63 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -190,6 +190,7 @@ struct smu_context };struct pptable_funcs { +int (*alloc_dpm_context)(struct smu_context *smu);int (*store_powerplay_table)(struct smu_context *smu);int (*check_powerplay_table)(struct smu_context *smu);int (*append_powerplay_table)(struct smu_context *smu);
@@ -273,6 +274,8 @@ struct smu_funcs ((smu)->funcs->send_smc_msg_with_param? (smu)->funcs->send_smc_msg_with_param((smu), (msg), (param)) : 0)#define smu_read_smc_arg (smu, arg) \ ((smu)->funcs->read_smc_arg? (smu)->funcs->read_smc_arg((smu), (arg)) : 0) +#define smu_alloc_dpm_context (smu) \ + ((smu)->ppt_funcs->alloc_dpm_context ? (smu)->ppt_funcs->alloc_dpm_context((smu)) : 0)#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -6
@@ -251,12 +251,7 @@ static int smu_v11_0_init_dpm_context(struct smu_context *smu)if (smu_dpm->dpm_context || smu_dpm->dpm_context_size !=0 )return -EINVAL ; - smu_dpm->dpm_context =kzalloc (sizeof (struct smu_11_0_dpm_context ),GFP_KERNEL ); -if (!smu_dpm->dpm_context) -return -ENOMEM ; - smu_dpm->dpm_context_size =sizeof (struct smu_11_0_dpm_context ); - -return 0 ; +return smu_alloc_dpm_context (smu); }static int smu_v11_0_fini_dpm_context (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +15 -0
@@ -132,6 +132,20 @@ static int vega20_get_smu_msg_index(struct smu_context *smc, uint32_t index) } +static int vega20_allocate_dpm_context (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; + + smu_dpm->dpm_context =kzalloc (sizeof (struct vega20_dpm_table ), +GFP_KERNEL ); +if (!smu_dpm->dpm_context) +return -ENOMEM ; + + smu_dpm->dpm_context_size =sizeof (struct vega20_dpm_table ); + +return 0 ; +} +static int vega20_store_powerplay_table (struct smu_context *smu) {ATOM_Vega20_POWERPLAYTABLE *powerplay_table =NULL ;
@@ -260,6 +274,7 @@ static int vega20_check_powerplay_table(struct smu_context *smu) }static const struct pptable_funcs vega20_ppt_funcs = { + .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table, .check_powerplay_table = vega20_check_powerplay_table, .append_powerplay_table = vega20_append_powerplay_table,
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +44 -0
50 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 61/138 drm/amd/powerplay: implement smu_init_display for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Add smu_init_display function to send msg to smc to init display.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 8 ++++++++ 3 files changed, 16 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +4 -0
@@ -236,6 +236,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu) {int ret; + ret =smu_init_display (smu); +if (ret) +return ret; + ret =smu_read_pptable_from_vbios (smu);if (ret)return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -223,6 +223,7 @@ struct smu_funcsint (*send_smc_msg)(struct smu_context *smu,uint16_t msg);int (*send_smc_msg_with_param)(struct smu_context *smu,uint16_t msg,uint32_t param);int (*read_smc_arg)(struct smu_context *smu,uint32_t *arg); +int (*init_display)(struct smu_context *smu); };
@@ -276,6 +277,9 @@ struct smu_funcs ((smu)->funcs->read_smc_arg? (smu)->funcs->read_smc_arg((smu), (arg)) : 0)#define smu_alloc_dpm_context (smu) \ ((smu)->ppt_funcs->alloc_dpm_context ? (smu)->ppt_funcs->alloc_dpm_context((smu)) : 0) +#define smu_init_display (smu) \ + ((smu)->funcs->init_display ? (smu)->funcs->init_display((smu)) : 0) +#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +8 -0
@@ -658,6 +658,13 @@ static int smu_v11_0_set_tool_table_location(struct smu_context *smu)return ret; } +static int smu_v11_0_init_display (struct smu_context *smu) +{ +int ret =0 ; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_NumOfDisplays,0 ); +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -680,6 +687,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .write_pptable = smu_v11_0_write_pptable, .set_min_dcef_deep_sleep = smu_v11_0_set_min_dcef_deep_sleep, .set_tool_table_location = smu_v11_0_set_tool_table_location, + .init_display = smu_v11_0_init_display, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 62/138 drm/amd/powerplay: implement smu_run_afll_btc function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
Add smu_run_afll_btc function to send msg to smc to start run afll btc.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 ++++++ 3 files changed, 15 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -0
@@ -232,6 +232,7 @@ static int smu_fini_fb_allocations(struct smu_context *smu)return 0 ; } +static int smu_smc_table_hw_init (struct smu_context *smu) {int ret;
@@ -306,6 +307,11 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; +/* issue RunAfllBtc msg */ + ret =smu_run_afll_btc (smu); +if (ret) +return ret; +/* * Set min deep sleep dce fclk with bootup value from vbios via * SetMinDeepSleepDcefclk MSG.
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -195,6 +195,7 @@ struct pptable_funcs {int (*check_powerplay_table)(struct smu_context *smu);int (*append_powerplay_table)(struct smu_context *smu);int (*get_smu_msg_index)(struct smu_context *smu,uint32_t index); +int (*run_afll_btc)(struct smu_context *smu); };struct smu_funcs
@@ -289,6 +290,8 @@ struct smu_funcs#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL) +#define smu_run_afll_btc (smu) \ + ((smu)->ppt_funcs? ((smu)->ppt_funcs->run_afll_btc? (smu)->ppt_funcs->run_afll_btc((smu)) : 0) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +6 -0
@@ -273,12 +273,18 @@ static int vega20_check_powerplay_table(struct smu_context *smu)return 0 ; } +static int vega20_run_btc_afll (struct smu_context *smu) +{ +return smu_send_smc_msg (smu, SMU_MSG_RunAfllBtc); +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table, .check_powerplay_table = vega20_check_powerplay_table, .append_powerplay_table = vega20_append_powerplay_table, .get_smu_msg_index = vega20_get_smu_msg_index, + .run_afll_btc = vega20_run_btc_afll, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 63/138 drm/amd/powerplay: implement smu feature functions
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
each ip will support different smu feature,
the driver use bitmap to management this feature.
bitmap:
-allowed: sw driver to enable & disable some feature when driver init. -suppored: the feature is supproed.
-enabled: the feature is enabled.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 36 ++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 28 +++++++- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 99 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 14 ++++ 4 files changed, 176 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +36 -0
@@ -29,6 +29,26 @@#include "smu_v11_0.h" #include "atom.h" +int smu_feature_init_dpm (struct smu_context *smu) +{ +struct smu_feature *feature = &smu->smu_feature; +int ret =0 ; +uint32_t unallowed_feature_mask[SMU_FEATURE_MAX /32 ]; + +bitmap_fill (feature->allowed,SMU_FEATURE_MAX ); + + ret =smu_get_unallowed_feature_mask (smu, unallowed_feature_mask, +SMU_FEATURE_MAX /32 ); +if (ret) +return ret; + +bitmap_andnot (feature->allowed, feature->allowed, + (unsigned long *)unallowed_feature_mask, + feature->feature_num); + +return ret; +} +static int smu_set_funcs (struct amdgpu_device *adev) {struct smu_context *smu = &adev->smu;
@@ -133,6 +153,10 @@ static int smu_sw_init(void *handle)return -EINVAL ; smu->pool_size = adev->pm.smu_prv_buffer_size; + smu->smu_feature.feature_num =SMU_FEATURE_MAX ; +bitmap_zero (smu->smu_feature.supported,SMU_FEATURE_MAX ); +bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX ); +bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX ); ret =smu_init_microcode (smu);if (ret) {
@@ -241,6 +265,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_feature_set_allowed_mask (smu); +if (ret) +return ret; + ret =smu_read_pptable_from_vbios (smu);if (ret)return ret;
@@ -312,6 +340,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_feature_enable_all (smu); +if (ret) +return ret; +/* * Set min deep sleep dce fclk with bootup value from vbios via * SetMinDeepSleepDcefclk MSG.
@@ -413,6 +445,10 @@ static int smu_hw_init(void *handle)mutex_lock (&smu->mutex); + ret =smu_feature_init_dpm (smu); +if (ret) + goto failed; + ret =smu_smc_table_hw_init (smu);if (ret) goto failed;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +27 -1
@@ -175,6 +175,16 @@ struct smu_power_context {uint32_t power_context_size; }; + +#define SMU_FEATURE_MAX (64) +struct smu_feature +{ +uint32_t feature_num; + DECLARE_BITMAP(supported, SMU_FEATURE_MAX); + DECLARE_BITMAP(allowed, SMU_FEATURE_MAX); + DECLARE_BITMAP(enabled, SMU_FEATURE_MAX); +}; +struct smu_context {struct amdgpu_device *adev;
@@ -187,6 +197,7 @@ struct smu_contextstruct smu_table_context smu_table;struct smu_dpm_context smu_dpm;struct smu_power_context smu_power; +struct smu_feature smu_feature; };struct pptable_funcs {
@@ -196,6 +207,7 @@ struct pptable_funcs {int (*append_powerplay_table)(struct smu_context *smu);int (*get_smu_msg_index)(struct smu_context *smu,uint32_t index);int (*run_afll_btc)(struct smu_context *smu); +int (*get_unallowed_feature_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num); };struct smu_funcs
@@ -225,6 +237,10 @@ struct smu_funcsint (*send_smc_msg_with_param)(struct smu_context *smu,uint16_t msg,uint32_t param);int (*read_smc_arg)(struct smu_context *smu,uint32_t *arg);int (*init_display)(struct smu_context *smu); +int (*set_allowed_mask)(struct smu_context *smu); +int (*get_enabled_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num); +int (*enable_all_mask)(struct smu_context *smu); +int (*disable_all_mask)(struct smu_context *smu); };
@@ -280,7 +296,14 @@ struct smu_funcs ((smu)->ppt_funcs->alloc_dpm_context ? (smu)->ppt_funcs->alloc_dpm_context((smu)) : 0)#define smu_init_display (smu) \ ((smu)->funcs->init_display ? (smu)->funcs->init_display((smu)) : 0) - +#define smu_feature_set_allowed_mask (smu) \ + ((smu)->funcs->set_allowed_mask? (smu)->funcs->set_allowed_mask((smu)) : 0) +#define smu_feature_get_enabled_mask (smu, mask, num) \ + ((smu)->funcs->get_enabled_mask? (smu)->funcs->get_enabled_mask((smu), (mask), (num)) : 0) +#define smu_feature_enable_all (smu) \ + ((smu)->funcs->enable_all_mask? (smu)->funcs->enable_all_mask((smu)) : 0) +#define smu_feature_disable_all (smu) \ + ((smu)->funcs->disable_all_mask? (smu)->funcs->disable_all_mask((smu)) : 0)#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \
@@ -292,6 +315,8 @@ struct smu_funcs ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)#define smu_run_afll_btc (smu) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->run_afll_btc? (smu)->ppt_funcs->run_afll_btc((smu)) : 0) : 0) +#define smu_get_unallowed_feature_mask (smu, feature_mask, num) \ + ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_unallowed_feature_mask? (smu)->ppt_funcs->get_unallowed_feature_mask((smu), (feature_mask), (num)) : 0) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
@@ -300,5 +325,6 @@ extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,extern const struct amd_ip_funcs smu_ip_funcs;extern const struct amdgpu_ip_block_version smu_v11_0_ip_block; +extern int smu_feature_init_dpm (struct smu_context *smu);#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +99 -0
111 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +14 -0
@@ -278,6 +278,19 @@ static int vega20_run_btc_afll(struct smu_context *smu)return smu_send_smc_msg (smu, SMU_MSG_RunAfllBtc); } +static int +vega20_get_unallowed_feature_mask (struct smu_context *smu, +uint32_t *feature_mask,uint32_t num) +{ +if (num >2 ) +return -EINVAL ; + + feature_mask[0 ] =0xE0041C00 ; + feature_mask[1 ] =0xFFFFFFFE ;/* bit32~bit63 is Unsupported */ + +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
@@ -285,6 +298,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { .append_powerplay_table = vega20_append_powerplay_table, .get_smu_msg_index = vega20_get_smu_msg_index, .run_afll_btc = vega20_run_btc_afll, + .get_unallowed_feature_mask = vega20_get_unallowed_feature_mask, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 64/138 drm/amd/powerplay: implement feature get&set functions
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add smu feature operation function helper to deal with smu feature bitmap.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 37 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 ++++ 2 files changed, 42 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +37 -0
@@ -49,6 +49,43 @@ int smu_feature_init_dpm(struct smu_context *smu)return ret; } +int smu_feature_is_enabled (struct smu_context *smu,int feature_id) +{ +struct smu_feature *feature = &smu->smu_feature; +WARN_ON (feature_id > feature->feature_num); +return test_bit (feature_id, feature->enabled); +} + +int smu_feature_set_enabled (struct smu_context *smu,int feature_id,bool enable) +{ +struct smu_feature *feature = &smu->smu_feature; +WARN_ON (feature_id > feature->feature_num); +if (enable) +test_and_set_bit (feature_id, feature->enabled); +else +test_and_clear_bit (feature_id, feature->enabled); +return 0 ; +} + +int smu_feature_is_supported (struct smu_context *smu,int feature_id) +{ +struct smu_feature *feature = &smu->smu_feature; +WARN_ON (feature_id > feature->feature_num); +return test_bit (feature_id, feature->supported); +} + +int smu_feature_set_supported (struct smu_context *smu,int feature_id, +bool enable) +{ +struct smu_feature *feature = &smu->smu_feature; +WARN_ON (feature_id > feature->feature_num); +if (enable) +test_and_set_bit (feature_id, feature->supported); +else +test_and_clear_bit (feature_id, feature->supported); +return 0 ; +} +static int smu_set_funcs (struct amdgpu_device *adev) {struct smu_context *smu = &adev->smu;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -327,4 +327,9 @@ extern const struct amd_ip_funcs smu_ip_funcs;extern const struct amdgpu_ip_block_version smu_v11_0_ip_block;extern int smu_feature_init_dpm (struct smu_context *smu); +extern int smu_feature_is_enabled (struct smu_context *smu,int feature_id); +extern int smu_feature_set_enabled (struct smu_context *smu,int feature_id,bool enable); +extern int smu_feature_is_supported (struct smu_context *smu,int feature_id); +extern int smu_feature_set_supported (struct smu_context *smu,int feature_id,bool enable); +#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 65/138 drm/amd/powerplay: implement smu_notify_display_change function for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add smu_notify_display_change function to send msg to smc to notify display is changed.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 11 +++++++++++ 3 files changed, 18 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +4 -0
@@ -381,6 +381,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_notify_display_change (smu); +if (ret) +return ret; +/* * Set min deep sleep dce fclk with bootup value from vbios via * SetMinDeepSleepDcefclk MSG.
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -241,6 +241,7 @@ struct smu_funcsint (*get_enabled_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num);int (*enable_all_mask)(struct smu_context *smu);int (*disable_all_mask)(struct smu_context *smu); +int (*notify_display_change)(struct smu_context *smu); };
@@ -304,6 +305,8 @@ struct smu_funcs ((smu)->funcs->enable_all_mask? (smu)->funcs->enable_all_mask((smu)) : 0)#define smu_feature_disable_all (smu) \ ((smu)->funcs->disable_all_mask? (smu)->funcs->disable_all_mask((smu)) : 0) +#define smu_notify_display_change (smu) \ + ((smu)->funcs->notify_display_change? (smu)->funcs->notify_display_change((smu)) : 0)#define smu_store_powerplay_table (smu) \ ((smu)->ppt_funcs->store_powerplay_table ? (smu)->ppt_funcs->store_powerplay_table((smu)) : 0)#define smu_check_powerplay_table (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +11 -0
@@ -760,6 +760,16 @@ static int smu_v11_0_disable_all_mask(struct smu_context *smu)return ret; } +static int smu_v11_0_notify_display_change (struct smu_context *smu) +{ +int ret =0 ; + +if (smu_feature_is_enabled (smu,FEATURE_DPM_UCLK_BIT )) + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetUclkFastSwitch,1 ); + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -787,6 +797,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_enabled_mask = smu_v11_0_get_enabled_mask, .enable_all_mask = smu_v11_0_enable_all_mask, .disable_all_mask = smu_v11_0_disable_all_mask, + .notify_display_change = smu_v11_0_notify_display_change, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 66/138 drm/amd/powerplay: set defalut dpm table for smu
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_set_default_dpm_table function to set dpm table for smu11. Modified the sequence to populate smc pptable, as it should be done after related dpm feature is enabled.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 18 +- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 38 +--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 236 +++++++++++++++++++++++++ 4 files changed, 251 insertions(+), 44 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +9 -9
@@ -348,15 +348,6 @@ static int smu_smc_table_hw_init(struct smu_context *smu)return ret;/* -* Set initialized values (get from vbios) to dpm tables context such as -* gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each -* type of clks. -*/ - ret =smu_populate_smc_pptable (smu); -if (ret) -return ret; - -/* * Send msg GetDriverIfVersion to check if the return value is equal * with DRIVER_IF_VERSION of smc header. */
@@ -394,6 +385,15 @@ static int smu_smc_table_hw_init(struct smu_context *smu)return ret;/* +* Set initialized values (get from vbios) to dpm tables context such as +* gfxclk, memclk, dcefclk, and etc. And enable the DPM feature for each +* type of clks. +*/ + ret =smu_populate_smc_pptable (smu); +if (ret) +return ret; + +/* * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. */ ret =smu_set_tool_table_location (smu);
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -208,6 +208,7 @@ struct pptable_funcs {int (*get_smu_msg_index)(struct smu_context *smu,uint32_t index);int (*run_afll_btc)(struct smu_context *smu);int (*get_unallowed_feature_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num); +int (*set_default_dpm_table)(struct smu_context *smu); };struct smu_funcs
@@ -313,6 +314,8 @@ struct smu_funcs ((smu)->ppt_funcs->check_powerplay_table ? (smu)->ppt_funcs->check_powerplay_table((smu)) : 0)#define smu_append_powerplay_table (smu) \ ((smu)->ppt_funcs->append_powerplay_table ? (smu)->ppt_funcs->append_powerplay_table((smu)) : 0) +#define smu_set_default_dpm_table (smu) \ + ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +3 -35
@@ -525,43 +525,11 @@ static int smu_v11_0_parse_pptable(struct smu_context *smu)static int smu_v11_0_populate_smc_pptable (struct smu_context *smu) { -struct smu_dpm_context *smu_dpm = &smu->smu_dpm; - -PPTable_t *driver_ppt = (PPTable_t *)&(smu->smu_table.tables[TABLE_PPTABLE ]); -struct smu_11_0_dpm_context *dpm_context = (struct smu_11_0_dpm_context *)smu_dpm->dpm_context; - -if (dpm_context && driver_ppt) { - dpm_context->dpm_tables.soc_table.min = driver_ppt->FreqTableSocclk[0 ]; - dpm_context->dpm_tables.soc_table.max = driver_ppt->FreqTableSocclk[NUM_SOCCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.gfx_table.min = driver_ppt->FreqTableGfx[0 ]; - dpm_context->dpm_tables.gfx_table.max = driver_ppt->FreqTableGfx[NUM_GFXCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.uclk_table.min = driver_ppt->FreqTableUclk[0 ]; - dpm_context->dpm_tables.uclk_table.max = driver_ppt->FreqTableUclk[NUM_UCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.vclk_table.min = driver_ppt->FreqTableVclk[0 ]; - dpm_context->dpm_tables.vclk_table.max = driver_ppt->FreqTableVclk[NUM_VCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.dclk_table.min = driver_ppt->FreqTableDclk[0 ]; - dpm_context->dpm_tables.dclk_table.max = driver_ppt->FreqTableDclk[NUM_DCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.dcef_table.min = driver_ppt->FreqTableDcefclk[0 ]; - dpm_context->dpm_tables.dcef_table.max = driver_ppt->FreqTableDcefclk[NUM_DCEFCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.pixel_table.min = driver_ppt->FreqTablePixclk[0 ]; - dpm_context->dpm_tables.pixel_table.max = driver_ppt->FreqTablePixclk[NUM_PIXCLK_DPM_LEVELS -1 ]; - - dpm_context->dpm_tables.display_table.min = driver_ppt->FreqTableDispclk[0 ]; - dpm_context->dpm_tables.display_table.max = driver_ppt->FreqTableDispclk[NUM_DISPCLK_DPM_LEVELS -1 ]; +int ret; - dpm_context->dpm_tables.phy_table.min = driver_ppt->FreqTablePhyclk[0 ]; - dpm_context->dpm_tables.phy_table.max = driver_ppt->FreqTablePhyclk[NUM_PHYCLK_DPM_LEVELS -1 ]; + ret =smu_set_default_dpm_table (smu); -return 0 ; - } - -return -EINVAL ; +return ret; } static int smu_v11_0_copy_table_to_smc(struct smu_context *smu,
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +236 -0
248 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 67/138 drm/amd/powerplay: add function to populate umd state clk.
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add vega20_populate_umd_state_clk function to set pstate_sclk and pstate_mclk.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 27 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 3 +++ 4 files changed, 40 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +4 -0
@@ -393,6 +393,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_populate_umd_state_clk (smu); +if (ret) +return ret; +/* * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -0
@@ -198,6 +198,9 @@ struct smu_contextstruct smu_dpm_context smu_dpm;struct smu_power_context smu_power;struct smu_feature smu_feature; + +uint32_t pstate_sclk; +uint32_t pstate_mclk; };struct pptable_funcs {
@@ -209,6 +212,7 @@ struct pptable_funcs {int (*run_afll_btc)(struct smu_context *smu);int (*get_unallowed_feature_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num);int (*set_default_dpm_table)(struct smu_context *smu); +int (*populate_umd_state_clk)(struct smu_context *smu); };struct smu_funcs
@@ -316,6 +320,8 @@ struct smu_funcs ((smu)->ppt_funcs->append_powerplay_table ? (smu)->ppt_funcs->append_powerplay_table((smu)) : 0)#define smu_set_default_dpm_table (smu) \ ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0) +#define smu_populate_umd_state_clk (smu) \ + ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +27 -0
@@ -526,6 +526,32 @@ static int vega20_set_default_dpm_table(struct smu_context *smu)return 0 ; } +static int vega20_populate_umd_state_clk (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; +struct vega20_dpm_table *dpm_table =NULL ; +struct vega20_single_dpm_table *gfx_table =NULL ; +struct vega20_single_dpm_table *mem_table =NULL ; + + dpm_table = smu_dpm->dpm_context; + gfx_table = &(dpm_table->gfx_table); + mem_table = &(dpm_table->mem_table); + + smu->pstate_sclk = gfx_table->dpm_levels[0 ].value; + smu->pstate_mclk = mem_table->dpm_levels[0 ].value; + +if (gfx_table->count >VEGA20_UMD_PSTATE_GFXCLK_LEVEL && + mem_table->count >VEGA20_UMD_PSTATE_MCLK_LEVEL ) { + smu->pstate_sclk = gfx_table->dpm_levels[VEGA20_UMD_PSTATE_GFXCLK_LEVEL ].value; + smu->pstate_mclk = mem_table->dpm_levels[VEGA20_UMD_PSTATE_MCLK_LEVEL ].value; + } + + smu->pstate_sclk = smu->pstate_sclk *100 ; + smu->pstate_mclk = smu->pstate_mclk *100 ; + +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
@@ -535,6 +561,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { .run_afll_btc = vega20_run_btc_afll, .get_unallowed_feature_mask = vega20_get_unallowed_feature_mask, .set_default_dpm_table = vega20_set_default_dpm_table, + .populate_umd_state_clk = vega20_populate_umd_state_clk, };void vega20_set_ppt_funcs (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +3 -0
@@ -23,6 +23,9 @@#ifndef __VEGA20_PPT_H__#define __VEGA20_PPT_H__ +#define VEGA20_UMD_PSTATE_GFXCLK_LEVEL 0x3 +#define VEGA20_UMD_PSTATE_MCLK_LEVEL 0x2 +#define MAX_REGULAR_DPM_NUMBER 16#define MAX_PCIE_CONF 2
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 68/138 drm/amd/powerplay: add function to get power limit for smu11 (v2)
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add smu_v11_0_get_power_limit function to get power limit vaule.
v2: update "set" to "get", it only implements "get" behavior. (Alex)
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 7 ++++++- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 20 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +4 -0
@@ -397,6 +397,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_get_power_limit (smu); +if (ret) +return ret; +/* * Set PMSTATUSLOG table bo address with SetToolsDramAddr MSG for tools. */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -1
@@ -201,6 +201,9 @@ struct smu_contextuint32_t pstate_sclk;uint32_t pstate_mclk; + +uint32_t power_limit; +uint32_t default_power_limit; };struct pptable_funcs {
@@ -247,7 +250,7 @@ struct smu_funcsint (*enable_all_mask)(struct smu_context *smu);int (*disable_all_mask)(struct smu_context *smu);int (*notify_display_change)(struct smu_context *smu); - +int (*get_power_limit)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -322,6 +325,8 @@ struct smu_funcs ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0)#define smu_populate_umd_state_clk (smu) \ ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0) +#define smu_get_power_limit (smu) \ + ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +20 -0
@@ -738,6 +738,25 @@ static int smu_v11_0_notify_display_change(struct smu_context *smu)return ret; } +static int smu_v11_0_get_power_limit (struct smu_context *smu) +{ +int ret; +uint32_t power_limit_value; + + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_GetPptLimit, +POWER_SOURCE_AC <<16 ); +if (ret) { +pr_err ("[GetPptLimit] get default PPT limit failed!" ); +return ret; + } + +smu_read_smc_arg (smu, &power_limit_value); + smu->power_limit = smu->default_power_limit = power_limit_value; + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -766,6 +785,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .enable_all_mask = smu_v11_0_enable_all_mask, .disable_all_mask = smu_v11_0_disable_all_mask, .notify_display_change = smu_v11_0_notify_display_change, + .get_power_limit = smu_v11_0_get_power_limit, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 69/138 drm/amd/powerplay: implement get_current_clk_freq for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
This patch implements get_current_clk_freq for smu11 future use.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -251,6 +251,7 @@ struct smu_funcsint (*disable_all_mask)(struct smu_context *smu);int (*notify_display_change)(struct smu_context *smu);int (*get_power_limit)(struct smu_context *smu); +int (*get_current_clk_freq)(struct smu_context *smu,uint32_t clk_id,uint32_t *value); };#define smu_init_microcode (smu) \
@@ -327,6 +328,8 @@ struct smu_funcs ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0)#define smu_get_power_limit (smu) \ ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 0) +#define smu_get_current_clk_freq (smu, clk_id, value) \ + ((smu)->funcs->get_current_clk_freq? (smu)->funcs->get_current_clk_freq((smu), (clk_id), (value)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +24 -0
@@ -757,6 +757,29 @@ static int smu_v11_0_get_power_limit(struct smu_context *smu)return 0 ; } +static int smu_v11_0_get_current_clk_freq (struct smu_context *smu,uint32_t clk_id,uint32_t *value) +{ +int ret =0 ; +uint32_t freq; + +if (clk_id >=PPCLK_COUNT || !value) +return -EINVAL ; + + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_GetDpmClockFreq, (clk_id <<16 )); +if (ret) +return ret; + + ret =smu_read_smc_arg (smu, &freq); +if (ret) +return ret; + + freq *=100 ; + *value = freq; + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -786,6 +809,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .disable_all_mask = smu_v11_0_disable_all_mask, .notify_display_change = smu_v11_0_notify_display_change, .get_power_limit = smu_v11_0_get_power_limit, + .get_current_clk_freq = smu_v11_0_get_current_clk_freq, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 70/138 drm/amd/powerplay: print clock levels for smu11 (v2)
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to print current levels for smu11.
v2: expose get_current_clk_freq for smu v11. (Kevin)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 9 ++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 79 ++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7 -2
@@ -28,6 +28,7 @@#include "amdgpu_pm.h" #include "amdgpu_dpm.h" #include "amdgpu_display.h" +#include "amdgpu_smu.h" #include "atom.h" #include <linux/power_supply.h> #include <linux/hwmon.h>
@@ -711,7 +712,9 @@ static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->powerplay.pp_funcs->print_clock_levels) +if (adev->smu.ppt_funcs) +return smu_print_clk_levels (&adev->smu,PP_SCLK , buf); +else if (adev->powerplay.pp_funcs->print_clock_levels)return amdgpu_dpm_print_clock_levels (adev,PP_SCLK , buf);else return snprintf (buf,PAGE_SIZE ,"\n" );
@@ -783,7 +786,9 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->powerplay.pp_funcs->print_clock_levels) +if (adev->smu.ppt_funcs) +return smu_print_clk_levels (&adev->smu,PP_MCLK , buf); +else if (adev->powerplay.pp_funcs->print_clock_levels)return amdgpu_dpm_print_clock_levels (adev,PP_MCLK , buf);else return snprintf (buf,PAGE_SIZE ,"\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -216,6 +216,7 @@ struct pptable_funcs {int (*get_unallowed_feature_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num);int (*set_default_dpm_table)(struct smu_context *smu);int (*populate_umd_state_clk)(struct smu_context *smu); +int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf); };struct smu_funcs
@@ -330,6 +331,8 @@ struct smu_funcs ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 0)#define smu_get_current_clk_freq (smu, clk_id, value) \ ((smu)->funcs->get_current_clk_freq? (smu)->funcs->get_current_clk_freq((smu), (clk_id), (value)) : 0) +#define smu_print_clk_levels (smu, type, buf) \ + ((smu)->ppt_funcs->print_clk_levels ? (smu)->ppt_funcs->print_clk_levels((smu), (type), (buf)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +79 -0
91 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 71/138 drm/amd/powerplay: add get_max_sustainable_clock function
In reply to a message not in the archiveThis patch adds get_max_sustainable_clock function for smu11.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 9 ++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 + drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h | 8 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 114 +++++++++++++++++++++++++ 4 files changed, 135 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +9 -0
@@ -393,6 +393,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_init_max_sustainable_clocks (smu); +if (ret) +return ret; + ret =smu_populate_umd_state_clk (smu);if (ret)return ret;
@@ -539,6 +543,11 @@ static int smu_hw_fini(void *handle)return -EINVAL ;kfree (table_context->driver_pptable); +if (table_context->max_sustainable_clocks) { +kfree (table_context->max_sustainable_clocks); + table_context->max_sustainable_clocks =NULL ; + } + ret =smu_fini_fb_allocations (smu);if (ret)return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -158,6 +158,7 @@ struct smu_table_contextvoid *power_play_table;uint32_t power_play_table_size; +void *max_sustainable_clocks;struct smu_bios_boot_up_values boot_values;void *driver_pptable;struct smu_table *tables;
@@ -253,6 +254,7 @@ struct smu_funcsint (*notify_display_change)(struct smu_context *smu);int (*get_power_limit)(struct smu_context *smu);int (*get_current_clk_freq)(struct smu_context *smu,uint32_t clk_id,uint32_t *value); +int (*init_max_sustainable_clocks)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -297,6 +299,8 @@ struct smu_funcs ((smu)->funcs->set_last_dcef_min_deep_sleep_clk ? (smu)->funcs->set_last_dcef_min_deep_sleep_clk((smu)) : 0)#define smu_system_features_control (smu, en) \ ((smu)->funcs->system_features_control ? (smu)->funcs->system_features_control((smu), (en)) : 0) +#define smu_init_max_sustainable_clocks (smu) \ + ((smu)->funcs->init_max_sustainable_clocks ? (smu)->funcs->init_max_sustainable_clocks((smu)) : 0)#define smu_send_smc_msg (smu, msg) \ ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)#define smu_send_smc_msg_with_param (smu, msg, param) \
drivers/gpu/drm/amd/powerplay/inc/smu_v11_0.h +8 -0
@@ -36,6 +36,14 @@#define smnMP0_FW_INTF 0x30101c0#define smnMP1_PUB_CTRL 0x3010b14 +struct smu_11_0_max_sustainable_clocks { +uint32_t display_clock; +uint32_t phy_clock; +uint32_t pixel_clock; +uint32_t uclock; +uint32_t dcef_clock; +uint32_t soc_clock; +};struct smu_11_0_dpm_table {uint32_t min;/* MHz */
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +114 -0
126 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 72/138 drm/amd/powerplay: add function to get thermal range
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add the function to get the min and max thermal value for vega20 with smu11 architecture.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 12 ++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 2 ++ 3 files changed, 15 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -164,6 +164,7 @@ struct smu_table_contextstruct smu_table *tables;uint32_t table_count;struct smu_table memory_pool; +uint16_t software_shutdown_temp; };struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +12 -0
@@ -31,6 +31,7 @@#include "soc15_common.h" #include "atom.h" #include "vega20_ppt.h" +#include "pp_thermal.h" #include "asic_reg/thm/thm_11_0_2_offset.h" #include "asic_reg/thm/thm_11_0_2_sh_mask.h"
@@ -893,6 +894,17 @@ static int smu_v11_0_get_current_clk_freq(struct smu_context *smu, uint32_t clk_return ret; } +static int smu_v11_0_get_thermal_range (struct smu_context *smu, +struct PP_TemperatureRange *range) +{ +memcpy (range, &SMU7ThermalWithDelayPolicy[0 ],sizeof (struct PP_TemperatureRange )); + + range->max = smu->smu_table.software_shutdown_temp * +PP_TEMPERATURE_UNITS_PER_CENTIGRADES ; + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +2 -0
@@ -159,6 +159,8 @@ static int vega20_store_powerplay_table(struct smu_context *smu)memcpy (table_context->driver_pptable, &powerplay_table->smcPPTable,sizeof (PPTable_t)); + table_context->software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 73/138 drm/amd/powerplay: add function to set thermal range
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add the function to set the correct min and max thermal value for smu11
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +32 -0
@@ -42,6 +42,8 @@MODULE_FIRMWARE ("amdgpu/vega20_smc.bin" );#define SMU11_TOOL_SIZE 0x19000 +#define SMU11_THERMAL_MINIMUM_ALERT_TEMP 0 +#define SMU11_THERMAL_MAXIMUM_ALERT_TEMP 255static int smu_v11_0_send_msg_without_waiting (struct smu_context *smu,uint16_t msg)
@@ -905,6 +907,36 @@ static int smu_v11_0_get_thermal_range(struct smu_context *smu,return 0 ; } +static int smu_v11_0_set_thermal_range (struct smu_context *smu, +struct PP_TemperatureRange *range) +{ +struct amdgpu_device *adev = smu->adev; +int low =SMU11_THERMAL_MINIMUM_ALERT_TEMP * +PP_TEMPERATURE_UNITS_PER_CENTIGRADES ; +int high =SMU11_THERMAL_MAXIMUM_ALERT_TEMP * +PP_TEMPERATURE_UNITS_PER_CENTIGRADES ; +uint32_t val; + +if (low < range->min) + low = range->min; +if (high > range->max) + high = range->max; + +if (low > high) +return -EINVAL ; + + val =RREG32_SOC15 (THM ,0 , mmTHM_THERMAL_INT_CTRL); + val =REG_SET_FIELD (val,THM_THERMAL_INT_CTRL ,MAX_IH_CREDIT ,5 ); + val =REG_SET_FIELD (val,THM_THERMAL_INT_CTRL ,THERM_IH_HW_ENA ,1 ); + val =REG_SET_FIELD (val,THM_THERMAL_INT_CTRL ,DIG_THERM_INTH , (high /PP_TEMPERATURE_UNITS_PER_CENTIGRADES )); + val =REG_SET_FIELD (val,THM_THERMAL_INT_CTRL ,DIG_THERM_INTL , (low /PP_TEMPERATURE_UNITS_PER_CENTIGRADES )); + val = val & (~THM_THERMAL_INT_CTRL__THERM_TRIGGER_MASK_MASK ); + +WREG32_SOC15 (THM ,0 , mmTHM_THERMAL_INT_CTRL, val); + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 74/138 drm/amd/powerplay: add function to enable thermal alert
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to enable thermal alerts on thermal control for smu11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +14 -0
@@ -937,6 +937,20 @@ static int smu_v11_0_set_thermal_range(struct smu_context *smu,return 0 ; } +static int smu_v11_0_enable_thermal_alert (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; +uint32_t val =0 ; + + val |= (1 <<THM_THERMAL_INT_ENA__THERM_INTH_CLR__SHIFT ); + val |= (1 <<THM_THERMAL_INT_ENA__THERM_INTL_CLR__SHIFT ); + val |= (1 <<THM_THERMAL_INT_ENA__THERM_TRIGGER_CLR__SHIFT ); + +WREG32_SOC15 (THM ,0 , mmTHM_THERMAL_INT_ENA, val); + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 75/138 drm/amd/powerplay: add function to set fan table to control thermal
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function of smu_v11_0_set_thermal_fan_table to set fan table for smu11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +12 -0
@@ -951,6 +951,18 @@ static int smu_v11_0_enable_thermal_alert(struct smu_context *smu)return 0 ; } +static int smu_v11_0_set_thermal_fan_table (struct smu_context *smu) +{ +int ret; +struct smu_table_context *table_context = &smu->smu_table; +PPTable_t *pptable = table_context->driver_pptable; + + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetFanTemperatureTarget, + (uint32_t )pptable->FanTargetTemperature); + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 76/138 drm/amd/powerplay: add function to start thermal control
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to start thermal control for smu11 when smu hw_init.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 4 ++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 28 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 1 + 4 files changed, 37 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +4 -0
@@ -518,6 +518,10 @@ static int smu_hw_init(void *handle)if (ret) goto failed; + ret =smu_start_thermal_control (smu); +if (ret) + goto failed; +mutex_unlock (&smu->mutex);pr_info ("SMU is initialized successfully!\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -165,6 +165,7 @@ struct smu_table_contextuint32_t table_count;struct smu_table memory_pool;uint16_t software_shutdown_temp; +uint8_t thermal_controller_type; };struct smu_dpm_context {
@@ -256,6 +257,7 @@ struct smu_funcsint (*get_power_limit)(struct smu_context *smu);int (*get_current_clk_freq)(struct smu_context *smu,uint32_t clk_id,uint32_t *value);int (*init_max_sustainable_clocks)(struct smu_context *smu); +int (*start_thermal_control)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -338,6 +340,8 @@ struct smu_funcs ((smu)->funcs->get_current_clk_freq? (smu)->funcs->get_current_clk_freq((smu), (clk_id), (value)) : 0)#define smu_print_clk_levels (smu, type, buf) \ ((smu)->ppt_funcs->print_clk_levels ? (smu)->ppt_funcs->print_clk_levels((smu), (type), (buf)) : 0) +#define smu_start_thermal_control (smu) \ + ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +28 -0
@@ -963,6 +963,33 @@ static int smu_v11_0_set_thermal_fan_table(struct smu_context *smu)return ret; } +static int smu_v11_0_start_thermal_control (struct smu_context *smu) +{ +int ret =0 ; +struct PP_TemperatureRange range; +struct amdgpu_device *adev = smu->adev; + +smu_v11_0_get_thermal_range (smu, &range); + +if (smu->smu_table.thermal_controller_type) { + ret =smu_v11_0_set_thermal_range (smu, &range); +if (ret) +return ret; + + ret =smu_v11_0_enable_thermal_alert (smu); +if (ret) +return ret; + ret =smu_v11_0_set_thermal_fan_table (smu); +if (ret) +return ret; + } + + adev->pm.dpm.thermal.min_temp = range.min; + adev->pm.dpm.thermal.max_temp = range.max; + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -994,6 +1021,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_power_limit = smu_v11_0_get_power_limit, .get_current_clk_freq = smu_v11_0_get_current_clk_freq, .init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks, + .start_thermal_control = smu_v11_0_start_thermal_control, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -0
@@ -160,6 +160,7 @@ static int vega20_store_powerplay_table(struct smu_context *smu) sizeof(PPTable_t)); table_context->software_shutdown_temp = powerplay_table->usSoftwareShutdownTemp; + table_context->thermal_controller_type = powerplay_table->ucThermalControllerType;return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 77/138 drm/amd/powerplay: implement smu update table function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
sometime, the driver need changed table data between driver and smu. this function can help update table data
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 30 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ 2 files changed, 32 insertions(+)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +30 -0
@@ -29,6 +29,36 @@#include "smu_v11_0.h" #include "atom.h" +int smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu) +{ +struct smu_table_context *smu_table = &smu->smu_table; +struct smu_table *table =NULL ; +int ret =0 ; + +if (!table_data || table_id >= smu_table->table_count) +return -EINVAL ; + + table = &smu_table->tables[table_id]; + +if (drv2smu) +memcpy (table->cpu_addr, table_data, table->size); + + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetDriverDramAddrHigh,upper_32_bits (table->mc_address)); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, SMU_MSG_SetDriverDramAddrLow,lower_32_bits (table->mc_address)); +if (ret) +return ret; + ret =smu_send_smc_msg_with_param (smu, drv2smu ? SMU_MSG_TransferTableDram2Smu : SMU_MSG_TransferTableSmu2Dram, table_id); +if (ret) +return ret; + +if (!drv2smu) +memcpy (table_data, table->cpu_addr, table->size); + +return ret; +} +int smu_feature_init_dpm (struct smu_context *smu) {struct smu_feature *feature = &smu->smu_feature;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -364,4 +364,6 @@ extern int smu_feature_set_enabled(struct smu_context *smu, int feature_id, boolextern int smu_feature_is_supported (struct smu_context *smu,int feature_id);extern int smu_feature_set_supported (struct smu_context *smu,int feature_id,bool enable); +int smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu); +#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 78/138 drm/amd/powerplay: implement is_support_sw_smu function for new smu
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add this helper to check new sw-smu support.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/soc15.c | 2 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 23 +++++++++++++++++------ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + 4 files changed, 21 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -2
@@ -712,7 +712,7 @@ static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->smu.ppt_funcs) +if (is_support_sw_smu (adev))return smu_print_clk_levels (&adev->smu,PP_SCLK , buf);else if (adev->powerplay.pp_funcs->print_clock_levels)return amdgpu_dpm_print_clock_levels (adev,PP_SCLK , buf);
@@ -786,7 +786,7 @@ static ssize_t amdgpu_get_pp_dpm_mclk(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->smu.ppt_funcs) +if (is_support_sw_smu (adev))return smu_print_clk_levels (&adev->smu,PP_MCLK , buf);else if (adev->powerplay.pp_funcs->print_clock_levels)return amdgpu_dpm_print_clock_levels (adev,PP_MCLK , buf);
drivers/gpu/drm/amd/amdgpu/soc15.c +1 -1
@@ -605,7 +605,7 @@ int soc15_set_ip_blocks(struct amdgpu_device *adev)amdgpu_device_ip_block_add (adev, &gfx_v9_0_ip_block);amdgpu_device_ip_block_add (adev, &sdma_v4_0_ip_block);if (!amdgpu_sriov_vf (adev)) { -if (amdgpu_dpm ==1 && adev->asic_type >=CHIP_VEGA20 ) +if (is_support_sw_smu (adev))amdgpu_device_ip_block_add (adev, &smu_v11_0_ip_block);else amdgpu_device_ip_block_add (adev, &pp_smu_ip_block);
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +17 -6
@@ -59,6 +59,17 @@ int smu_update_table(struct smu_context *smu, uint32_t table_id, void *table_datreturn ret; } +bool is_support_sw_smu (struct amdgpu_device *adev) +{ +if (amdgpu_dpm !=1 ) +return false; + +if (adev->asic_type >=CHIP_VEGA20 ) +return true; + +return false; +} +int smu_feature_init_dpm (struct smu_context *smu) {struct smu_feature *feature = &smu->smu_feature;
@@ -216,7 +227,7 @@ static int smu_sw_init(void *handle)struct smu_context *smu = &adev->smu;int ret; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ; smu->pool_size = adev->pm.smu_prv_buffer_size;
@@ -246,7 +257,7 @@ static int smu_sw_fini(void *handle)struct smu_context *smu = &adev->smu;int ret; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ; ret =smu_smc_table_sw_fini (smu);
@@ -511,7 +522,7 @@ static int smu_hw_init(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ;if (adev->firmware.load_type !=AMDGPU_FW_LOAD_PSP ) {
@@ -570,7 +581,7 @@ static int smu_hw_fini(void *handle)struct smu_table_context *table_context = &smu->smu_table;int ret =0 ; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ;if (!table_context->driver_pptable)
@@ -597,7 +608,7 @@ static int smu_suspend(void *handle) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ;return 0 ;
@@ -609,7 +620,7 @@ static int smu_resume(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu; -if (adev->asic_type <CHIP_VEGA20 ) +if (!is_support_sw_smu (adev))return -EINVAL ;pr_info ("SMU is resuming...\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -365,5 +365,6 @@ extern int smu_feature_is_supported(struct smu_context *smu, int feature_id);extern int smu_feature_set_supported (struct smu_context *smu,int feature_id,bool enable);int smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu); +bool is_support_sw_smu (struct amdgpu_device *adev);#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 79/138 drm/amd/powerplay: implement sysfs of amdgpu_get_busy_percent for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add interface amdgpu_get_busy_percent for smu11
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 7 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 5 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 62 ++++++++++---------------- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 40 +++++++++++++++++ 5 files changed, 73 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -4
@@ -571,10 +571,9 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf, idx = *pos >>2 ; valuesize =sizeof (values); -if (adev->powerplay.pp_funcs && adev->powerplay.pp_funcs->read_sensor) - r =amdgpu_dpm_read_sensor (adev, idx, &values[0 ], &valuesize); -else -return -EINVAL ; + r =amdgpu_dpm_read_sensor (adev, idx, &values[0 ], &valuesize); +if (r) +return r;if (size > valuesize)return -EINVAL ;
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +2 -3
@@ -260,9 +260,6 @@ enum amdgpu_pcie_gen {#define amdgpu_dpm_enable_bapm (adev, e) \ ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) -#define amdgpu_dpm_read_sensor (adev, idx, value, size) \ - ((adev)->powerplay.pp_funcs->read_sensor((adev)->powerplay.pp_handle, (idx), (value), (size))) -#define amdgpu_dpm_set_fan_control_mode (adev, m) \ ((adev)->powerplay.pp_funcs->set_fan_control_mode((adev)->powerplay.pp_handle, (m)))
@@ -486,6 +483,8 @@ void amdgpu_dpm_print_ps_status(struct amdgpu_device *adev,u32 amdgpu_dpm_get_vblank_time (struct amdgpu_device *adev);u32 amdgpu_dpm_get_vrefresh (struct amdgpu_device *adev);void amdgpu_dpm_get_active_displays (struct amdgpu_device *adev); +int amdgpu_dpm_read_sensor (struct amdgpu_device *adev,enum amd_pp_sensors sensor, +void *data,uint32_t *size);bool amdgpu_is_uvd_state (u32 class,u32 class2);void amdgpu_calculate_u_and_p (u32 i,u32 r_c,u32 p_b,u32 *p,u32 *u);
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +23 -39
125 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -23,6 +23,7 @@#define __AMDGPU_SMU_H__#include "amdgpu.h" +#include "kgd_pp_interface.h" enum smu_message_type {
@@ -258,6 +259,8 @@ struct smu_funcsint (*get_current_clk_freq)(struct smu_context *smu,uint32_t clk_id,uint32_t *value);int (*init_max_sustainable_clocks)(struct smu_context *smu);int (*start_thermal_control)(struct smu_context *smu); +int (*read_sensor)(struct smu_context *smu,enum amd_pp_sensors sensor, +void *data,uint32_t *size); };#define smu_init_microcode (smu) \
@@ -342,6 +345,8 @@ struct smu_funcs ((smu)->ppt_funcs->print_clk_levels ? (smu)->ppt_funcs->print_clk_levels((smu), (type), (buf)) : 0)#define smu_start_thermal_control (smu) \ ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0) +#define smu_read_sensor (smu, sensor, data, size) \ + ((smu)->funcs->read_sensor? (smu)->funcs->read_sensor((smu), (sensor), (data), (size)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +40 -0
@@ -990,6 +990,45 @@ static int smu_v11_0_start_thermal_control(struct smu_context *smu)return ret; } +static int smu_v11_0_get_current_activity_percent (struct smu_context *smu, +uint32_t *value) +{ +int ret =0 ; +SmuMetrics_t metrics; + +if (!value) +return -EINVAL ; + + ret =smu_update_table (smu,TABLE_SMU_METRICS , (void *)&metrics, false); +if (ret) +return ret; + + *value = metrics.AverageGfxActivity; + +return 0 ; +} + +static int smu_v11_0_read_sensor (struct smu_context *smu, +enum amd_pp_sensors sensor, +void *data,uint32_t *size) +{ +int ret =0 ; +switch (sensor) { +case AMDGPU_PP_SENSOR_GPU_LOAD : + ret =smu_v11_0_get_current_activity_percent (smu, data); + *size =4 ; +break ; +default : + ret = -EINVAL ; +break ; + } + +if (ret) + *size =0 ; + +return ret; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -1022,6 +1061,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_current_clk_freq = smu_v11_0_get_current_clk_freq, .init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks, .start_thermal_control = smu_v11_0_start_thermal_control, + .read_sensor = smu_v11_0_read_sensor, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 80/138 drm/amd/powerplay: implement sysfs of pp_table for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add pp_table sysfs interface for new sw-smu.
get: return pptable raw data
set: write pptable raw data to pptable, then reset smu (hw_fini -> hw_init)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 14 ++++- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 73 ++++++++++++++++++++++++-- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 6 ++- 4 files changed, 89 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +12 -2
@@ -464,7 +464,12 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,char *table =NULL ;int size; -if (adev->powerplay.pp_funcs->get_pp_table) +if (is_support_sw_smu (adev)) { + size =smu_sys_get_pp_table (&adev->smu, (void **)&table); +if (size <0 ) +return size; + } +else if (adev->powerplay.pp_funcs->get_pp_table) size =amdgpu_dpm_get_pp_table (adev, &table);else return 0 ;
@@ -484,8 +489,13 @@ static ssize_t amdgpu_set_pp_table(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; +int ret =0 ; -if (adev->powerplay.pp_funcs->set_pp_table) +if (is_support_sw_smu (adev)) { + ret =smu_sys_set_pp_table (&adev->smu, (void *)buf, count); +if (ret) +return ret; + }else if (adev->powerplay.pp_funcs->set_pp_table)amdgpu_dpm_set_pp_table (adev, buf, count);return count;
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +69 -4
97 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -158,6 +158,7 @@ struct smu_table_context {void *power_play_table;uint32_t power_play_table_size; +void *hardcode_pptable;void *max_sustainable_clocks;struct smu_bios_boot_up_values boot_values;
@@ -371,5 +372,8 @@ extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, boint smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu);bool is_support_sw_smu (struct amdgpu_device *adev); +int smu_reset (struct smu_context *smu); +int smu_sys_get_pp_table (struct smu_context *smu,void **table); +int smu_sys_set_pp_table (struct smu_context *smu,void *buf,size_t size);#endif
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +4 -2
@@ -241,8 +241,10 @@ static int smu_v11_0_read_pptable_from_vbios(struct smu_context *smu)if (ret)return ret; - smu->smu_table.power_play_table = table; - smu->smu_table.power_play_table_size = size; +if (!smu->smu_table.power_play_table) + smu->smu_table.power_play_table = table; +if (!smu->smu_table.power_play_table_size) + smu->smu_table.power_play_table_size = size;return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 81/138 drm/amd/powerplay: upload dpm level for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to support gfx_clk and mem_clk upload min and max dpm level for smu11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 72 ++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +72 -0
@@ -633,6 +633,78 @@ static int vega20_print_clk_levels(struct smu_context *smu,return size; } +static int vega20_upload_dpm_min_level (struct smu_context *smu) +{ +struct vega20_dpm_table *dpm_table; +struct vega20_single_dpm_table *single_dpm_table; +uint32_t min_freq; +int ret =0 ; + + dpm_table = smu->smu_dpm.dpm_context; + +if (smu_feature_is_enabled (smu,FEATURE_DPM_GFXCLK_BIT )) { + single_dpm_table = &(dpm_table->gfx_table); + min_freq = single_dpm_table->dpm_state.soft_min_level; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetSoftMinByFreq, + (PPCLK_GFXCLK <<16 ) | (min_freq &0xffff )); +if (ret) { +pr_err ("Failed to set soft min gfxclk !\n" ); +return ret; + } + } + +if (smu_feature_is_enabled (smu,FEATURE_DPM_UCLK_BIT )) { + single_dpm_table = &(dpm_table->mem_table); + min_freq = single_dpm_table->dpm_state.soft_min_level; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetSoftMinByFreq, + (PPCLK_UCLK <<16 ) | (min_freq &0xffff )); +if (ret) { +pr_err ("Failed to set soft min memclk !\n" ); +return ret; + } + } + +return ret; +} + +static int vega20_upload_dpm_max_level (struct smu_context *smu) +{ +struct vega20_dpm_table *dpm_table; +struct vega20_single_dpm_table *single_dpm_table; +uint32_t max_freq; +int ret =0 ; + + dpm_table = smu->smu_dpm.dpm_context; + +if (smu_feature_is_enabled (smu,FEATURE_DPM_GFXCLK_BIT )) { + single_dpm_table = &(dpm_table->gfx_table); + max_freq = single_dpm_table->dpm_state.soft_max_level; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetSoftMaxByFreq, + (PPCLK_GFXCLK <<16 ) | (max_freq &0xffff )); +if (ret) { +pr_err ("Failed to set soft max gfxclk !\n" ); +return ret; + } + } + +if (smu_feature_is_enabled (smu,FEATURE_DPM_UCLK_BIT )) { + single_dpm_table = &(dpm_table->mem_table); + max_freq = single_dpm_table->dpm_state.soft_max_level; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetSoftMaxByFreq, + (PPCLK_UCLK <<16 ) | (max_freq &0xffff )); +if (ret) { +pr_err ("Failed to set soft max memclk !\n" ); +return ret; + } + } + +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 82/138 drm/amd/powerplay: force clock levels for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to set sclk or mclk level for smu11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 8 ++- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 78 ++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -2
@@ -801,7 +801,9 @@ static ssize_t amdgpu_set_pp_dpm_sclk(struct device *dev,if (ret)return ret; -if (adev->powerplay.pp_funcs->force_clock_level) +if (is_support_sw_smu (adev)) + ret =smu_force_clk_levels (&adev->smu,PP_SCLK , mask); +else if (adev->powerplay.pp_funcs->force_clock_level) ret =amdgpu_dpm_force_clock_level (adev,PP_SCLK , mask);if (ret)
@@ -839,7 +841,9 @@ static ssize_t amdgpu_set_pp_dpm_mclk(struct device *dev,if (ret)return ret; -if (adev->powerplay.pp_funcs->force_clock_level) +if (is_support_sw_smu (adev)) + ret =smu_force_clk_levels (&adev->smu,PP_MCLK , mask); +else if (adev->powerplay.pp_funcs->force_clock_level) ret =amdgpu_dpm_force_clock_level (adev,PP_MCLK , mask);if (ret)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -222,6 +222,7 @@ struct pptable_funcs {int (*set_default_dpm_table)(struct smu_context *smu);int (*populate_umd_state_clk)(struct smu_context *smu);int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf); +int (*force_clk_levels)(struct smu_context *smu,enum pp_clock_type type,uint32_t mask); };struct smu_funcs
@@ -344,6 +345,8 @@ struct smu_funcs ((smu)->funcs->get_current_clk_freq? (smu)->funcs->get_current_clk_freq((smu), (clk_id), (value)) : 0)#define smu_print_clk_levels (smu, type, buf) \ ((smu)->ppt_funcs->print_clk_levels ? (smu)->ppt_funcs->print_clk_levels((smu), (type), (buf)) : 0) +#define smu_force_clk_levels (smu, type, level) \ + ((smu)->ppt_funcs->force_clk_levels ? (smu)->ppt_funcs->force_clk_levels((smu), (type), (level)) : 0)#define smu_start_thermal_control (smu) \ ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_read_sensor (smu, sensor, data, size) \
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +78 -0
90 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 83/138 drm/amd/powerplay: implement sensor of SCLK and MCLK for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add sensor interface of SCLK and MCKL for sys interface and hwmon.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +8 -0
@@ -1020,6 +1020,14 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ret =smu_v11_0_get_current_activity_percent (smu, data); *size =4 ;break ; +case AMDGPU_PP_SENSOR_GFX_MCLK : + ret =smu_get_current_clk_freq (smu,PPCLK_UCLK , (uint32_t *)data); + *size =4 ; +break ; +case AMDGPU_PP_SENSOR_GFX_SCLK : + ret =smu_get_current_clk_freq (smu,PPCLK_GFXCLK , (uint32_t *)data); + *size =4 ; +break ;default : ret = -EINVAL ;break ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 84/138 drm/amd/powerplay: implement sensor of thermal_get_temperature for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add sensor interface of thermal temperature for debugfs and hwmon.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 26 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 1 + drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 1 - 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +26 -0
@@ -45,6 +45,8 @@ MODULE_FIRMWARE("amdgpu/vega20_smc.bin");#define SMU11_THERMAL_MINIMUM_ALERT_TEMP 0#define SMU11_THERMAL_MAXIMUM_ALERT_TEMP 255 +#define SMU11_TEMPERATURE_UNITS_PER_CENTIGRADES 1000 +static int smu_v11_0_send_msg_without_waiting (struct smu_context *smu,uint16_t msg) {
@@ -1010,6 +1012,26 @@ static int smu_v11_0_get_current_activity_percent(struct smu_context *smu,return 0 ; } +static int smu_v11_0_thermal_get_temperature (struct smu_context *smu,uint32_t *value) +{ +struct amdgpu_device *adev = smu->adev; +uint32_t temp =0 ; + +if (!value) +return -EINVAL ; + + temp =RREG32_SOC15 (THM ,0 , mmCG_MULT_THERMAL_STATUS); + temp = (temp &CG_MULT_THERMAL_STATUS__CTF_TEMP_MASK ) >> +CG_MULT_THERMAL_STATUS__CTF_TEMP__SHIFT ; + + temp = temp &0x1ff ; + temp *=SMU11_TEMPERATURE_UNITS_PER_CENTIGRADES ; + + *value = temp; + +return 0 ; +} +static int smu_v11_0_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size)
@@ -1028,6 +1050,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ret =smu_get_current_clk_freq (smu,PPCLK_GFXCLK , (uint32_t *)data); *size =4 ;break ; +case AMDGPU_PP_SENSOR_GPU_TEMP : + ret =smu_v11_0_thermal_get_temperature (smu, (uint32_t *)data); + *size =4 ; +break ;default : ret = -EINVAL ;break ;
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +1 -0
@@ -794,6 +794,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { .populate_umd_state_clk = vega20_populate_umd_state_clk, .print_clk_levels = vega20_print_clk_levels, .force_clk_levels = vega20_force_clk_levels, + };void vega20_set_ppt_funcs (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +0 -1
@@ -28,7 +28,6 @@#define MAX_REGULAR_DPM_NUMBER 16#define MAX_PCIE_CONF 2 -struct vega20_dpm_level {bool enabled;uint32_t value;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 85/138 drm/amd/powerplay: implement sensor of get_gpu_power for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add sensor interface of get gpu power for debugfs and hwmon.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +21 -0
@@ -1032,6 +1032,23 @@ static int smu_v11_0_thermal_get_temperature(struct smu_context *smu, uint32_t *return 0 ; } +static int smu_v11_0_get_gpu_power (struct smu_context *smu,uint32_t *value) +{ +int ret =0 ; +SmuMetrics_t metrics; + +if (!value) +return -EINVAL ; + + ret =smu_update_table (smu,TABLE_SMU_METRICS , (void *)&metrics, false); +if (ret) +return ret; + + *value = metrics.CurrSocketPower <<8 ; + +return 0 ; +} +static int smu_v11_0_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size)
@@ -1054,6 +1071,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ret =smu_v11_0_thermal_get_temperature (smu, (uint32_t *)data); *size =4 ;break ; +case AMDGPU_PP_SENSOR_GPU_POWER : + ret =smu_v11_0_get_gpu_power (smu, (uint32_t *)data); + *size =4 ; +break ;default : ret = -EINVAL ;break ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 86/138 drm/amd/powerplay: implement sensor of get_gfx_vdd for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add sensor interface of gfx vdd for hwmon
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 31 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 1 + 2 files changed, 32 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +31 -0
@@ -38,6 +38,8 @@#include "asic_reg/mp/mp_9_0_offset.h" #include "asic_reg/mp/mp_9_0_sh_mask.h" #include "asic_reg/nbio/nbio_7_4_offset.h" +#include "asic_reg/smuio/smuio_9_0_offset.h" +#include "asic_reg/smuio/smuio_9_0_sh_mask.h" MODULE_FIRMWARE ("amdgpu/vega20_smc.bin" );
@@ -46,6 +48,7 @@ MODULE_FIRMWARE("amdgpu/vega20_smc.bin");#define SMU11_THERMAL_MAXIMUM_ALERT_TEMP 255#define SMU11_TEMPERATURE_UNITS_PER_CENTIGRADES 1000 +#define SMU11_VOLTAGE_SCALE 4static int smu_v11_0_send_msg_without_waiting (struct smu_context *smu,uint16_t msg)
@@ -1049,6 +1052,30 @@ static int smu_v11_0_get_gpu_power(struct smu_context *smu, uint32_t *value)return 0 ; } +static uint16_t convert_to_vddc (uint8_t vid) +{ +return (uint16_t ) ((6200 - (vid *25 )) /SMU11_VOLTAGE_SCALE ); +} + +static int smu_v11_0_get_gfx_vdd (struct smu_context *smu,uint32_t *value) +{ +struct amdgpu_device *adev = smu->adev; +uint32_t vdd =0 , val_vid =0 ; + +if (!value) +return -EINVAL ; + val_vid = (RREG32_SOC15 (SMUIO ,0 , mmSMUSVI0_TEL_PLANE0) & +SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR_MASK ) >> +SMUSVI0_TEL_PLANE0__SVI0_PLANE0_VDDCOR__SHIFT ; + + vdd = (uint32_t )convert_to_vddc ((uint8_t )val_vid); + + *value = vdd; + +return 0 ; + +} +static int smu_v11_0_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size)
@@ -1075,6 +1102,10 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ret =smu_v11_0_get_gpu_power (smu, (uint32_t *)data); *size =4 ;break ; +case AMDGPU_PP_SENSOR_VDDGFX : + ret =smu_v11_0_get_gfx_vdd (smu, (uint32_t *)data); + *size =4 ; +break ;default : ret = -EINVAL ;break ;
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +1 -0
@@ -28,6 +28,7 @@#define MAX_REGULAR_DPM_NUMBER 16#define MAX_PCIE_CONF 2 +struct vega20_dpm_level {bool enabled;uint32_t value;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 87/138 drm/amd/powerplay: implement sensor of get feature mask
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add sensor interface of feature mask for debugfs.
this interface is not ip related function, so need move high level file to implement (amdgpu_smu)
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 21 +++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +21 -0
@@ -29,6 +29,27 @@#include "smu_v11_0.h" #include "atom.h" +int smu_common_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor, +void *data,uint32_t *size) +{ +int ret =0 ; + +switch (sensor) { +case AMDGPU_PP_SENSOR_ENABLED_SMC_FEATURES_MASK : + ret =smu_feature_get_enabled_mask (smu, (uint32_t *)data,2 ); + *size =8 ; +break ; +default : + ret = -EINVAL ; +break ; + } + +if (ret) + *size =0 ; + +return ret; +} +int smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu) {struct smu_table_context *smu_table = &smu->smu_table;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -0
@@ -376,6 +376,8 @@ extern int smu_feature_set_supported(struct smu_context *smu, int feature_id, boint smu_update_table (struct smu_context *smu,uint32_t table_id,void *table_data,bool drv2smu);bool is_support_sw_smu (struct amdgpu_device *adev);int smu_reset (struct smu_context *smu); +int smu_common_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor, +void *data,uint32_t *size);int smu_sys_get_pp_table (struct smu_context *smu,void **table);int smu_sys_set_pp_table (struct smu_context *smu,void *buf,size_t size);
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -1
@@ -1107,7 +1107,7 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, *size =4 ;break ;default : - ret = -EINVAL ; + ret =smu_common_read_sensor (smu, sensor, data, size);break ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 88/138 drm/amd/powerplay: implement sysfs of get num states function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add function smu_get_power_num_state function for sw-smu.
it's only for sysfs interface, the power state feature is not ready for sw-smu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 7 ++++++- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 12 ++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + 3 files changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -1
@@ -350,10 +350,15 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private;struct pp_states_info data; -int i, buf_len; +int i, buf_len, ret;if (adev->powerplay.pp_funcs->get_pp_num_states)amdgpu_dpm_get_pp_num_states (adev, &data); +else if (is_support_sw_smu (adev)) { + ret =smu_get_power_num_states (&adev->smu, &data); +if (ret) +return ret; + } buf_len =snprintf (buf,PAGE_SIZE ,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +12 -0
@@ -29,6 +29,18 @@#include "smu_v11_0.h" #include "atom.h" +int smu_get_power_num_states (struct smu_context *smu,struct pp_states_info *state_info) +{ +if (!state_info) +return -EINVAL ; + +/* not support power state */ +memset (state_info,0 ,sizeof (struct pp_states_info )); + state_info->nums =0 ; + +return 0 ; +} +int smu_common_read_sensor (struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size) {
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -380,5 +380,6 @@ int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor, void *data, uint32_t *size);int smu_sys_get_pp_table (struct smu_context *smu,void **table);int smu_sys_set_pp_table (struct smu_context *smu,void *buf,size_t size); +int smu_get_power_num_states (struct smu_context *smu,struct pp_states_info *state_info);#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 89/138 drm/amd/powerplay: implement sysfs of pp_cur_state function
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add function of smu_get_currente_state for sw-smu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 22 ++++++++++++++-------- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + 3 files changed, 21 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +14 -8
@@ -378,23 +378,29 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private;struct pp_states_info data; +struct smu_context *smu = &adev->smu;enum amd_pm_state_type pm =0 ; -int i =0 ; +int i =0 , ret =0 ;if (adev->powerplay.pp_funcs->get_current_power_state && adev->powerplay.pp_funcs->get_pp_num_states) { pm =amdgpu_dpm_get_current_power_state (adev);amdgpu_dpm_get_pp_num_states (adev, &data); + }else if (is_support_sw_smu (adev)) { + pm =smu_get_current_power_state (smu); + ret =smu_get_power_num_states (smu, &data); +if (ret); +return ret; + } -for (i =0 ; i < data.nums; i++) { -if (pm == data.states[i]) -break ; - } - -if (i == data.nums) - i = -EINVAL ; +for (i =0 ; i < data.nums; i++) { +if (pm == data.states[i]) +break ; } +if (i == data.nums) + i = -EINVAL ; +return snprintf (buf,PAGE_SIZE ,"%d\n" , i); }
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +6 -0
@@ -29,6 +29,12 @@#include "smu_v11_0.h" #include "atom.h" +enum amd_pm_state_type smu_get_current_power_state (struct smu_context *smu) +{ +/* not support power state */ +return POWER_STATE_TYPE_DEFAULT ; +} +int smu_get_power_num_states (struct smu_context *smu,struct pp_states_info *state_info) {if (!state_info)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -381,5 +381,6 @@ int smu_common_read_sensor(struct smu_context *smu, enum amd_pp_sensors sensor,int smu_sys_get_pp_table (struct smu_context *smu,void **table);int smu_sys_set_pp_table (struct smu_context *smu,void *buf,size_t size);int smu_get_power_num_states (struct smu_context *smu,struct pp_states_info *state_info); +enum amd_pm_state_type smu_get_current_power_state (struct smu_context *smu);#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 90/138 drm/amd/powerplay: implement sysfs of pp_force_state for sw-smu
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
the SMU v11 doesn’t support pp_force_state so far, so we didn’t implement it.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +2 -0
@@ -450,6 +450,8 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, AMD_PP_TASK_ENABLE_USER_STATE, &state); adev->pp_force_state_enabled = true; } + }else if (is_support_sw_smu (adev)) { + adev->pp_force_state_enabled = false; } fail:return count;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 91/138 drm/amd/powerplay: add the function to set deep sleep dcefclk
In reply to a message not in the archiveThis patch adds the function to set deep sleep dcefclk. It will be used on display part.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -263,6 +263,7 @@ struct smu_funcsint (*start_thermal_control)(struct smu_context *smu);int (*read_sensor)(struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size); +int (*set_deep_sleep_dcefclk)(struct smu_context *smu,uint32_t clk); };#define smu_init_microcode (smu) \
@@ -358,6 +359,8 @@ struct smu_funcs ((smu)->ppt_funcs? ((smu)->ppt_funcs->run_afll_btc? (smu)->ppt_funcs->run_afll_btc((smu)) : 0) : 0)#define smu_get_unallowed_feature_mask (smu, feature_mask, num) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_unallowed_feature_mask? (smu)->ppt_funcs->get_unallowed_feature_mask((smu), (feature_mask), (num)) : 0) : 0) +#define smu_set_deep_sleep_dcefclk (smu, clk) \ + ((smu)->funcs->set_deep_sleep_dcefclk ? (smu)->funcs->set_deep_sleep_dcefclk((smu), (clk)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +14 -7
@@ -601,21 +601,27 @@ static int smu_v11_0_write_pptable(struct smu_context *smu)return ret; } +static int smu_v11_0_set_deep_sleep_dcefclk (struct smu_context *smu,uint32_t clk) +{ +int ret; + + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetMinDeepSleepDcefclk, clk); +if (ret) +pr_err ("SMU11 attempt to set divider for DCEFCLK Failed!" ); + +return ret; +} +static int smu_v11_0_set_min_dcef_deep_sleep (struct smu_context *smu) { -int ret =0 ;struct smu_table_context *table_context = &smu->smu_table;if (!table_context)return -EINVAL ; - ret =smu_send_smc_msg_with_param (smu, - SMU_MSG_SetMinDeepSleepDcefclk, +return smu_set_deep_sleep_dcefclk (smu, table_context->boot_values.dcefclk /100 ); -if (ret) -pr_err ("SMU11 attempt to set divider for DCEFCLK Failed!" ); - -return ret; }static int smu_v11_0_set_tool_table_location (struct smu_context *smu)
@@ -1150,6 +1156,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks, .start_thermal_control = smu_v11_0_start_thermal_control, .read_sensor = smu_v11_0_read_sensor, + .set_deep_sleep_dcefclk = smu_v11_0_set_deep_sleep_dcefclk, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 92/138 drm/amd/powerplay: add two interfaces to set_active_display_count and store_cc6_data
In reply to a message not in the archiveThis patch adds two interfaces to set_active_display_count and store_cc6_data, they won't be used for smu11, and just be the placeholders for future asic on display to smu interface.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +8 -0
@@ -264,6 +264,10 @@ struct smu_funcsint (*read_sensor)(struct smu_context *smu,enum amd_pp_sensors sensor,void *data,uint32_t *size);int (*set_deep_sleep_dcefclk)(struct smu_context *smu,uint32_t clk); +int (*set_active_display_count)(struct smu_context *smu,uint32_t count); +int (*store_cc6_data)(struct smu_context *smu,uint32_t separation_time, +bool cc6_disable,bool pstate_disable, +bool pstate_switch_disable); };#define smu_init_microcode (smu) \
@@ -361,6 +365,10 @@ struct smu_funcs ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_unallowed_feature_mask? (smu)->ppt_funcs->get_unallowed_feature_mask((smu), (feature_mask), (num)) : 0) : 0)#define smu_set_deep_sleep_dcefclk (smu, clk) \ ((smu)->funcs->set_deep_sleep_dcefclk ? (smu)->funcs->set_deep_sleep_dcefclk((smu), (clk)) : 0) +#define smu_set_active_display_count (smu, count) \ + ((smu)->funcs->set_active_display_count ? (smu)->funcs->set_active_display_count((smu), (count)) : 0) +#define smu_store_cc6_data (smu, st, cc6_dis, pst_dis, pst_sw_dis) \ + ((smu)->funcs->store_cc6_data ? (smu)->funcs->store_cc6_data((smu), (st), (cc6_dis), (pst_dis), (pst_sw_dis)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 93/138 drm/amd/powerplay: add smu display configuration change function
In reply to a message not in the archiveThis patch adds display configuration change function that creates the new path with sw smu driver instead of powerplay.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 5 ++++ drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 34 ++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++++ 3 files changed, 45 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +5 -0
@@ -33,6 +33,7 @@#include "amdgpu_dm_irq.h" #include "amdgpu_pm.h" #include "dm_pp_smu.h" +#include "amdgpu_smu.h" bool dm_pp_apply_display_requirements(
@@ -40,6 +41,7 @@ bool dm_pp_apply_display_requirements( const struct dm_pp_display_configuration *pp_display_cfg) {struct amdgpu_device *adev = ctx->driver_context; +struct smu_context *smu = &adev->smu;int i;if (adev->pm.dpm_enabled) {
@@ -105,6 +107,9 @@ bool dm_pp_apply_display_requirements( adev->powerplay.pp_funcs->display_configuration_change ( adev->powerplay.pp_handle, &adev->pm.pm_display_cfg); + else + smu_display_configuration_change(smu, + &adev->pm.pm_display_cfg);amdgpu_pm_compute_clocks (adev); }
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +34 -0
@@ -773,6 +773,40 @@ static int smu_resume(void *handle)return ret; } +int smu_display_configuration_change (struct smu_context *smu, +const struct amd_pp_display_configuration *display_config) +{ +int index =0 ; +int num_of_active_display =0 ; + +if (!is_support_sw_smu (smu->adev)) +return -EINVAL ; + +if (!display_config) +return -EINVAL ; + +mutex_lock (&smu->mutex); + +smu_set_deep_sleep_dcefclk (smu, + display_config->min_dcef_deep_sleep_set_clk /100 ); + +for (index =0 ; index < display_config->num_path_including_non_display; index++) { +if (display_config->displays[index].controller_id !=0 ) + num_of_active_display++; + } + +smu_set_active_display_count (smu, num_of_active_display); + +smu_store_cc6_data (smu, display_config->cpu_pstate_separation_time, + display_config->cpu_cc6_disable, + display_config->cpu_pstate_disable, + display_config->nb_pstate_switch_disable); + +mutex_unlock (&smu->mutex); + +return 0 ; +} +static int smu_set_clockgating_state (void *handle,enum amd_clockgating_state state) {
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -0
@@ -24,6 +24,7 @@#include "amdgpu.h" #include "kgd_pp_interface.h" +#include "dm_pp_interface.h" enum smu_message_type {
@@ -394,4 +395,9 @@ int smu_sys_set_pp_table(struct smu_context *smu, void *buf, size_t size);int smu_get_power_num_states (struct smu_context *smu,struct pp_states_info *state_info);enum amd_pm_state_type smu_get_current_power_state (struct smu_context *smu); +/* smu to display interface */ +extern int smu_display_configuration_change (struct smu_context *smu,const +struct amd_pp_display_configuration + *display_config); +#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 94/138 drm/amd/powerplay: add get_clock_by_type interface for display
In reply to a message not in the archiveThis patch adds get_clock_by_type interface for display, in smu v11 didn't have the implementation.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 6 ++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 +++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +6 -0
@@ -313,6 +313,12 @@ bool dm_pp_get_clock_levels_by_type(if (adev->powerplay.pp_funcs->get_clock_by_type (pp_handle,dc_to_pp_clock_type (clk_type), &pp_clks)) {/* Error in pplib. Provide default values. */ +return true; + } + }else if (adev->smu.funcs && adev->smu.funcs->get_clock_by_type) { +if (smu_get_clock_by_type (&adev->smu, +dc_to_pp_clock_type (clk_type), + &pp_clks)) {get_default_clock_levels (clk_type, dc_clks);return true; }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -269,6 +269,9 @@ struct smu_funcsint (*store_cc6_data)(struct smu_context *smu,uint32_t separation_time,bool cc6_disable,bool pstate_disable,bool pstate_switch_disable); +int (*get_clock_by_type)(struct smu_context *smu, +enum amd_pp_clock_type type, +struct amd_pp_clocks *clocks); };#define smu_init_microcode (smu) \
@@ -370,6 +373,8 @@ struct smu_funcs ((smu)->funcs->set_active_display_count ? (smu)->funcs->set_active_display_count((smu), (count)) : 0)#define smu_store_cc6_data (smu, st, cc6_dis, pst_dis, pst_sw_dis) \ ((smu)->funcs->store_cc6_data ? (smu)->funcs->store_cc6_data((smu), (st), (cc6_dis), (pst_dis), (pst_sw_dis)) : 0) +#define smu_get_clock_by_type (smu, type, clocks) \ + ((smu)->funcs->get_clock_by_type ? (smu)->funcs->get_clock_by_type((smu), (type), (clocks)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 95/138 drm/amd/powerplay: add interface to get max high clocks for display
In reply to a message not in the archiveThis patch adds interface to get max high clocks for display and in smu v11 didn't have this implementation.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 7 +++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +7 -0
@@ -335,6 +335,13 @@ bool dm_pp_get_clock_levels_by_type( validation_clks.memory_max_clock =80000 ; validation_clks.level =0 ; } + }else if (adev->smu.funcs && adev->smu.funcs->get_max_high_clocks) { +if (smu_get_max_high_clocks (&adev->smu, &validation_clks)) { +DRM_INFO ("DM_PPLIB: Warning: using default validation clocks!\n" ); + validation_clks.engine_max_clock =72000 ; + validation_clks.memory_max_clock =80000 ; + validation_clks.level =0 ; + } }DRM_INFO ("DM_PPLIB: Validation clocks:\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -272,6 +272,8 @@ struct smu_funcsint (*get_clock_by_type)(struct smu_context *smu,enum amd_pp_clock_type type,struct amd_pp_clocks *clocks); +int (*get_max_high_clocks)(struct smu_context *smu, +struct amd_pp_simple_clock_info *clocks); };#define smu_init_microcode (smu) \
@@ -375,6 +377,8 @@ struct smu_funcs ((smu)->funcs->store_cc6_data ? (smu)->funcs->store_cc6_data((smu), (st), (cc6_dis), (pst_dis), (pst_sw_dis)) : 0)#define smu_get_clock_by_type (smu, type, clocks) \ ((smu)->funcs->get_clock_by_type ? (smu)->funcs->get_clock_by_type((smu), (type), (clocks)) : 0) +#define smu_get_max_high_clocks (smu, clocks) \ + ((smu)->funcs->get_max_high_clocks ? (smu)->funcs->get_max_high_clocks((smu), (clocks)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 96/138 drm/amd/powerplay: add interface to get clock by type with latency for display (v2)
In reply to a message not in the archiveThis patch adds get clock by type with latency, display will use it to get current clocks with latency.
v2: fix the missed mutex lock before return.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 21 ++++++++---- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 8 +++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 40 +++++++++++++++++++++- 3 files changed, 61 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +14 -7
@@ -392,14 +392,21 @@ bool dm_pp_get_clock_levels_by_type_with_latency(void *pp_handle = adev->powerplay.pp_handle;struct pp_clock_levels_with_latency pp_clks = {0 };const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret; + +if (pp_funcs && pp_funcs->get_clock_by_type_with_latency) { + ret = pp_funcs->get_clock_by_type_with_latency (pp_handle, +dc_to_pp_clock_type (clk_type), + &pp_clks); +if (ret) +return false; + }else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_latency) { +if (smu_get_clock_by_type_with_latency (&adev->smu, +dc_to_pp_clock_type (clk_type), + &pp_clks)) +return false; + } -if (!pp_funcs || !pp_funcs->get_clock_by_type_with_latency) -return false; - -if (pp_funcs->get_clock_by_type_with_latency (pp_handle, -dc_to_pp_clock_type (clk_type), - &pp_clks)) -return false;pp_to_dc_clock_levels_with_latency (&pp_clks, clk_level_info, clk_type);
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +8 -0
@@ -224,6 +224,11 @@ struct pptable_funcs {int (*populate_umd_state_clk)(struct smu_context *smu);int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf);int (*force_clk_levels)(struct smu_context *smu,enum pp_clock_type type,uint32_t mask); +int (*get_clock_by_type_with_latency)(struct smu_context *smu, +enum amd_pp_clock_type type, +struct +pp_clock_levels_with_latency + *clocks); };struct smu_funcs
@@ -379,6 +384,9 @@ struct smu_funcs ((smu)->funcs->get_clock_by_type ? (smu)->funcs->get_clock_by_type((smu), (type), (clocks)) : 0)#define smu_get_max_high_clocks (smu, clocks) \ ((smu)->funcs->get_max_high_clocks ? (smu)->funcs->get_max_high_clocks((smu), (clocks)) : 0) +#define smu_get_clock_by_type_with_latency (smu, type, clocks) \ + ((smu)->ppt_funcs->get_clock_by_type_with_latency ? (smu)->ppt_funcs->get_clock_by_type_with_latency((smu), (type), (clocks)) : 0) + extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table, uint16_t *size, uint8_t *frev, uint8_t *crev,
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +39 -1
@@ -782,6 +782,44 @@ static int vega20_force_clk_levels(struct smu_context *smu,return 0 ; } +static int vega20_get_clock_by_type_with_latency (struct smu_context *smu, +enum amd_pp_clock_type type, +struct pp_clock_levels_with_latency *clocks) +{ +int ret; +struct vega20_single_dpm_table *single_dpm_table; +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; +struct vega20_dpm_table *dpm_table =NULL ; + + dpm_table = smu_dpm->dpm_context; + +mutex_lock (&smu->mutex); + +switch (type) { +case amd_pp_sys_clock: + single_dpm_table = &(dpm_table->gfx_table); + ret =vega20_get_clk_table (smu, clocks, single_dpm_table); +break ; +case amd_pp_mem_clock: + single_dpm_table = &(dpm_table->mem_table); + ret =vega20_get_clk_table (smu, clocks, single_dpm_table); +break ; +case amd_pp_dcef_clock: + single_dpm_table = &(dpm_table->dcef_table); + ret =vega20_get_clk_table (smu, clocks, single_dpm_table); +break ; +case amd_pp_soc_clock: + single_dpm_table = &(dpm_table->soc_table); + ret =vega20_get_clk_table (smu, clocks, single_dpm_table); +break ; +default : + ret = -EINVAL ; + } + +mutex_unlock (&smu->mutex); +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
@@ -794,7 +832,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { .populate_umd_state_clk = vega20_populate_umd_state_clk, .print_clk_levels = vega20_print_clk_levels, .force_clk_levels = vega20_force_clk_levels, - + .get_clock_by_type_with_latency = vega20_get_clock_by_type_with_latency, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 97/138 drm/amd/powerplay: add interface to get clock by type with voltage for display
In reply to a message not in the archiveThis patch adds inteface to get clock by type with voltage, display will use it to get current clocks with voltage.
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 20 +++++++++++++------- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 7 +++++++ 2 files changed, 20 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +13 -7
@@ -422,14 +422,20 @@ bool dm_pp_get_clock_levels_by_type_with_voltage(void *pp_handle = adev->powerplay.pp_handle;struct pp_clock_levels_with_voltage pp_clk_info = {0 };const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +int ret; -if (!pp_funcs || !pp_funcs->get_clock_by_type_with_voltage) -return false; - -if (pp_funcs->get_clock_by_type_with_voltage (pp_handle, -dc_to_pp_clock_type (clk_type), - &pp_clk_info)) -return false; +if (pp_funcs && pp_funcs->get_clock_by_type_with_voltage) { + ret = pp_funcs->get_clock_by_type_with_voltage (pp_handle, +dc_to_pp_clock_type (clk_type), + &pp_clk_info); +if (ret) +return false; + }else if (adev->smu.ppt_funcs && adev->smu.ppt_funcs->get_clock_by_type_with_voltage) { +if (smu_get_clock_by_type_with_voltage (&adev->smu, +dc_to_pp_clock_type (clk_type), + &pp_clk_info)) +return false; + }pp_to_dc_clock_levels_with_voltage (&pp_clk_info, clk_level_info, clk_type);
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +7 -0
@@ -229,6 +229,11 @@ struct pptable_funcs {struct pp_clock_levels_with_latency *clocks); +int (*get_clock_by_type_with_voltage)(struct smu_context *smu, +enum amd_pp_clock_type type, +struct +pp_clock_levels_with_voltage + *clocks); };struct smu_funcs
@@ -386,6 +391,8 @@ struct smu_funcs ((smu)->funcs->get_max_high_clocks ? (smu)->funcs->get_max_high_clocks((smu), (clocks)) : 0)#define smu_get_clock_by_type_with_latency (smu, type, clocks) \ ((smu)->ppt_funcs->get_clock_by_type_with_latency ? (smu)->ppt_funcs->get_clock_by_type_with_latency((smu), (type), (clocks)) : 0) +#define smu_get_clock_by_type_with_voltage (smu, type, clocks) \ + ((smu)->ppt_funcs->get_clock_by_type_with_voltage ? (smu)->ppt_funcs->get_clock_by_type_with_voltage((smu), (type), (clocks)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 98/138 drm/amd/powerplay: add interface to request display clock voltage
In reply to a message not in the archiveThis patch adds interface to request display clock voltage, display will use it to request current display clock voltage.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 17 ++++++--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 44 ++++++++++++++++++++++ 3 files changed, 61 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +12 -5
@@ -476,6 +476,10 @@ bool dm_pp_apply_clock_for_voltage_request( ret = adev->powerplay.pp_funcs->display_clock_voltage_request ( adev->powerplay.pp_handle, &pp_clock_request); + else if (adev->smu.funcs && + adev->smu.funcs->display_clock_voltage_request) + ret =smu_display_clock_voltage_request (&adev->smu, + &pp_clock_request);if (ret)return false;return true;
@@ -512,16 +516,19 @@ void pp_rv_set_display_requirement(struct pp_smu *pp,const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;struct pp_display_clock_request clock = {0 }; -if (!pp_funcs || !pp_funcs->display_clock_voltage_request) -return ; - clock.clock_type = amd_pp_dcf_clock; clock.clock_freq_in_khz = req->hard_min_dcefclk_mhz *1000 ; - pp_funcs->display_clock_voltage_request (pp_handle, &clock); +if (pp_funcs && pp_funcs->display_clock_voltage_request) + pp_funcs->display_clock_voltage_request (pp_handle, &clock); +else if (adev->smu.funcs && adev->smu.funcs->display_clock_voltage_request) +smu_display_clock_voltage_request (&adev->smu, &clock); clock.clock_type = amd_pp_f_clock; clock.clock_freq_in_khz = req->hard_min_fclk_mhz *1000 ; - pp_funcs->display_clock_voltage_request (pp_handle, &clock); +if (pp_funcs && pp_funcs->display_clock_voltage_request) + pp_funcs->display_clock_voltage_request (pp_handle, &clock); +else if (adev->smu.funcs && adev->smu.funcs->display_clock_voltage_request) +smu_display_clock_voltage_request (&adev->smu, &clock); } void pp_rv_set_wm_ranges(struct pp_smu *pp,
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -284,6 +284,9 @@ struct smu_funcs struct amd_pp_clocks *clocks);int (*get_max_high_clocks)(struct smu_context *smu,struct amd_pp_simple_clock_info *clocks); +int (*display_clock_voltage_request)(struct smu_context *smu,struct +pp_display_clock_request + *clock_req); };#define smu_init_microcode (smu) \
@@ -393,6 +396,8 @@ struct smu_funcs ((smu)->ppt_funcs->get_clock_by_type_with_latency ? (smu)->ppt_funcs->get_clock_by_type_with_latency((smu), (type), (clocks)) : 0)#define smu_get_clock_by_type_with_voltage (smu, type, clocks) \ ((smu)->ppt_funcs->get_clock_by_type_with_voltage ? (smu)->ppt_funcs->get_clock_by_type_with_voltage((smu), (type), (clocks)) : 0) +#define smu_display_clock_voltage_request (smu, clock_req) \ + ((smu)->funcs->display_clock_voltage_request ? (smu)->funcs->display_clock_voltage_request((smu), (clock_req)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +44 -0
56 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 99/138 drm/amd/powerplay: add interface to get dal power level
In reply to a message not in the archiveThis patch adds interface to get dal power level for display and in smu v11 didn't have this implementation.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -287,6 +287,8 @@ struct smu_funcsint (*display_clock_voltage_request)(struct smu_context *smu,struct pp_display_clock_request *clock_req); +int (*get_dal_power_level)(struct smu_context *smu, +struct amd_pp_simple_clock_info *clocks); };#define smu_init_microcode (smu) \
@@ -398,6 +400,8 @@ struct smu_funcs ((smu)->ppt_funcs->get_clock_by_type_with_voltage ? (smu)->ppt_funcs->get_clock_by_type_with_voltage((smu), (type), (clocks)) : 0)#define smu_display_clock_voltage_request (smu, clock_req) \ ((smu)->funcs->display_clock_voltage_request ? (smu)->funcs->display_clock_voltage_request((smu), (clock_req)) : 0) +#define smu_get_dal_power_level (smu, clocks) \ + ((smu)->funcs->get_dal_power_level ? (smu)->funcs->get_dal_power_level((smu), (clocks)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 100/138 drm/amd/powerplay: add interface to get performance level
In reply to a message not in the archiveThis patch adds interface to get performance level for display and in smu v11 didn't have this implementation.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +19 -0
@@ -140,6 +140,20 @@ struct smu_table {struct amdgpu_bo *bo; }; +enum smu_perf_level_designation { +PERF_LEVEL_ACTIVITY , +PERF_LEVEL_POWER_CONTAINMENT , +}; + +struct smu_performance_level { +uint32_t core_clock; +uint32_t memory_clock; +uint32_t vddc; +uint32_t vddci; +uint32_t non_local_mem_freq; +uint32_t non_local_mem_width; +}; +struct smu_bios_boot_up_values {uint32_t revision;
@@ -289,6 +303,9 @@ struct smu_funcs *clock_req);int (*get_dal_power_level)(struct smu_context *smu,struct amd_pp_simple_clock_info *clocks); +int (*get_perf_level)(struct smu_context *smu, +enum smu_perf_level_designation designation, +struct smu_performance_level *level); };#define smu_init_microcode (smu) \
@@ -402,6 +419,8 @@ struct smu_funcs ((smu)->funcs->display_clock_voltage_request ? (smu)->funcs->display_clock_voltage_request((smu), (clock_req)) : 0)#define smu_get_dal_power_level (smu, clocks) \ ((smu)->funcs->get_dal_power_level ? (smu)->funcs->get_dal_power_level((smu), (clocks)) : 0) +#define smu_get_perf_level (smu, designation, level) \ + ((smu)->funcs->get_perf_level ? (smu)->funcs->get_perf_level((smu), (designation), (level)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 101/138 drm/amd/powerplay: add interface to get current shallow sleep clocks
In reply to a message not in the archiveThis patch adds interface to get current shallow sleep clocks for display and in smu v11 didn't have this implementation.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +13 -0
@@ -154,6 +154,15 @@ struct smu_performance_level {uint32_t non_local_mem_width; }; +struct smu_clock_info { +uint32_t min_mem_clk; +uint32_t max_mem_clk; +uint32_t min_eng_clk; +uint32_t max_eng_clk; +uint32_t min_bus_bandwidth; +uint32_t max_bus_bandwidth; +}; +struct smu_bios_boot_up_values {uint32_t revision;
@@ -306,6 +315,8 @@ struct smu_funcsint (*get_perf_level)(struct smu_context *smu,enum smu_perf_level_designation designation,struct smu_performance_level *level); +int (*get_current_shallow_sleep_clocks)(struct smu_context *smu, +struct smu_clock_info *clocks); };#define smu_init_microcode (smu) \
@@ -421,6 +432,8 @@ struct smu_funcs ((smu)->funcs->get_dal_power_level ? (smu)->funcs->get_dal_power_level((smu), (clocks)) : 0)#define smu_get_perf_level (smu, designation, level) \ ((smu)->funcs->get_perf_level ? (smu)->funcs->get_perf_level((smu), (designation), (level)) : 0) +#define smu_get_current_shallow_sleep_clocks (smu, clocks) \ + ((smu)->funcs->get_current_shallow_sleep_clocks ? (smu)->funcs->get_current_shallow_sleep_clocks((smu), (clocks)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 102/138 drm/amd/powerplay: add interface to get current clocks for display
In reply to a message not in the archiveThis patch fills the amd_pp_clock_info data for display, it will get the current info in that structure.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 2 + drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 78 ++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++ 3 files changed, 84 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +2 -0
@@ -497,6 +497,8 @@ bool dm_pp_get_static_clocks( ret = adev->powerplay.pp_funcs->get_current_clocks ( adev->powerplay.pp_handle, &pp_clk_info); + else if (adev->smu.funcs) + ret =smu_get_current_clocks (&adev->smu, &pp_clk_info);if (ret)return false;
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +78 -0
84 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -233,6 +233,8 @@ struct smu_contextuint32_t power_limit;uint32_t default_power_limit; + +bool support_power_containment; };struct pptable_funcs {
@@ -464,5 +466,7 @@ enum amd_pm_state_type smu_get_current_power_state(struct smu_context *smu);extern int smu_display_configuration_change (struct smu_context *smu,const struct amd_pp_display_configuration *display_config); +extern int smu_get_current_clocks (struct smu_context *smu, +struct amd_pp_clock_info *clocks);#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 103/138 drm/amd/powerplay: add interface to notify smu enable pme restore register
In reply to a message not in the archiveThis patch adds interface to notify smu enable pme restore register for display and in smu v11 didn't have this implementation.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 8 ++++---- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +4 -4
@@ -593,10 +593,10 @@ void pp_rv_set_pme_wa_enable(struct pp_smu *pp)void *pp_handle = adev->powerplay.pp_handle;const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; -if (!pp_funcs || !pp_funcs->notify_smu_enable_pwe) -return ; - - pp_funcs->notify_smu_enable_pwe (pp_handle); +if (pp_funcs && pp_funcs->notify_smu_enable_pwe) + pp_funcs->notify_smu_enable_pwe (pp_handle); +else if (adev->smu.funcs) +smu_notify_smu_enable_pwe (&adev->smu); }void pp_rv_set_active_display_count (struct pp_smu *pp,int count)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -319,6 +319,7 @@ struct smu_funcs struct smu_performance_level *level);int (*get_current_shallow_sleep_clocks)(struct smu_context *smu,struct smu_clock_info *clocks); +int (*notify_smu_enable_pwe)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -436,6 +437,8 @@ struct smu_funcs ((smu)->funcs->get_perf_level ? (smu)->funcs->get_perf_level((smu), (designation), (level)) : 0)#define smu_get_current_shallow_sleep_clocks (smu, clocks) \ ((smu)->funcs->get_current_shallow_sleep_clocks ? (smu)->funcs->get_current_shallow_sleep_clocks((smu), (clocks)) : 0) +#define smu_notify_smu_enable_pwe (smu) \ + ((smu)->funcs->notify_smu_enable_pwe ? (smu)->funcs->notify_smu_enable_pwe((smu)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 104/138 drm/amd/powerplay: implement interface to set watermarks for clock ranges
In reply to a message not in the archiveThis patch implements inteferface to set watermarks table for clock ranges on smu 11. It fills watermark table before it is written to SMC.
--- .../drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c | 11 +-- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 9 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 80 ++++++++++++++++++++++ 4 files changed, 97 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c +7 -4
@@ -548,9 +548,6 @@ void pp_rv_set_wm_ranges(struct pp_smu *pp, wm_with_clock_ranges.num_wm_dmif_sets = ranges->num_reader_wm_sets; wm_with_clock_ranges.num_wm_mcif_sets = ranges->num_writer_wm_sets; -if (!pp_funcs || !pp_funcs->set_watermarks_for_clocks_ranges) -return ; -for (i =0 ; i < wm_with_clock_ranges.num_wm_dmif_sets; i++) {if (ranges->reader_wm_sets[i].wm_inst >3 ) wm_dce_clocks[i].wm_set_id =WM_SET_A ;
@@ -583,7 +580,13 @@ void pp_rv_set_wm_ranges(struct pp_smu *pp, ranges->writer_wm_sets[i].min_drain_clk_mhz *1000 ; } - pp_funcs->set_watermarks_for_clocks_ranges (pp_handle, &wm_with_clock_ranges); +if (pp_funcs && pp_funcs->set_watermarks_for_clocks_ranges) + pp_funcs->set_watermarks_for_clocks_ranges (pp_handle, + &wm_with_clock_ranges); +else if (adev->smu.funcs && + adev->smu.funcs->set_watermarks_for_clock_ranges) +smu_set_watermarks_for_clock_ranges (&adev->smu, + &wm_with_clock_ranges); }void pp_rv_set_pme_wa_enable (struct pp_smu *pp)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
@@ -322,6 +322,7 @@ static int smu_sw_init(void *handle)bitmap_zero (smu->smu_feature.supported,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX ); + smu->watermarks_bitmap =0 ; ret =smu_init_microcode (smu);if (ret) {
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +9 -0
@@ -235,6 +235,11 @@ struct smu_contextuint32_t default_power_limit;bool support_power_containment; +bool disable_watermark; + +#define WATERMARKS_EXIST (1 << 0) +#define WATERMARKS_LOADED (1 << 1) +uint32_t watermarks_bitmap; };struct pptable_funcs {
@@ -320,6 +325,8 @@ struct smu_funcsint (*get_current_shallow_sleep_clocks)(struct smu_context *smu,struct smu_clock_info *clocks);int (*notify_smu_enable_pwe)(struct smu_context *smu); +int (*set_watermarks_for_clock_ranges)(struct smu_context *smu, +struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges); };#define smu_init_microcode (smu) \
@@ -439,6 +446,8 @@ struct smu_funcs ((smu)->funcs->get_current_shallow_sleep_clocks ? (smu)->funcs->get_current_shallow_sleep_clocks((smu), (clocks)) : 0)#define smu_notify_smu_enable_pwe (smu) \ ((smu)->funcs->notify_smu_enable_pwe ? (smu)->funcs->notify_smu_enable_pwe((smu)) : 0) +#define smu_set_watermarks_for_clock_ranges (smu, clock_ranges) \ + ((smu)->funcs->set_watermarks_for_clock_ranges ? (smu)->funcs->set_watermarks_for_clock_ranges((smu), (clock_ranges)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +80 -0
92 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 105/138 drm/amd/powerplay: add function to store overdrive information for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add vega20_setup_od8_information function to store overdrive information from powerplay_table to smu_table which will used when setting od8.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 15 +++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 ++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 86 +++++++++++++++++++++++++- 3 files changed, 104 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +15 -0
@@ -682,6 +682,21 @@ static int smu_hw_fini(void *handle) table_context->max_sustainable_clocks =NULL ; } +if (table_context->od_feature_capabilities) { +kfree (table_context->od_feature_capabilities); + table_context->od_feature_capabilities =NULL ; + } + +if (table_context->od_settings_max) { +kfree (table_context->od_settings_max); + table_context->od_settings_max =NULL ; + } + +if (table_context->od_settings_min) { +kfree (table_context->od_settings_min); + table_context->od_settings_min =NULL ; + } + ret =smu_fini_fb_allocations (smu);if (ret)return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -192,6 +192,10 @@ struct smu_table_contextstruct smu_table memory_pool;uint16_t software_shutdown_temp;uint8_t thermal_controller_type; + +uint8_t *od_feature_capabilities; +uint32_t *od_settings_max; +uint32_t *od_settings_min; };struct smu_dpm_context {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +85 -1
102 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 106/138 drm/amd/powerplay: add function to set default overdrive settings
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function of vega20_set_default_od8_setttings for vega20 with smu11 arch to setup default overdrive value.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 14 ++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 8 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 84 ++++------ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 203 +++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 51 +++++++ 5 files changed, 309 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +14 -0
@@ -526,6 +526,10 @@ static int smu_smc_table_hw_init(struct smu_context *smu)if (ret)return ret; + ret =smu_set_od8_default_settings (smu); +if (ret) +return ret; + ret =smu_populate_umd_state_clk (smu);if (ret)return ret;
@@ -697,6 +701,16 @@ static int smu_hw_fini(void *handle) table_context->od_settings_min =NULL ; } +if (table_context->overdrive_table) { +kfree (table_context->overdrive_table); + table_context->overdrive_table =NULL ; + } + +if (table_context->od8_settings) { +kfree (table_context->od8_settings); + table_context->od8_settings =NULL ; + } + ret =smu_fini_fb_allocations (smu);if (ret)return ret;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +8 -0
@@ -196,6 +196,8 @@ struct smu_table_contextuint8_t *od_feature_capabilities;uint32_t *od_settings_max;uint32_t *od_settings_min; +void *overdrive_table; +void *od8_settings; };struct smu_dpm_context {
@@ -258,6 +260,7 @@ struct pptable_funcs {int (*populate_umd_state_clk)(struct smu_context *smu);int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf);int (*force_clk_levels)(struct smu_context *smu,enum pp_clock_type type,uint32_t mask); +int (*set_default_od8_settings)(struct smu_context *smu); int (*get_clock_by_type_with_latency)(struct smu_context *smu, enum amd_pp_clock_type type, struct
@@ -331,6 +334,7 @@ struct smu_funcsint (*notify_smu_enable_pwe)(struct smu_context *smu);int (*set_watermarks_for_clock_ranges)(struct smu_context *smu,struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges); +int (*set_od8_default_settings)(struct smu_context *smu); };#define smu_init_microcode (smu) \
@@ -377,6 +381,8 @@ struct smu_funcs ((smu)->funcs->system_features_control ? (smu)->funcs->system_features_control((smu), (en)) : 0)#define smu_init_max_sustainable_clocks (smu) \ ((smu)->funcs->init_max_sustainable_clocks ? (smu)->funcs->init_max_sustainable_clocks((smu)) : 0) +#define smu_set_od8_default_settings (smu) \ + ((smu)->funcs->set_od8_default_settings ? (smu)->funcs->set_od8_default_settings((smu)) : 0)#define smu_send_smc_msg (smu, msg) \ ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)#define smu_send_smc_msg_with_param (smu, msg, param) \
@@ -407,6 +413,8 @@ struct smu_funcs ((smu)->ppt_funcs->set_default_dpm_table ? (smu)->ppt_funcs->set_default_dpm_table((smu)) : 0)#define smu_populate_umd_state_clk (smu) \ ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0) +#define smu_set_default_od8_settings (smu) \ + ((smu)->ppt_funcs->set_default_od8_settings ? (smu)->ppt_funcs->set_default_od8_settings((smu)) : 0)#define smu_get_power_limit (smu) \ ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 0)#define smu_get_current_clk_freq (smu, clk_id, value) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +33 -51
106 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +203 -0
215 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +51 -0
63 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 107/138 drm/amd/powerplay: add golden dpm table to backup default DPM table
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Backup default DPM table into golden dpm table.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 11 +++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 ++- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +11 -0
@@ -671,11 +671,22 @@ static int smu_hw_fini(void *handle)struct amdgpu_device *adev = (struct amdgpu_device *)handle;struct smu_context *smu = &adev->smu;struct smu_table_context *table_context = &smu->smu_table; +struct smu_dpm_context *smu_dpm = &smu->smu_dpm;int ret =0 ;if (!is_support_sw_smu (adev))return -EINVAL ; +if (smu_dpm->dpm_context) { +kfree (smu_dpm->dpm_context); + smu_dpm->dpm_context =NULL ; + } + +if (smu_dpm->golden_dpm_context) { +kfree (smu_dpm->golden_dpm_context); + smu_dpm->golden_dpm_context =NULL ; + } +if (table_context->driver_pptable) {kfree (table_context->driver_pptable); table_context->driver_pptable =NULL ;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +2 -1
@@ -201,8 +201,9 @@ struct smu_table_context };struct smu_dpm_context { -void *dpm_context;uint32_t dpm_context_size; +void *dpm_context; +void *golden_dpm_context; };struct smu_power_context {
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +14 -0
@@ -136,11 +136,22 @@ static int vega20_allocate_dpm_context(struct smu_context *smu) {struct smu_dpm_context *smu_dpm = &smu->smu_dpm; +if (smu_dpm->dpm_context) +return -EINVAL ; + smu_dpm->dpm_context =kzalloc (sizeof (struct vega20_dpm_table ),GFP_KERNEL );if (!smu_dpm->dpm_context)return -ENOMEM ; +if (smu_dpm->golden_dpm_context) +return -EINVAL ; + + smu_dpm->golden_dpm_context =kzalloc (sizeof (struct vega20_dpm_table ), +GFP_KERNEL ); +if (!smu_dpm->golden_dpm_context) +return -ENOMEM ; + smu_dpm->dpm_context_size =sizeof (struct vega20_dpm_table );return 0 ;
@@ -610,6 +621,9 @@ static int vega20_set_default_dpm_table(struct smu_context *smu) }vega20_init_single_dpm_state (&(single_dpm_table->dpm_state)); +memcpy (smu_dpm->golden_dpm_context, dpm_table, +sizeof (struct vega20_dpm_table )); +return 0 ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 108/138 drm/amd/powerplay: print overdrive percentage information for smu11
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function to get sclk or mclk overdrive percentage information for smu11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 8 ++++-- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 3 +++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 37 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -2
@@ -1017,7 +1017,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,struct amdgpu_device *adev = ddev->dev_private;uint32_t value =0 ; -if (adev->powerplay.pp_funcs->get_sclk_od) +if (is_support_sw_smu (adev)) + value =smu_get_od_percentage (&(adev->smu),OD_SCLK ); +else if (adev->powerplay.pp_funcs->get_sclk_od) value =amdgpu_dpm_get_sclk_od (adev);return snprintf (buf,PAGE_SIZE ,"%d\n" , value);
@@ -1061,7 +1063,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,struct amdgpu_device *adev = ddev->dev_private;uint32_t value =0 ; -if (adev->powerplay.pp_funcs->get_mclk_od) +if (is_support_sw_smu (adev)) + value =smu_get_od_percentage (&(adev->smu),OD_MCLK ); +else if (adev->powerplay.pp_funcs->get_mclk_od) value =amdgpu_dpm_get_mclk_od (adev);return snprintf (buf,PAGE_SIZE ,"%d\n" , value);
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +3 -0
@@ -262,6 +262,7 @@ struct pptable_funcs {int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf);int (*force_clk_levels)(struct smu_context *smu,enum pp_clock_type type,uint32_t mask);int (*set_default_od8_settings)(struct smu_context *smu); +int (*get_od_percentage)(struct smu_context *smu,enum pp_clock_type type); int (*get_clock_by_type_with_latency)(struct smu_context *smu, enum amd_pp_clock_type type, struct
@@ -424,6 +425,8 @@ struct smu_funcs ((smu)->ppt_funcs->print_clk_levels ? (smu)->ppt_funcs->print_clk_levels((smu), (type), (buf)) : 0)#define smu_force_clk_levels (smu, type, level) \ ((smu)->ppt_funcs->force_clk_levels ? (smu)->ppt_funcs->force_clk_levels((smu), (type), (level)) : 0) +#define smu_get_od_percentage (smu, type) \ + ((smu)->ppt_funcs->get_od_percentage ? (smu)->ppt_funcs->get_od_percentage((smu), (type)) : 0)#define smu_start_thermal_control (smu) \ ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_read_sensor (smu, sensor, data, size) \
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +37 -0
@@ -1120,6 +1120,42 @@ static int vega20_set_default_od8_setttings(struct smu_context *smu)return 0 ; } +static int vega20_get_od_percentage (struct smu_context *smu, +enum pp_clock_type type) +{ +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; +struct vega20_dpm_table *dpm_table =NULL ; +struct vega20_dpm_table *golden_table =NULL ; +struct vega20_single_dpm_table *single_dpm_table; +struct vega20_single_dpm_table *golden_dpm_table; +int value, golden_value; + + dpm_table = smu_dpm->dpm_context; + golden_table = smu_dpm->golden_dpm_context; + +switch (type) { +case OD_SCLK : + single_dpm_table = &(dpm_table->gfx_table); + golden_dpm_table = &(golden_table->gfx_table); +break ; +case OD_MCLK : + single_dpm_table = &(dpm_table->mem_table); + golden_dpm_table = &(golden_table->mem_table); +break ; +default : +return -EINVAL ; +break ; + } + + value = single_dpm_table->dpm_levels[single_dpm_table->count -1 ].value; + golden_value = golden_dpm_table->dpm_levels[golden_dpm_table->count -1 ].value; + + value -= golden_value; + value =DIV_ROUND_UP (value *100 , golden_value); + +return value; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
@@ -1134,6 +1170,7 @@ static const struct pptable_funcs vega20_ppt_funcs = { .force_clk_levels = vega20_force_clk_levels, .get_clock_by_type_with_latency = vega20_get_clock_by_type_with_latency, .set_default_od8_settings = vega20_set_default_od8_setttings, + .get_od_percentage = vega20_get_od_percentage, };void vega20_set_ppt_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 109/138 drm/amd/powerplay: get overdrive clock and voltage information
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add sys interface to get overdrive clock and voltage information for smu11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 8 ++- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 99 ++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +7 -1
@@ -658,7 +658,13 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,struct amdgpu_device *adev = ddev->dev_private;uint32_t size =0 ; -if (adev->powerplay.pp_funcs->print_clock_levels) { +if (is_support_sw_smu (adev)) { + size =smu_print_clk_levels (&adev->smu,OD_SCLK , buf); + size +=smu_print_clk_levels (&adev->smu,OD_MCLK , buf+size); + size +=smu_print_clk_levels (&adev->smu,OD_VDDC_CURVE , buf+size); + size +=smu_print_clk_levels (&adev->smu,OD_RANGE , buf+size); +return size; + }else if (adev->powerplay.pp_funcs->print_clock_levels) { size =amdgpu_dpm_print_clock_levels (adev,OD_SCLK , buf); size +=amdgpu_dpm_print_clock_levels (adev,OD_MCLK , buf+size); size +=amdgpu_dpm_print_clock_levels (adev,OD_VDDC_CURVE , buf+size);
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +99 -0
113 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 110/138 drm/amd/powerplay: remove unnecessary checking in smu_hw_fini
In reply to a message not in the archiveThis patch removes unnecessary NULL pointer checking in smu_hw_fini, because kfree is able to handle NULL pointer case.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 54 ++++++++++-------------------- 1 file changed, 18 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +18 -36
@@ -677,50 +677,32 @@ static int smu_hw_fini(void *handle)if (!is_support_sw_smu (adev))return -EINVAL ; -if (smu_dpm->dpm_context) { -kfree (smu_dpm->dpm_context); - smu_dpm->dpm_context =NULL ; - } +kfree (smu_dpm->dpm_context); + smu_dpm->dpm_context =NULL ; -if (smu_dpm->golden_dpm_context) { -kfree (smu_dpm->golden_dpm_context); - smu_dpm->golden_dpm_context =NULL ; - } +kfree (smu_dpm->golden_dpm_context); + smu_dpm->golden_dpm_context =NULL ; -if (table_context->driver_pptable) { -kfree (table_context->driver_pptable); - table_context->driver_pptable =NULL ; - } +kfree (table_context->driver_pptable); + table_context->driver_pptable =NULL ; -if (table_context->max_sustainable_clocks) { -kfree (table_context->max_sustainable_clocks); - table_context->max_sustainable_clocks =NULL ; - } +kfree (table_context->max_sustainable_clocks); + table_context->max_sustainable_clocks =NULL ; -if (table_context->od_feature_capabilities) { -kfree (table_context->od_feature_capabilities); - table_context->od_feature_capabilities =NULL ; - } +kfree (table_context->od_feature_capabilities); + table_context->od_feature_capabilities =NULL ; -if (table_context->od_settings_max) { -kfree (table_context->od_settings_max); - table_context->od_settings_max =NULL ; - } +kfree (table_context->od_settings_max); + table_context->od_settings_max =NULL ; -if (table_context->od_settings_min) { -kfree (table_context->od_settings_min); - table_context->od_settings_min =NULL ; - } +kfree (table_context->od_settings_min); + table_context->od_settings_min =NULL ; -if (table_context->overdrive_table) { -kfree (table_context->overdrive_table); - table_context->overdrive_table =NULL ; - } +kfree (table_context->overdrive_table); + table_context->overdrive_table =NULL ; -if (table_context->od8_settings) { -kfree (table_context->od8_settings); - table_context->od8_settings =NULL ; - } +kfree (table_context->od8_settings); + table_context->od8_settings =NULL ; ret =smu_fini_fb_allocations (smu);if (ret)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 111/138 drm/amd/powerplay: don't check hwmgr while using the sw smu
In reply to a message not in the archiveWhile using the sw smu path, driver won't init hwmgr structure.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +1 -1
@@ -2443,7 +2443,7 @@ int amdgpu_pm_sysfs_init(struct amdgpu_device *adev) "pp_power_profile_mode\n");return ret; } -if (hwmgr->od_enabled) { +if (is_support_sw_smu (adev) || hwmgr->od_enabled) { ret =device_create_file (adev->dev, &dev_attr_pp_od_clk_voltage);if (ret) {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 112/138 drm/amd/powerplay: implement power_dpm_state sys interface for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
Add functions to get/set dpm state for SMU11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h | 6 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 4 +- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 116 +++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 4 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 46 ++++++++++ 5 files changed, 175 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.h +6 -0
@@ -290,6 +290,12 @@ enum amdgpu_pcie_gen {#define amdgpu_dpm_get_current_power_state (adev) \ ((adev)->powerplay.pp_funcs->get_current_power_state((adev)->powerplay.pp_handle)) +#define amdgpu_smu_get_current_power_state (adev) \ + ((adev)->smu.ppt_funcs->get_current_power_state(&((adev)->smu))) + +#define amdgpu_smu_set_power_state (adev) \ + ((adev)->smu.ppt_funcs->set_power_state(&((adev)->smu))) +#define amdgpu_dpm_get_pp_num_states (adev, data) \ ((adev)->powerplay.pp_funcs->get_pp_num_states((adev)->powerplay.pp_handle, data))
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3 -1
@@ -144,7 +144,9 @@ static ssize_t amdgpu_get_dpm_state(struct device *dev,struct amdgpu_device *adev = ddev->dev_private;enum amd_pm_state_type pm; -if (adev->powerplay.pp_funcs->get_current_power_state) +if (adev->smu.ppt_funcs->get_current_power_state) + pm =amdgpu_smu_get_current_power_state (adev); +else if (adev->powerplay.pp_funcs->get_current_power_state) pm =amdgpu_dpm_get_current_power_state (adev);else pm = adev->pm.dpm.user_state;
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +116 -0
135 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +4 -0
@@ -272,8 +272,12 @@ static int smu_v11_0_fini_dpm_context(struct smu_context *smu)return -EINVAL ;kfree (smu_dpm->dpm_context); +kfree (smu_dpm->dpm_current_power_state); +kfree (smu_dpm->dpm_request_power_state); smu_dpm->dpm_context =NULL ; smu_dpm->dpm_context_size =0 ; + smu_dpm->dpm_current_power_state =NULL ; + smu_dpm->dpm_request_power_state =NULL ;return 0 ; }
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +46 -0
71 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 113/138 drm/amd/powerplay: add watermarks related data structs and function for SMU11.
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add write watermark table function and watermark flags to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +7 -0
@@ -556,6 +556,12 @@ static int smu_v11_0_write_pptable(struct smu_context *smu)return ret; } +static int smu_v11_0_write_watermarks_table (struct smu_context *smu) +{ +return smu_update_table (smu,TABLE_WATERMARKS , + smu->smu_table.tables[TABLE_WATERMARKS ].cpu_addr, true); +} +static int smu_v11_0_set_deep_sleep_dcefclk (struct smu_context *smu,uint32_t clk) {int ret;
@@ -1250,6 +1256,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .parse_pptable = smu_v11_0_parse_pptable, .populate_smc_pptable = smu_v11_0_populate_smc_pptable, .write_pptable = smu_v11_0_write_pptable, + .write_watermarks_table = smu_v11_0_write_watermarks_table, .set_min_dcef_deep_sleep = smu_v11_0_set_min_dcef_deep_sleep, .set_tool_table_location = smu_v11_0_set_tool_table_location, .init_display = smu_v11_0_init_display,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 114/138 drm/amd/powerplay: implement pp_power_profile_mode sys inerface for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
Add set/get power profile mode functions.
Added dependency interfaces:
1) vega20_set_activity_monitor_coeff
2) vega20_get_activity_monitor_coeff
3) conv_power_profile_to_pplib_workload
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 9 +- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 19 ++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 22 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 293 +++++++++++++++++++++++++ 4 files changed, 340 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -3
@@ -1136,7 +1136,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->powerplay.pp_funcs->get_power_profile_mode) +if (is_support_sw_smu (adev)) +return smu_get_power_profile_mode (&adev->smu, buf); +else if (adev->powerplay.pp_funcs->get_power_profile_mode)return amdgpu_dpm_get_power_profile_mode (adev, buf);return snprintf (buf,PAGE_SIZE ,"\n" );
@@ -1186,9 +1188,10 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, } } parameter[parameter_size] = profile_mode; -if (adev->powerplay.pp_funcs->set_power_profile_mode) +if (is_support_sw_smu (adev)) + ret =smu_set_power_profile_mode (&adev->smu, parameter, parameter_size); +else if (adev->powerplay.pp_funcs->set_power_profile_mode) ret =amdgpu_dpm_set_power_profile_mode (adev, parameter, parameter_size); -if (!ret)return count; fail:
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +19 -0
@@ -323,6 +323,25 @@ static int smu_sw_init(void *handle)bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX ); smu->watermarks_bitmap =0 ; + smu->power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; + smu->default_power_profile_mode =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; + + smu->workload_mask =1 << smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ]; + smu->workload_prority[PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ] =0 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_FULLSCREEN3D ] =1 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_POWERSAVING ] =2 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_VIDEO ] =3 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_VR ] =4 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_COMPUTE ] =5 ; + smu->workload_prority[PP_SMC_POWER_PROFILE_CUSTOM ] =6 ; + + smu->workload_setting[0 ] =PP_SMC_POWER_PROFILE_BOOTUP_DEFAULT ; + smu->workload_setting[1 ] =PP_SMC_POWER_PROFILE_FULLSCREEN3D ; + smu->workload_setting[2 ] =PP_SMC_POWER_PROFILE_POWERSAVING ; + smu->workload_setting[3 ] =PP_SMC_POWER_PROFILE_VIDEO ; + smu->workload_setting[4 ] =PP_SMC_POWER_PROFILE_VR ; + smu->workload_setting[5 ] =PP_SMC_POWER_PROFILE_COMPUTE ; + smu->workload_setting[6 ] =PP_SMC_POWER_PROFILE_CUSTOM ; ret =smu_init_microcode (smu);if (ret) {
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +22 -0
@@ -335,6 +335,7 @@ struct smu_featureDECLARE_BITMAP (enabled,SMU_FEATURE_MAX ); }; +#define WORKLOAD_POLICY_MAX 7struct smu_context {struct amdgpu_device *adev;
@@ -361,6 +362,12 @@ struct smu_context#define WATERMARKS_EXIST (1 << 0)#define WATERMARKS_LOADED (1 << 1)uint32_t watermarks_bitmap; + +uint32_t workload_mask; +uint32_t workload_prority[WORKLOAD_POLICY_MAX ]; +uint32_t workload_setting[WORKLOAD_POLICY_MAX ]; +uint32_t power_profile_mode; +uint32_t default_power_profile_mode; };struct pptable_funcs {
@@ -389,6 +396,8 @@ struct pptable_funcs {struct pp_clock_levels_with_voltage *clocks); +int (*get_power_profile_mode)(struct smu_context *smu,char *buf); +int (*set_power_profile_mode)(struct smu_context *smu,long *input,uint32_t size); };struct smu_funcs
@@ -453,6 +462,15 @@ struct smu_funcsint (*set_watermarks_for_clock_ranges)(struct smu_context *smu,struct dm_pp_wm_sets_with_clock_ranges_soc15 *clock_ranges);int (*set_od8_default_settings)(struct smu_context *smu); +int (*get_activity_monitor_coeff)(struct smu_context *smu, +uint8_t *table, +uint16_t workload_type); +int (*set_activity_monitor_coeff)(struct smu_context *smu, +uint8_t *table, +uint16_t workload_type); +int (*conv_power_profile_to_pplib_workload)(int power_profile); +int (*get_power_profile_mode)(struct smu_context *smu,char *buf); +int (*set_power_profile_mode)(struct smu_context *smu,long *input,uint32_t size); };#define smu_init_microcode (smu) \
@@ -547,6 +565,10 @@ struct smu_funcs ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_read_sensor (smu, sensor, data, size) \ ((smu)->funcs->read_sensor? (smu)->funcs->read_sensor((smu), (sensor), (data), (size)) : 0) +#define smu_get_power_profile_mode (smu, buf) \ + ((smu)->funcs->get_power_profile_mode ? (smu)->funcs->get_power_profile_mode((smu), buf) : 0) +#define smu_set_power_profile_mode (smu, param, param_size) \ + ((smu)->funcs->set_power_profile_mode ? (smu)->funcs->set_power_profile_mode((smu), (param), (param_size)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +293 -0
311 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 115/138 drm/amd/powerplay: add display_config to handle display config for SMU11.
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add display_config to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 1 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 1 + drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 1 - 3 files changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +1 -0
@@ -342,6 +342,7 @@ static int smu_sw_init(void *handle) smu->workload_setting[4 ] =PP_SMC_POWER_PROFILE_VR ; smu->workload_setting[5 ] =PP_SMC_POWER_PROFILE_COMPUTE ; smu->workload_setting[6 ] =PP_SMC_POWER_PROFILE_CUSTOM ; + smu->display_config = &adev->pm.pm_display_cfg; ret =smu_init_microcode (smu);if (ret) {
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -0
@@ -349,6 +349,7 @@ struct smu_contextstruct smu_dpm_context smu_dpm;struct smu_power_context smu_power;struct smu_feature smu_feature; +struct amd_pp_display_configuration *display_config;uint32_t pstate_sclk;uint32_t pstate_mclk;
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -1
@@ -336,7 +336,6 @@ static int smu_v11_0_fini_smc_tables(struct smu_context *smu)if (ret)return ret;return 0 ; - }static int smu_v11_0_init_power (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 116/138 drm/amd/powerplay: add mclk_latency_table struct and smu_clocks struct for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add mclk_latency_table struct and smu_clocks structi to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +20 -0
@@ -318,6 +318,7 @@ struct smu_dpm_context {void *golden_dpm_context;struct smu_power_state *dpm_request_power_state;struct smu_power_state *dpm_current_power_state; +struct mclock_latency_table *mclk_latency_table; };struct smu_power_context {
@@ -335,6 +336,25 @@ struct smu_featureDECLARE_BITMAP (enabled,SMU_FEATURE_MAX ); }; +struct smu_clocks { +uint32_t engine_clock; +uint32_t memory_clock; +uint32_t bus_bandwidth; +uint32_t engine_clock_in_sr; +uint32_t dcef_clock; +uint32_t dcef_clock_in_sr; +}; + +#define MAX_REGULAR_DPM_NUM 16 +struct mclk_latency_entries { +uint32_t frequency; +uint32_t latency; +}; +struct mclock_latency_table { +uint32_t count; +struct mclk_latency_entries entries[MAX_REGULAR_DPM_NUM ]; +}; +#define WORKLOAD_POLICY_MAX 7struct smu_context {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 117/138 drm/amd/powerplay: add enable_umd_pstate functions for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add enable_umd_pstate to support sys interface for SMU11.
--- drivers/gpu/drm/amd/include/amd_shared.h | 3 ++ drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 44 ++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 +++ 3 files changed, 51 insertions(+)
drivers/gpu/drm/amd/include/amd_shared.h +3 -0
@@ -137,6 +137,7 @@ enum DC_FEATURE_MASK { DC_FBC_MASK = 0x1, }; +enum amd_dpm_forced_level ;/** * struct amd_ip_funcs - general hooks for managing amdgpu IP Blocks */
@@ -186,6 +187,8 @@ struct amd_ip_funcs { enum amd_powergating_state state);/** @get_clockgating_state: get current clockgating status */ void (*get_clockgating_state)(void *handle,u32 *flags); +/** @enable_umd_pstate: enable UMD powerstate */ +int (*enable_umd_pstate)(void *handle,enum amd_dpm_forced_level *level); };
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +44 -0
56 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -316,6 +316,10 @@ struct smu_dpm_context {uint32_t dpm_context_size;void *dpm_context;void *golden_dpm_context; +bool enable_umd_pstate; +enum amd_dpm_forced_level dpm_level; +enum amd_dpm_forced_level saved_dpm_level; +enum amd_dpm_forced_level requested_dpm_level;struct smu_power_state *dpm_request_power_state;struct smu_power_state *dpm_current_power_state;struct mclock_latency_table *mclk_latency_table;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 118/138 drm/amd/powerplay: add get_profiling_clk_mask functions for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add get_profiling_clk_masking_clk_mask
to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 40 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.h | 3 +++ 2 files changed, 43 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +40 -0
@@ -1299,6 +1299,46 @@ static int vega20_get_od_percentage(struct smu_context *smu,return value; } +static int +vega20_get_profiling_clk_mask (struct smu_context *smu, +enum amd_dpm_forced_level level, +uint32_t *sclk_mask, +uint32_t *mclk_mask, +uint32_t *soc_mask) +{ +struct vega20_dpm_table *dpm_table = (struct vega20_dpm_table *)smu->smu_dpm.dpm_context; +if (!smu->smu_dpm.dpm_context) +return -EINVAL ; + +struct vega20_single_dpm_table *gfx_dpm_table = &(dpm_table->gfx_table); +struct vega20_single_dpm_table *mem_dpm_table = &(dpm_table->mem_table); +struct vega20_single_dpm_table *soc_dpm_table = &(dpm_table->soc_table); + + *sclk_mask =0 ; + *mclk_mask =0 ; + *soc_mask =0 ; + +if (gfx_dpm_table->count >VEGA20_UMD_PSTATE_GFXCLK_LEVEL && + mem_dpm_table->count >VEGA20_UMD_PSTATE_MCLK_LEVEL && + soc_dpm_table->count >VEGA20_UMD_PSTATE_SOCCLK_LEVEL ) { + *sclk_mask =VEGA20_UMD_PSTATE_GFXCLK_LEVEL ; + *mclk_mask =VEGA20_UMD_PSTATE_MCLK_LEVEL ; + *soc_mask =VEGA20_UMD_PSTATE_SOCCLK_LEVEL ; + } + +if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { + *sclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { + *mclk_mask =0 ; + }else if (level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + *sclk_mask = gfx_dpm_table->count -1 ; + *mclk_mask = mem_dpm_table->count -1 ; + *soc_mask = soc_dpm_table->count -1 ; + } + +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
drivers/gpu/drm/amd/powerplay/vega20_ppt.h +3 -0
@@ -24,7 +24,10 @@#define __VEGA20_PPT_H__#define VEGA20_UMD_PSTATE_GFXCLK_LEVEL 0x3 +#define VEGA20_UMD_PSTATE_SOCCLK_LEVEL 0x3#define VEGA20_UMD_PSTATE_MCLK_LEVEL 0x2 +#define VEGA20_UMD_PSTATE_UVDCLK_LEVEL 0x3 +#define VEGA20_UMD_PSTATE_VCEMCLK_LEVEL 0x3#define MAX_REGULAR_DPM_NUMBER 16#define MAX_PCIE_CONF 2
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 119/138 drm/amd/powerplay: add set_uclk_to_highest_level for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add set_uclk_to_highest_level to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 43 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +40 -3
@@ -1307,12 +1307,16 @@ vega20_get_profiling_clk_mask(struct smu_context *smu, uint32_t *soc_mask) {struct vega20_dpm_table *dpm_table = (struct vega20_dpm_table *)smu->smu_dpm.dpm_context; +struct vega20_single_dpm_table *gfx_dpm_table; +struct vega20_single_dpm_table *mem_dpm_table; +struct vega20_single_dpm_table *soc_dpm_table; +if (!smu->smu_dpm.dpm_context)return -EINVAL ; -struct vega20_single_dpm_table *gfx_dpm_table = &(dpm_table->gfx_table); -struct vega20_single_dpm_table *mem_dpm_table = &(dpm_table->mem_table); -struct vega20_single_dpm_table *soc_dpm_table = &(dpm_table->soc_table); + gfx_dpm_table = &dpm_table->gfx_table; + mem_dpm_table = &dpm_table->mem_table; + soc_dpm_table = &dpm_table->soc_table; *sclk_mask =0 ; *mclk_mask =0 ;
@@ -1339,6 +1343,39 @@ vega20_get_profiling_clk_mask(struct smu_context *smu,return 0 ; } +static int +vega20_set_uclk_to_highest_dpm_level (struct smu_context *smu, +struct vega20_single_dpm_table *dpm_table) +{ +int ret =0 ; +struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); +if (!smu_dpm_ctx->dpm_context) +return -EINVAL ; + +if (smu_feature_is_enabled (smu,FEATURE_DPM_UCLK_BIT )) { +if (dpm_table->count <=0 ) { +pr_err ("[%s] Dpm table has no entry!" , __func__); +return -EINVAL ; + } + +if (dpm_table->count >NUM_UCLK_DPM_LEVELS ) { +pr_err ("[%s] Dpm table has too many entries!" , __func__); +return -EINVAL ; + } + + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetHardMinByFreq, + (PPCLK_UCLK <<16 ) | dpm_table->dpm_state.hard_min_level); +if (ret) { +pr_err ("[%s] Set hard min uclk failed!" , __func__); +return ret; + } + } + +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 120/138 drm/amd/powerplay: add display_config_changed for SMU11.
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add display_config_changed to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +42 -0
@@ -1376,6 +1376,48 @@ vega20_set_uclk_to_highest_dpm_level(struct smu_context *smu,return ret; } +static int vega20_display_config_changed (struct smu_context *smu) +{ +int ret =0 ; +struct vega20_dpm_table *dpm_table = smu->smu_dpm.dpm_context; + +if (!smu->funcs) +return -EINVAL ; + +if (!smu->smu_dpm.dpm_context || + !smu->smu_table.tables || + !smu->smu_table.tables[TABLE_WATERMARKS ].cpu_addr) +return -EINVAL ; + +smu_send_smc_msg_with_param (smu, SMU_MSG_NumOfDisplays,0 ); + ret =vega20_set_uclk_to_highest_dpm_level (smu, + &dpm_table->mem_table); +if (ret) { +pr_err ("Failed to set uclk to highest dpm level" ); +return ret; + } + +if ((smu->watermarks_bitmap &WATERMARKS_EXIST ) && + !(smu->watermarks_bitmap &WATERMARKS_LOADED )) { + ret = smu->funcs->write_watermarks_table (smu); +if (ret) { +pr_err ("Failed to update WMTABLE!" ); +return ret; + } + smu->watermarks_bitmap |=WATERMARKS_LOADED ; + } + +if ((smu->watermarks_bitmap &WATERMARKS_EXIST ) && +smu_feature_is_supported (smu,FEATURE_DPM_DCEFCLK_BIT ) && +smu_feature_is_supported (smu,FEATURE_DPM_SOCCLK_BIT )) { +smu_send_smc_msg_with_param (smu, + SMU_MSG_NumOfDisplays, + smu->display_config->num_display); + } + +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 121/138 drm/amd/powerplay: add apply_clock_adjust_rules for SMU11.
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add apply_clock_adjust_rules to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 151 +++++++++++++++++++++++++++++ 1 file changed, 151 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +151 -0
@@ -1418,6 +1418,157 @@ static int vega20_display_config_changed(struct smu_context *smu)return ret; } +static int vega20_apply_clocks_adjust_rules (struct smu_context *smu) +{ +struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); +struct vega20_dpm_table *dpm_ctx = (struct vega20_dpm_table *)(smu_dpm_ctx->dpm_context); +struct vega20_single_dpm_table *dpm_table; +bool vblank_too_short = false; +bool disable_mclk_switching; +uint32_t i, latency; + + disable_mclk_switching = ((1 < smu->display_config->num_display) && + !smu->display_config->multi_monitor_in_sync) || vblank_too_short; + latency = smu->display_config->dce_tolerable_mclk_in_active_latency; + +/* gfxclk */ + dpm_table = &(dpm_ctx->gfx_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_GFXCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_GFXCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_GFXCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_SCLK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[0 ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } + +/* memclk */ + dpm_table = &(dpm_ctx->mem_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_MCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_MCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_MCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_MIN_MCLK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[0 ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } + +/* honour DAL's UCLK Hardmin */ +if (dpm_table->dpm_state.hard_min_level < (smu->display_config->min_mem_set_clock /100 )) + dpm_table->dpm_state.hard_min_level = smu->display_config->min_mem_set_clock /100 ; + +/* Hardmin is dependent on displayconfig */ +if (disable_mclk_switching) { + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; +for (i =0 ; i < smu_dpm_ctx->mclk_latency_table->count -1 ; i++) { +if (smu_dpm_ctx->mclk_latency_table->entries[i].latency <= latency) { +if (dpm_table->dpm_levels[i].value >= (smu->display_config->min_mem_set_clock /100 )) { + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[i].value; +break ; + } + } + } + } + +if (smu->display_config->nb_pstate_switch_disable) + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +#if 0 +/* vclk */ + dpm_table = &(dpm_ctx->vclk_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_UVDCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_UVDCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_UVDCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } + +/* dclk */ + dpm_table = &(dpm_ctx->dclk_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_UVDCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_UVDCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_UVDCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } +#endif + +/* socclk */ + dpm_table = &(dpm_ctx->soc_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_SOCCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_SOCCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_SOCCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } + +#if 0 +/* eclk */ + dpm_table = &(dpm_ctx->eclk_table); + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.hard_min_level = dpm_table->dpm_levels[0 ].value; + dpm_table->dpm_state.hard_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + +if (VEGA20_UMD_PSTATE_VCEMCLK_LEVEL < dpm_table->count) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_VCEMCLK_LEVEL ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[VEGA20_UMD_PSTATE_VCEMCLK_LEVEL ].value; + } + +if (smu_dpm_ctx->dpm_level ==AMD_DPM_FORCED_LEVEL_PROFILE_PEAK ) { + dpm_table->dpm_state.soft_min_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + dpm_table->dpm_state.soft_max_level = dpm_table->dpm_levels[dpm_table->count -1 ].value; + } +#endif +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 122/138 drm/amd/powerplay: add vega20_notify_smc_display_config functions for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add vega20_notify_smc_display_config functions to
support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +45 -0
@@ -1569,6 +1569,51 @@ static int vega20_apply_clocks_adjust_rules(struct smu_context *smu)return 0 ; } +static int +vega20_notify_smc_dispaly_config (struct smu_context *smu) +{ +struct vega20_dpm_table *dpm_table = smu->smu_dpm.dpm_context; +struct vega20_single_dpm_table *memtable = &dpm_table->mem_table; +struct smu_clocks min_clocks = {0 }; +struct pp_display_clock_request clock_req; +int ret =0 ; + + min_clocks.dcef_clock = smu->display_config->min_dcef_set_clk; + min_clocks.dcef_clock_in_sr = smu->display_config->min_dcef_deep_sleep_set_clk; + min_clocks.memory_clock = smu->display_config->min_mem_set_clock; + +if (smu_feature_is_supported (smu,FEATURE_DPM_DCEFCLK_BIT )) { + clock_req.clock_type = amd_pp_dcef_clock; + clock_req.clock_freq_in_khz = min_clocks.dcef_clock *10 ; +if (!smu->funcs->display_clock_voltage_request (smu, &clock_req)) { +if (smu_feature_is_supported (smu,FEATURE_DS_DCEFCLK_BIT )) { + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetMinDeepSleepDcefclk, + min_clocks.dcef_clock_in_sr/100 ); +if (ret) { +pr_err ("Attempt to set divider for DCEFCLK Failed!" ); +return ret; + } + } + }else { +pr_info ("Attempt to set Hard Min for DCEFCLK Failed!" ); + } + } + +if (smu_feature_is_enabled (smu,FEATURE_DPM_UCLK_BIT )) { + memtable->dpm_state.hard_min_level = min_clocks.memory_clock/100 ; + ret =smu_send_smc_msg_with_param (smu, + SMU_MSG_SetHardMinByFreq, + (PPCLK_UCLK <<16 ) | memtable->dpm_state.hard_min_level); +if (ret) { +pr_err ("[%s] Set hard min uclk failed!" , __func__); +return ret; + } + } + +return 0 ; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 123/138 drm/amd/powerplay: add vega20_find/force_higest/lowest_dpm for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add vega20_find_highest_dpm_level, vega20_find_lowest_dpm_level,
vega20_force_highest_dpm and vega20_force_lowest_dpm functions to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 111 +++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +111 -0
@@ -1614,6 +1614,117 @@ vega20_notify_smc_dispaly_config(struct smu_context *smu)return 0 ; } +static uint32_t vega20_find_highest_dpm_level (struct vega20_single_dpm_table *table) +{ +uint32_t i; + +for (i =0 ; i < table->count; i++) { +if (table->dpm_levels[i].enabled) +break ; + } +if (i >= table->count) { + i =0 ; + table->dpm_levels[i].enabled = true; + } + +return i; +} + +static uint32_t vega20_find_lowest_dpm_level (struct vega20_single_dpm_table *table) +{ +int i =0 ; + +if (!table) { +pr_err ("[%s] DPM Table does not exist!" , __func__); +return 0 ; + } +if (table->count <=0 ) { +pr_err ("[%s] DPM Table has no entry!" , __func__); +return 0 ; + } +if (table->count >MAX_REGULAR_DPM_NUMBER ) { +pr_err ("[%s] DPM Table has too many entries!" , __func__); +return MAX_REGULAR_DPM_NUMBER -1 ; + } + +for (i = table->count -1 ; i >=0 ; i--) { +if (table->dpm_levels[i].enabled) +break ; + } +if (i <0 ) { + i =0 ; + table->dpm_levels[i].enabled = true; + } + +return i; +} + +static int vega20_force_dpm_highest (struct smu_context *smu) +{ +uint32_t soft_level; +int ret =0 ; +struct vega20_dpm_table *dpm_table = (struct vega20_dpm_table *)smu->smu_dpm.dpm_context; + + soft_level =vega20_find_highest_dpm_level (&(dpm_table->gfx_table)); + + dpm_table->gfx_table.dpm_state.soft_min_level = + dpm_table->gfx_table.dpm_state.soft_max_level = + dpm_table->gfx_table.dpm_levels[soft_level].value; + + soft_level =vega20_find_highest_dpm_level (&(dpm_table->mem_table)); + + dpm_table->mem_table.dpm_state.soft_min_level = + dpm_table->mem_table.dpm_state.soft_max_level = + dpm_table->mem_table.dpm_levels[soft_level].value; + + ret =vega20_upload_dpm_min_level (smu); +if (ret) { +pr_err ("Failed to upload boot level to highest!" ); +return ret; + } + + ret =vega20_upload_dpm_max_level (smu); +if (ret) { +pr_err ("Failed to upload dpm max level to highest!" ); +return ret; + } + +return ret; +} + +static int vega20_force_dpm_lowest (struct smu_context *smu) +{ +uint32_t soft_level; +int ret =0 ; +struct vega20_dpm_table *dpm_table = (struct vega20_dpm_table *)smu->smu_dpm.dpm_context; + + soft_level =vega20_find_lowest_dpm_level (&(dpm_table->gfx_table)); + + dpm_table->gfx_table.dpm_state.soft_min_level = + dpm_table->gfx_table.dpm_state.soft_max_level = + dpm_table->gfx_table.dpm_levels[soft_level].value; + + soft_level =vega20_find_lowest_dpm_level (&(dpm_table->mem_table)); + + dpm_table->mem_table.dpm_state.soft_min_level = + dpm_table->mem_table.dpm_state.soft_max_level = + dpm_table->mem_table.dpm_levels[soft_level].value; + + ret =vega20_upload_dpm_min_level (smu); +if (ret) { +pr_err ("Failed to upload boot level to lowest!" ); +return ret; + } + + ret =vega20_upload_dpm_max_level (smu); +if (ret) { +pr_err ("Failed to upload dpm max level to lowest!" ); +return ret; + } + +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 124/138 drm/amd/powerplay: add vega20_unforce_dpm_levels for SMU11.
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add vega20_unforce_dpm_levels to support sys interface for SMU11.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +19 -0
@@ -1725,6 +1725,25 @@ static int vega20_force_dpm_lowest(struct smu_context *smu)return ret; } +static int vega20_unforce_dpm_levels (struct smu_context *smu) +{ +int ret =0 ; + + ret =vega20_upload_dpm_min_level (smu); +if (ret) { +pr_err ("Failed to upload DPM Bootup Levels!" ); +return ret; + } + + ret =vega20_upload_dpm_max_level (smu); +if (ret) { +pr_err ("Failed to upload DPM Max Levels!" ); +return ret; + } + +return ret; +} +static const struct pptable_funcs vega20_ppt_funcs = { .alloc_dpm_context = vega20_allocate_dpm_context, .store_powerplay_table = vega20_store_powerplay_table,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 125/138 drm/amd/powerplay: implement power_dpm_force_performance_level for SMU11
In reply to a message not in the archiveFrom: Chengming Gui <[email protected]>
add get_performance_level and force_performance_level to implement the sys interface for SMU11.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 23 +++++- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 2 + drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 2 - drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 99 ++++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +20 -3
@@ -264,7 +264,9 @@ static ssize_t amdgpu_get_dpm_forced_performance_level(struct device *dev, (ddev->switch_power_state != DRM_SWITCH_POWER_ON))return snprintf (buf,PAGE_SIZE ,"off\n" ); -if (adev->powerplay.pp_funcs->get_performance_level) +if (is_support_sw_smu (adev)) + level =smu_get_performance_level (&adev->smu); +else if (adev->powerplay.pp_funcs->get_performance_level) level =amdgpu_dpm_get_performance_level (adev);else level = adev->pm.dpm.forced_level;
@@ -297,7 +299,9 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev, (ddev->switch_power_state != DRM_SWITCH_POWER_ON))return -EINVAL ; -if (adev->powerplay.pp_funcs->get_performance_level) +if (is_support_sw_smu (adev)) + current_level =smu_get_performance_level (&adev->smu); +else if (adev->powerplay.pp_funcs->get_performance_level) current_level =amdgpu_dpm_get_performance_level (adev);if (strncmp ("low" , buf,strlen ("low" )) ==0 ) {
@@ -326,7 +330,20 @@ static ssize_t amdgpu_set_dpm_forced_performance_level(struct device *dev,if (current_level == level)return count; -if (adev->powerplay.pp_funcs->force_performance_level) { +if (is_support_sw_smu (adev)) { +mutex_lock (&adev->pm.mutex); +if (adev->pm.dpm.thermal_active) { + count = -EINVAL ; +mutex_unlock (&adev->pm.mutex); + goto fail; + } + ret =smu_force_performance_level (&adev->smu, level); +if (ret) + count = -EINVAL ; +else + adev->pm.dpm.forced_level = level; +mutex_unlock (&adev->pm.mutex); + }else if (adev->powerplay.pp_funcs->force_performance_level) {mutex_lock (&adev->pm.mutex);if (adev->pm.dpm.thermal_active) { count = -EINVAL ;
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +2 -0
@@ -344,6 +344,8 @@ static int smu_sw_init(void *handle) smu->workload_setting[6 ] =PP_SMC_POWER_PROFILE_CUSTOM ; smu->display_config = &adev->pm.pm_display_cfg; + smu->smu_dpm.dpm_level =AMD_DPM_FORCED_LEVEL_AUTO ; + smu->smu_dpm.requested_dpm_level =AMD_DPM_FORCED_LEVEL_AUTO ; ret =smu_init_microcode (smu);if (ret) {pr_err ("Failed to load smu firmware!\n" );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -0
@@ -423,6 +423,8 @@ struct pptable_funcs { *clocks);int (*get_power_profile_mode)(struct smu_context *smu,char *buf);int (*set_power_profile_mode)(struct smu_context *smu,long *input,uint32_t size); +enum amd_dpm_forced_level (*get_performance_level)(struct smu_context *smu); +int (*force_performance_level)(struct smu_context *smu,enum amd_dpm_forced_level level); };struct smu_funcs
@@ -594,6 +596,10 @@ struct smu_funcs ((smu)->funcs->get_power_profile_mode ? (smu)->funcs->get_power_profile_mode((smu), buf) : 0)#define smu_set_power_profile_mode (smu, param, param_size) \ ((smu)->funcs->set_power_profile_mode ? (smu)->funcs->set_power_profile_mode((smu), (param), (param_size)) : 0) +#define smu_get_performance_level (smu) \ + ((smu)->ppt_funcs->get_performance_level ? (smu)->ppt_funcs->get_performance_level((smu)) : 0) +#define smu_force_performance_level (smu, level) \ + ((smu)->ppt_funcs->force_performance_level ? (smu)->ppt_funcs->force_performance_level((smu), (level)) : 0)#define smu_msg_get_index (smu, msg) \ ((smu)->ppt_funcs? ((smu)->ppt_funcs->get_smu_msg_index? (smu)->ppt_funcs->get_smu_msg_index((smu), (msg)) : -EINVAL) : -EINVAL)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -2
@@ -1097,7 +1097,6 @@ smu_v11_0_display_clock_voltage_request(struct smu_context *smu,PPCLK_e clk_select =0 ;uint32_t clk_freq = clock_req->clock_freq_in_khz /1000 ; -mutex_lock (&smu->mutex);if (smu_feature_is_enabled (smu,FEATURE_DPM_DCEFCLK_BIT )) {switch (clk_type) {case amd_pp_dcef_clock:
@@ -1126,7 +1125,6 @@ smu_v11_0_display_clock_voltage_request(struct smu_context *smu, } failed: -mutex_unlock (&smu->mutex);return ret; }
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +99 -0
111 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 126/138 drm/amd/powerplay: add sys interface for pcie for smu
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add sys interface for set/get PCIE info for SMU.
The related operate will do nothing as vega20 do not support it now.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 8 ++++++-- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +6 -2
@@ -1005,7 +1005,9 @@ static ssize_t amdgpu_get_pp_dpm_pcie(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; -if (adev->powerplay.pp_funcs->print_clock_levels) +if (is_support_sw_smu (adev)) +return smu_print_clk_levels (&adev->smu,PP_PCIE , buf); +else if (adev->powerplay.pp_funcs->print_clock_levels)return amdgpu_dpm_print_clock_levels (adev,PP_PCIE , buf);else return snprintf (buf,PAGE_SIZE ,"\n" );
@@ -1025,7 +1027,9 @@ static ssize_t amdgpu_set_pp_dpm_pcie(struct device *dev,if (ret)return ret; -if (adev->powerplay.pp_funcs->force_clock_level) +if (is_support_sw_smu (adev)) + ret =smu_force_clk_levels (&adev->smu,PP_PCIE , mask); +else if (adev->powerplay.pp_funcs->force_clock_level) ret =amdgpu_dpm_force_clock_level (adev,PP_PCIE , mask);if (ret)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +6 -0
@@ -775,6 +775,9 @@ static int vega20_print_clk_levels(struct smu_context *smu, ? "*" : "");break ; +case PP_PCIE : +break ; +case OD_SCLK :if (od8_settings->od8_settings_array[OD8_SETTING_GFXCLK_FMIN ].feature_id && od8_settings->od8_settings_array[OD8_SETTING_GFXCLK_FMAX ].feature_id) {
@@ -1016,6 +1019,9 @@ static int vega20_force_clk_levels(struct smu_context *smu,break ; +case PP_PCIE : +break ; +default :break ; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 127/138 drm/amd/powerplay: add function to update overdrive settings
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add function of smu_update_specified_od8_value to modify specified overdrive value.
Add fucntion of smu_update_od8_settings to update overdrive table.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 10 ++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 27 +++++++++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 78 ++++++++++++++++++++++++++ 3 files changed, 115 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +10 -0
@@ -410,6 +410,9 @@ struct pptable_funcs {int (*print_clk_levels)(struct smu_context *smu,enum pp_clock_type type,char *buf);int (*force_clk_levels)(struct smu_context *smu,enum pp_clock_type type,uint32_t mask);int (*set_default_od8_settings)(struct smu_context *smu); +int (*update_specified_od8_value)(struct smu_context *smu, +uint32_t index, +uint32_t value);int (*get_od_percentage)(struct smu_context *smu,enum pp_clock_type type); int (*get_clock_by_type_with_latency)(struct smu_context *smu, enum amd_pp_clock_type type,
@@ -498,6 +501,9 @@ struct smu_funcsint (*conv_power_profile_to_pplib_workload)(int power_profile);int (*get_power_profile_mode)(struct smu_context *smu,char *buf);int (*set_power_profile_mode)(struct smu_context *smu,long *input,uint32_t size); +int (*update_od8_settings)(struct smu_context *smu, +uint32_t index, +uint32_t value); };#define smu_init_microcode (smu) \
@@ -546,6 +552,8 @@ struct smu_funcs ((smu)->funcs->init_max_sustainable_clocks ? (smu)->funcs->init_max_sustainable_clocks((smu)) : 0)#define smu_set_od8_default_settings (smu) \ ((smu)->funcs->set_od8_default_settings ? (smu)->funcs->set_od8_default_settings((smu)) : 0) +#define smu_update_od8_settings (smu, index, value) \ + ((smu)->funcs->update_od8_settings ? (smu)->funcs->update_od8_settings((smu), (index), (value)) : 0)#define smu_send_smc_msg (smu, msg) \ ((smu)->funcs->send_smc_msg? (smu)->funcs->send_smc_msg((smu), (msg)) : 0)#define smu_send_smc_msg_with_param (smu, msg, param) \
@@ -578,6 +586,8 @@ struct smu_funcs ((smu)->ppt_funcs->populate_umd_state_clk ? (smu)->ppt_funcs->populate_umd_state_clk((smu)) : 0)#define smu_set_default_od8_settings (smu) \ ((smu)->ppt_funcs->set_default_od8_settings ? (smu)->ppt_funcs->set_default_od8_settings((smu)) : 0) +#define smu_update_specified_od8_value (smu, index, value) \ + ((smu)->ppt_funcs->update_specified_od8_value ? (smu)->ppt_funcs->update_specified_od8_value((smu), (index), (value)) : 0)#define smu_get_power_limit (smu) \ ((smu)->funcs->get_power_limit? (smu)->funcs->get_power_limit((smu)) : 0)#define smu_get_current_clk_freq (smu, clk_id, value) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +27 -0
@@ -1521,6 +1521,32 @@ static int smu_v11_0_set_power_profile_mode(struct smu_context *smu, long *inputreturn ret; } +static int smu_v11_0_update_od8_settings (struct smu_context *smu, +uint32_t index, +uint32_t value) +{ +struct smu_table_context *table_context = &smu->smu_table; +int ret; + + ret =smu_update_table (smu,TABLE_OVERDRIVE , + table_context->overdrive_table, false); +if (ret) { +pr_err ("Failed to export over drive table!\n" ); +return ret; + } + +smu_update_specified_od8_value (smu, index, value); + + ret =smu_update_table (smu,TABLE_OVERDRIVE , + table_context->overdrive_table, true); +if (ret) { +pr_err ("Failed to import over drive table!\n" ); +return ret; + } + +return 0 ; +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -1564,6 +1590,7 @@ static const struct smu_funcs smu_v11_0_funcs = { .conv_power_profile_to_pplib_workload = smu_v11_0_conv_power_profile_to_pplib_workload, .get_power_profile_mode = smu_v11_0_get_power_profile_mode, .set_power_profile_mode = smu_v11_0_set_power_profile_mode, + .update_od8_settings = smu_v11_0_update_od8_settings, };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +78 -0
90 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 128/138 drm/amd/powerplay: add sys interface for set sclk_od/mclk_od for smu
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add sys interface for set pp_sclk_od and pp_mclk_od for smu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 34 +++++++++----- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 5 +++ drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 62 ++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +22 -12
@@ -1070,14 +1070,19 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev, count = -EINVAL ; goto fail; } -if (adev->powerplay.pp_funcs->set_sclk_od) -amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); -if (adev->powerplay.pp_funcs->dispatch_tasks) { -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); +if (is_support_sw_smu (adev)) { + value =smu_set_od_percentage (&(adev->smu),OD_SCLK , (uint32_t )value); }else { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +if (adev->powerplay.pp_funcs->set_sclk_od) +amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); + +if (adev->powerplay.pp_funcs->dispatch_tasks) { +amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); + }else { + adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; +amdgpu_pm_compute_clocks (adev); + } } fail:
@@ -1116,14 +1121,19 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev, count = -EINVAL ; goto fail; } -if (adev->powerplay.pp_funcs->set_mclk_od) -amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); -if (adev->powerplay.pp_funcs->dispatch_tasks) { -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); +if (is_support_sw_smu (adev)) { + value =smu_set_od_percentage (&(adev->smu),OD_MCLK , (uint32_t )value); }else { - adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; -amdgpu_pm_compute_clocks (adev); +if (adev->powerplay.pp_funcs->set_mclk_od) +amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); + +if (adev->powerplay.pp_funcs->dispatch_tasks) { +amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); + }else { + adev->pm.dpm.current_ps = adev->pm.dpm.boot_ps; +amdgpu_pm_compute_clocks (adev); + } } fail:
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +5 -0
@@ -414,6 +414,9 @@ struct pptable_funcs {uint32_t index, uint32_t value);int (*get_od_percentage)(struct smu_context *smu,enum pp_clock_type type); +int (*set_od_percentage)(struct smu_context *smu, +enum pp_clock_type type, +uint32_t value); int (*get_clock_by_type_with_latency)(struct smu_context *smu, enum amd_pp_clock_type type, struct
@@ -598,6 +601,8 @@ struct smu_funcs ((smu)->ppt_funcs->force_clk_levels ? (smu)->ppt_funcs->force_clk_levels((smu), (type), (level)) : 0)#define smu_get_od_percentage (smu, type) \ ((smu)->ppt_funcs->get_od_percentage ? (smu)->ppt_funcs->get_od_percentage((smu), (type)) : 0) +#define smu_set_od_percentage (smu, type, value) \ + ((smu)->ppt_funcs->set_od_percentage ? (smu)->ppt_funcs->set_od_percentage((smu), (type), (value)) : 0)#define smu_start_thermal_control (smu) \ ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_read_sensor (smu, sensor, data, size) \
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +62 -0
74 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 129/138 drm/amd/powerplay: add sys interface to set pp_od_clk_voltage for smu
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add sys interface to set pp_od_clk_voltage for smu.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 30 ++-- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 7 + drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 223 +++++++++++++++++++++++++ 3 files changed, 250 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +20 -10
@@ -650,19 +650,29 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, tmp_str++; } -if (adev->powerplay.pp_funcs->odn_edit_dpm_table) - ret =amdgpu_dpm_odn_edit_dpm_table (adev, type, - parameter, parameter_size); +if (is_support_sw_smu (adev)) { + ret =smu_od_edit_dpm_table (&adev->smu, type, + parameter, parameter_size); -if (ret) -return -EINVAL ; +if (ret) +return -EINVAL ; + }else { +if (adev->powerplay.pp_funcs->odn_edit_dpm_table) + ret =amdgpu_dpm_odn_edit_dpm_table (adev, type, + parameter, parameter_size); -if (type ==PP_OD_COMMIT_DPM_TABLE ) { -if (adev->powerplay.pp_funcs->dispatch_tasks) { -amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL ); -return count; - }else { +if (ret)return -EINVAL ; + +if (type ==PP_OD_COMMIT_DPM_TABLE ) { +if (adev->powerplay.pp_funcs->dispatch_tasks) { +amdgpu_dpm_dispatch_task (adev, +AMD_PP_TASK_READJUST_POWER_STATE , +NULL ); +return count; + }else { +return -EINVAL ; + } } }
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +7 -0
@@ -310,6 +310,8 @@ struct smu_table_contextuint32_t *od_settings_min;void *overdrive_table;void *od8_settings; +bool od_gfxclk_update; +bool od_memclk_update; };struct smu_dpm_context {
@@ -417,6 +419,9 @@ struct pptable_funcs {int (*set_od_percentage)(struct smu_context *smu,enum pp_clock_type type,uint32_t value); +int (*od_edit_dpm_table)(struct smu_context *smu, +enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size); int (*get_clock_by_type_with_latency)(struct smu_context *smu, enum amd_pp_clock_type type, struct
@@ -603,6 +608,8 @@ struct smu_funcs ((smu)->ppt_funcs->get_od_percentage ? (smu)->ppt_funcs->get_od_percentage((smu), (type)) : 0)#define smu_set_od_percentage (smu, type, value) \ ((smu)->ppt_funcs->set_od_percentage ? (smu)->ppt_funcs->set_od_percentage((smu), (type), (value)) : 0) +#define smu_od_edit_dpm_table (smu, type, input, size) \ + ((smu)->ppt_funcs->od_edit_dpm_table ? (smu)->ppt_funcs->od_edit_dpm_table((smu), (type), (input), (size)) : 0)#define smu_start_thermal_control (smu) \ ((smu)->funcs->start_thermal_control? (smu)->funcs->start_thermal_control((smu)) : 0)#define smu_read_sensor (smu, sensor, data, size) \
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +223 -0
235 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 130/138 drm/amd/powerplay: adjust power state when set od_clk
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Expose the function of adjust_power_state_dynamic to make it common to other functions.
Add the operate of adjust powet state when set od percentage or overdrive commit dpm table.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 80 +++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +56 -24
@@ -1764,44 +1764,35 @@ static enum amd_dpm_forced_level vega20_get_performance_level(struct smu_contextreturn smu_dpm_ctx->dpm_level; } -static int -vega20_force_performance_level (struct smu_context *smu,enum amd_dpm_forced_level level) +static int vega20_adjust_power_state_dynamic (struct smu_context *smu, +enum amd_dpm_forced_level level) {int ret =0 ;int index =0 ; -int i =0 ;uint32_t sclk_mask, mclk_mask, soc_mask;long workload;struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); -if (!smu_dpm_ctx->dpm_context) -return -EINVAL ; -for (i =0 ; i < smu->adev->num_ip_blocks; i++) { -if (smu->adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_SMC ) -break ; - } -mutex_lock (&smu->mutex); - smu->adev->ip_blocks[i].version->funcs->enable_umd_pstate (smu, &level); ret =vega20_display_config_changed (smu);if (ret) {pr_err ("Failed to change display config!" ); - goto failed; +return ret; } ret =vega20_apply_clocks_adjust_rules (smu);if (ret) {pr_err ("Failed to apply clocks adjust rules!" ); - goto failed; +return ret; } ret =vega20_notify_smc_dispaly_config (smu);if (ret) {pr_err ("Failed to notify smc display config!" ); - goto failed; +return ret; } +switch (level) {case AMD_DPM_FORCED_LEVEL_HIGH : ret =vega20_force_dpm_highest (smu);break ; -case AMD_DPM_FORCED_LEVEL_LOW : ret =vega20_force_dpm_lowest (smu);break ;
@@ -1819,7 +1810,7 @@ vega20_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_leve &mclk_mask, &soc_mask);if (ret) - goto failed; +return ret;vega20_force_clk_levels (smu,PP_SCLK ,1 << sclk_mask);vega20_force_clk_levels (smu,PP_MCLK ,1 << mclk_mask);break ;
@@ -1842,8 +1833,31 @@ vega20_force_performance_level(struct smu_context *smu, enum amd_dpm_forced_leve smu->funcs->set_power_profile_mode (smu, &workload,0 ); } -failed: +return ret; +} + +static int +vega20_force_performance_level (struct smu_context *smu,enum amd_dpm_forced_level level) +{ +int ret =0 ; +int i; +struct smu_dpm_context *smu_dpm_ctx = &(smu->smu_dpm); + +if (!smu_dpm_ctx->dpm_context) +return -EINVAL ; + +for (i =0 ; i < smu->adev->num_ip_blocks; i++) { +if (smu->adev->ip_blocks[i].version->type ==AMD_IP_BLOCK_TYPE_SMC ) +break ; + } + +mutex_lock (&smu->mutex); + + smu->adev->ip_blocks[i].version->funcs->enable_umd_pstate (smu, &level); + ret =vega20_adjust_power_state_dynamic (smu, level); +mutex_unlock (&smu->mutex); +return ret; }
@@ -1934,9 +1948,12 @@ static int vega20_set_od_percentage(struct smu_context *smu,struct vega20_single_dpm_table *single_dpm_table;struct vega20_single_dpm_table *golden_dpm_table;uint32_t od_clk, index; -int ret, feature_enabled; +int ret =0 ; +int feature_enabled;PPCLK_e clk_id; +mutex_lock (&(smu->mutex)); + dpm_table = smu_dpm->dpm_context; golden_table = smu_dpm->golden_dpm_context;
@@ -1956,10 +1973,13 @@ static int vega20_set_od_percentage(struct smu_context *smu, index =OD8_SETTING_UCLK_FMAX ;break ;default : -return -EINVAL ; + ret = -EINVAL ;break ; } +if (ret) + goto set_od_failed; + od_clk = golden_dpm_table->dpm_levels[golden_dpm_table->count -1 ].value * value; od_clk /=100 ; od_clk += golden_dpm_table->dpm_levels[golden_dpm_table->count -1 ].value;
@@ -1967,7 +1987,7 @@ static int vega20_set_od_percentage(struct smu_context *smu, ret =smu_update_od8_settings (smu, index, od_clk);if (ret) {pr_err ("[Setoverdrive] failed to set od clk!\n" ); -return ret; + goto set_od_failed; }if (feature_enabled) {
@@ -1975,14 +1995,19 @@ static int vega20_set_od_percentage(struct smu_context *smu, clk_id);if (ret) {pr_err ("[Setoverdrive] failed to refresh dpm table!\n" ); -return ret; + goto set_od_failed; } }else { single_dpm_table->count =1 ; single_dpm_table->dpm_levels[0 ].value = smu->smu_table.boot_values.gfxclk /100 ; } -return 0 ; + ret =vega20_adjust_power_state_dynamic (smu, smu_dpm->dpm_level); + +set_od_failed: +mutex_unlock (&(smu->mutex)); + +return ret; } static int vega20_odn_edit_dpm_table(struct smu_context *smu,
@@ -1999,7 +2024,8 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu, (struct vega20_od8_settings *)table_context->od8_settings;struct pp_clock_levels_with_latency clocks;int32_t input_index, input_clk, input_vol, i; -int od8_id, ret; +int od8_id; +int ret =0 ; dpm_table = smu_dpm->dpm_context;
@@ -2204,7 +2230,13 @@ static int vega20_odn_edit_dpm_table(struct smu_context *smu,return -EINVAL ; } -return 0 ; +if (type ==PP_OD_COMMIT_DPM_TABLE ) { +mutex_lock (&(smu->mutex)); + ret =vega20_adjust_power_state_dynamic (smu, smu_dpm->dpm_level); +mutex_unlock (&(smu->mutex)); + } + +return ret; }static const struct pptable_funcs vega20_ppt_funcs = {
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 131/138 drm/amd/powerplay: dpm clk can be set only when performance level is manual
In reply to a message not in the archiveFrom: Likun Gao <[email protected]>
Add condition to make dpm clk can not be set when perfomance level isn't equal to manual.
Add mutex lock to smu when set dpm clk.
--- drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/powerplay/vega20_ppt.c +19 -12
@@ -955,7 +955,15 @@ static int vega20_force_clk_levels(struct smu_context *smu,struct vega20_dpm_table *dpm_table;struct vega20_single_dpm_table *single_dpm_table;uint32_t soft_min_level, soft_max_level; -int ret; +struct smu_dpm_context *smu_dpm = &smu->smu_dpm; +int ret =0 ; + +if (smu_dpm->dpm_level !=AMD_DPM_FORCED_LEVEL_MANUAL ) { +pr_info ("force clock level is for dpm manual mode only.\n" ); +return -EINVAL ; + } + +mutex_lock (&(smu->mutex)); soft_min_level = mask ? (ffs (mask) -1 ) :0 ; soft_max_level = mask ? (fls (mask) -1 ) :0 ;
@@ -969,7 +977,8 @@ static int vega20_force_clk_levels(struct smu_context *smu,if (soft_max_level >= single_dpm_table->count) {pr_err ("Clock level specified %d is over max allowed %d\n" , soft_max_level, single_dpm_table->count -1 ); -return -EINVAL ; + ret = -EINVAL ; +break ; } single_dpm_table->dpm_state.soft_min_level =
@@ -980,14 +989,12 @@ static int vega20_force_clk_levels(struct smu_context *smu, ret =vega20_upload_dpm_min_level (smu);if (ret) {pr_err ("Failed to upload boot level to lowest!\n" ); -return ret; +break ; } ret =vega20_upload_dpm_max_level (smu); -if (ret) { +if (ret)pr_err ("Failed to upload dpm max level to highest!\n" ); -return ret; - }break ;
@@ -997,7 +1004,8 @@ static int vega20_force_clk_levels(struct smu_context *smu,if (soft_max_level >= single_dpm_table->count) {pr_err ("Clock level specified %d is over max allowed %d\n" , soft_max_level, single_dpm_table->count -1 ); -return -EINVAL ; + ret = -EINVAL ; +break ; } single_dpm_table->dpm_state.soft_min_level =
@@ -1008,14 +1016,12 @@ static int vega20_force_clk_levels(struct smu_context *smu, ret =vega20_upload_dpm_min_level (smu);if (ret) {pr_err ("Failed to upload boot level to lowest!\n" ); -return ret; +break ; } ret =vega20_upload_dpm_max_level (smu); -if (ret) { +if (ret)pr_err ("Failed to upload dpm max level to highest!\n" ); -return ret; - }break ;
@@ -1026,7 +1032,8 @@ static int vega20_force_clk_levels(struct smu_context *smu,break ; } -return 0 ; +mutex_unlock (&(smu->mutex)); +return ret; } static int vega20_get_clock_by_type_with_latency(struct smu_context *smu,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 132/138 drm/amd/powerplay: implement update enabled feature state to smc for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
change:
1.when enable smu feature, the feature id will store sw-bitmap and smu controller.
2.add feature mutex lock to protect feature bitmap changed when update feature enabled state.
--- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 45 +++++++++++++++++++++--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 4 +++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 47 ++++++++++++++++++++++++-- 3 files changed, 89 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +41 -4
@@ -163,16 +163,20 @@ int smu_feature_init_dpm(struct smu_context *smu)int ret =0 ;uint32_t unallowed_feature_mask[SMU_FEATURE_MAX /32 ]; +mutex_lock (&feature->mutex);bitmap_fill (feature->allowed,SMU_FEATURE_MAX ); +mutex_unlock (&feature->mutex); ret =smu_get_unallowed_feature_mask (smu, unallowed_feature_mask,SMU_FEATURE_MAX /32 );if (ret)return ret; +mutex_lock (&feature->mutex);bitmap_andnot (feature->allowed, feature->allowed, (unsigned long *)unallowed_feature_mask, feature->feature_num); +mutex_unlock (&feature->mutex);return ret; }
@@ -180,38 +184,70 @@ int smu_feature_init_dpm(struct smu_context *smu)int smu_feature_is_enabled (struct smu_context *smu,int feature_id) {struct smu_feature *feature = &smu->smu_feature; +int ret =0 ; +WARN_ON (feature_id > feature->feature_num); -return test_bit (feature_id, feature->enabled); + +mutex_lock (&feature->mutex); + ret =test_bit (feature_id, feature->enabled); +mutex_unlock (&feature->mutex); + +return ret; }int smu_feature_set_enabled (struct smu_context *smu,int feature_id,bool enable) {struct smu_feature *feature = &smu->smu_feature; +int ret =0 ; +WARN_ON (feature_id > feature->feature_num); + +mutex_lock (&feature->mutex); + ret =smu_feature_update_enable_state (smu, feature_id, enable); +if (ret) + goto failed; +if (enable)test_and_set_bit (feature_id, feature->enabled);else test_and_clear_bit (feature_id, feature->enabled); -return 0 ; + +failed: +mutex_unlock (&feature->mutex); + +return ret; }int smu_feature_is_supported (struct smu_context *smu,int feature_id) {struct smu_feature *feature = &smu->smu_feature; +int ret =0 ; +WARN_ON (feature_id > feature->feature_num); -return test_bit (feature_id, feature->supported); + +mutex_lock (&feature->mutex); + ret =test_bit (feature_id, feature->supported); +mutex_unlock (&feature->mutex); + +return ret; }int smu_feature_set_supported (struct smu_context *smu,int feature_id,bool enable) {struct smu_feature *feature = &smu->smu_feature; +int ret =0 ; +WARN_ON (feature_id > feature->feature_num); + +mutex_unlock (&feature->mutex);if (enable)test_and_set_bit (feature_id, feature->supported);else test_and_clear_bit (feature_id, feature->supported); -return 0 ; +mutex_unlock (&feature->mutex); + +return ret; }static int smu_set_funcs (struct amdgpu_device *adev)
@@ -319,6 +355,7 @@ static int smu_sw_init(void *handle) smu->pool_size = adev->pm.smu_prv_buffer_size; smu->smu_feature.feature_num =SMU_FEATURE_MAX ; +mutex_init (&smu->smu_feature.mutex);bitmap_zero (smu->smu_feature.supported,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.enabled,SMU_FEATURE_MAX );bitmap_zero (smu->smu_feature.allowed,SMU_FEATURE_MAX );
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +4 -0
@@ -340,6 +340,7 @@ struct smu_featureDECLARE_BITMAP (supported,SMU_FEATURE_MAX );DECLARE_BITMAP (allowed,SMU_FEATURE_MAX );DECLARE_BITMAP (enabled,SMU_FEATURE_MAX ); +struct mutex mutex; };struct smu_clocks {
@@ -469,6 +470,7 @@ struct smu_funcsint (*get_enabled_mask)(struct smu_context *smu,uint32_t *feature_mask,uint32_t num);int (*enable_all_mask)(struct smu_context *smu);int (*disable_all_mask)(struct smu_context *smu); +int (*update_feature_enable_state)(struct smu_context *smu,uint32_t feature_id,bool enabled);int (*notify_display_change)(struct smu_context *smu);int (*get_power_limit)(struct smu_context *smu);int (*get_current_clk_freq)(struct smu_context *smu,uint32_t clk_id,uint32_t *value);
@@ -580,6 +582,8 @@ struct smu_funcs ((smu)->funcs->enable_all_mask? (smu)->funcs->enable_all_mask((smu)) : 0)#define smu_feature_disable_all (smu) \ ((smu)->funcs->disable_all_mask? (smu)->funcs->disable_all_mask((smu)) : 0) +#define smu_feature_update_enable_state (smu, feature_id, enabled) \ + ((smu)->funcs->update_feature_enable_state? (smu)->funcs->update_feature_enable_state((smu), (feature_id), (enabled)) : 0)#define smu_notify_display_change (smu) \ ((smu)->funcs->notify_display_change? (smu)->funcs->notify_display_change((smu)) : 0)#define smu_store_powerplay_table (smu) \
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +44 -3
77 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 133/138 drm/amd/powerplay: hwmon don't check powerplay when sw smu is enabled
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
when sw-smu is enabled, the driver won't init powerplay structure.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 56 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +30 -26
@@ -2046,18 +2046,20 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_fan1_enable.dev_attr.attr))return 0 ; -/* mask fan attributes if we have no bindings for this asic to expose */ -if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't query fan */ - (!adev->powerplay.pp_funcs->get_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't query state */ - effective_mode &= ~S_IRUGO ; - -if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && - attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ - (!adev->powerplay.pp_funcs->set_fan_control_mode && - attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ - effective_mode &= ~S_IWUSR ; +if (!is_support_sw_smu (adev)) { +/* mask fan attributes if we have no bindings for this asic to expose */ +if ((!adev->powerplay.pp_funcs->get_fan_speed_percent && + attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't query fan */ + (!adev->powerplay.pp_funcs->get_fan_control_mode && + attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't query state */ + effective_mode &= ~S_IRUGO ; + +if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && + attr == &sensor_dev_attr_pwm1.dev_attr.attr) ||/* can't manage fan */ + (!adev->powerplay.pp_funcs->set_fan_control_mode && + attr == &sensor_dev_attr_pwm1_enable.dev_attr.attr))/* can't manage state */ + effective_mode &= ~S_IWUSR ; + } if ((adev->flags & AMD_IS_APU) && (attr == &sensor_dev_attr_power1_cap_max.dev_attr.attr ||
@@ -2065,20 +2067,22 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj, attr == &sensor_dev_attr_power1_cap.dev_attr.attr))return 0 ; -/* hide max/min values if we can't both query and manage the fan */ -if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && - !adev->powerplay.pp_funcs->get_fan_speed_percent) && - (!adev->powerplay.pp_funcs->set_fan_speed_rpm && - !adev->powerplay.pp_funcs->get_fan_speed_rpm) && - (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || - attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) -return 0 ; - -if ((!adev->powerplay.pp_funcs->set_fan_speed_rpm && - !adev->powerplay.pp_funcs->get_fan_speed_rpm) && - (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || - attr == &sensor_dev_attr_fan1_min.dev_attr.attr)) -return 0 ; +if (!is_support_sw_smu (adev)) { +/* hide max/min values if we can't both query and manage the fan */ +if ((!adev->powerplay.pp_funcs->set_fan_speed_percent && + !adev->powerplay.pp_funcs->get_fan_speed_percent) && + (!adev->powerplay.pp_funcs->set_fan_speed_rpm && + !adev->powerplay.pp_funcs->get_fan_speed_rpm) && + (attr == &sensor_dev_attr_pwm1_max.dev_attr.attr || + attr == &sensor_dev_attr_pwm1_min.dev_attr.attr)) +return 0 ; + +if ((!adev->powerplay.pp_funcs->set_fan_speed_rpm && + !adev->powerplay.pp_funcs->get_fan_speed_rpm) && + (attr == &sensor_dev_attr_fan1_max.dev_attr.attr || + attr == &sensor_dev_attr_fan1_min.dev_attr.attr)) +return 0 ; + }/* only APUs have vddnb */ if (!(adev->flags & AMD_IS_APU) &&
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 134/138 drm/amd/powerplay: implement uvd & vce dpm enable functions
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add dpm enable functions for vce,uvd.
--- drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 6 ++++++ drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 25 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+)
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +6 -0
@@ -514,6 +514,8 @@ struct smu_funcsint (*update_od8_settings)(struct smu_context *smu,uint32_t index,uint32_t value); +int (*dpm_set_uvd_enable)(struct smu_context *smu,bool enable); +int (*dpm_set_vce_enable)(struct smu_context *smu,bool enable); };#define smu_init_microcode (smu) \
@@ -659,6 +661,10 @@ struct smu_funcs ((smu)->funcs->notify_smu_enable_pwe ? (smu)->funcs->notify_smu_enable_pwe((smu)) : 0)#define smu_set_watermarks_for_clock_ranges (smu, clock_ranges) \ ((smu)->funcs->set_watermarks_for_clock_ranges ? (smu)->funcs->set_watermarks_for_clock_ranges((smu), (clock_ranges)) : 0) +#define smu_dpm_set_uvd_enable (smu, enable) \ + ((smu)->funcs->dpm_set_uvd_enable ? (smu)->funcs->dpm_set_uvd_enable((smu), (enable)) : 0) +#define smu_dpm_set_vce_enable (smu, enable) \ + ((smu)->funcs->dpm_set_vce_enable ? (smu)->funcs->dpm_set_vce_enable((smu), (enable)) : 0) extern int smu_get_atom_data_table(struct smu_context *smu, uint32_t table,
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +25 -0
@@ -1587,6 +1587,28 @@ static int smu_v11_0_update_od8_settings(struct smu_context *smu,return 0 ; } +static int smu_v11_0_dpm_set_uvd_enable (struct smu_context *smu,bool enable) +{ +if (!smu_feature_is_supported (smu,FEATURE_DPM_VCE_BIT )) +return 0 ; + +if (enable ==smu_feature_is_enabled (smu,FEATURE_DPM_VCE_BIT )) +return 0 ; + +return smu_feature_set_enabled (smu,FEATURE_DPM_VCE_BIT , enable); +} + +static int smu_v11_0_dpm_set_vce_enable (struct smu_context *smu,bool enable) +{ +if (!smu_feature_is_supported (smu,FEATURE_DPM_UVD_BIT )) +return 0 ; + +if (enable ==smu_feature_is_enabled (smu,FEATURE_DPM_UVD_BIT )) +return 0 ; + +return smu_feature_set_enabled (smu,FEATURE_DPM_UVD_BIT , enable); +} +static const struct smu_funcs smu_v11_0_funcs = { .init_microcode = smu_v11_0_init_microcode, .load_microcode = smu_v11_0_load_microcode,
@@ -1632,6 +1654,9 @@ static const struct smu_funcs smu_v11_0_funcs = { .get_power_profile_mode = smu_v11_0_get_power_profile_mode, .set_power_profile_mode = smu_v11_0_set_power_profile_mode, .update_od8_settings = smu_v11_0_update_od8_settings, + .dpm_set_uvd_enable = smu_v11_0_dpm_set_uvd_enable, + .dpm_set_vce_enable = smu_v11_0_dpm_set_vce_enable, + };void smu_v11_0_set_smu_funcs (struct smu_context *smu)
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 135/138 drm/amd/powerplay: implement sensor of uvd & vce power state for smu11
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add functions of uvd & vce for hwmon.
--- drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +8 -0
@@ -1116,6 +1116,14 @@ static int smu_v11_0_read_sensor(struct smu_context *smu, ret =smu_v11_0_get_gfx_vdd (smu, (uint32_t *)data); *size =4 ;break ; +case AMDGPU_PP_SENSOR_UVD_POWER : + *(uint32_t *)data =smu_feature_is_enabled (smu,FEATURE_DPM_UVD_BIT ) ?1 :0 ; + *size =4 ; +break ; +case AMDGPU_PP_SENSOR_VCE_POWER : + *(uint32_t *)data =smu_feature_is_enabled (smu,FEATURE_DPM_VCE_BIT ) ?1 :0 ; + *size =4 ; +break ;default : ret =smu_common_read_sensor (smu, sensor, data, size);break ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 136/138 drm/amd/powerplay: implement dpm enable functions of uvd & vce for smu
In reply to a message not in the archiveFrom: Kevin Wang <[email protected]>
add function of dpm enable uvd & vce for extern module use.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 16 ++++++++++++++-- drivers/gpu/drm/amd/powerplay/amdgpu_smu.c | 18 ++++++++++++++++++ drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h | 2 +- 3 files changed, 33 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +14 -2
@@ -2347,7 +2347,13 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev)void amdgpu_dpm_enable_uvd (struct amdgpu_device *adev,bool enable) { -if (adev->powerplay.pp_funcs->set_powergating_by_smu) { +int ret =0 ; +if (is_support_sw_smu (adev)) { + ret =smu_dpm_set_power_gate (&adev->smu,AMD_IP_BLOCK_TYPE_UVD , enable); +if (ret) +DRM_ERROR ("[SW SMU]: dpm enable uvd failed, state = %s, ret = %d. \n" , + enable ?"true" :"false" , ret); + }else if (adev->powerplay.pp_funcs->set_powergating_by_smu) {/* enable/disable UVD */ mutex_lock (&adev->pm.mutex);amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_UVD , !enable);
@@ -2368,7 +2374,13 @@ void amdgpu_dpm_enable_uvd(struct amdgpu_device *adev, bool enable)void amdgpu_dpm_enable_vce (struct amdgpu_device *adev,bool enable) { -if (adev->powerplay.pp_funcs->set_powergating_by_smu) { +int ret =0 ; +if (is_support_sw_smu (adev)) { + ret =smu_dpm_set_power_gate (&adev->smu,AMD_IP_BLOCK_TYPE_VCE , enable); +if (ret) +DRM_ERROR ("[SW SMU]: dpm enable vce failed, state = %s, ret = %d. \n" , + enable ?"true" :"false" , ret); + }else if (adev->powerplay.pp_funcs->set_powergating_by_smu) {/* enable/disable VCE */ mutex_lock (&adev->pm.mutex);amdgpu_dpm_set_powergating_by_smu (adev,AMD_IP_BLOCK_TYPE_VCE , !enable);
drivers/gpu/drm/amd/powerplay/amdgpu_smu.c +18 -0
@@ -29,6 +29,24 @@#include "smu_v11_0.h" #include "atom.h" +int smu_dpm_set_power_gate (struct smu_context *smu,uint32_t block_type,bool gate) +{ +int ret =0 ; + +switch (block_type) { +case AMD_IP_BLOCK_TYPE_UVD : + ret =smu_dpm_set_uvd_enable (smu, gate); +break ; +case AMD_IP_BLOCK_TYPE_VCE : + ret =smu_dpm_set_vce_enable (smu, gate); +break ; +default : +break ; + } + +return ret; +} +enum amd_pm_state_type smu_get_current_power_state (struct smu_context *smu) {/* not support power state */
drivers/gpu/drm/amd/powerplay/inc/amdgpu_smu.h +1 -1
@@ -697,5 +697,5 @@ extern int smu_display_configuration_change(struct smu_context *smu, const *display_config);extern int smu_get_current_clocks (struct smu_context *smu,struct amd_pp_clock_info *clocks); - +extern int smu_dpm_set_power_gate (struct smu_context *smu,uint32_t block_type,bool gate);#endif
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx