drm/amd/pm runtime pm changes
Subsystems (3)
cover drm/amd/pm runtime pm changes
This series rework how runtime power management is handled in drm/amd/pm.
The main ideas are:
* simplify code and reduce copy-pate of runtimepm calls
* avoid waking up suspended GPU when reading debugfs files.
It is similar to Mario's earlier series:
https://lists.freedesktop.org/archives/amd-gfx/2024-August/113213.html
It's not a direct successor of it, hence v1.
Instead, this is part of a larger series that applies the same ideas to the whole amdgpu module.
Pierre-Eric Pelloux-Prayer (9):
drm/amd/pm: remove dump_pptable functions
drm/amd/pm: fix rpm refcount handling on error
drm/amd/pm: use pm_runtime_resume_and_get
drm/amd/pm: don't update runpm last_usage on debugfs getter drm/amd/pm: use pm_runtime_get_if_active for debugfs getters drm/amd/pm: stop extra checks for runtime pm state drm/amd/pm: add sysfs attribute access wrappers drm/amd/pm: move private definitions to the .c file drm/amd/pm: use pm_runtime_get_if_active in amdgpu_debugfs_sensor_read
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 9 +- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 734 +++------- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 96 -- .../powerplay/hwmgr/vega20_processpptables.c | 574 -------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 433 ------ .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 1269 ----------------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 14 - .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 14 - .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 14 - drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 1 - 11 files changed, 208 insertions(+), 2955 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/9 drm/amd/pm: remove dump_pptable functions
They're not used.
--- .../powerplay/hwmgr/vega20_processpptables.c | 574 -------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 433 ------ .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 1269 ----------------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 14 - .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 14 - .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 14 - drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 1 - 8 files changed, 2324 deletions(-)
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega20_processpptables.c +0 -574
@@ -62,578 +62,6 @@ static const void *get_powerplay_table(struct pp_hwmgr *hwmgr)return table_address; } -#if 0 -static void dump_pptable (PPTable_t *pptable) -{ -int i; - -pr_info ("Version = 0x%08x\n" , pptable->Version); - -pr_info ("FeaturesToRun[0] = 0x%08x\n" , pptable->FeaturesToRun[0 ]); -pr_info ("FeaturesToRun[1] = 0x%08x\n" , pptable->FeaturesToRun[1 ]); - -pr_info ("SocketPowerLimitAc0 = %d\n" , pptable->SocketPowerLimitAc0); -pr_info ("SocketPowerLimitAc0Tau = %d\n" , pptable->SocketPowerLimitAc0Tau); -pr_info ("SocketPowerLimitAc1 = %d\n" , pptable->SocketPowerLimitAc1); -pr_info ("SocketPowerLimitAc1Tau = %d\n" , pptable->SocketPowerLimitAc1Tau); -pr_info ("SocketPowerLimitAc2 = %d\n" , pptable->SocketPowerLimitAc2); -pr_info ("SocketPowerLimitAc2Tau = %d\n" , pptable->SocketPowerLimitAc2Tau); -pr_info ("SocketPowerLimitAc3 = %d\n" , pptable->SocketPowerLimitAc3); -pr_info ("SocketPowerLimitAc3Tau = %d\n" , pptable->SocketPowerLimitAc3Tau); -pr_info ("SocketPowerLimitDc = %d\n" , pptable->SocketPowerLimitDc); -pr_info ("SocketPowerLimitDcTau = %d\n" , pptable->SocketPowerLimitDcTau); -pr_info ("TdcLimitSoc = %d\n" , pptable->TdcLimitSoc); -pr_info ("TdcLimitSocTau = %d\n" , pptable->TdcLimitSocTau); -pr_info ("TdcLimitGfx = %d\n" , pptable->TdcLimitGfx); -pr_info ("TdcLimitGfxTau = %d\n" , pptable->TdcLimitGfxTau); - -pr_info ("TedgeLimit = %d\n" , pptable->TedgeLimit); -pr_info ("ThotspotLimit = %d\n" , pptable->ThotspotLimit); -pr_info ("ThbmLimit = %d\n" , pptable->ThbmLimit); -pr_info ("Tvr_gfxLimit = %d\n" , pptable->Tvr_gfxLimit); -pr_info ("Tvr_memLimit = %d\n" , pptable->Tvr_memLimit); -pr_info ("Tliquid1Limit = %d\n" , pptable->Tliquid1Limit); -pr_info ("Tliquid2Limit = %d\n" , pptable->Tliquid2Limit); -pr_info ("TplxLimit = %d\n" , pptable->TplxLimit); -pr_info ("FitLimit = %d\n" , pptable->FitLimit); - -pr_info ("PpmPowerLimit = %d\n" , pptable->PpmPowerLimit); -pr_info ("PpmTemperatureThreshold = %d\n" , pptable->PpmTemperatureThreshold); - -pr_info ("MemoryOnPackage = 0x%02x\n" , pptable->MemoryOnPackage); -pr_info ("padding8_limits = 0x%02x\n" , pptable->padding8_limits); -pr_info ("Tvr_SocLimit = %d\n" , pptable->Tvr_SocLimit); - -pr_info ("UlvVoltageOffsetSoc = %d\n" , pptable->UlvVoltageOffsetSoc); -pr_info ("UlvVoltageOffsetGfx = %d\n" , pptable->UlvVoltageOffsetGfx); - -pr_info ("UlvSmnclkDid = %d\n" , pptable->UlvSmnclkDid); -pr_info ("UlvMp1clkDid = %d\n" , pptable->UlvMp1clkDid); -pr_info ("UlvGfxclkBypass = %d\n" , pptable->UlvGfxclkBypass); -pr_info ("Padding234 = 0x%02x\n" , pptable->Padding234); - -pr_info ("MinVoltageGfx = %d\n" , pptable->MinVoltageGfx); -pr_info ("MinVoltageSoc = %d\n" , pptable->MinVoltageSoc); -pr_info ("MaxVoltageGfx = %d\n" , pptable->MaxVoltageGfx); -pr_info ("MaxVoltageSoc = %d\n" , pptable->MaxVoltageSoc); - -pr_info ("LoadLineResistanceGfx = %d\n" , pptable->LoadLineResistanceGfx); -pr_info ("LoadLineResistanceSoc = %d\n" , pptable->LoadLineResistanceSoc); - -pr_info ("[PPCLK_GFXCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_GFXCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_GFXCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_GFXCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_GFXCLK ].padding, - pptable->DpmDescriptor[PPCLK_GFXCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_GFXCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_GFXCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_GFXCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_GFXCLK ].SsCurve.c); - -pr_info ("[PPCLK_VCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_VCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_VCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_VCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_VCLK ].padding, - pptable->DpmDescriptor[PPCLK_VCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_VCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_VCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_VCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_VCLK ].SsCurve.c); - -pr_info ("[PPCLK_DCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_DCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_DCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_DCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_DCLK ].padding, - pptable->DpmDescriptor[PPCLK_DCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_DCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_DCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_DCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_DCLK ].SsCurve.c); - -pr_info ("[PPCLK_ECLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_ECLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_ECLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_ECLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_ECLK ].padding, - pptable->DpmDescriptor[PPCLK_ECLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_ECLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_ECLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_ECLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_ECLK ].SsCurve.c); - -pr_info ("[PPCLK_SOCCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_SOCCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_SOCCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_SOCCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_SOCCLK ].padding, - pptable->DpmDescriptor[PPCLK_SOCCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_SOCCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_SOCCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_SOCCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_SOCCLK ].SsCurve.c); - -pr_info ("[PPCLK_UCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_UCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_UCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_UCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_UCLK ].padding, - pptable->DpmDescriptor[PPCLK_UCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_UCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_UCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_UCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_UCLK ].SsCurve.c); - -pr_info ("[PPCLK_DCEFCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_DCEFCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].padding, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_DCEFCLK ].SsCurve.c); - -pr_info ("[PPCLK_DISPCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_DISPCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_DISPCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_DISPCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_DISPCLK ].padding, - pptable->DpmDescriptor[PPCLK_DISPCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_DISPCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_DISPCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_DISPCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_DISPCLK ].SsCurve.c); - -pr_info ("[PPCLK_PIXCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_PIXCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_PIXCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_PIXCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_PIXCLK ].padding, - pptable->DpmDescriptor[PPCLK_PIXCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_PIXCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_PIXCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_PIXCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_PIXCLK ].SsCurve.c); - -pr_info ("[PPCLK_PHYCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_PHYCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_PHYCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_PHYCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_PHYCLK ].padding, - pptable->DpmDescriptor[PPCLK_PHYCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_PHYCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_PHYCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_PHYCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_PHYCLK ].SsCurve.c); - -pr_info ("[PPCLK_FCLK]\n" -" .VoltageMode = 0x%02x\n" -" .SnapToDiscrete = 0x%02x\n" -" .NumDiscreteLevels = 0x%02x\n" -" .padding = 0x%02x\n" -" .ConversionToAvfsClk{m = 0x%08x b = 0x%08x}\n" -" .SsCurve {a = 0x%08x b = 0x%08x c = 0x%08x}\n" , - pptable->DpmDescriptor[PPCLK_FCLK ].VoltageMode, - pptable->DpmDescriptor[PPCLK_FCLK ].SnapToDiscrete, - pptable->DpmDescriptor[PPCLK_FCLK ].NumDiscreteLevels, - pptable->DpmDescriptor[PPCLK_FCLK ].padding, - pptable->DpmDescriptor[PPCLK_FCLK ].ConversionToAvfsClk.m, - pptable->DpmDescriptor[PPCLK_FCLK ].ConversionToAvfsClk.b, - pptable->DpmDescriptor[PPCLK_FCLK ].SsCurve.a, - pptable->DpmDescriptor[PPCLK_FCLK ].SsCurve.b, - pptable->DpmDescriptor[PPCLK_FCLK ].SsCurve.c); - - -pr_info ("FreqTableGfx\n" ); -for (i =0 ; i <NUM_GFXCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableGfx[i]); - -pr_info ("FreqTableVclk\n" ); -for (i =0 ; i <NUM_VCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableVclk[i]); - -pr_info ("FreqTableDclk\n" ); -for (i =0 ; i <NUM_DCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableDclk[i]); - -pr_info ("FreqTableEclk\n" ); -for (i =0 ; i <NUM_ECLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableEclk[i]); - -pr_info ("FreqTableSocclk\n" ); -for (i =0 ; i <NUM_SOCCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableSocclk[i]); - -pr_info ("FreqTableUclk\n" ); -for (i =0 ; i <NUM_UCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableUclk[i]); - -pr_info ("FreqTableFclk\n" ); -for (i =0 ; i <NUM_FCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableFclk[i]); - -pr_info ("FreqTableDcefclk\n" ); -for (i =0 ; i <NUM_DCEFCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableDcefclk[i]); - -pr_info ("FreqTableDispclk\n" ); -for (i =0 ; i <NUM_DISPCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTableDispclk[i]); - -pr_info ("FreqTablePixclk\n" ); -for (i =0 ; i <NUM_PIXCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTablePixclk[i]); - -pr_info ("FreqTablePhyclk\n" ); -for (i =0 ; i <NUM_PHYCLK_DPM_LEVELS ; i++) -pr_info (" .[%02d] = %d\n" , i, pptable->FreqTablePhyclk[i]); - -pr_info ("DcModeMaxFreq[PPCLK_GFXCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_GFXCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_VCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_VCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_DCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_DCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_ECLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_ECLK ]); -pr_info ("DcModeMaxFreq[PPCLK_SOCCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_SOCCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_UCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_UCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_DCEFCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_DCEFCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_DISPCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_DISPCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_PIXCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_PIXCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_PHYCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_PHYCLK ]); -pr_info ("DcModeMaxFreq[PPCLK_FCLK] = %d\n" , pptable->DcModeMaxFreq[PPCLK_FCLK ]); -pr_info ("Padding8_Clks = %d\n" , pptable->Padding8_Clks); - -pr_info ("Mp0clkFreq\n" ); -for (i =0 ; i <NUM_MP0CLK_DPM_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->Mp0clkFreq[i]); - -pr_info ("Mp0DpmVoltage\n" ); -for (i =0 ; i <NUM_MP0CLK_DPM_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->Mp0DpmVoltage[i]); - -pr_info ("GfxclkFidle = 0x%x\n" , pptable->GfxclkFidle); -pr_info ("GfxclkSlewRate = 0x%x\n" , pptable->GfxclkSlewRate); -pr_info ("CksEnableFreq = 0x%x\n" , pptable->CksEnableFreq); -pr_info ("Padding789 = 0x%x\n" , pptable->Padding789); -pr_info ("CksVoltageOffset[a = 0x%08x b = 0x%08x c = 0x%08x]\n" , - pptable->CksVoltageOffset.a, - pptable->CksVoltageOffset.b, - pptable->CksVoltageOffset.c); -pr_info ("Padding567[0] = 0x%x\n" , pptable->Padding567[0 ]); -pr_info ("Padding567[1] = 0x%x\n" , pptable->Padding567[1 ]); -pr_info ("Padding567[2] = 0x%x\n" , pptable->Padding567[2 ]); -pr_info ("Padding567[3] = 0x%x\n" , pptable->Padding567[3 ]); -pr_info ("GfxclkDsMaxFreq = %d\n" , pptable->GfxclkDsMaxFreq); -pr_info ("GfxclkSource = 0x%x\n" , pptable->GfxclkSource); -pr_info ("Padding456 = 0x%x\n" , pptable->Padding456); - -pr_info ("LowestUclkReservedForUlv = %d\n" , pptable->LowestUclkReservedForUlv); -pr_info ("Padding8_Uclk[0] = 0x%x\n" , pptable->Padding8_Uclk[0 ]); -pr_info ("Padding8_Uclk[1] = 0x%x\n" , pptable->Padding8_Uclk[1 ]); -pr_info ("Padding8_Uclk[2] = 0x%x\n" , pptable->Padding8_Uclk[2 ]); - -pr_info ("PcieGenSpeed\n" ); -for (i =0 ; i <NUM_LINK_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->PcieGenSpeed[i]); - -pr_info ("PcieLaneCount\n" ); -for (i =0 ; i <NUM_LINK_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->PcieLaneCount[i]); - -pr_info ("LclkFreq\n" ); -for (i =0 ; i <NUM_LINK_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->LclkFreq[i]); - -pr_info ("EnableTdpm = %d\n" , pptable->EnableTdpm); -pr_info ("TdpmHighHystTemperature = %d\n" , pptable->TdpmHighHystTemperature); -pr_info ("TdpmLowHystTemperature = %d\n" , pptable->TdpmLowHystTemperature); -pr_info ("GfxclkFreqHighTempLimit = %d\n" , pptable->GfxclkFreqHighTempLimit); - -pr_info ("FanStopTemp = %d\n" , pptable->FanStopTemp); -pr_info ("FanStartTemp = %d\n" , pptable->FanStartTemp); - -pr_info ("FanGainEdge = %d\n" , pptable->FanGainEdge); -pr_info ("FanGainHotspot = %d\n" , pptable->FanGainHotspot); -pr_info ("FanGainLiquid = %d\n" , pptable->FanGainLiquid); -pr_info ("FanGainVrGfx = %d\n" , pptable->FanGainVrGfx); -pr_info ("FanGainVrSoc = %d\n" , pptable->FanGainVrSoc); -pr_info ("FanGainPlx = %d\n" , pptable->FanGainPlx); -pr_info ("FanGainHbm = %d\n" , pptable->FanGainHbm); -pr_info ("FanPwmMin = %d\n" , pptable->FanPwmMin); -pr_info ("FanAcousticLimitRpm = %d\n" , pptable->FanAcousticLimitRpm); -pr_info ("FanThrottlingRpm = %d\n" , pptable->FanThrottlingRpm); -pr_info ("FanMaximumRpm = %d\n" , pptable->FanMaximumRpm); -pr_info ("FanTargetTemperature = %d\n" , pptable->FanTargetTemperature); -pr_info ("FanTargetGfxclk = %d\n" , pptable->FanTargetGfxclk); -pr_info ("FanZeroRpmEnable = %d\n" , pptable->FanZeroRpmEnable); -pr_info ("FanTachEdgePerRev = %d\n" , pptable->FanTachEdgePerRev); - -pr_info ("FuzzyFan_ErrorSetDelta = %d\n" , pptable->FuzzyFan_ErrorSetDelta); -pr_info ("FuzzyFan_ErrorRateSetDelta = %d\n" , pptable->FuzzyFan_ErrorRateSetDelta); -pr_info ("FuzzyFan_PwmSetDelta = %d\n" , pptable->FuzzyFan_PwmSetDelta); -pr_info ("FuzzyFan_Reserved = %d\n" , pptable->FuzzyFan_Reserved); - -pr_info ("OverrideAvfsGb[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->OverrideAvfsGb[AVFS_VOLTAGE_GFX ]); -pr_info ("OverrideAvfsGb[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->OverrideAvfsGb[AVFS_VOLTAGE_SOC ]); -pr_info ("Padding8_Avfs[0] = %d\n" , pptable->Padding8_Avfs[0 ]); -pr_info ("Padding8_Avfs[1] = %d\n" , pptable->Padding8_Avfs[1 ]); - -pr_info ("qAvfsGb[AVFS_VOLTAGE_GFX]{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->qAvfsGb[AVFS_VOLTAGE_GFX ].a, - pptable->qAvfsGb[AVFS_VOLTAGE_GFX ].b, - pptable->qAvfsGb[AVFS_VOLTAGE_GFX ].c); -pr_info ("qAvfsGb[AVFS_VOLTAGE_SOC]{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->qAvfsGb[AVFS_VOLTAGE_SOC ].a, - pptable->qAvfsGb[AVFS_VOLTAGE_SOC ].b, - pptable->qAvfsGb[AVFS_VOLTAGE_SOC ].c); -pr_info ("dBtcGbGfxCksOn{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->dBtcGbGfxCksOn.a, - pptable->dBtcGbGfxCksOn.b, - pptable->dBtcGbGfxCksOn.c); -pr_info ("dBtcGbGfxCksOff{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->dBtcGbGfxCksOff.a, - pptable->dBtcGbGfxCksOff.b, - pptable->dBtcGbGfxCksOff.c); -pr_info ("dBtcGbGfxAfll{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->dBtcGbGfxAfll.a, - pptable->dBtcGbGfxAfll.b, - pptable->dBtcGbGfxAfll.c); -pr_info ("dBtcGbSoc{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->dBtcGbSoc.a, - pptable->dBtcGbSoc.b, - pptable->dBtcGbSoc.c); -pr_info ("qAgingGb[AVFS_VOLTAGE_GFX]{m = 0x%x b = 0x%x}\n" , - pptable->qAgingGb[AVFS_VOLTAGE_GFX ].m, - pptable->qAgingGb[AVFS_VOLTAGE_GFX ].b); -pr_info ("qAgingGb[AVFS_VOLTAGE_SOC]{m = 0x%x b = 0x%x}\n" , - pptable->qAgingGb[AVFS_VOLTAGE_SOC ].m, - pptable->qAgingGb[AVFS_VOLTAGE_SOC ].b); - -pr_info ("qStaticVoltageOffset[AVFS_VOLTAGE_GFX]{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX ].a, - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX ].b, - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_GFX ].c); -pr_info ("qStaticVoltageOffset[AVFS_VOLTAGE_SOC]{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC ].a, - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC ].b, - pptable->qStaticVoltageOffset[AVFS_VOLTAGE_SOC ].c); - -pr_info ("DcTol[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->DcTol[AVFS_VOLTAGE_GFX ]); -pr_info ("DcTol[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->DcTol[AVFS_VOLTAGE_SOC ]); - -pr_info ("DcBtcEnabled[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->DcBtcEnabled[AVFS_VOLTAGE_GFX ]); -pr_info ("DcBtcEnabled[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->DcBtcEnabled[AVFS_VOLTAGE_SOC ]); -pr_info ("Padding8_GfxBtc[0] = 0x%x\n" , pptable->Padding8_GfxBtc[0 ]); -pr_info ("Padding8_GfxBtc[1] = 0x%x\n" , pptable->Padding8_GfxBtc[1 ]); - -pr_info ("DcBtcMin[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->DcBtcMin[AVFS_VOLTAGE_GFX ]); -pr_info ("DcBtcMin[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->DcBtcMin[AVFS_VOLTAGE_SOC ]); -pr_info ("DcBtcMax[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->DcBtcMax[AVFS_VOLTAGE_GFX ]); -pr_info ("DcBtcMax[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->DcBtcMax[AVFS_VOLTAGE_SOC ]); - -pr_info ("XgmiLinkSpeed\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiLinkSpeed[i]); -pr_info ("XgmiLinkWidth\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiLinkWidth[i]); -pr_info ("XgmiFclkFreq\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiFclkFreq[i]); -pr_info ("XgmiUclkFreq\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiUclkFreq[i]); -pr_info ("XgmiSocclkFreq\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiSocclkFreq[i]); -pr_info ("XgmiSocVoltage\n" ); -for (i =0 ; i <NUM_XGMI_LEVELS ; i++) -pr_info (" .[%d] = %d\n" , i, pptable->XgmiSocVoltage[i]); - -pr_info ("DebugOverrides = 0x%x\n" , pptable->DebugOverrides); -pr_info ("ReservedEquation0{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->ReservedEquation0.a, - pptable->ReservedEquation0.b, - pptable->ReservedEquation0.c); -pr_info ("ReservedEquation1{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->ReservedEquation1.a, - pptable->ReservedEquation1.b, - pptable->ReservedEquation1.c); -pr_info ("ReservedEquation2{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->ReservedEquation2.a, - pptable->ReservedEquation2.b, - pptable->ReservedEquation2.c); -pr_info ("ReservedEquation3{a = 0x%x b = 0x%x c = 0x%x}\n" , - pptable->ReservedEquation3.a, - pptable->ReservedEquation3.b, - pptable->ReservedEquation3.c); - -pr_info ("MinVoltageUlvGfx = %d\n" , pptable->MinVoltageUlvGfx); -pr_info ("MinVoltageUlvSoc = %d\n" , pptable->MinVoltageUlvSoc); - -pr_info ("MGpuFanBoostLimitRpm = %d\n" , pptable->MGpuFanBoostLimitRpm); -pr_info ("padding16_Fan = %d\n" , pptable->padding16_Fan); - -pr_info ("FanGainVrMem0 = %d\n" , pptable->FanGainVrMem0); -pr_info ("FanGainVrMem0 = %d\n" , pptable->FanGainVrMem0); - -pr_info ("DcBtcGb[AVFS_VOLTAGE_GFX] = 0x%x\n" , pptable->DcBtcGb[AVFS_VOLTAGE_GFX ]); -pr_info ("DcBtcGb[AVFS_VOLTAGE_SOC] = 0x%x\n" , pptable->DcBtcGb[AVFS_VOLTAGE_SOC ]); - -for (i =0 ; i <11 ; i++) -pr_info ("Reserved[%d] = 0x%x\n" , i, pptable->Reserved[i]); - -for (i =0 ; i <3 ; i++) -pr_info ("Padding32[%d] = 0x%x\n" , i, pptable->Padding32[i]); - -pr_info ("MaxVoltageStepGfx = 0x%x\n" , pptable->MaxVoltageStepGfx); -pr_info ("MaxVoltageStepSoc = 0x%x\n" , pptable->MaxVoltageStepSoc); - -pr_info ("VddGfxVrMapping = 0x%x\n" , pptable->VddGfxVrMapping); -pr_info ("VddSocVrMapping = 0x%x\n" , pptable->VddSocVrMapping); -pr_info ("VddMem0VrMapping = 0x%x\n" , pptable->VddMem0VrMapping); -pr_info ("VddMem1VrMapping = 0x%x\n" , pptable->VddMem1VrMapping); - -pr_info ("GfxUlvPhaseSheddingMask = 0x%x\n" , pptable->GfxUlvPhaseSheddingMask); -pr_info ("SocUlvPhaseSheddingMask = 0x%x\n" , pptable->SocUlvPhaseSheddingMask); -pr_info ("ExternalSensorPresent = 0x%x\n" , pptable->ExternalSensorPresent); -pr_info ("Padding8_V = 0x%x\n" , pptable->Padding8_V); - -pr_info ("GfxMaxCurrent = 0x%x\n" , pptable->GfxMaxCurrent); -pr_info ("GfxOffset = 0x%x\n" , pptable->GfxOffset); -pr_info ("Padding_TelemetryGfx = 0x%x\n" , pptable->Padding_TelemetryGfx); - -pr_info ("SocMaxCurrent = 0x%x\n" , pptable->SocMaxCurrent); -pr_info ("SocOffset = 0x%x\n" , pptable->SocOffset); -pr_info ("Padding_TelemetrySoc = 0x%x\n" , pptable->Padding_TelemetrySoc); - -pr_info ("Mem0MaxCurrent = 0x%x\n" , pptable->Mem0MaxCurrent); -pr_info ("Mem0Offset = 0x%x\n" , pptable->Mem0Offset); -pr_info ("Padding_TelemetryMem0 = 0x%x\n" , pptable->Padding_TelemetryMem0); - -pr_info ("Mem1MaxCurrent = 0x%x\n" , pptable->Mem1MaxCurrent); -pr_info ("Mem1Offset = 0x%x\n" , pptable->Mem1Offset); -pr_info ("Padding_TelemetryMem1 = 0x%x\n" , pptable->Padding_TelemetryMem1); - -pr_info ("AcDcGpio = %d\n" , pptable->AcDcGpio); -pr_info ("AcDcPolarity = %d\n" , pptable->AcDcPolarity); -pr_info ("VR0HotGpio = %d\n" , pptable->VR0HotGpio); -pr_info ("VR0HotPolarity = %d\n" , pptable->VR0HotPolarity); - -pr_info ("VR1HotGpio = %d\n" , pptable->VR1HotGpio); -pr_info ("VR1HotPolarity = %d\n" , pptable->VR1HotPolarity); -pr_info ("Padding1 = 0x%x\n" , pptable->Padding1); -pr_info ("Padding2 = 0x%x\n" , pptable->Padding2); - -pr_info ("LedPin0 = %d\n" , pptable->LedPin0); -pr_info ("LedPin1 = %d\n" , pptable->LedPin1); -pr_info ("LedPin2 = %d\n" , pptable->LedPin2); -pr_info ("padding8_4 = 0x%x\n" , pptable->padding8_4); - -pr_info ("PllGfxclkSpreadEnabled = %d\n" , pptable->PllGfxclkSpreadEnabled); -pr_info ("PllGfxclkSpreadPercent = %d\n" , pptable->PllGfxclkSpreadPercent); -pr_info ("PllGfxclkSpreadFreq = %d\n" , pptable->PllGfxclkSpreadFreq); - -pr_info ("UclkSpreadEnabled = %d\n" , pptable->UclkSpreadEnabled); -pr_info ("UclkSpreadPercent = %d\n" , pptable->UclkSpreadPercent); -pr_info ("UclkSpreadFreq = %d\n" , pptable->UclkSpreadFreq); - -pr_info ("FclkSpreadEnabled = %d\n" , pptable->FclkSpreadEnabled); -pr_info ("FclkSpreadPercent = %d\n" , pptable->FclkSpreadPercent); -pr_info ("FclkSpreadFreq = %d\n" , pptable->FclkSpreadFreq); - -pr_info ("FllGfxclkSpreadEnabled = %d\n" , pptable->FllGfxclkSpreadEnabled); -pr_info ("FllGfxclkSpreadPercent = %d\n" , pptable->FllGfxclkSpreadPercent); -pr_info ("FllGfxclkSpreadFreq = %d\n" , pptable->FllGfxclkSpreadFreq); - -for (i =0 ; i <I2C_CONTROLLER_NAME_COUNT ; i++) { -pr_info ("I2cControllers[%d]:\n" , i); -pr_info (" .Enabled = %d\n" , - pptable->I2cControllers[i].Enabled); -pr_info (" .SlaveAddress = 0x%x\n" , - pptable->I2cControllers[i].SlaveAddress); -pr_info (" .ControllerPort = %d\n" , - pptable->I2cControllers[i].ControllerPort); -pr_info (" .ControllerName = %d\n" , - pptable->I2cControllers[i].ControllerName); -pr_info (" .ThermalThrottler = %d\n" , - pptable->I2cControllers[i].ThermalThrottler); -pr_info (" .I2cProtocol = %d\n" , - pptable->I2cControllers[i].I2cProtocol); -pr_info (" .I2cSpeed = %d\n" , - pptable->I2cControllers[i].I2cSpeed); - } - -for (i =0 ; i <10 ; i++) -pr_info ("BoardReserved[%d] = 0x%x\n" , i, pptable->BoardReserved[i]); - -for (i =0 ; i <8 ; i++) -pr_info ("MmHubPadding[%d] = 0x%x\n" , i, pptable->MmHubPadding[i]); -} -#endif -static int check_powerplay_tables (struct pp_hwmgr *hwmgr,const ATOM_Vega20_POWERPLAYTABLE *powerplay_table)
@@ -652,8 +80,6 @@ static int check_powerplay_tables(return -EINVAL ; } -//dump_pptable(&powerplay_table->smcPPTable); -return 0 ; }
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +0 -5
@@ -858,11 +858,6 @@ struct pptable_funcs {*/ int (*display_disable_memory_clock_switch)(struct smu_context *smu,bool disable_memory_clock_switch); -/** -* @dump_pptable: Print the power play table to the system log. -*/ -void (*dump_pptable)(struct smu_context *smu); -/** * @get_power_limit: Get the device's power limits. */
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c +0 -433
445 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -1269
1,281 lines not on this page · raw message
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c +0 -14
@@ -736,19 +736,6 @@ static bool smu_v13_0_0_is_dpm_running(struct smu_context *smu)return !!(feature_enabled &SMC_DPM_FEATURE ); } -static void smu_v13_0_0_dump_pptable (struct smu_context *smu) -{ -struct smu_table_context *table_context = &smu->smu_table; -PPTable_t *pptable = table_context->driver_pptable; -SkuTable_t *skutable = &pptable->SkuTable; - -dev_info (smu->adev->dev,"Dumped PPTable:\n" ); - -dev_info (smu->adev->dev,"Version = 0x%08x\n" , skutable->Version); -dev_info (smu->adev->dev,"FeaturesToRun[0] = 0x%08x\n" , skutable->FeaturesToRun[0 ]); -dev_info (smu->adev->dev,"FeaturesToRun[1] = 0x%08x\n" , skutable->FeaturesToRun[1 ]); -} -static int smu_v13_0_0_system_features_control (struct smu_context *smu,bool en) {
@@ -3022,7 +3009,6 @@ static const struct pptable_funcs smu_v13_0_0_ppt_funcs = { .i2c_init = smu_v13_0_0_i2c_control_init, .i2c_fini = smu_v13_0_0_i2c_control_fini, .is_dpm_running = smu_v13_0_0_is_dpm_running, - .dump_pptable = smu_v13_0_0_dump_pptable, .init_microcode = smu_v13_0_init_microcode, .load_microcode = smu_v13_0_load_microcode, .fini_microcode = smu_v13_0_fini_microcode,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c +0 -14
@@ -734,19 +734,6 @@ static bool smu_v13_0_7_is_dpm_running(struct smu_context *smu)return !!(feature_enabled &SMC_DPM_FEATURE ); } -static void smu_v13_0_7_dump_pptable (struct smu_context *smu) -{ -struct smu_table_context *table_context = &smu->smu_table; -PPTable_t *pptable = table_context->driver_pptable; -SkuTable_t *skutable = &pptable->SkuTable; - -dev_info (smu->adev->dev,"Dumped PPTable:\n" ); - -dev_info (smu->adev->dev,"Version = 0x%08x\n" , skutable->Version); -dev_info (smu->adev->dev,"FeaturesToRun[0] = 0x%08x\n" , skutable->FeaturesToRun[0 ]); -dev_info (smu->adev->dev,"FeaturesToRun[1] = 0x%08x\n" , skutable->FeaturesToRun[1 ]); -} -static uint32_t smu_v13_0_7_get_throttler_status (SmuMetrics_t *metrics) {uint32_t throttler_status =0 ;
@@ -2602,7 +2589,6 @@ static const struct pptable_funcs smu_v13_0_7_ppt_funcs = { .get_allowed_feature_mask = smu_v13_0_7_get_allowed_feature_mask, .set_default_dpm_table = smu_v13_0_7_set_default_dpm_table, .is_dpm_running = smu_v13_0_7_is_dpm_running, - .dump_pptable = smu_v13_0_7_dump_pptable, .init_microcode = smu_v13_0_init_microcode, .load_microcode = smu_v13_0_load_microcode, .fini_microcode = smu_v13_0_fini_microcode,
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c +0 -14
@@ -732,19 +732,6 @@ static bool smu_v14_0_2_is_dpm_running(struct smu_context *smu)return !!(feature_enabled &SMC_DPM_FEATURE ); } -static void smu_v14_0_2_dump_pptable (struct smu_context *smu) -{ -struct smu_table_context *table_context = &smu->smu_table; -PPTable_t *pptable = table_context->driver_pptable; -PFE_Settings_t *PFEsettings = &pptable->PFE_Settings; - -dev_info (smu->adev->dev,"Dumped PPTable:\n" ); - -dev_info (smu->adev->dev,"Version = 0x%08x\n" , PFEsettings->Version); -dev_info (smu->adev->dev,"FeaturesToRun[0] = 0x%08x\n" , PFEsettings->FeaturesToRun[0 ]); -dev_info (smu->adev->dev,"FeaturesToRun[1] = 0x%08x\n" , PFEsettings->FeaturesToRun[1 ]); -} -static uint32_t smu_v14_0_2_get_throttler_status (SmuMetrics_t *metrics) {uint32_t throttler_status =0 ;
@@ -2802,7 +2789,6 @@ static const struct pptable_funcs smu_v14_0_2_ppt_funcs = { .i2c_init = smu_v14_0_2_i2c_control_init, .i2c_fini = smu_v14_0_2_i2c_control_fini, .is_dpm_running = smu_v14_0_2_is_dpm_running, - .dump_pptable = smu_v14_0_2_dump_pptable, .init_microcode = smu_v14_0_init_microcode, .load_microcode = smu_v14_0_load_microcode, .fini_microcode = smu_v14_0_fini_microcode,
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -1
@@ -78,7 +78,6 @@#define smu_register_irq_handler (smu) smu_ppt_funcs(register_irq_handler, 0, smu)#define smu_get_dpm_ultimate_freq (smu, param, min, max) smu_ppt_funcs(get_dpm_ultimate_freq, 0, smu, param, min, max)#define smu_asic_set_performance_level (smu, level) smu_ppt_funcs(set_performance_level, -EINVAL, smu, level) -#define smu_dump_pptable (smu) smu_ppt_funcs(dump_pptable, 0, smu)#define smu_update_pcie_parameters (smu, pcie_gen_cap, pcie_width_cap) smu_ppt_funcs(update_pcie_parameters, 0, smu, pcie_gen_cap, pcie_width_cap)#define smu_set_power_source (smu, power_src) smu_ppt_funcs(set_power_source, 0, smu, power_src)#define smu_i2c_init (smu) smu_ppt_funcs(i2c_init, 0, smu)
Signature · 1 line
2.40.1
PATCH 2/9 drm/amd/pm: fix rpm refcount handling on error
In reply to Pierre-Eric Pelloux-Prayerpm_runtime_put_autosuspend must be called from all exit paths.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +2 -0
@@ -1815,6 +1815,8 @@ static ssize_t amdgpu_set_apu_thermal_cap(struct device *dev, ret =amdgpu_dpm_set_apu_thermal_limit (adev, value);if (ret) { +pm_runtime_mark_last_busy (ddev->dev); +pm_runtime_put_autosuspend (ddev->dev);dev_err (dev,"failed to update thermal limit\n" );return ret; }
Signature · 1 line
2.40.1
PATCH 3/9 drm/amd/pm: use pm_runtime_resume_and_get
In reply to Pierre-Eric Pelloux-PrayerUsing pm_runtime_resume_and_get over pm_runtime_get_sync is recommended.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 263 ++++++++++------------------- 1 file changed, 89 insertions(+), 174 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +89 -174
@@ -145,11 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -185,11 +183,9 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,else return -EINVAL ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_dpm_set_power_state (adev, state);
@@ -273,11 +269,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } level =amdgpu_dpm_get_performance_level (adev);
@@ -336,11 +330,9 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,return -EINVAL ; } - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }mutex_lock (&adev->pm.stable_pstate_ctx_lock);if (amdgpu_dpm_force_performance_level (adev, level)) {
@@ -374,11 +366,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));
@@ -412,11 +402,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -485,11 +473,9 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, idx =array_index_nospec (idx,ARRAY_SIZE (data.states)); - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_get_pp_num_states (adev, &data);if (ret)
@@ -544,11 +530,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_get_pp_table (adev, &table);
@@ -580,11 +564,9 @@ static ssize_t amdgpu_set_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_pp_table (adev, buf, count);
@@ -808,11 +790,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, tmp_str++; } - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } if (amdgpu_dpm_set_fine_grain_clk_vol(adev, type,
@@ -865,11 +845,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);
@@ -929,11 +907,9 @@ static ssize_t amdgpu_set_pp_features(struct device *dev,if (ret)return -EINVAL ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_ppfeature_status (adev, featuremask);
@@ -960,11 +936,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )
@@ -1029,11 +1003,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )
@@ -1102,11 +1074,9 @@ static ssize_t amdgpu_set_pp_dpm_clock(struct device *dev,if (ret)return ret; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_force_clock_level (adev, type, mask);
@@ -1283,11 +1253,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } value =amdgpu_dpm_get_sclk_od (adev);
@@ -1317,11 +1285,9 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,if (ret)return -EINVAL ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_dpm_set_sclk_od (adev, (uint32_t )value);
@@ -1345,11 +1311,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } value =amdgpu_dpm_get_mclk_od (adev);
@@ -1379,11 +1343,9 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,if (ret)return -EINVAL ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_dpm_set_mclk_od (adev, (uint32_t )value);
@@ -1427,11 +1389,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )
@@ -1492,11 +1452,9 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, } parameter[parameter_size] = profile_mode; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_power_profile_mode (adev, parameter, parameter_size);
@@ -1520,11 +1478,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + r =pm_runtime_resume_and_get (adev->dev); +if (r <0 )return r; - }/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);
@@ -1639,11 +1595,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - }amdgpu_asic_get_pcie_usage (adev, &count0, &count1);
@@ -1770,11 +1724,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)
@@ -1807,11 +1759,9 @@ static ssize_t amdgpu_set_apu_thermal_cap(struct device *dev,return -EINVAL ; } - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_apu_thermal_limit (adev, value);if (ret) {
@@ -1851,11 +1801,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );
@@ -1892,11 +1840,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )
@@ -2010,11 +1956,9 @@ static ssize_t amdgpu_set_smartshift_bias(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_get_sync (ddev->dev); -if (r <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + r =pm_runtime_resume_and_get (ddev->dev); +if (r <0 )return r; - } r =kstrtoint (buf,10 , &bias);if (r)
@@ -2337,11 +2281,9 @@ static ssize_t amdgpu_set_pm_policy_attr(struct device *dev, policy_attr = container_of(attr, struct amdgpu_pm_policy_attr, dev_attr); - ret =pm_runtime_get_sync (ddev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (ddev->dev); + ret =pm_runtime_resume_and_get (ddev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_pm_policy (adev, policy_attr->id, val);
@@ -2774,11 +2716,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + ret =pm_runtime_resume_and_get (adev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);
@@ -2819,11 +2759,9 @@ static ssize_t amdgpu_hwmon_set_pwm1_enable(struct device *dev,else return -EINVAL ; - ret =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + ret =pm_runtime_resume_and_get (adev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode);
@@ -2868,11 +2806,9 @@ static ssize_t amdgpu_hwmon_set_pwm1(struct device *dev,if (err)return err; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);if (err)
@@ -2909,11 +2845,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);
@@ -2939,11 +2873,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);
@@ -3003,11 +2935,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);
@@ -3038,11 +2968,9 @@ static ssize_t amdgpu_hwmon_set_fan1_target(struct device *dev,if (err)return err; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);if (err)
@@ -3078,11 +3006,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + ret =pm_runtime_resume_and_get (adev->dev); +if (ret <0 )return ret; - } ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);
@@ -3121,11 +3047,9 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,else return -EINVAL ; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode);
@@ -3250,11 +3174,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + r =pm_runtime_resume_and_get (adev->dev); +if (r <0 )return r; - } r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);
@@ -3341,11 +3263,9 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev, value = value /1000000 ;/* convert to Watt */ value |= limit_type <<24 ; - err =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (err <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); + err =pm_runtime_resume_and_get (adev->dev); +if (err <0 )return err; - } err =amdgpu_dpm_set_power_limit (adev, value);
@@ -3789,11 +3709,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_get_sync (adev->dev); -if (ret <0 ) { -pm_runtime_put_autosuspend (adev->dev); + ret =pm_runtime_resume_and_get (adev->dev); +if (ret <0 )return ret; - } size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
@@ -3881,23 +3799,23 @@ amdgpu_distribute_custom_od_settings(struct amdgpu_device *adev,if (ret)return ret; - ret =pm_runtime_get_sync (adev->dev); + ret =pm_runtime_resume_and_get (adev->dev);if (ret <0 ) - goto err_out0; +return ret; ret =amdgpu_dpm_odn_edit_dpm_table (adev, cmd_type, parameter, parameter_size);if (ret) - goto err_out1; + goto err_out;if (cmd_type ==PP_OD_COMMIT_DPM_TABLE ) { ret =amdgpu_dpm_dispatch_task (adev,AMD_PP_TASK_READJUST_POWER_STATE ,NULL );if (ret) - goto err_out1; + goto err_out; }pm_runtime_mark_last_busy (adev->dev);
@@ -3905,9 +3823,8 @@ amdgpu_distribute_custom_od_settings(struct amdgpu_device *adev,return count; -err_out1: +err_out:pm_runtime_mark_last_busy (adev->dev); -err_out0:pm_runtime_put_autosuspend (adev->dev);return ret;
@@ -4760,11 +4677,9 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_get_sync (dev->dev); -if (r <0 ) { -pm_runtime_put_autosuspend (dev->dev); + r =pm_runtime_resume_and_get (dev->dev); +if (r <0 )return r; - }if (amdgpu_dpm_debugfs_print_current_performance_level (adev, m)) { r =amdgpu_debugfs_pm_info_pp (m, adev);
Signature · 1 line
2.40.1
PATCH 4/9 drm/amd/pm: don't update runpm last_usage on debugfs getter
In reply to Pierre-Eric Pelloux-PrayerReading pm values from the GPU shouldn't prevent it to be suspended by resetting the last active timestamp (eg: if an background app monitors GPU sensors every second, it would prevent the autosuspend sequence to trigger).
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 26 -------------------------- 1 file changed, 26 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -26
@@ -151,7 +151,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,amdgpu_dpm_get_current_power_state (adev, &pm); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",
@@ -275,7 +274,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev, level =amdgpu_dpm_get_performance_level (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",
@@ -373,7 +371,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data)); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); buf_len =sysfs_emit (buf,"states: %d\n" , data.nums);
@@ -410,7 +407,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev, ret =amdgpu_dpm_get_pp_num_states (adev, &data); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (ret)
@@ -536,7 +532,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev, size =amdgpu_dpm_get_pp_table (adev, &table); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (size <=0 )
@@ -866,7 +861,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -944,7 +938,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -1014,7 +1007,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -1259,7 +1251,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, value =amdgpu_dpm_get_sclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);
@@ -1317,7 +1308,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev, value =amdgpu_dpm_get_mclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);
@@ -1397,7 +1387,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -1485,7 +1474,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return r;
@@ -1601,7 +1589,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,amdgpu_asic_get_pcie_usage (adev, &count0, &count1); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%llu %llu %i\n",
@@ -1734,7 +1721,6 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,else size =sysfs_emit (buf,"failed to get thermal limit\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -1807,7 +1793,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -1854,7 +1839,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,memcpy (buf, gpu_metrics, size); out: -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;
@@ -2722,7 +2706,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)
@@ -2851,7 +2834,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev, err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)
@@ -2879,7 +2861,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)
@@ -2941,7 +2922,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)
@@ -3012,7 +2992,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)
@@ -3053,7 +3032,6 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, err =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)
@@ -3186,7 +3164,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,else size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return size;
@@ -3269,7 +3246,6 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev, err =amdgpu_dpm_set_power_limit (adev, value); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)
@@ -3717,7 +3693,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev->dev);pm_runtime_put_autosuspend (adev->dev);return size;
@@ -4694,7 +4669,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)seq_printf (m,"\n" ); out: -pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);return r;
Signature · 1 line
2.40.1
Re: [PATCH v1 4/9] drm/amd/pm: don't update runpm last_usage on debugfs getter
Quoted 184 lines · Pierre-Eric Pelloux-Prayer
Reading pm values from the GPU shouldn't prevent it to be suspended by resetting the last active timestamp (eg: if an background app monitors GPU sensors every second, it would prevent the autosuspend sequence to trigger).
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 26 -------------------------- 1 file changed, 26 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-21@@ -151,7 +151,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,amdgpu_dpm_get_current_power_state (adev, &pm); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",@@ -275,7 +274,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev, level =amdgpu_dpm_get_performance_level (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",@@ -373,7 +371,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data)); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); buf_len =sysfs_emit (buf,"states: %d\n" , data.nums);@@ -410,7 +407,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev, ret =amdgpu_dpm_get_pp_num_states (adev, &data); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (ret)@@ -536,7 +532,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev, size =amdgpu_dpm_get_pp_table (adev, &table); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (size <=0 )@@ -866,7 +861,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -944,7 +938,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1014,7 +1007,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1259,7 +1251,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, value =amdgpu_dpm_get_sclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);@@ -1317,7 +1308,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev, value =amdgpu_dpm_get_mclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);@@ -1397,7 +1387,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1485,7 +1474,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return r;@@ -1601,7 +1589,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,amdgpu_asic_get_pcie_usage (adev, &count0, &count1); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%llu %llu %i\n",@@ -1734,7 +1721,6 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,else size =sysfs_emit (buf,"failed to get thermal limit\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1807,7 +1793,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1854,7 +1839,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,memcpy (buf, gpu_metrics, size); out: -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -2722,7 +2706,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)@@ -2851,7 +2834,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev, err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -2879,7 +2861,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -2941,7 +2922,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3012,7 +2992,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, · line 3056
Quoted 4 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1@@ -3053,7 +3032,6 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, err =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);
Monitoring not affecting runtime PM is valid reasoning for get operations, but not so much for set operations.
Thanks,
Lijo
Quoted 35 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-4pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3186,7 +3164,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,else size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return size;@@ -3269,7 +3246,6 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev, err =amdgpu_dpm_set_power_limit (adev, value); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3717,7 +3693,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev->dev);pm_runtime_put_autosuspend (adev->dev);return size;@@ -4694,7 +4669,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)seq_printf (m,"\n" ); out: -pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);return r;
Re: [PATCH v1 4/9] drm/amd/pm: don't update runpm last_usage on debugfs getter
Le 26/09/2024 à 10:55, Lazar, Lijo a écrit :
Quoted 188 lines · Pierre-Eric Pelloux-Prayer
Quoted 185 lines
Reading pm values from the GPU shouldn't prevent it to be suspended by resetting the last active timestamp (eg: if an background app monitors GPU sensors every second, it would prevent the autosuspend sequence to trigger).
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 26 -------------------------- 1 file changed, 26 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-21@@ -151,7 +151,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,amdgpu_dpm_get_current_power_state (adev, &pm); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",@@ -275,7 +274,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev, level =amdgpu_dpm_get_performance_level (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%s\n",@@ -373,7 +371,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data)); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); buf_len =sysfs_emit (buf,"states: %d\n" , data.nums);@@ -410,7 +407,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev, ret =amdgpu_dpm_get_pp_num_states (adev, &data); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (ret)@@ -536,7 +532,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev, size =amdgpu_dpm_get_pp_table (adev, &table); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);if (size <=0 )@@ -866,7 +861,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -944,7 +938,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1014,7 +1007,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1259,7 +1251,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, value =amdgpu_dpm_get_sclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);@@ -1317,7 +1308,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev, value =amdgpu_dpm_get_mclk_od (adev); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return sysfs_emit (buf,"%d\n" , value);@@ -1397,7 +1387,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1485,7 +1474,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return r;@@ -1601,7 +1589,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,amdgpu_asic_get_pcie_usage (adev, &count0, &count1); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev); return sysfs_emit(buf, "%llu %llu %i\n",@@ -1734,7 +1721,6 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,else size =sysfs_emit (buf,"failed to get thermal limit\n" ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1807,7 +1793,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -1854,7 +1839,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,memcpy (buf, gpu_metrics, size); out: -pm_runtime_mark_last_busy (ddev->dev);pm_runtime_put_autosuspend (ddev->dev);return size;@@ -2722,7 +2706,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)@@ -2851,7 +2834,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev, err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -2879,7 +2861,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -2941,7 +2922,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3012,7 +2992,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (ret)@@ -3053,7 +3032,6 @@ static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev,
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_hwmon_set_fan1_enable(struct device *dev, · line 3056
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-1err =amdgpu_dpm_set_fan_control_mode (adev, pwm_mode); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);Monitoring not affecting runtime PM is valid reasoning for get operations, but not so much for set operations.
Good catch: only the getter functions should be modified by this commit. I'll fix it.
Pierre-Eric
Quoted 37 lines
Thanks,
LijoQuoted 35 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-4pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3186,7 +3164,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,else size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);return size;@@ -3269,7 +3246,6 @@ static ssize_t amdgpu_hwmon_set_power_cap(struct device *dev, err =amdgpu_dpm_set_power_limit (adev, value); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (err)@@ -3717,7 +3693,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_mark_last_busy (adev->dev);pm_runtime_put_autosuspend (adev->dev);return size;@@ -4694,7 +4669,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)seq_printf (m,"\n" ); out: -pm_runtime_mark_last_busy (dev->dev);pm_runtime_put_autosuspend (dev->dev);return r;
PATCH 5/9 drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
In reply to Pierre-Eric Pelloux-PrayerDon't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use pm_runtime_get_if_in_active(ign_usage_count=true) because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +69 -69
@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);
@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));
@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);
@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);
@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )
@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )
@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);
@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);
@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )
@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);
@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);
@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)
@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );
@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )
@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);
@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);
@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);
@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);
@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);
@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);
@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
Signature · 1 line
2.40.1
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Quoted 21 lines · Pierre-Eric Pelloux-Prayer
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct device *dev, · line 150
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-3@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;
Not all our devices support runtime PM.
As per the API documentation -
"-EINVAL is returned if runtime PM is disabled for the device, in which case also the usage_count will remain unmodified."
If that's true, this won't be working on devices without runtime PM support.
Thanks,
Lijo
Quoted 289 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +66
-66amdgpu_dpm_get_current_power_state (adev, &pm);@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Le 25/09/2024 à 15:35, Lazar, Lijo a écrit :
Quoted 36 lines · Pierre-Eric Pelloux-Prayer
Quoted 21 lines
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct device *dev, · line 150
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-3@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;Not all our devices support runtime PM.
Quoted 4 lines
As per the API documentation -
"
-EINVALis returned if runtime PM is disabled for the device, in which case also theusage_countwill remain unmodified."
This doc is about "dev->power.disable_depth > 0", not about runtime PM being disabled (like you would get by using pm_runtime_forbid).
When runtime PM is disabled, usage_count is always >= 1 and the status is RPM_ACTIVE so pm_runtime_get_if_active will succeed.
I tested on 2 dGPUs without runtime PM, and both seemed to work fine.
Pierre-Eric
Quoted 294 lines
If that's true, this won't be working on devices without runtime PM support.
Thanks,
LijoQuoted 289 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +66
-66amdgpu_dpm_get_current_power_state (adev, &pm);@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Quoted 46 lines · Pierre-Eric Pelloux-Prayer
Le 25/09/2024 à 15:35, Lazar, Lijo a écrit :
Quoted 38 lines · Pierre-Eric Pelloux-Prayer
Quoted 23 lines
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c| 138 ++++++++++++++---------------1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct · line 151
Quoted 9 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM;Not all our devices support runtime PM.
Quoted 4 lines
As per the API documentation -
"
-EINVALis returned if runtime PM is disabled for the device, in which case also theusage_countwill remain unmodified."
Quoted 8 lines
This doc is about "
dev->power.disable_depth> 0", not about runtime PM being disabled (like you would get by usingpm_runtime_forbid).When runtime PM is disabled,
usage_countis always >= 1 and the status isRPM_ACTIVEsopm_runtime_get_if_activewill succeed.I tested on 2 dGPUs without runtime PM, and both seemed to work fine.
Thanks for clarifying. Found that default enablement is taken care by pci base driver.
https://elixir.bootlin.com/linux/v6.11/source/drivers/pci/pci.c#L3173
Thanks,
Lijo
Quoted 262 lines
Pierre-Eric
Quoted 260 lines
If that's true, this won't be working on devices without runtime PM support.
Thanks,
LijoQuoted 254 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0amdgpu_dpm_get_current_power_state(adev, &pm);@@ -268,9 +268,9 @@ static
ssize_tamdgpu_get_power_dpm_force_performance_level(struct device *dev, if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
level =amdgpu_dpm_get_performance_level(adev); @@ -364,9 +364,9 @@ staticssize_tamdgpu_get_pp_num_states(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
if (amdgpu_dpm_get_pp_num_states(adev, &data))memset(&data, 0, sizeof(data));drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; amdgpu_dpm_get_current_power_state(adev, &pm);@@ -526,9 +526,9 @@ static
ssize_tamdgpu_get_pp_table(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_pp_table(adev, &table); @@ -840,9 +840,9 @@ staticssize_tamdgpu_get_pp_od_clk_voltage(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
for (clk_index= 0 ;clk_index< 6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);drivers/gpu/drm/amd/pm/amdgpu_pm.c +9
-6@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_get_ppfeature_status(adev, buf); if (size <= 0)@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; ret = amdgpu_dpm_emit_clock_levels(adev, type, buf, &size); if (ret == -ENOENT)@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; value = amdgpu_dpm_get_sclk_od(adev);@@ -1302,9 +1302,9 @@ static
ssize_tamdgpu_get_pp_mclk_od(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
value =amdgpu_dpm_get_mclk_od(adev);
@@ -1379,9 +1379,9 @@ staticssize_tamdgpu_get_pp_power_profile_mode(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_power_profile_mode(adev, buf); if (size <= 0)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-4@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - r = pm_runtime_resume_and_get(adev->dev); - if (r < 0) - return r; + r = pm_runtime_get_if_active(adev->dev, true); + if (r <= 0) + return r ?: -EPERM; /* get the sensor value */ r = amdgpu_dpm_read_sensor(adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev, if (!adev->asic_funcs->get_pcie_usage) return -ENODATA; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; amdgpu_asic_get_pcie_usage(adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static
ssize_tamdgpu_get_apu_thermal_cap(struct device *dev, structdrm_device*ddev =dev_get_drvdata(dev); structamdgpu_device*adev =drm_to_adev(ddev); - ret =pm_runtime_resume_and_get(ddev->dev); - if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
ret =amdgpu_dpm_get_apu_thermal_limit(adev, &limit); if (!ret)drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_get_pm_metrics(adev, buf, PAGE_SIZE);@@ -1825,9 +1825,9 @@ static
ssize_tamdgpu_get_gpu_metrics(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_gpu_metrics(adev, &gpu_metrics); if (size <= 0)drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(adev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(adev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; ret = amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static
ssize_tamdgpu_hwmon_get_pwm1(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_pwm(adev, &speed); @@ -2855,9 +2855,9 @@ staticssize_tamdgpu_hwmon_get_fan1_input(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_rpm(adev, &speed); @@ -2916,9 +2916,9 @@ staticssize_tamdgpu_hwmon_get_fan1_target(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_rpm(adev, &rpm); @@ -2986,9 +2986,9 @@ staticssize_tamdgpu_hwmon_get_fan1_enable(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(adev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(adev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
ret =amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode); @@ -3152,9 +3152,9 @@ staticssize_tamdgpu_hwmon_show_power_cap_generic(struct device *dev, if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- r =pm_runtime_resume_and_get(adev->dev);
- if (r < 0)
- return r;
+ r =pm_runtime_get_if_active(adev->dev, true);
+ if (r <= 0)
+ return r ?:-EPERM;
r =amdgpu_dpm_get_power_limit(adev, &limit, pp_limit_level, power_type);drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(adev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(adev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); if (size == 0)
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
In reply to Pierre-Eric Pelloux-PrayerQuoted 9 lines · Pierre-Eric Pelloux-Prayer
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".
One possible downside of this approach is - let's say an application tries this way on a BACO enabled device (device is visible on bus, but powered off due to runtime PM)
Get current clock level
If (success) && (not desired clock level)
Set clock level
Submit some jobs to run at set clock level
This type of approach won't work since get clock level() itself will fail. That said, I don't know if there is any app out there does something like this.
Thanks,
Lijo
Quoted 310 lines
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +69
-69@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Le 26/09/2024 à 11:27, Lazar, Lijo a écrit :
Quoted 17 lines · Pierre-Eric Pelloux-Prayer
Quoted 9 lines
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".One possible downside of this approach is - let's say an application tries this way on a BACO enabled device (device is visible on bus, but powered off due to runtime PM)
Quoted 8 lines
Get current clock level
If (success) && (not desired clock level)
Set clock level
Submit some jobs to run at set clock levelThis type of approach won't work since get clock
level()itself will fail. That said, I don't know if there is any app out there does something like this.
Yes, this would break this pattern but I don't see why it would be used.
If this theoretical concern becomes real because an application reports a breakage after this series is merged, we can figure out how to best deal with it.
Pierr-Eric
Quoted 314 lines
Thanks,
LijoQuoted 310 lines
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +69
-69@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r =amdgpu_dpm_read_sensor (adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 )
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Quoted 29 lines · Pierre-Eric Pelloux-Prayer
Le 26/09/2024 à 11:27, Lazar, Lijo a écrit :
Quoted 17 lines · Pierre-Eric Pelloux-Prayer
Quoted 9 lines
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake.
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".One possible downside of this approach is - let's say an application tries this way on a BACO enabled device (device is visible on bus, but powered off due to runtime PM)
Quoted 8 lines
Get current clock level
If (success) && (not desired clock level) Set clock level
Submit some jobs to run at set clock levelThis type of approach won't work since get clock
level()itself will fail. That said, I don't know if there is any app out there does something like this.
Quoted 6 lines
Yes, this would break this pattern but I don't see why it would be used.
If this theoretical concern becomes real because an application reports a breakage after this series is merged, we can figure out how to best deal with it.
Right, will see if Alex/Kenneth has any comments.
That apart, the series looks good to me.
Thanks,
Lijo
Quoted 284 lines
Pierr-Eric
Quoted 281 lines
Thanks,
LijoQuoted 277 lines
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c| 138 ++++++++++++++---------------1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; amdgpu_dpm_get_current_power_state(adev, &pm);@@ -268,9 +268,9 @@ static
ssize_tamdgpu_get_power_dpm_force_performance_level(struct device *dev, if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
level =amdgpu_dpm_get_performance_level(adev); @@ -364,9 +364,9 @@ staticssize_tamdgpu_get_pp_num_states(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
if (amdgpu_dpm_get_pp_num_states(adev, &data))memset(&data, 0, sizeof(data));drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; amdgpu_dpm_get_current_power_state(adev, &pm);@@ -526,9 +526,9 @@ static
ssize_tamdgpu_get_pp_table(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_pp_table(adev, &table); @@ -840,9 +840,9 @@ staticssize_tamdgpu_get_pp_od_clk_voltage(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
for (clk_index= 0 ;clk_index< 6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size);drivers/gpu/drm/amd/pm/amdgpu_pm.c +9
-6@@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_get_ppfeature_status(adev, buf); if (size <= 0)@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; ret = amdgpu_dpm_emit_clock_levels(adev, type, buf, &size); if (ret == -ENOENT)@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; value = amdgpu_dpm_get_sclk_od(adev);@@ -1302,9 +1302,9 @@ static
ssize_tamdgpu_get_pp_mclk_od(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
value =amdgpu_dpm_get_mclk_od(adev);
@@ -1379,9 +1379,9 @@ staticssize_tamdgpu_get_pp_power_profile_mode(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_power_profile_mode(adev, buf); if (size <= 0)drivers/gpu/drm/amd/pm/amdgpu_pm.c +6
-4@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - r = pm_runtime_resume_and_get(adev->dev); - if (r < 0) - return r; + r = pm_runtime_get_if_active(adev->dev, true); + if (r <= 0) + return r ?: -EPERM; /* get the sensor value */ r = amdgpu_dpm_read_sensor(adev, sensor, query, &size);@@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev, if (!adev->asic_funcs->get_pcie_usage) return -ENODATA; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; amdgpu_asic_get_pcie_usage(adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static
ssize_tamdgpu_get_apu_thermal_cap(struct device *dev, structdrm_device*ddev =dev_get_drvdata(dev); structamdgpu_device*adev =drm_to_adev(ddev); - ret =pm_runtime_resume_and_get(ddev->dev); - if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0)
+ return ret ?:-EPERM;
ret =amdgpu_dpm_get_apu_thermal_limit(adev, &limit); if (!ret)drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(ddev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(ddev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_get_pm_metrics(adev, buf, PAGE_SIZE);@@ -1825,9 +1825,9 @@ static
ssize_tamdgpu_get_gpu_metrics(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
size =amdgpu_dpm_get_gpu_metrics(adev, &gpu_metrics); if (size <= 0)drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(adev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(adev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; ret = amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static
ssize_tamdgpu_hwmon_get_pwm1(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_pwm(adev, &speed); @@ -2855,9 +2855,9 @@ staticssize_tamdgpu_hwmon_get_fan1_input(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_rpm(adev, &speed); @@ -2916,9 +2916,9 @@ staticssize_tamdgpu_hwmon_get_fan1_target(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- err =pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err =pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?:-EPERM;
err =amdgpu_dpm_get_fan_speed_rpm(adev, &rpm); @@ -2986,9 +2986,9 @@ staticssize_tamdgpu_hwmon_get_fan1_enable(struct device *dev,
if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- ret =pm_runtime_resume_and_get(adev->dev);
- if (ret < 0)
- return ret;
+ ret =pm_runtime_get_if_active(adev->dev, true);
+ if (ret <= 0)
+ return ret ?:-EPERM;
ret =amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode); @@ -3152,9 +3152,9 @@ staticssize_tamdgpu_hwmon_show_power_cap_generic(struct device *dev, if (adev->in_suspend&& !adev->in_runpm)
return-EPERM;
- r =pm_runtime_resume_and_get(adev->dev);
- if (r < 0)
- return r;
+ r =pm_runtime_get_if_active(adev->dev, true);
+ if (r <= 0)
+ return r ?:-EPERM;
r =amdgpu_dpm_get_power_limit(adev, &limit, pp_limit_level, power_type);drivers/gpu/drm/amd/pm/amdgpu_pm.c +3
-2@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev, if (adev->in_suspend && !adev->in_runpm) return -EPERM; - ret = pm_runtime_resume_and_get(adev->dev); - if (ret < 0) - return ret; + ret = pm_runtime_get_if_active(adev->dev, true); + if (ret <= 0) + return ret ?: -EPERM; size = amdgpu_dpm_print_clock_levels(adev, od_type, buf); if (size == 0)
RE: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
In reply to Pierre-Eric Pelloux-Prayer[AMD Official Use Only - AMD Internal Distribution Only]
-----Original Message-----
From: Pelloux-Prayer, Pierre-Eric <[email protected]>
Sent: Wednesday, September 25, 2024 3:54 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>; Limonciello, Mario <[email protected]>
Cc: Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Don't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake. Kenneth - just a nit-pick iff(typo) -> if
This avoids spurious wake ups (eg: from applets).
We use pm_runtime_get_if_in_active(ign_usage_count=true) because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +18 -18
@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);
@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));
@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);
@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);
@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret = amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size); @@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
size = amdgpu_dpm_get_ppfeature_status(adev, buf);
if (size <= 0)
@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
ret = amdgpu_dpm_emit_clock_levels(adev, type, buf, &size);
if (ret == -ENOENT)
@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
value = amdgpu_dpm_get_sclk_od(adev);
@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
value = amdgpu_dpm_get_mclk_od(adev);
@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
size = amdgpu_dpm_get_power_profile_mode(adev, buf);
if (size <= 0)
@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- r = pm_runtime_resume_and_get(adev->dev);
- if (r < 0)
- return r;
+ r = pm_runtime_get_if_active(adev->dev, true);
+ if (r <= 0)
+ return r ?: -EPERM;
/* get the sensor value */
r = amdgpu_dpm_read_sensor(adev, sensor, query, &size); @@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,
if (!adev->asic_funcs->get_pcie_usage)
return -ENODATA;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
amdgpu_asic_get_pcie_usage(adev, &count0, &count1);
@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
ret = amdgpu_dpm_get_apu_thermal_limit(adev, &limit);
if (!ret)
@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
size = amdgpu_dpm_get_pm_metrics(adev, buf, PAGE_SIZE);
@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(ddev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(ddev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
size = amdgpu_dpm_get_gpu_metrics(adev, &gpu_metrics);
if (size <= 0)
@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(adev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(adev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
ret = amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode);
@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- err = pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err = pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?: -EPERM;
err = amdgpu_dpm_get_fan_speed_pwm(adev, &speed);
@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- err = pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err = pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?: -EPERM;
err = amdgpu_dpm_get_fan_speed_rpm(adev, &speed);
@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- err = pm_runtime_resume_and_get(adev->dev);
- if (err < 0)
- return err;
+ err = pm_runtime_get_if_active(adev->dev, true);
+ if (err <= 0)
+ return err ?: -EPERM;
err = amdgpu_dpm_get_fan_speed_rpm(adev, &rpm);
@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(adev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(adev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
ret = amdgpu_dpm_get_fan_control_mode(adev, &pwm_mode);
@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- r = pm_runtime_resume_and_get(adev->dev);
- if (r < 0)
- return r;
+ r = pm_runtime_get_if_active(adev->dev, true);
+ if (r <= 0)
+ return r ?: -EPERM;
r = amdgpu_dpm_get_power_limit(adev, &limit,
pp_limit_level, power_type);
@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;- ret = pm_runtime_resume_and_get(adev->dev);
- if (ret < 0)
- return ret;
+ ret = pm_runtime_get_if_active(adev->dev, true);
+ if (ret <= 0)
+ return ret ?: -EPERM;
size = amdgpu_dpm_print_clock_levels(adev, od_type, buf);
if (size == 0)--
2.40.1
Re: [PATCH v1 5/9] drm/amd/pm: use pm_runtime_get_if_active for debugfs getters
Quoted 1 line · Kenneth
[AMD Official Use Only - AMD Internal Distribution Only]
I don't know what I can do with this.
1) The "AMD Official Use Only - AMD Internal Distribution Only" above suggests to me that I can't act on it. Is there any way you can get rid of that notice?
2) Even if I could act on this, I don't see any comments or reactions below.
Quoted 324 lines
-----Original Message-----
From: Pelloux-Prayer, Pierre-Eric <[email protected]>
Sent: Wednesday, September 25, 2024 3:54 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>; Limonciello, Mario <[email protected]>
Cc: Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: [PATCH v1 5/9] drm/amd/pm: usepm_runtime_get_if_activefor debugfs gettersDon't wake up the GPU for reading pm values. Instead, take a runtime powermanagement ref when trying to read it iff the GPU is already awake. Kenneth - just a nit-pick iff(typo) -> if
This avoids spurious wake ups (eg: from applets).
We use
pm_runtime_get_if_in_active(ign_usage_count=true)because we care about "is the GPU awake?" not about "is the GPU awake and something else prevents suspend?".Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 138 ++++++++++++++--------------- 1 file changed, 69 insertions(+), 69 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +18
-18@@ -145,9 +145,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -268,9 +268,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev);@@ -364,9 +364,9 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data));@@ -399,9 +399,9 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm);@@ -526,9 +526,9 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pp_table (adev, &table);@@ -840,9 +840,9 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;for (clk_index =0 ; clk_index <6 ; clk_index++) { ret = amdgpu_dpm_emit_clock_levels(adev, od_clocks[clk_index], buf, &size); @@ -930,9 +930,9 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (adev->in_suspend && !adev->in_runpm) return -EPERM;drivers/gpu/drm/amd/pm/amdgpu_pm.c +18
-18- ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 )@@ -996,9 +996,9 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -1245,9 +1245,9 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_sclk_od (adev);@@ -1302,9 +1302,9 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; value =amdgpu_dpm_get_mclk_od (adev);@@ -1379,9 +1379,9 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 )@@ -1467,9 +1467,9 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ;/* get the sensor value */ r = amdgpu_dpm_read_sensor(adev, sensor, query, &size); @@ -1583,9 +1583,9 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage) return -ENODATA;drivers/gpu/drm/amd/pm/amdgpu_pm.c +33
-34- ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ;amdgpu_asic_get_pcie_usage (adev, &count0, &count1);@@ -1711,9 +1711,9 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret)@@ -1787,9 +1787,9 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE );@@ -1825,9 +1825,9 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (ddev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -2700,9 +2700,9 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -2828,9 +2828,9 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_pwm (adev, &speed);@@ -2855,9 +2855,9 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &speed);@@ -2916,9 +2916,9 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - err =pm_runtime_resume_and_get (adev->dev); -if (err <0 ) -return err; + err =pm_runtime_get_if_active (adev->dev, true); +if (err <=0 ) +return err ?: -EPERM ; err =amdgpu_dpm_get_fan_speed_rpm (adev, &rpm);@@ -2986,9 +2986,9 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; ret =amdgpu_dpm_get_fan_control_mode (adev, &pwm_mode);@@ -3152,9 +3152,9 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - r =pm_runtime_resume_and_get (adev->dev); -if (r <0 ) -return r; + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_dpm_get_power_limit (adev, &limit, pp_limit_level, power_type);@@ -3685,9 +3685,9 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (adev->in_suspend && !adev->in_runpm)return -EPERM ; - ret =pm_runtime_resume_and_get (adev->dev); -if (ret <0 ) -return ret; + ret =pm_runtime_get_if_active (adev->dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; size =amdgpu_dpm_print_clock_levels (adev, od_type, buf);if (size ==0 ) --2.40.1
PATCH 6/9 drm/amd/pm: stop extra checks for runtime pm state
In reply to Pierre-Eric Pelloux-Prayerpm_runtime_get_if_in_use already checks if the GPU is active, so there's no need for manually checking runtimepm status:
if (adev->in_suspend && !adev->in_runpm)
return -EPERM;--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 46 ------------------------------ 1 file changed, 46 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0 -46
@@ -142,8 +142,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -265,8 +263,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -361,8 +357,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -396,8 +390,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -523,8 +515,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -837,8 +827,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -927,8 +915,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -993,8 +979,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -1242,8 +1226,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -1299,8 +1281,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -1376,8 +1356,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -1464,8 +1442,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )
@@ -1574,8 +1550,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;
@@ -1784,8 +1758,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -1822,8 +1794,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )
@@ -2697,8 +2667,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )
@@ -2825,8 +2793,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )
@@ -2852,8 +2818,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )
@@ -2913,8 +2877,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )
@@ -2983,8 +2945,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )
@@ -3149,8 +3109,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )
@@ -3682,8 +3640,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )
@@ -4649,8 +4605,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_resume_and_get (dev->dev);if (r <0 )
Signature · 1 line
2.40.1
Re: [PATCH v1 6/9] drm/amd/pm: stop extra checks for runtime pm state
Quoted 17 lines · Pierre-Eric Pelloux-Prayer
pm_runtime_get_if_in_usealready checks if the GPU is active, so there's no need for manually checking runtimepm status:if (adev->in_suspend && !adev->in_runpm) return -EPERM;Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 46 ------------------------------ 1 file changed, 46 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct device *dev, · line 145
Quoted 6 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-2@@ -142,8 +142,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;
I believe this check is for accesses before the device is fully resumed from a suspend sequence. That is not tied to runtime PM.
Thanks,
Lijo
Quoted 200 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-44ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -265,8 +263,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -361,8 +357,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -396,8 +390,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -523,8 +515,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -837,8 +827,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -927,8 +915,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -993,8 +979,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1242,8 +1226,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1299,8 +1281,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1376,8 +1356,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1464,8 +1442,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -1574,8 +1550,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;@@ -1784,8 +1758,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1822,8 +1794,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -2697,8 +2667,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -2825,8 +2793,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2852,8 +2818,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2913,8 +2877,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2983,8 +2945,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -3149,8 +3109,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -3682,8 +3640,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -4649,8 +4605,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_resume_and_get (dev->dev);if (r <0 )
Re: [PATCH v1 6/9] drm/amd/pm: stop extra checks for runtime pm state
Le 25/09/2024 à 15:37, Lazar, Lijo a écrit :
Quoted 21 lines · Pierre-Eric Pelloux-Prayer
Quoted 18 lines
pm_runtime_get_if_in_usealready checks if the GPU is active, so there's no need for manually checking runtimepm status:if (adev->in_suspend && !adev->in_runpm) return -EPERM;Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 46 ------------------------------ 1 file changed, 46 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -142,8 +142,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct device *dev, · line 145
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-2if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;I believe this check is for accesses before the device is fully resumed from a suspend sequence. That is not tied to runtime PM.
AFAICT in_suspend / in_runpm are only set from resume / suspend sequences, so checking runtime_status != RPM_ACTIVE like pm_runtime_get_if_in_use does should provide the same result.
(= during resume the device status is RPM_RESUMING)
Pierre-Eric
Quoted 204 lines
Thanks,
LijoQuoted 200 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-44ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -265,8 +263,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -361,8 +357,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -396,8 +390,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -523,8 +515,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -837,8 +827,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -927,8 +915,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -993,8 +979,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1242,8 +1226,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1299,8 +1281,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1376,8 +1356,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1464,8 +1442,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -1574,8 +1550,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;@@ -1784,8 +1758,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1822,8 +1794,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -2697,8 +2667,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -2825,8 +2793,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2852,8 +2818,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2913,8 +2877,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2983,8 +2945,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -3149,8 +3109,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -3682,8 +3640,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -4649,8 +4605,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_resume_and_get (dev->dev);if (r <0 )
Re: [PATCH v1 6/9] drm/amd/pm: stop extra checks for runtime pm state
Quoted 35 lines · Pierre-Eric Pelloux-Prayer
Le 25/09/2024 à 15:37, Lazar, Lijo a écrit :
Quoted 16 lines · Pierre-Eric Pelloux-Prayer
Quoted 13 lines
pm_runtime_get_if_in_usealready checks if the GPU is active, so there's no need for manually checking runtimepm status:if (
adev->in_suspend&& !adev->in_runpm)
return-EPERM;Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer<[email protected]>
---
drivers/gpu/drm/amd/pm/amdgpu_pm.c| 46 ------------------------------1 file changed, 46 deletions(-)Quoted 15 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-2@@ -142,8 +142,6 @@ static ssize_t amdgpu_get_power_dpm_state(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM;Quoted 1 line
I believe this check is for accesses before the device is fully resumed from a suspend sequence. That is not tied to runtime PM.
Quoted 8 lines
AFAICT
in_suspend/in_runpmare only set from resume / suspend sequences, so checkingruntime_status!=RPM_ACTIVElikepm_runtime_get_if_in_usedoes should provide the same result.(= during resume the device status is
RPM_RESUMING)Pierre-Eric
On devices whose runtime PM is forbidden, I'm not sure if it goes through RPM_ state changes or just statically remains at RPM_ACTIVE.
Regardless, these checks are removed only for sys/debug fs attributes. Hence as Alex mentioned this access check was not required in the first place.
Thanks,
Lijo
Quoted 183 lines
Quoted 183 lines
Thanks,
LijoQuoted 178 lines
ret =
pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-44@@ -265,8 +263,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -361,8 +357,6 @@ static ssize_t amdgpu_get_pp_num_states(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -396,8 +390,6 @@ static ssize_t amdgpu_get_pp_cur_state(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -523,8 +515,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -837,8 +827,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -927,8 +915,6 @@ static ssize_t amdgpu_get_pp_features(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -993,8 +979,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -1242,8 +1226,6 @@ static ssize_t amdgpu_get_pp_sclk_od(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -1299,8 +1281,6 @@ static ssize_t amdgpu_get_pp_mclk_od(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -1376,8 +1356,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -1464,8 +1442,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; r = pm_runtime_get_if_active(adev->dev, true); if (r <= 0)@@ -1574,8 +1550,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; if (adev->flags & AMD_IS_APU) return -ENODATA;@@ -1784,8 +1758,6 @@ static ssize_t amdgpu_get_pm_metrics(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -1822,8 +1794,6 @@ static ssize_t amdgpu_get_gpu_metrics(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(ddev->dev, true); if (ret <= 0)@@ -2697,8 +2667,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(adev->dev, true); if (ret <= 0)@@ -2825,8 +2793,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(structdevice *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; err = pm_runtime_get_if_active(adev->dev, true); if (err <= 0)@@ -2852,8 +2818,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; err = pm_runtime_get_if_active(adev->dev, true); if (err <= 0)@@ -2913,8 +2877,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; err = pm_runtime_get_if_active(adev->dev, true); if (err <= 0)@@ -2983,8 +2945,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(adev->dev, true); if (ret <= 0)@@ -3149,8 +3109,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; r = pm_runtime_get_if_active(adev->dev, true); if (r <= 0)@@ -3682,8 +3640,6 @@ static int amdgpu_retrieve_od_settings(structamdgpu_device *adev, if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; ret = pm_runtime_get_if_active(adev->dev, true); if (ret <= 0)@@ -4649,8 +4605,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused) if (amdgpu_in_reset(adev)) return -EPERM; - if (adev->in_suspend && !adev->in_runpm) - return -EPERM; r = pm_runtime_resume_and_get(dev->dev); if (r < 0)
Re: [PATCH v1 6/9] drm/amd/pm: stop extra checks for runtime pm state
In reply to Lazar, LijoQuoted 22 lines · Lijo
Quoted 18 lines · Pierre-Eric Pelloux-Prayer
pm_runtime_get_if_in_usealready checks if the GPU is active, so there's no need for manually checking runtimepm status:if (adev->in_suspend && !adev->in_runpm) return -EPERM;Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 46 ------------------------------ 1 file changed, 46 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-0@@ -142,8 +142,6 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,
Quoted 8 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c static ssize_t amdgpu_get_power_dpm_state(struct device *dev, · line 145
Quoted 5 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-2if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;I believe this check is for accesses before the device is fully resumed from a suspend sequence. That is not tied to runtime PM.
In theory, user processes should not be resumed until the kernel drivers have resumed so I think the check was probably not needed in the first place.
Alex
Quoted 204 lines
Thanks,
LijoQuoted 200 lines
drivers/gpu/drm/amd/pm/amdgpu_pm.c +0
-44ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -265,8 +263,6 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -361,8 +357,6 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -396,8 +390,6 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -523,8 +515,6 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -837,8 +827,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -927,8 +915,6 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -993,8 +979,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1242,8 +1226,6 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1299,8 +1281,6 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1376,8 +1356,6 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1464,8 +1442,6 @@ static int amdgpu_hwmon_get_sensor_generic(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -1574,8 +1550,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;@@ -1784,8 +1758,6 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -1822,8 +1794,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (ddev->dev, true);if (ret <=0 )@@ -2697,8 +2667,6 @@ static ssize_t amdgpu_hwmon_get_pwm1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -2825,8 +2793,6 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2852,8 +2818,6 @@ static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2913,8 +2877,6 @@ static ssize_t amdgpu_hwmon_get_fan1_target(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; err =pm_runtime_get_if_active (adev->dev, true);if (err <=0 )@@ -2983,8 +2945,6 @@ static ssize_t amdgpu_hwmon_get_fan1_enable(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -3149,8 +3109,6 @@ static ssize_t amdgpu_hwmon_show_power_cap_generic(struct device *dev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_get_if_active (adev->dev, true);if (r <=0 )@@ -3682,8 +3640,6 @@ static int amdgpu_retrieve_od_settings(struct amdgpu_device *adev,if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; ret =pm_runtime_get_if_active (adev->dev, true);if (ret <=0 )@@ -4649,8 +4605,6 @@ static int amdgpu_debugfs_pm_info_show(struct seq_file *m, void *unused)if (amdgpu_in_reset (adev))return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; r =pm_runtime_resume_and_get (dev->dev);if (r <0 )
PATCH 7/9 drm/amd/pm: add sysfs attribute access wrappers
In reply to Pierre-Eric Pelloux-PrayerAll attributes do the same thing wrt to runtime power management, so we can consolidate the handling in 2 wrappers.
For some setters this will change the behavior slightly, as rpm is now done before arguments validation - so the device will be resumed even if the arguments passed in are incorrect.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 399 ++++--------------------- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 16 +- 2 files changed, 78 insertions(+), 337 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +66 -333
@@ -97,6 +97,61 @@ const char * const amdgpu_pp_profile_name[] = { "UNCAPPED", }; +static ssize_t amdgpu_pp_attr_show_wrapper (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct amdgpu_device_attr *aattr; +ssize_t r; +int ret; + +if (amdgpu_in_reset (adev)) +return -EPERM ; + ret =pm_runtime_get_if_active (dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; + + aattr =to_amdgpu_device_attr (attr); + + r = aattr->attr_show (dev, attr, buf); + +pm_runtime_put_autosuspend (dev); + +return r; +} + +static ssize_t amdgpu_pp_attr_store_wrapper (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct amdgpu_device_attr *aattr; +ssize_t r; +int ret; + +if (amdgpu_in_reset (adev)) +return -EPERM ; +if (adev->in_suspend && !adev->in_runpm) +return -EPERM ; + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; + + aattr =to_amdgpu_device_attr (attr); + + r = aattr->attr_store (dev, attr, buf, count); + +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); + +return r; +} + +/** * DOC: power_dpm_state *
@@ -138,19 +193,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_pm_state_type pm; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%s\n" , (pm ==POWER_STATE_TYPE_BATTERY ) ?"battery" : (pm ==POWER_STATE_TYPE_BALANCED ) ?"balanced" :"performance" );
@@ -164,12 +209,6 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_pm_state_type state; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (strncmp ("battery" , buf,strlen ("battery" )) ==0 ) state =POWER_STATE_TYPE_BATTERY ;
@@ -180,15 +219,8 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,else return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_power_state (adev, state); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }
@@ -259,19 +291,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_dpm_forced_level level =0xff ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%s\n" , (level ==AMD_DPM_FORCED_LEVEL_AUTO ) ?"auto" : (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" :
@@ -293,12 +315,6 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_dpm_forced_level level; -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (strncmp ("low" , buf,strlen ("low" )) ==0 ) { level =AMD_DPM_FORCED_LEVEL_LOW ;
@@ -324,14 +340,8 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,return -EINVAL ; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -mutex_lock (&adev->pm.stable_pstate_ctx_lock);if (amdgpu_dpm_force_performance_level (adev, level)) { -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);mutex_unlock (&adev->pm.stable_pstate_ctx_lock);return -EINVAL ; }
@@ -339,9 +349,6 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev, adev->pm.stable_pstate_ctx =NULL ;mutex_unlock (&adev->pm.stable_pstate_ctx_lock); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }
@@ -353,20 +360,11 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,struct amdgpu_device *adev =drm_to_adev (ddev);struct pp_states_info data;uint32_t i; -int buf_len, ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int buf_len;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data)); -pm_runtime_put_autosuspend (ddev->dev); - buf_len =sysfs_emit (buf,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) buf_len += sysfs_emit_at(buf, buf_len, "%d %s\n", i,
@@ -386,21 +384,12 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,struct amdgpu_device *adev =drm_to_adev (ddev);struct pp_states_info data = {0 };enum amd_pm_state_type pm =0 ; -int i =0 , ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int i, ret;amdgpu_dpm_get_current_power_state (adev, &pm); ret =amdgpu_dpm_get_pp_num_states (adev, &data); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;
@@ -422,11 +411,6 @@ static ssize_t amdgpu_get_pp_force_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (adev->pm.pp_force_state_enabled)return amdgpu_get_pp_cur_state (dev, attr, buf);else
@@ -445,11 +429,6 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,unsigned long idx;int ret; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - adev->pm.pp_force_state_enabled = false;if (strlen (buf) ==1 )
@@ -461,10 +440,6 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, idx =array_index_nospec (idx,ARRAY_SIZE (data.states)); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_get_pp_num_states (adev, &data);if (ret) goto err_out;
@@ -482,14 +457,9 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, adev->pm.pp_force_state_enabled = true; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; err_out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return ret; }
@@ -511,19 +481,10 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);char *table =NULL ; -int size, ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int size; size =amdgpu_dpm_get_pp_table (adev, &table); -pm_runtime_put_autosuspend (ddev->dev); -if (size <=0 )return size;
@@ -542,22 +503,10 @@ static ssize_t amdgpu_set_pp_table(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; +int ret; ret =amdgpu_dpm_set_pp_table (adev, buf, count); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;
@@ -725,11 +674,6 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,const char delimiter[3 ] = {' ' ,'\n' ,'\0' };uint32_t type; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (count >127 || count ==0 )return -EINVAL ;
@@ -775,10 +719,6 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, tmp_str++; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - if (amdgpu_dpm_set_fine_grain_clk_vol(adev, type, parameter,
@@ -796,14 +736,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, goto err_out; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; err_out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return -EINVAL ; }
@@ -825,13 +760,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, };uint clk_index; -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; -for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);if (ret)
@@ -849,8 +777,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -880,24 +806,12 @@ static ssize_t amdgpu_set_pp_features(struct device *dev,uint64_t featuremask;int ret; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtou64 (buf,0 , &featuremask);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_ppfeature_status (adev, featuremask); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return -EINVAL ;
@@ -911,21 +825,11 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);ssize_t size; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -975,14 +879,7 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);int size =0 ; -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int ret; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )
@@ -991,8 +888,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -1041,24 +936,12 @@ static ssize_t amdgpu_set_pp_dpm_clock(struct device *dev,int ret;uint32_t mask =0 ; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =amdgpu_read_mask (buf, count, &mask);if (ret)return ret; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_force_clock_level (adev, type, mask); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return -EINVAL ;
@@ -1221,20 +1104,10 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -uint32_t value =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +uint32_t value; value =amdgpu_dpm_get_sclk_od (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%d\n" , value); }
@@ -1248,25 +1121,13 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,int ret;long int value; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtol (buf,0 , &value);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }
@@ -1276,20 +1137,10 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -uint32_t value =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +uint32_t value; value =amdgpu_dpm_get_mclk_od (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%d\n" , value); }
@@ -1303,25 +1154,13 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,int ret;long int value; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtol (buf,0 , &value);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }
@@ -1352,21 +1191,11 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);ssize_t size; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -1388,11 +1217,6 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,long int profile_mode =0 ;const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - tmp[0 ] = *(buf); tmp[1 ] ='\0' ; ret =kstrtol (tmp,0 , &profile_mode);
@@ -1419,15 +1243,8 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, } parameter[parameter_size] = profile_mode; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_power_profile_mode (adev, parameter, parameter_size); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (!ret)return count;
@@ -1546,10 +1363,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);uint64_t count0 =0 , count1 =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;
@@ -1557,14 +1370,8 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; -amdgpu_asic_get_pcie_usage (adev, &count0, &count1); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%llu %llu %i\n" , count0, count1,pcie_get_mps (adev->pdev)); }
@@ -1586,11 +1393,6 @@ static ssize_t amdgpu_get_unique_id(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (adev->unique_id)return sysfs_emit (buf,"%016llx\n" , adev->unique_id);
@@ -1685,18 +1487,12 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; - ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret) size =sysfs_emit (buf,"%u\n" , limit);else size =sysfs_emit (buf,"failed to get thermal limit\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -1719,21 +1515,12 @@ static ssize_t amdgpu_set_apu_thermal_cap(struct device *dev,return -EINVAL ; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_apu_thermal_limit (adev, value);if (ret) { -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);dev_err (dev,"failed to update thermal limit\n" );return ret; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }
@@ -1753,21 +1540,8 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -ssize_t size =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; - size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); - -pm_runtime_put_autosuspend (ddev->dev); - -return size; +return amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); }/**
@@ -1789,15 +1563,7 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);void *gpu_metrics; -ssize_t size =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +ssize_t size; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )
@@ -1809,8 +1575,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,memcpy (buf, gpu_metrics, size); out: -pm_runtime_put_autosuspend (ddev->dev); -return size; }
@@ -1900,23 +1664,12 @@ static ssize_t amdgpu_set_smartshift_bias(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) { - struct drm_device *ddev = dev_get_drvdata(dev); -struct amdgpu_device *adev =drm_to_adev (ddev); -int r =0 ; + int r;int bias =0 ; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - - r =pm_runtime_resume_and_get (ddev->dev); -if (r <0 ) -return r; - r =kstrtoint (buf,10 , &bias);if (r) - goto out; +return r;if (bias >AMDGPU_SMARTSHIFT_MAX_BIAS ) bias =AMDGPU_SMARTSHIFT_MAX_BIAS ;
@@ -1928,9 +1681,6 @@ static ssize_t amdgpu_set_smartshift_bias(struct device *dev,/* TODO: update bias level with SMU message */ -out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return r; }
@@ -2184,11 +1934,6 @@ static ssize_t amdgpu_get_pm_policy_attr(struct device *dev, policy_attr = container_of(attr, struct amdgpu_pm_policy_attr, dev_attr); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -return amdgpu_dpm_get_pm_policy_info (adev, policy_attr->id, buf); }
@@ -2205,11 +1950,6 @@ static ssize_t amdgpu_set_pm_policy_attr(struct device *dev,char *tmp, *param;long val; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - count =min (count,sizeof (tmp_buf));memcpy (tmp_buf, buf, count); tmp_buf[count -1 ] ='\0' ;
@@ -2235,15 +1975,8 @@ static ssize_t amdgpu_set_pm_policy_attr(struct device *dev, policy_attr = container_of(attr, struct amdgpu_pm_policy_attr, dev_attr); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_pm_policy (adev, policy_attr->id, val); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +12 -4
@@ -88,6 +88,10 @@ struct amdgpu_device_attr {int (*attr_update)(struct amdgpu_device *adev,struct amdgpu_device_attr *attr,uint32_t mask,enum amdgpu_device_attr_states *states); +ssize_t (*attr_show)(struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t (*attr_store)(struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); };struct amdgpu_device_attr_entry {
@@ -98,10 +102,14 @@ struct amdgpu_device_attr_entry {#define to_amdgpu_device_attr (_dev_attr) \ container_of(_dev_attr, struct amdgpu_device_attr, dev_attr) -#define __AMDGPU_DEVICE_ATTR (_name, _mode, _show, _store, _flags, ...) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .attr_id = device_attr_id__##_name, \ - .flags = _flags, \ +#define __AMDGPU_DEVICE_ATTR (_name, _mode, _show, _store, _flags, ...) \ + { .dev_attr = __ATTR(_name, _mode, \ + amdgpu_pp_attr_show_wrapper, \ + _store ? amdgpu_pp_attr_store_wrapper : NULL), \ + .attr_id = device_attr_id__##_name, \ + .flags = _flags, \ + .attr_show = _show, \ + .attr_store = _store, \ ##__VA_ARGS__, }#define AMDGPU_DEVICE_ATTR (_name, _mode, _flags, ...) \
Signature · 1 line
2.40.1
Re: [PATCH v1 7/9] drm/amd/pm: add sysfs attribute access wrappers
Le 25/09/2024 à 09:54, Pierre-Eric Pelloux-Prayer a écrit :
Quoted 852 lines
All attributes do the same thing wrt to runtime power management, so we can consolidate the handling in 2 wrappers.
For some setters this will change the behavior slightly, as rpm is now done before arguments validation - so the device will be resumed even if the arguments passed in are incorrect.
Tested-by Mario Limonciello <[email protected]>Signed-off-by Pierre-Eric Pelloux-Prayer <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 399 ++++--------------------- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 16 +- 2 files changed, 78 insertions(+), 337 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_pm.c +66
-333@@ -97,6 +97,61 @@ const char * const amdgpu_pp_profile_name[] = { "UNCAPPED", }; +static ssize_t amdgpu_pp_attr_show_wrapper (struct device *dev, +struct device_attribute *attr, +char *buf) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct amdgpu_device_attr *aattr; +ssize_t r; +int ret; + +if (amdgpu_in_reset (adev)) +return -EPERM ; + ret =pm_runtime_get_if_active (dev, true); +if (ret <=0 ) +return ret ?: -EPERM ; + + aattr =to_amdgpu_device_attr (attr); + + r = aattr->attr_show (dev, attr, buf); + +pm_runtime_put_autosuspend (dev); + +return r; +} + +static ssize_t amdgpu_pp_attr_store_wrapper (struct device *dev, +struct device_attribute *attr, +const char *buf, +size_t count) +{ +struct drm_device *ddev =dev_get_drvdata (dev); +struct amdgpu_device *adev =drm_to_adev (ddev); +struct amdgpu_device_attr *aattr; +ssize_t r; +int ret; + +if (amdgpu_in_reset (adev)) +return -EPERM ; +if (adev->in_suspend && !adev->in_runpm) +return -EPERM ; + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) +return ret; + + aattr =to_amdgpu_device_attr (attr); + + r = aattr->attr_store (dev, attr, buf, count); + +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); + +return r; +} + +/** * DOC: power_dpm_state * @@ -138,19 +193,9 @@ static ssize_t amdgpu_get_power_dpm_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_pm_state_type pm; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ;amdgpu_dpm_get_current_power_state (adev, &pm); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%s\n" , (pm ==POWER_STATE_TYPE_BATTERY ) ?"battery" : (pm ==POWER_STATE_TYPE_BALANCED ) ?"balanced" :"performance" );@@ -164,12 +209,6 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_pm_state_type state; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (strncmp ("battery" , buf,strlen ("battery" )) ==0 ) state =POWER_STATE_TYPE_BATTERY ;@@ -180,15 +219,8 @@ static ssize_t amdgpu_set_power_dpm_state(struct device *dev,else return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_power_state (adev, state); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }@@ -259,19 +291,9 @@ static ssize_t amdgpu_get_power_dpm_force_performance_level(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_dpm_forced_level level =0xff ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; level =amdgpu_dpm_get_performance_level (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%s\n" , (level ==AMD_DPM_FORCED_LEVEL_AUTO ) ?"auto" : (level == AMD_DPM_FORCED_LEVEL_LOW) ? "low" :@@ -293,12 +315,6 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);enum amd_dpm_forced_level level; -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ;if (strncmp ("low" , buf,strlen ("low" )) ==0 ) { level =AMD_DPM_FORCED_LEVEL_LOW ;@@ -324,14 +340,8 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev,return -EINVAL ; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -mutex_lock (&adev->pm.stable_pstate_ctx_lock);if (amdgpu_dpm_force_performance_level (adev, level)) { -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);mutex_unlock (&adev->pm.stable_pstate_ctx_lock);return -EINVAL ; }@@ -339,9 +349,6 @@ static ssize_t amdgpu_set_power_dpm_force_performance_level(struct device *dev, adev->pm.stable_pstate_ctx =NULL ;mutex_unlock (&adev->pm.stable_pstate_ctx_lock); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }@@ -353,20 +360,11 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,struct amdgpu_device *adev =drm_to_adev (ddev);struct pp_states_info data;uint32_t i; -int buf_len, ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int buf_len;if (amdgpu_dpm_get_pp_num_states (adev, &data))memset (&data,0 ,sizeof (data)); -pm_runtime_put_autosuspend (ddev->dev); - buf_len =sysfs_emit (buf,"states: %d\n" , data.nums);for (i =0 ; i < data.nums; i++) buf_len += sysfs_emit_at(buf, buf_len, "%d %s\n", i,@@ -386,21 +384,12 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,struct amdgpu_device *adev =drm_to_adev (ddev);struct pp_states_info data = {0 };enum amd_pm_state_type pm =0 ; -int i =0 , ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int i, ret;amdgpu_dpm_get_current_power_state (adev, &pm); ret =amdgpu_dpm_get_pp_num_states (adev, &data); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;@@ -422,11 +411,6 @@ static ssize_t amdgpu_get_pp_force_state(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (adev->pm.pp_force_state_enabled)return amdgpu_get_pp_cur_state (dev, attr, buf);else @@ -445,11 +429,6 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev,unsigned long idx;int ret; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - adev->pm.pp_force_state_enabled = false;if (strlen (buf) ==1 )@@ -461,10 +440,6 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, idx =array_index_nospec (idx,ARRAY_SIZE (data.states)); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_get_pp_num_states (adev, &data);if (ret) goto err_out;@@ -482,14 +457,9 @@ static ssize_t amdgpu_set_pp_force_state(struct device *dev, adev->pm.pp_force_state_enabled = true; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; err_out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return ret; }@@ -511,19 +481,10 @@ static ssize_t amdgpu_get_pp_table(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);char *table =NULL ; -int size, ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int size; size =amdgpu_dpm_get_pp_table (adev, &table); -pm_runtime_put_autosuspend (ddev->dev); -if (size <=0 )return size;@@ -542,22 +503,10 @@ static ssize_t amdgpu_set_pp_table(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; +int ret; ret =amdgpu_dpm_set_pp_table (adev, buf, count); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;@@ -725,11 +674,6 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev,const char delimiter[3 ] = {' ' ,'\n' ,'\0' };uint32_t type; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (count >127 || count ==0 )return -EINVAL ;@@ -775,10 +719,6 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, tmp_str++; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - if (amdgpu_dpm_set_fine_grain_clk_vol(adev, type, parameter,@@ -796,14 +736,9 @@ static ssize_t amdgpu_set_pp_od_clk_voltage(struct device *dev, goto err_out; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; err_out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return -EINVAL ; }@@ -825,13 +760,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev, };uint clk_index; -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; -for (clk_index =0 ; clk_index <6 ; clk_index++) { ret =amdgpu_dpm_emit_clock_levels (adev, od_clocks[clk_index], buf, &size);if (ret)@@ -849,8 +777,6 @@ static ssize_t amdgpu_get_pp_od_clk_voltage(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -880,24 +806,12 @@ static ssize_t amdgpu_set_pp_features(struct device *dev,uint64_t featuremask;int ret; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtou64 (buf,0 , &featuremask);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_ppfeature_status (adev, featuremask); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return -EINVAL ;@@ -911,21 +825,11 @@ static ssize_t amdgpu_get_pp_features(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);ssize_t size; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; size =amdgpu_dpm_get_ppfeature_status (adev, buf);if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -975,14 +879,7 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);int size =0 ; -int ret =0 ; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +int ret; ret =amdgpu_dpm_emit_clock_levels (adev, type, buf, &size);if (ret == -ENOENT )@@ -991,8 +888,6 @@ static ssize_t amdgpu_get_pp_dpm_clock(struct device *dev,if (size ==0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -1041,24 +936,12 @@ static ssize_t amdgpu_set_pp_dpm_clock(struct device *dev,int ret;uint32_t mask =0 ; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =amdgpu_read_mask (buf, count, &mask);if (ret)return ret; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_force_clock_level (adev, type, mask); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return -EINVAL ;@@ -1221,20 +1104,10 @@ static ssize_t amdgpu_get_pp_sclk_od(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -uint32_t value =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +uint32_t value; value =amdgpu_dpm_get_sclk_od (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%d\n" , value); }@@ -1248,25 +1121,13 @@ static ssize_t amdgpu_set_pp_sclk_od(struct device *dev,int ret;long int value; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtol (buf,0 , &value);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_sclk_od (adev, (uint32_t )value); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }@@ -1276,20 +1137,10 @@ static ssize_t amdgpu_get_pp_mclk_od(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -uint32_t value =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +uint32_t value; value =amdgpu_dpm_get_mclk_od (adev); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%d\n" , value); }@@ -1303,25 +1154,13 @@ static ssize_t amdgpu_set_pp_mclk_od(struct device *dev,int ret;long int value; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - ret =kstrtol (buf,0 , &value);if (ret)return -EINVAL ; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; -amdgpu_dpm_set_mclk_od (adev, (uint32_t )value); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }@@ -1352,21 +1191,11 @@ static ssize_t amdgpu_get_pp_power_profile_mode(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);ssize_t size; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; size =amdgpu_dpm_get_power_profile_mode (adev, buf);if (size <=0 ) size =sysfs_emit (buf,"\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -1388,11 +1217,6 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev,long int profile_mode =0 ;const char delimiter[3 ] = {' ' ,'\n' ,'\0' }; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - tmp[0 ] = *(buf); tmp[1 ] ='\0' ; ret =kstrtol (tmp,0 , &profile_mode);@@ -1419,15 +1243,8 @@ static ssize_t amdgpu_set_pp_power_profile_mode(struct device *dev, } parameter[parameter_size] = profile_mode; - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_power_profile_mode (adev, parameter, parameter_size); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (!ret)return count;@@ -1546,10 +1363,6 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);uint64_t count0 =0 , count1 =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ;if (adev->flags &AMD_IS_APU )return -ENODATA ;@@ -1557,14 +1370,8 @@ static ssize_t amdgpu_get_pcie_bw(struct device *dev,if (!adev->asic_funcs->get_pcie_usage)return -ENODATA ; - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; -amdgpu_asic_get_pcie_usage (adev, &count0, &count1); -pm_runtime_put_autosuspend (ddev->dev); -return sysfs_emit (buf,"%llu %llu %i\n" , count0, count1,pcie_get_mps (adev->pdev)); }@@ -1586,11 +1393,6 @@ static ssize_t amdgpu_get_unique_id(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -if (adev->unique_id)return sysfs_emit (buf,"%016llx\n" , adev->unique_id);@@ -1685,18 +1487,12 @@ static ssize_t amdgpu_get_apu_thermal_cap(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; - ret =amdgpu_dpm_get_apu_thermal_limit (adev, &limit);if (!ret) size =sysfs_emit (buf,"%u\n" , limit);else size =sysfs_emit (buf,"failed to get thermal limit\n" ); -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -1719,21 +1515,12 @@ static ssize_t amdgpu_set_apu_thermal_cap(struct device *dev,return -EINVAL ; } - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_apu_thermal_limit (adev, value);if (ret) { -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);dev_err (dev,"failed to update thermal limit\n" );return ret; } -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -return count; }@@ -1753,21 +1540,8 @@ static ssize_t amdgpu_get_pm_metrics(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev); -ssize_t size =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; - size =amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); - -pm_runtime_put_autosuspend (ddev->dev); - -return size; +return amdgpu_dpm_get_pm_metrics (adev, buf,PAGE_SIZE ); }/** @@ -1789,15 +1563,7 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev =drm_to_adev (ddev);void *gpu_metrics; -ssize_t size =0 ; -int ret; - -if (amdgpu_in_reset (adev)) -return -EPERM ; - - ret =pm_runtime_get_if_active (ddev->dev, true); -if (ret <=0 ) -return ret ?: -EPERM ; +ssize_t size; size =amdgpu_dpm_get_gpu_metrics (adev, &gpu_metrics);if (size <=0 )@@ -1809,8 +1575,6 @@ static ssize_t amdgpu_get_gpu_metrics(struct device *dev,memcpy (buf, gpu_metrics, size); out: -pm_runtime_put_autosuspend (ddev->dev); -return size; }@@ -1900,23 +1664,12 @@ static ssize_t amdgpu_set_smartshift_bias(struct device *dev,struct device_attribute *attr, const char *buf, size_t count) { - struct drm_device *ddev = dev_get_drvdata(dev); -struct amdgpu_device *adev =drm_to_adev (ddev); -int r =0 ; + int r;int bias =0 ; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - - r =pm_runtime_resume_and_get (ddev->dev); -if (r <0 ) -return r; - r =kstrtoint (buf,10 , &bias);if (r) - goto out; +return r;if (bias >AMDGPU_SMARTSHIFT_MAX_BIAS ) bias =AMDGPU_SMARTSHIFT_MAX_BIAS ;@@ -1928,9 +1681,6 @@ static ssize_t amdgpu_set_smartshift_bias(struct device *dev,/* TODO: update bias level with SMU message */ -out: -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev);return r; }@@ -2184,11 +1934,6 @@ static ssize_t amdgpu_get_pm_policy_attr(struct device *dev, policy_attr = container_of(attr, struct amdgpu_pm_policy_attr, dev_attr); -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; -return amdgpu_dpm_get_pm_policy_info (adev, policy_attr->id, buf); }@@ -2205,11 +1950,6 @@ static ssize_t amdgpu_set_pm_policy_attr(struct device *dev,char *tmp, *param;long val; -if (amdgpu_in_reset (adev)) -return -EPERM ; -if (adev->in_suspend && !adev->in_runpm) -return -EPERM ; - count =min (count,sizeof (tmp_buf));memcpy (tmp_buf, buf, count); tmp_buf[count -1 ] ='\0' ;@@ -2235,15 +1975,8 @@ static ssize_t amdgpu_set_pm_policy_attr(struct device *dev, policy_attr = container_of(attr, struct amdgpu_pm_policy_attr, dev_attr); - ret =pm_runtime_resume_and_get (ddev->dev); -if (ret <0 ) -return ret; - ret =amdgpu_dpm_set_pm_policy (adev, policy_attr->id, val); -pm_runtime_mark_last_busy (ddev->dev); -pm_runtime_put_autosuspend (ddev->dev); -if (ret)return ret;drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +4
-0@@ -88,6 +88,10 @@ struct amdgpu_device_attr {int (*attr_update)(struct amdgpu_device *adev,struct amdgpu_device_attr *attr,uint32_t mask,enum amdgpu_device_attr_states *states); +ssize_t (*attr_show)(struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t (*attr_store)(struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); };struct amdgpu_device_attr_entry {@@ -98,10 +102,14 @@ struct amdgpu_device_attr_entry {#define to_amdgpu_device_attr (_dev_attr) \
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h struct amdgpu_device_attr_entry { · line 108
Quoted 10 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +4
-4container_of(_dev_attr, struct amdgpu_device_attr, dev_attr) -#define __AMDGPU_DEVICE_ATTR (_name, _mode, _show, _store, _flags, ...) \ - { .dev_attr = __ATTR(_name, _mode, _show, _store), \ - .attr_id = device_attr_id__##_name, \ - .flags = _flags, \ +#define __AMDGPU_DEVICE_ATTR (_name, _mode, _show, _store, _flags, ...) \ + { .dev_attr = __ATTR(_name, _mode, \ + amdgpu_pp_attr_show_wrapper, \ + _store ? amdgpu_pp_attr_store_wrapper : NULL), \
FYI this triggers a warning on some compilers (the address of xxx will always evaluate as true) so I'll update this patch before merging to use AMDGPU_DEVICE_ATTR_RO / AMDGPU_DEVICE_ATTR_RW macros from the next patch.
Thanks,
Pierre-Eric
Quoted 7 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +4
-0+ .attr_id = device_attr_id__##_name, \ + .flags = _flags, \ + .attr_show = _show, \ + .attr_store = _store, \ ##__VA_ARGS__, }#define AMDGPU_DEVICE_ATTR (_name, _mode, _flags, ...) \
PATCH 8/9 drm/amd/pm: move private definitions to the .c file
In reply to Pierre-Eric Pelloux-PrayerMove stuff that's only used in amdgpu_pm.c to the top of file instead of leaving it in a .h files included in 30+ files.
--- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 98 +++++++++++++++++++++++ drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 104 ------------------------- 2 files changed, 98 insertions(+), 104 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_pm.c +98 -0
@@ -97,6 +97,85 @@ const char * const amdgpu_pp_profile_name[] = { "UNCAPPED", }; +struct cg_flag_name { +u64 flag; +const char *name; +}; + +enum amdgpu_device_attr_flags { +ATTR_FLAG_BASIC = (1 <<0 ), +ATTR_FLAG_ONEVF = (1 <<16 ), +}; + +#define ATTR_FLAG_TYPE_MASK (0x0000ffff) +#define ATTR_FLAG_MODE_MASK (0xffff0000) +#define ATTR_FLAG_MASK_ALL (0xffffffff) + +enum amdgpu_device_attr_states { +ATTR_STATE_UNSUPPORTED =0 , +ATTR_STATE_SUPPORTED , +}; + +enum amdgpu_device_attr_id { + device_attr_id__unknown =-1 , + device_attr_id__power_dpm_state =0 , + device_attr_id__power_dpm_force_performance_level, + device_attr_id__pp_num_states, + device_attr_id__pp_cur_state, + device_attr_id__pp_force_state, + device_attr_id__pp_table, + device_attr_id__pp_dpm_sclk, + device_attr_id__pp_dpm_mclk, + device_attr_id__pp_dpm_socclk, + device_attr_id__pp_dpm_fclk, + device_attr_id__pp_dpm_vclk, + device_attr_id__pp_dpm_vclk1, + device_attr_id__pp_dpm_dclk, + device_attr_id__pp_dpm_dclk1, + device_attr_id__pp_dpm_dcefclk, + device_attr_id__pp_dpm_pcie, + device_attr_id__pp_sclk_od, + device_attr_id__pp_mclk_od, + device_attr_id__pp_power_profile_mode, + device_attr_id__pp_od_clk_voltage, + device_attr_id__gpu_busy_percent, + device_attr_id__mem_busy_percent, + device_attr_id__vcn_busy_percent, + device_attr_id__pcie_bw, + device_attr_id__pp_features, + device_attr_id__unique_id, + device_attr_id__thermal_throttling_logging, + device_attr_id__apu_thermal_cap, + device_attr_id__gpu_metrics, + device_attr_id__smartshift_apu_power, + device_attr_id__smartshift_dgpu_power, + device_attr_id__smartshift_bias, + device_attr_id__pm_metrics, + device_attr_id__count, +}; + +struct amdgpu_device_attr { +struct device_attribute dev_attr; +enum amdgpu_device_attr_id attr_id; +enum amdgpu_device_attr_flags flags; +int (*attr_update)(struct amdgpu_device *adev,struct amdgpu_device_attr *attr, +uint32_t mask,enum amdgpu_device_attr_states *states); + +ssize_t (*attr_show)(struct device *dev,struct device_attribute *attr, +char *buf); +ssize_t (*attr_store)(struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); +}; + +#define to_amdgpu_device_attr (_dev_attr) \ + container_of(_dev_attr, struct amdgpu_device_attr, dev_attr) + +struct amdgpu_device_attr_entry { +struct list_head entry; +struct amdgpu_device_attr *attr; +}; + +static ssize_t amdgpu_pp_attr_show_wrapper (struct device *dev,struct device_attribute *attr,char *buf)
@@ -151,6 +230,25 @@ static ssize_t amdgpu_pp_attr_store_wrapper(struct device *dev,return r; } +#define AMDGPU_DEVICE_ATTR_RW (_name, _flags, ...) \ + { .dev_attr = __ATTR(_name, S_IRUGO | S_IWUSR, \ + amdgpu_pp_attr_show_wrapper, \ + amdgpu_pp_attr_store_wrapper), \ + .attr_id = device_attr_id__##_name, \ + .flags = _flags, \ + .attr_show = amdgpu_get_##_name, \ + .attr_store = amdgpu_set_##_name, \ + ##__VA_ARGS__, } + +#define AMDGPU_DEVICE_ATTR_RO (_name, _flags, ...) \ + { .dev_attr = __ATTR(_name, S_IRUGO, \ + amdgpu_pp_attr_show_wrapper, \ + NULL), \ + .attr_id = device_attr_id__##_name, \ + .flags = _flags, \ + .attr_show = amdgpu_get_##_name, \ + ##__VA_ARGS__, } +/** * DOC: power_dpm_state
drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h +0 -104
112 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH 9/9 drm/amd/pm: use pm_runtime_get_if_active in amdgpu_debugfs_sensor_read
In reply to Pierre-Eric Pelloux-PrayerSame logic as the previous commit ("drm/amdgpu/pm: use pm_runtime_get_if_active for debugfs getters"): debugfs accesses shouldn't wake up the GPU nor preventing it to be suspended.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +3 -6
@@ -989,11 +989,9 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf, valuesize =sizeof (values); - r =pm_runtime_get_sync (adev_to_drm (adev)->dev); -if (r <0 ) { -pm_runtime_put_autosuspend (adev_to_drm (adev)->dev); -return r; - } + r =pm_runtime_get_if_active (adev->dev, true); +if (r <=0 ) +return r ?: -EPERM ; r =amdgpu_virt_enable_access_debugfs (adev);if (r <0 ) {
@@ -1003,7 +1001,6 @@ static ssize_t amdgpu_debugfs_sensor_read(struct file *f, char __user *buf, r =amdgpu_dpm_read_sensor (adev, idx, &values[0 ], &valuesize); -pm_runtime_mark_last_busy (adev_to_drm (adev)->dev);pm_runtime_put_autosuspend (adev_to_drm (adev)->dev);if (r) {
Signature · 1 line
2.40.1
Feng, Kenneth
maintainer[AMD Official Use Only - AMD Internal Distribution Only]
Series is Reviewed-by: Kenneth Feng <[email protected]>
-----Original Message-----
From: Pelloux-Prayer, Pierre-Eric <[email protected]>
Sent: Wednesday, September 25, 2024 3:54 PM
To: [email protected]; Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>; Limonciello, Mario <[email protected]>
Cc: Pelloux-Prayer, Pierre-Eric <[email protected]>
Subject: [PATCH v1 0/9] drm/amd/pm runtime pm changes
This series rework how runtime power management is handled in drm/amd/pm.
The main ideas are:
* simplify code and reduce copy-pate of runtimepm calls
* avoid waking up suspended GPU when reading debugfs files.
It is similar to Mario's earlier series:
https://lists.freedesktop.org/archives/amd-gfx/2024-August/113213.html
It's not a direct successor of it, hence v1.
Instead, this is part of a larger series that applies the same ideas to the whole amdgpu module.
Pierre-Eric Pelloux-Prayer (9):
drm/amd/pm: remove dump_pptable functions
drm/amd/pm: fix rpm refcount handling on error
drm/amd/pm: use pm_runtime_resume_and_get
drm/amd/pm: don't update runpm last_usage on debugfs getter drm/amd/pm: use pm_runtime_get_if_active for debugfs getters drm/amd/pm: stop extra checks for runtime pm state drm/amd/pm: add sysfs attribute access wrappers drm/amd/pm: move private definitions to the .c file drm/amd/pm: use pm_runtime_get_if_active in amdgpu_debugfs_sensor_read
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 9 +- drivers/gpu/drm/amd/pm/amdgpu_pm.c | 734 +++------- drivers/gpu/drm/amd/pm/inc/amdgpu_pm.h | 96 -- .../powerplay/hwmgr/vega20_processpptables.c | 574 -------- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 5 - .../gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c | 433 ------ .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c | 1269 ----------------- .../drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c | 14 - .../drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c | 14 - .../drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c | 14 - drivers/gpu/drm/amd/pm/swsmu/smu_internal.h | 1 - 11 files changed, 208 insertions(+), 2955 deletions(-)
--
2.40.1