Enable BACO function for VGf10
Subsystems (2)
cover Enable BACO function for VGf10
Bus Alive Chip Off Power mode(BACO) refers to the case in which the power consumption in the GPU is at its lowest level while keeping the PCIe config space alive.
Jim Qu (6):
drm/amdgpu: update nbio v6.1 register/master to support BACO drm/amdgpu: add BACO interfaces in pm and hwmgr function table drm/amdpgu: add common functions for BACO feature in PP drm/amdgpu: add BACO interfaces for vega10 drm/amdgpu: expose BACO interfaces to upper level from PP drm/amdgpu: use BACO reset if platform support
drivers/gpu/drm/amd/amdgpu/soc15.c | 62 +++++++- .../include/asic_reg/nbio/nbio_6_1_offset.h | 2 + .../include/asic_reg/nbio/nbio_6_1_sh_mask.h | 4 + .../gpu/drm/amd/include/kgd_pp_interface.h | 3 + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 54 +++++++ drivers/gpu/drm/amd/powerplay/hwmgr/Makefile | 2 +- .../gpu/drm/amd/powerplay/hwmgr/common_baco.c | 98 +++++++++++++ .../gpu/drm/amd/powerplay/hwmgr/common_baco.h | 50 +++++++ .../gpu/drm/amd/powerplay/hwmgr/vega10_baco.c | 136 ++++++++++++++++++ .../gpu/drm/amd/powerplay/hwmgr/vega10_baco.h | 32 +++++ .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 4 + drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 8 ++ 12 files changed, 451 insertions(+), 4 deletions(-) create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.h create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.c create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.h
Signature · 6 lines
2.17.1 _______________________________________________ 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): [email protected]
PATCH 1/6 drm/amdgpu: update nbio v6.1 register/master to support BACO
--- drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_offset.h | 2 ++ drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h | 4 ++++ 2 files changed, 6 insertions(+)
drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_offset.h +2 -0
@@ -2247,6 +2247,8 @@// addressBlock: nbio_nbif_rcc_strap_BIFDEC1[13440..14975] // base address: 0x3480 +#define mmRCC_BIF_STRAP0 0x0000 +#define mmRCC_BIF_STRAP0_BASE_IDX 2#define mmRCC_DEV0_EPF0_STRAP0 0x000f#define mmRCC_DEV0_EPF0_STRAP0_BASE_IDX 2
drivers/gpu/drm/amd/include/asic_reg/nbio/nbio_6_1_sh_mask.h +4 -0
@@ -16838,6 +16838,10 @@// addressBlock: nbio_nbif_rcc_strap_BIFDEC1[13440..14975] +//RCC_BIF_STRAP0 +#define RCC_BIF_STRAP0__STRAP_PX_CAPABLE__SHIFT 0x7 +#define RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK 0x00000080L +//RCC_DEV0_EPF0_STRAP0 #define RCC_DEV0_EPF0_STRAP0__STRAP_DEVICE_ID_DEV0_F0__SHIFT 0x0#define RCC_DEV0_EPF0_STRAP0__STRAP_MAJOR_REV_ID_DEV0_F0__SHIFT 0x10
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/6 drm/amdgpu: add BACO interfaces in pm and hwmgr function table
In reply to a message not in the archive--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 3 +++ drivers/gpu/drm/amd/powerplay/inc/hwmgr.h | 8 ++++++++ 2 files changed, 11 insertions(+)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +3 -0
@@ -281,6 +281,9 @@ struct amd_pm_funcs {int (*set_hard_min_dcefclk_by_freq)(void *handle,uint32_t clock);int (*set_hard_min_fclk_by_freq)(void *handle,uint32_t clock);int (*set_min_deep_sleep_dcefclk)(void *handle,uint32_t clock); +int (*get_asic_baco_capability)(void *handle,bool *cap); +int (*get_asic_baco_state)(void *handle,int *state); + int (*set_asic_baco_state)(void *handle, int state); };#endif
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +8 -0
@@ -47,6 +47,11 @@ enum DISPLAY_GAP { };typedef enum DISPLAY_GAP DISPLAY_GAP ; +enum BACO_STATE { +BACO_STATE_OUT =0 , +BACO_STATE_IN , +}; +struct vi_dpm_level {bool enabled;uint32_t value;
@@ -333,6 +338,9 @@ struct pp_hwmgr_func {int (*enable_mgpu_fan_boost)(struct pp_hwmgr *hwmgr);int (*set_hard_min_dcefclk_by_freq)(struct pp_hwmgr *hwmgr,uint32_t clock);int (*set_hard_min_fclk_by_freq)(struct pp_hwmgr *hwmgr,uint32_t clock); +int (*get_asic_baco_capability)(struct pp_hwmgr *hwmgr,bool *cap); +int (*get_asic_baco_state)(struct pp_hwmgr *hwmgr,enum BACO_STATE *state); +int (*set_asic_baco_state)(struct pp_hwmgr *hwmgr,enum BACO_STATE state); };struct pp_table_func {
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/6 drm/amdpgu: add common functions for BACO feature in PP
In reply to a message not in the archive--- drivers/gpu/drm/amd/powerplay/hwmgr/Makefile | 2 +- .../gpu/drm/amd/powerplay/hwmgr/common_baco.c | 98 +++++++++++++++++++ .../gpu/drm/amd/powerplay/hwmgr/common_baco.h | 50 ++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.h
drivers/gpu/drm/amd/powerplay/hwmgr/Makefile +1 -1
@@ -35,7 +35,7 @@ HARDWARE_MGR = hwmgr.o processpptables.o \ vega12_thermal.o \ pp_overdriver.o smu_helper.o \ vega20_processpptables.o vega20_hwmgr.o vega20_powertune.o \ - vega20_thermal.o + vega20_thermal.o common_baco.o AMD_PP_HWMGR = $(addprefix $(AMD_PP_PATH)/hwmgr/,$(HARDWARE_MGR))
drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.c new file +98 -0
98 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/hwmgr/common_baco.h new file +50 -0
50 lines not on this page · raw message
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/6 drm/amdgpu: add BACO interfaces for vega10
In reply to a message not in the archiveV2: delay 20ms before BACO out.
V3: rename function to vega10_baco_xxx
--- drivers/gpu/drm/amd/powerplay/hwmgr/Makefile | 2 +- .../gpu/drm/amd/powerplay/hwmgr/vega10_baco.c | 136 ++++++++++++++++++ .../gpu/drm/amd/powerplay/hwmgr/vega10_baco.h | 32 +++++ 3 files changed, 169 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.c create mode 100644 drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.h
drivers/gpu/drm/amd/powerplay/hwmgr/Makefile +1 -1
@@ -35,7 +35,7 @@ HARDWARE_MGR = hwmgr.o processpptables.o \ vega12_thermal.o \ pp_overdriver.o smu_helper.o \ vega20_processpptables.o vega20_hwmgr.o vega20_powertune.o \ - vega20_thermal.o common_baco.o + vega20_thermal.o common_baco.o vega10_baco.o AMD_PP_HWMGR = $(addprefix $(AMD_PP_PATH)/hwmgr/,$(HARDWARE_MGR))
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.c new file +136 -0
136 lines not on this page · raw message
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_baco.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* 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 __VEGA10_BOCO_H__ +#define __VEGA10_BOCO_H__ +#include "hwmgr.h" +#include "common_baco.h" + +extern int vega10_baco_get_capability (struct pp_hwmgr *hwmgr,bool *cap); +extern int vega10_baco_get_state (struct pp_hwmgr *hwmgr,enum BACO_STATE *state); +extern int vega10_baco_set_state (struct pp_hwmgr *hwmgr,enum BACO_STATE state); + +#endif
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/6 drm/amdgpu: expose BACO interfaces to upper level from PP
In reply to a message not in the archive--- drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 54 +++++++++++++++++++ .../drm/amd/powerplay/hwmgr/vega10_hwmgr.c | 4 ++ 2 files changed, 58 insertions(+)
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +54 -0
@@ -1404,6 +1404,57 @@ static int pp_set_active_display_count(void *handle, uint32_t count)return ret; } +static int pp_get_asic_baco_capability (void *handle,bool *cap) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr) +return -EINVAL ; + +if (!hwmgr->pm_en || !hwmgr->hwmgr_func->get_asic_baco_capability) +return 0 ; + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->get_asic_baco_capability (hwmgr, cap); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} + +static int pp_get_asic_baco_state (void *handle,int *state) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr) +return -EINVAL ; + +if (!hwmgr->pm_en || !hwmgr->hwmgr_func->get_asic_baco_state) +return 0 ; + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->get_asic_baco_state (hwmgr, (enum BACO_STATE *)state); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} + +static int pp_set_asic_baco_state (void *handle,int state) +{ +struct pp_hwmgr *hwmgr = handle; + +if (!hwmgr) +return -EINVAL ; + +if (!hwmgr->pm_en || !hwmgr->hwmgr_func->set_asic_baco_state) +return 0 ; + +mutex_lock (&hwmgr->smu_lock); + hwmgr->hwmgr_func->set_asic_baco_state (hwmgr, (enum BACO_STATE )state); +mutex_unlock (&hwmgr->smu_lock); + +return 0 ; +} +static const struct amd_pm_funcs pp_dpm_funcs = { .load_firmware = pp_dpm_load_fw, .wait_for_fw_loading_complete = pp_dpm_fw_loading_complete,
@@ -1454,4 +1505,7 @@ static const struct amd_pm_funcs pp_dpm_funcs = { .set_min_deep_sleep_dcefclk = pp_set_min_deep_sleep_dcefclk, .set_hard_min_dcefclk_by_freq = pp_set_hard_min_dcefclk_by_freq, .set_hard_min_fclk_by_freq = pp_set_hard_min_fclk_by_freq, + .get_asic_baco_capability = pp_get_asic_baco_capability, + .get_asic_baco_state = pp_get_asic_baco_state, + .set_asic_baco_state = pp_set_asic_baco_state, };
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c +4 -0
@@ -48,6 +48,7 @@#include "ppinterrupt.h" #include "pp_overdriver.h" #include "pp_thermal.h" +#include "vega10_baco.h" #include "smuio/smuio_9_0_offset.h" #include "smuio/smuio_9_0_sh_mask.h"
@@ -4980,6 +4981,9 @@ static const struct pp_hwmgr_func vega10_hwmgr_funcs = { .set_power_limit = vega10_set_power_limit, .odn_edit_dpm_table = vega10_odn_edit_dpm_table, .get_performance_level = vega10_get_performance_level, + .get_asic_baco_capability = vega10_baco_get_capability, + .get_asic_baco_state = vega10_baco_get_state, + .set_asic_baco_state = vega10_baco_set_state, };int vega10_hwmgr_init (struct pp_hwmgr *hwmgr)
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/6 drm/amdgpu: use BACO reset if platform support
In reply to a message not in the archiveIt will fall back to use mode1 reset if platform does not support BACO feature.
--- drivers/gpu/drm/amd/amdgpu/soc15.c | 62 ++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/soc15.c +59 -3
@@ -389,14 +389,13 @@ void soc15_program_register_sequence(struct amdgpu_device *adev, } - -static int soc15_asic_reset (struct amdgpu_device *adev) +static int soc15_asic_mode1_reset (struct amdgpu_device *adev) {u32 i;amdgpu_atombios_scratch_regs_engine_hung (adev, true); -dev_info (adev->dev,"GPU reset\n" ); +dev_info (adev->dev,"GPU mode1 reset\n" );/* disable BM */ pci_clear_master (adev->pdev);
@@ -421,6 +420,63 @@ static int soc15_asic_reset(struct amdgpu_device *adev)return 0 ; } +static int soc15_asic_get_baco_capability (struct amdgpu_device *adev,bool *cap) +{ +void *pp_handle = adev->powerplay.pp_handle; +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs || !pp_funcs->get_asic_baco_capability) { + *cap = false; +return -1 ; + } + +return pp_funcs->get_asic_baco_capability (pp_handle, cap); +} + +static int soc15_asic_baco_reset (struct amdgpu_device *adev) +{ +int state; +void *pp_handle = adev->powerplay.pp_handle; +const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; + +if (!pp_funcs ||!pp_funcs->get_asic_baco_state ||!pp_funcs->set_asic_baco_state) +return -1 ; + +/* enter BACO state */ +if (pp_funcs->set_asic_baco_state (pp_handle,1 )) +return -1 ; + +/* exit BACO state */ +if (pp_funcs->set_asic_baco_state (pp_handle,0 )) +return -1 ; + +dev_info (adev->dev,"GPU BACO reset\n" ); + +return 0 ; +} + +static int soc15_asic_reset (struct amdgpu_device *adev) +{ +int ret; +bool baco_reset; + +switch (adev->asic_type) { +case CHIP_VEGA10 : +soc15_asic_get_baco_capability (adev, &baco_reset); +break ; +default : + baco_reset = false; +break ; + } + +if (baco_reset) + ret =soc15_asic_baco_reset (adev); +else + ret =soc15_asic_mode1_reset (adev); + +return ret; +} +/*static int soc15_set_uvd_clock(struct amdgpu_device *adev, u32 clock, u32 cntl_reg, u32 status_reg) {
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx