Skip to content

Commit 8b514e8

Browse files
Evan Quanalexdeucher
authored andcommitted
drm/amd/pm: fix runpm hang when amdgpu loaded prior to sound driver
Current RUNPM mechanism relies on PMFW to master the timing for BACO in/exit. And that needs cooperation from sound driver for dstate change notification for function 1(audio). Otherwise(on sound driver missing), BACO cannot be kicked in correctly and hang will be observed on RUNPM exit. By switching back to legacy message way on sound driver missing, we are able to fix the runpm hang observed for the scenario below: amdgpu driver loaded -> runpm suspend kicked -> sound driver loaded Signed-off-by: Evan Quan <[email protected]> Reported-and-tested-by: Pierre-Eric Pelloux-Prayer <[email protected]> Reviewed-by: Lijo Lazar <[email protected]> Reviewed-by: Guchun Chen <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 93def70 commit 8b514e8

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,27 @@ static int navi10_baco_enter(struct smu_context *smu)
22742274
{
22752275
struct amdgpu_device *adev = smu->adev;
22762276

2277-
if (adev->in_runpm)
2277+
/*
2278+
* This aims the case below:
2279+
* amdgpu driver loaded -> runpm suspend kicked -> sound driver loaded
2280+
*
2281+
* For NAVI10 and later ASICs, we rely on PMFW to handle the runpm. To
2282+
* make that possible, PMFW needs to acknowledge the dstate transition
2283+
* process for both gfx(function 0) and audio(function 1) function of
2284+
* the ASIC.
2285+
*
2286+
* The PCI device's initial runpm status is RUNPM_SUSPENDED. So as the
2287+
* device representing the audio function of the ASIC. And that means
2288+
* even if the sound driver(snd_hda_intel) was not loaded yet, it's still
2289+
* possible runpm suspend kicked on the ASIC. However without the dstate
2290+
* transition notification from audio function, pmfw cannot handle the
2291+
* BACO in/exit correctly. And that will cause driver hang on runpm
2292+
* resuming.
2293+
*
2294+
* To address this, we revert to legacy message way(driver masters the
2295+
* timing for BACO in/exit) on sound driver missing.
2296+
*/
2297+
if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))
22782298
return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);
22792299
else
22802300
return smu_v11_0_baco_enter(smu);
@@ -2284,7 +2304,7 @@ static int navi10_baco_exit(struct smu_context *smu)
22842304
{
22852305
struct amdgpu_device *adev = smu->adev;
22862306

2287-
if (adev->in_runpm) {
2307+
if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
22882308
/* Wait for PMFW handling for the Dstate change */
22892309
msleep(10);
22902310
return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,7 +2189,7 @@ static int sienna_cichlid_baco_enter(struct smu_context *smu)
21892189
{
21902190
struct amdgpu_device *adev = smu->adev;
21912191

2192-
if (adev->in_runpm)
2192+
if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev))
21932193
return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);
21942194
else
21952195
return smu_v11_0_baco_enter(smu);
@@ -2199,7 +2199,7 @@ static int sienna_cichlid_baco_exit(struct smu_context *smu)
21992199
{
22002200
struct amdgpu_device *adev = smu->adev;
22012201

2202-
if (adev->in_runpm) {
2202+
if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
22032203
/* Wait for PMFW handling for the Dstate change */
22042204
msleep(10);
22052205
return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,3 +1053,24 @@ int smu_cmn_set_mp1_state(struct smu_context *smu,
10531053

10541054
return ret;
10551055
}
1056+
1057+
bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev)
1058+
{
1059+
struct pci_dev *p = NULL;
1060+
bool snd_driver_loaded;
1061+
1062+
/*
1063+
* If the ASIC comes with no audio function, we always assume
1064+
* it is "enabled".
1065+
*/
1066+
p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
1067+
adev->pdev->bus->number, 1);
1068+
if (!p)
1069+
return true;
1070+
1071+
snd_driver_loaded = pci_is_enabled(p) ? true : false;
1072+
1073+
pci_dev_put(p);
1074+
1075+
return snd_driver_loaded;
1076+
}

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,7 @@ static inline void smu_cmn_get_sysfs_buf(char **buf, int *offset)
123123
*buf -= *offset;
124124
}
125125

126+
bool smu_cmn_is_audio_func_enabled(struct amdgpu_device *adev);
127+
126128
#endif
127129
#endif

0 commit comments

Comments
 (0)