drm/amd/pm: correct gfx and pcie settings on umd pstate switching
Subsystems (3)
PATCH 1/4 drm/amd/pm: correct gfx and pcie settings on umd pstate switching
For entering UMD stable Pstate, the operations to enter rlc_safe mode, disable mgcg_perfmon and disable PCIE aspm are needed. And the opposite operations should be performed on UMD stable Pstate exiting.
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/nv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/soc15.c | 7 +++++++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 ++ 4 files changed, 19 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +3 -0
@@ -617,6 +617,8 @@ struct amdgpu_asic_funcs {uint64_t (*get_pcie_replay_count)(struct amdgpu_device *adev);/* device supports BACO */ bool (*supports_baco)(struct amdgpu_device *adev); +/* enter/exit umd stable pstate */ +int (*update_umd_stable_pstate)(struct amdgpu_device *adev,bool enter); };/*
@@ -1132,6 +1134,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_need_reset_on_init (adev) (adev)->asic_funcs->need_reset_on_init((adev))#define amdgpu_asic_get_pcie_replay_count (adev) ((adev)->asic_funcs->get_pcie_replay_count((adev)))#define amdgpu_asic_supports_baco (adev) (adev)->asic_funcs->supports_baco((adev)) +#define amdgpu_asic_update_umd_stable_pstate (adev, enter) (adev)->asic_funcs->update_umd_stable_pstate((adev), (enter))#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter));
drivers/gpu/drm/amd/amdgpu/nv.c +7 -0
@@ -691,6 +691,12 @@ static void nv_init_doorbell_index(struct amdgpu_device *adev) adev->doorbell_index.sdma_doorbell_range =20 ; } +static int nv_update_umd_stable_pstate (struct amdgpu_device *adev, +bool enter) +{ +return 0 ; +} +static const struct amdgpu_asic_funcs nv_asic_funcs = { .read_disabled_bios = &nv_read_disabled_bios,
@@ -710,6 +716,7 @@ static const struct amdgpu_asic_funcs nv_asic_funcs = .need_reset_on_init = &nv_need_reset_on_init, .get_pcie_replay_count = &nv_get_pcie_replay_count, .supports_baco = &nv_asic_supports_baco, + .update_umd_stable_pstate = &nv_update_umd_stable_pstate, };static int nv_common_early_init (void *handle)
drivers/gpu/drm/amd/amdgpu/soc15.c +7 -0
@@ -1029,6 +1029,12 @@ static uint64_t soc15_get_pcie_replay_count(struct amdgpu_device *adev)return (nak_r + nak_g); } +static int soc15_update_umd_stable_pstate (struct amdgpu_device *adev, +bool enter) +{ +return 0 ; +} +static const struct amdgpu_asic_funcs soc15_asic_funcs = { .read_disabled_bios = &soc15_read_disabled_bios,
@@ -1049,6 +1055,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs = .need_reset_on_init = &soc15_need_reset_on_init, .get_pcie_replay_count = &soc15_get_pcie_replay_count, .supports_baco = &soc15_supports_baco, + .update_umd_stable_pstate = &soc15_update_umd_stable_pstate, }; static const struct amdgpu_asic_funcs vega20_asic_funcs =
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -0
@@ -1442,6 +1442,7 @@ static int smu_enable_umd_pstate(void *handle, AMD_CG_STATE_UNGATE);smu_gfx_ulv_control (smu, false);smu_deep_sleep_control (smu, false); +amdgpu_asic_update_umd_stable_pstate (smu->adev, true); } }else {/* exit umd pstate, restore level, enable gfx cg*/
@@ -1449,6 +1450,7 @@ static int smu_enable_umd_pstate(void *handle,if (*level ==AMD_DPM_FORCED_LEVEL_PROFILE_EXIT ) *level = smu_dpm_ctx->saved_dpm_level; smu_dpm_ctx->enable_umd_pstate = false; +amdgpu_asic_update_umd_stable_pstate (smu->adev, false);smu_deep_sleep_control (smu, true);smu_gfx_ulv_control (smu, true); amdgpu_device_ip_set_clockgating_state(smu->adev,
Signature · 6 lines
2.28.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amdgpu: add interface for setting ASPM
Support NAVI10 ASPM setting.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h | 2 ++ drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c | 39 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h +2 -0
@@ -85,6 +85,8 @@ struct amdgpu_nbio_funcs {void (*query_ras_error_count)(struct amdgpu_device *adev,void *ras_error_status);int (*ras_late_init)(struct amdgpu_device *adev); +void (*enable_aspm)(struct amdgpu_device *adev, +bool enable); };struct amdgpu_nbio {
drivers/gpu/drm/amd/amdgpu/nbio_v2_3.c +39 -0
@@ -28,10 +28,12 @@#include "nbio/nbio_2_3_offset.h" #include "nbio/nbio_2_3_sh_mask.h" #include <uapi/linux/kfd_ioctl.h> +#include <linux/pci.h> #define smnPCIE_CONFIG_CNTL 0x11180044#define smnCPM_CONTROL 0x11180460#define smnPCIE_CNTL2 0x11180070 +#define smnPCIE_LC_CNTL 0x11140280#define mmBIF_SDMA2_DOORBELL_RANGE 0x01d6#define mmBIF_SDMA2_DOORBELL_RANGE_BASE_IDX 2
@@ -312,6 +314,42 @@ static void nbio_v2_3_init_registers(struct amdgpu_device *adev)WREG32_PCIE (smnPCIE_CONFIG_CNTL, data); } +#define NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT 0x00000000 // off by default, no gains over L1 +#define NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT 0x00000009 // 1=1us, 9=1ms +#define NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT 0x0000000E // 4ms + +static void nbio_v2_3_enable_aspm (struct amdgpu_device *adev, +bool enable) +{ +uint32_t def, data; + + def = data =RREG32_PCIE (smnPCIE_LC_CNTL); + +if (enable) { +/* Disable ASPM L0s/L1 first */ + data &= ~(PCIE_LC_CNTL__LC_L0S_INACTIVITY_MASK |PCIE_LC_CNTL__LC_L1_INACTIVITY_MASK ); + + data |=NAVI10_PCIE__LC_L0S_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L0S_INACTIVITY__SHIFT ; + +if (pci_is_thunderbolt_attached (adev->pdev)) + data |=NAVI10_PCIE__LC_L1_INACTIVITY_TBT_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ; +else + data |=NAVI10_PCIE__LC_L1_INACTIVITY_DEFAULT <<PCIE_LC_CNTL__LC_L1_INACTIVITY__SHIFT ; + + data &= ~PCIE_LC_CNTL__LC_PMI_TO_L1_DIS_MASK ; + }else { +/* Disbale ASPM L1 */ + data &= ~PCIE_LC_CNTL__LC_L1_INACTIVITY_MASK ; +/* Disable ASPM TxL0s */ + data &= ~PCIE_LC_CNTL__LC_L0S_INACTIVITY_MASK ; +/* Disable ACPI L1 */ + data |=PCIE_LC_CNTL__LC_PMI_TO_L1_DIS_MASK ; + } + +if (def != data) +WREG32_PCIE (smnPCIE_LC_CNTL, data); +} +const struct amdgpu_nbio_funcs nbio_v2_3_funcs = { .get_hdp_flush_req_offset = nbio_v2_3_get_hdp_flush_req_offset, .get_hdp_flush_done_offset = nbio_v2_3_get_hdp_flush_done_offset,
@@ -332,4 +370,5 @@ const struct amdgpu_nbio_funcs nbio_v2_3_funcs = { .ih_control = nbio_v2_3_ih_control, .init_registers = nbio_v2_3_init_registers, .remap_hdp_registers = nbio_v2_3_remap_hdp_registers, + .enable_aspm = nbio_v2_3_enable_aspm, };
Signature · 6 lines
2.28.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: add interface for setting MGCG perfmon
In reply to Evan QuanEnable Navi1X MGCG perfmon setting.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h | 1 + drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h +1 -0
@@ -217,6 +217,7 @@ struct amdgpu_gfx_funcs {int (*query_ras_error_count) (struct amdgpu_device *adev,void *ras_error_status);void (*reset_ras_error_count) (struct amdgpu_device *adev);void (*init_spm_golden)(struct amdgpu_device *adev); +void (*update_perfmon_mgcg)(struct amdgpu_device *adev,bool enable); };struct sq_work {
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +16 -0
@@ -4156,6 +4156,21 @@ static void gfx_v10_0_select_me_pipe_q(struct amdgpu_device *adev,nv_grbm_select (adev, me, pipe, q, vm); } +static void gfx_v10_0_update_perfmon_mgcg (struct amdgpu_device *adev, +bool enable) +{ +uint32_t data, def; + + data = def =RREG32_SOC15 (GC ,0 , mmRLC_PERFMON_CLK_CNTL); + +if (enable) + data |=RLC_PERFMON_CLK_CNTL__PERFMON_CLOCK_STATE_MASK ; +else + data &= ~RLC_PERFMON_CLK_CNTL__PERFMON_CLOCK_STATE_MASK ; + +if (data != def) +WREG32_SOC15 (GC ,0 , mmRLC_PERFMON_CLK_CNTL, data); +}static const struct amdgpu_gfx_funcs gfx_v10_0_gfx_funcs = { .get_gpu_clock_counter = &gfx_v10_0_get_gpu_clock_counter,
@@ -4165,6 +4180,7 @@ static const struct amdgpu_gfx_funcs gfx_v10_0_gfx_funcs = { .read_wave_vgprs = &gfx_v10_0_read_wave_vgprs, .select_me_pipe_q = &gfx_v10_0_select_me_pipe_q, .init_spm_golden = &gfx_v10_0_init_spm_golden_registers, + .update_perfmon_mgcg = &gfx_v10_0_update_perfmon_mgcg, };static void gfx_v10_0_gpu_early_init (struct amdgpu_device *adev)
Signature · 6 lines
2.28.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: fulfill Navi gfx and pcie settings on umd pstate switching(V2)
In reply to Evan QuanFulfill Navi gfx and pcie settings on umd pstate switching.
V2: temporarily skip the pcie ASPM setting considering the ASPM function
is not fully enabled yet
--- drivers/gpu/drm/amd/amdgpu/nv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/gpu/drm/amd/amdgpu/nv.c +17 -0
@@ -694,6 +694,23 @@ static void nv_init_doorbell_index(struct amdgpu_device *adev)static int nv_update_umd_stable_pstate (struct amdgpu_device *adev,bool enter) { +if (enter) +amdgpu_gfx_rlc_enter_safe_mode (adev); +else +amdgpu_gfx_rlc_exit_safe_mode (adev); + +if (adev->gfx.funcs->update_perfmon_mgcg) + adev->gfx.funcs->update_perfmon_mgcg (adev, !enter); + +/* +* The ASPM function is not fully enabled and verified on +* Navi yet. Temporarily skip this until ASPM enabled. +*/ +#if 0 +if (adev->nbio.funcs->enable_aspm) + adev->nbio.funcs->enable_aspm (adev, !enter); +#endif +return 0 ; }
Signature · 6 lines
2.28.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/amdgpu: fulfill Navi gfx and pcie settings on umd pstate switching(V2)
Series is Acked-by: Nirmoy Das <[email protected]>
Quoted 29 lines · Evan Quan
Fulfill Navi gfx and pcie settings on umd pstate switching.
V2: temporarily skip the pcie ASPM setting considering the ASPM function
is not fully enabled yetChange-Id I8d746d4c25f890665feeffddf64164ed2b1f5cccSigned-off-by Evan Quan <[email protected]>--- drivers/gpu/drm/amd/amdgpu/nv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)drivers/gpu/drm/amd/amdgpu/nv.c +10
-0@@ -694,6 +694,23 @@ static void nv_init_doorbell_index(struct amdgpu_device *adev)static int nv_update_umd_stable_pstate (struct amdgpu_device *adev,bool enter) { +if (enter) +amdgpu_gfx_rlc_enter_safe_mode (adev); +else +amdgpu_gfx_rlc_exit_safe_mode (adev); + +if (adev->gfx.funcs->update_perfmon_mgcg) + adev->gfx.funcs->update_perfmon_mgcg (adev, !enter); + +/* +* The ASPM function is not fully enabled and verified on
drivers/gpu/drm/amd/amdgpu/nv.c static void nv_init_doorbell_index(struct amdgpu_device *adev) · line 716
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/nv.c +7
-0+* Navi yet. Temporarily skip this until ASPM enabled. +*/ +#if 0 +if (adev->nbio.funcs->enable_aspm) + adev->nbio.funcs->enable_aspm (adev, !enter); +#endif +return 0 ; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 8 lines · Evan Quan
For entering UMD stable Pstate, the operations to enter
rlc_safemode, disablemgcg_perfmonand disable PCIE aspm are needed. And the opposite operations should be performed on UMD stable Pstate exiting.Change-Id Iff4aa465fd16f55a4f4de8ee0503997b204f8f9dSigned-off-by Evan Quan <[email protected]>
Might want to add stub callbacks for si.c, cik.c, vi.c as well to avoid unwanted crashes if this ends up getting used elsewhere.
Alex
Quoted 101 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 +++ drivers/gpu/drm/amd/amdgpu/nv.c | 7 +++++++ drivers/gpu/drm/amd/amdgpu/soc15.c | 7 +++++++ drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 2 ++ 4 files changed, 19 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu.h +3
-0@@ -617,6 +617,8 @@ struct amdgpu_asic_funcs {uint64_t (*get_pcie_replay_count)(struct amdgpu_device *adev);/* device supports BACO */ bool (*supports_baco)(struct amdgpu_device *adev); +/* enter/exit umd stable pstate */ +int (*update_umd_stable_pstate)(struct amdgpu_device *adev,bool enter); };/* @@ -1132,6 +1134,7 @@ int emu_soc_asic_init(struct amdgpu_device *adev);#define amdgpu_asic_need_reset_on_init (adev) (adev)->asic_funcs->need_reset_on_init((adev))#define amdgpu_asic_get_pcie_replay_count (adev) ((adev)->asic_funcs->get_pcie_replay_count((adev)))#define amdgpu_asic_supports_baco (adev) (adev)->asic_funcs->supports_baco((adev)) +#define amdgpu_asic_update_umd_stable_pstate (adev, enter) (adev)->asic_funcs->update_umd_stable_pstate((adev), (enter))#define amdgpu_inc_vram_lost (adev) atomic_inc(&((adev)->vram_lost_counter));drivers/gpu/drm/amd/amdgpu/nv.c +7
-0@@ -691,6 +691,12 @@ static void nv_init_doorbell_index(struct amdgpu_device *adev) adev->doorbell_index.sdma_doorbell_range =20 ; } +static int nv_update_umd_stable_pstate (struct amdgpu_device *adev, +bool enter) +{ +return 0 ; +} +static const struct amdgpu_asic_funcs nv_asic_funcs = { .read_disabled_bios = &nv_read_disabled_bios,@@ -710,6 +716,7 @@ static const struct amdgpu_asic_funcs nv_asic_funcs = .need_reset_on_init = &nv_need_reset_on_init, .get_pcie_replay_count = &nv_get_pcie_replay_count, .supports_baco = &nv_asic_supports_baco, + .update_umd_stable_pstate = &nv_update_umd_stable_pstate, };static int nv_common_early_init (void *handle)drivers/gpu/drm/amd/amdgpu/soc15.c +7
-0@@ -1029,6 +1029,12 @@ static uint64_t soc15_get_pcie_replay_count(struct amdgpu_device *adev)return (nak_r + nak_g); } +static int soc15_update_umd_stable_pstate (struct amdgpu_device *adev, +bool enter) +{ +return 0 ; +} +static const struct amdgpu_asic_funcs soc15_asic_funcs = { .read_disabled_bios = &soc15_read_disabled_bios,@@ -1049,6 +1055,7 @@ static const struct amdgpu_asic_funcs soc15_asic_funcs = .need_reset_on_init = &soc15_need_reset_on_init, .get_pcie_replay_count = &soc15_get_pcie_replay_count, .supports_baco = &soc15_supports_baco, + .update_umd_stable_pstate = &soc15_update_umd_stable_pstate, }; static const struct amdgpu_asic_funcs vega20_asic_funcs =drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2
-1@@ -1442,6 +1442,7 @@ static int smu_enable_umd_pstate(void *handle, AMD_CG_STATE_UNGATE);smu_gfx_ulv_control (smu, false);smu_deep_sleep_control (smu, false); +amdgpu_asic_update_umd_stable_pstate (smu->adev, true); } }else {/* exit umd pstate, restore level, enable gfx cg*/ @@ -1449,6 +1450,7 @@ static int smu_enable_umd_pstate(void *handle,if (*level ==AMD_DPM_FORCED_LEVEL_PROFILE_EXIT ) *level = smu_dpm_ctx->saved_dpm_level; smu_dpm_ctx->enable_umd_pstate = false; +amdgpu_asic_update_umd_stable_pstate (smu->adev, false);smu_deep_sleep_control (smu, true);smu_gfx_ulv_control (smu, true); amdgpu_device_ip_set_clockgating_state(smu->adev, --2.28.0
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx