Skip to contentSkip to conversation

Obey amdgpu.runpm even on BOCO systems

PATCH In review Mario Limonciello 3 participants 8 messages Nov 29, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Obey amdgpu.runpm even on BOCO systems

I've found that on a system that supports BOCO when I try to override it that it still uses BOCO. This is because module parameter use is intermingled with automatic detection.

This series moves automatic detection after module parameter use and makes all callers obey the result.

Mario Limonciello (3):
drm/amd: Fix handling of amdgpu.runpm on systems with BOCO drm/amd: Introduce new enum for BAMACO
drm/amd: Drop calls for checking "support" for BACO/BOCO/PX

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  7 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c       | 34 ++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c       | 80 +++++++++++--------
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h       |  1 +
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     |  3 +-
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    |  2 +-
 .../gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c    |  5 +-
 7 files changed, 77 insertions(+), 55 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 drm/amd: Fix handling of amdgpu.runpm on systems with BOCO

On products that support both BOCO and BACO it should be possible to override the BOCO detection and force BACO by amdgpu.runpm=1 but this doesn't work today.

Adjust the logic used in amdgpu_driver_load_kms() to make sure that module parameters are looked at first and only use automatic policies in the -1 or -2 cases.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 80 +++++++++++++++----------
 1 file changed, 48 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +48 -32
index b5ebafd4a3ad..29381da08fd5 100644
@@ -121,6 +121,53 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
 	mutex_unlock(&mgpu_info.mutex);
 }
 
+static void amdgpu_driver_set_runtime_pm_mode(struct amdgpu_device *adev)
+{
+	struct drm_device *dev = adev_to_drm(adev);
+
+	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
+
+	switch (amdgpu_runtime_pm) {
+	case -1:
+	case -2:
+		break;
+	case 0:
+	default:
+		return;
+	case 1:
+		if (amdgpu_device_supports_baco(dev))
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		else
+			dev_err(adev->dev, "BACO is not supported on this ASIC\n");
+		return;
+	case 2:
+		// TODO: adjust plumbing to be able to pull PP table to check MACO support as well
+		if (amdgpu_device_supports_baco(dev))
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		else
+			dev_err(adev->dev, "BAMACO is not supported on this ASIC\n");
+		return;
+	}
+
+	if (amdgpu_device_supports_px(dev)) {
+		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
+		dev_info(adev->dev, "Using ATPX for runtime pm\n");
+	} else if (amdgpu_device_supports_boco(dev)) {
+		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
+		dev_info(adev->dev, "Using BOCO for runtime pm\n");
+	} else if (amdgpu_device_supports_baco(dev)) {
+		if (adev->asic_type == CHIP_VEGA10) {
+			/* enable BACO as runpm mode if noretry=0 */
+			if (!adev->gmc.noretry)
+				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		} else {
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		}
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
+			dev_info(adev->dev, "Using BACO for runtime pm\n");
+	}
+}
+
 /**
  * amdgpu_driver_load_kms - Main load function for KMS.
  *
@@ -149,38 +196,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
 		goto out;
 	}
 
-	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
-	if (amdgpu_device_supports_px(dev) &&
-	    (amdgpu_runtime_pm != 0)) { /* enable PX as runtime mode */
-		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
-		dev_info(adev->dev, "Using ATPX for runtime pm\n");
-	} else if (amdgpu_device_supports_boco(dev) &&
-		   (amdgpu_runtime_pm != 0)) { /* enable boco as runtime mode */
-		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
-		dev_info(adev->dev, "Using BOCO for runtime pm\n");
-	} else if (amdgpu_device_supports_baco(dev) &&
-		   (amdgpu_runtime_pm != 0)) {
-		switch (adev->asic_type) {
-		case CHIP_VEGA20:
-		case CHIP_ARCTURUS:
-			/* enable BACO as runpm mode if runpm=1 */
-			if (amdgpu_runtime_pm > 0)
-				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		case CHIP_VEGA10:
-			/* enable BACO as runpm mode if noretry=0 */
-			if (!adev->gmc.noretry)
-				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		default:
-			/* enable BACO as runpm mode on CI+ */
-			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		}
-
-		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
-			dev_info(adev->dev, "Using BACO for runtime pm\n");
-	}
+	amdgpu_driver_set_runtime_pm_mode(adev);
 
 	/* Call ACPI methods: require modeset init
 	 * but failure is not fatal
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/3] drm/amd: Fix handling of amdgpu.runpm on systems with BOCO

Quoted 52 lines · Mario Limonciello

On products that support both BOCO and BACO it should be possible to override the BOCO detection and force BACO by amdgpu.runpm=1 but this doesn't work today.

Adjust the logic used in amdgpu_driver_load_kms() to make sure that module parameters are looked at first and only use automatic policies in the -1 or -2 cases.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 80 +++++++++++++++----------
  1 file changed, 48 insertions(+), 32 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +31 -0
index b5ebafd4a3ad..29381da08fd5 100644
@@ -121,6 +121,53 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
  	mutex_unlock(&mgpu_info.mutex);
  }
 
+static void amdgpu_driver_set_runtime_pm_mode(struct amdgpu_device *adev)
+{
+	struct drm_device *dev = adev_to_drm(adev);
+
+	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
+
+	switch (amdgpu_runtime_pm) {
+	case -1:
+	case -2:
+		break;
+	case 0:
+	default:
+		return;
+	case 1:
+		if (amdgpu_device_supports_baco(dev))
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		else
+			dev_err(adev->dev, "BACO is not supported on this ASIC\n");
+		return;
+	case 2:
+		// TODO: adjust plumbing to be able to pull PP table to check MACO support as well
+		if (amdgpu_device_supports_baco(dev))
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		else
+			dev_err(adev->dev, "BAMACO is not supported on this ASIC\n");
+		return;
+	}
+
+	if (amdgpu_device_supports_px(dev)) {
+		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
+		dev_info(adev->dev, "Using ATPX for runtime pm\n");

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_register_gpu_instance(struct amdgpu_device *adev) · line 164

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10 -0
+	} else if (amdgpu_device_supports_boco(dev)) {
+		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
+		dev_info(adev->dev, "Using BOCO for runtime pm\n");
+	} else if (amdgpu_device_supports_baco(dev)) {
+		if (adev->asic_type == CHIP_VEGA10) {
+			/* enable BACO as runpm mode if noretry=0 */
+			if (!adev->gmc.noretry)
+				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+		} else {
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;

On VG20/ARCT, older logic doesn't use BACO as runpm mode unless forced. This logic breaks it.

Thanks,
Lijo

Quoted 49 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +7 -32
+		}
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
+			dev_info(adev->dev, "Using BACO for runtime pm\n");
+	}
+}
+
  /**
   * amdgpu_driver_load_kms - Main load function for KMS.
   *
@@ -149,38 +196,7 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
  		goto out;
  	}
 
-	adev->pm.rpm_mode = AMDGPU_RUNPM_NONE;
-	if (amdgpu_device_supports_px(dev) &&
-	    (amdgpu_runtime_pm != 0)) { /* enable PX as runtime mode */
-		adev->pm.rpm_mode = AMDGPU_RUNPM_PX;
-		dev_info(adev->dev, "Using ATPX for runtime pm\n");
-	} else if (amdgpu_device_supports_boco(dev) &&
-		   (amdgpu_runtime_pm != 0)) { /* enable boco as runtime mode */
-		adev->pm.rpm_mode = AMDGPU_RUNPM_BOCO;
-		dev_info(adev->dev, "Using BOCO for runtime pm\n");
-	} else if (amdgpu_device_supports_baco(dev) &&
-		   (amdgpu_runtime_pm != 0)) {
-		switch (adev->asic_type) {
-		case CHIP_VEGA20:
-		case CHIP_ARCTURUS:
-			/* enable BACO as runpm mode if runpm=1 */
-			if (amdgpu_runtime_pm > 0)
-				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		case CHIP_VEGA10:
-			/* enable BACO as runpm mode if noretry=0 */
-			if (!adev->gmc.noretry)
-				adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		default:
-			/* enable BACO as runpm mode on CI+ */
-			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
-			break;
-		}
-
-		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO)
-			dev_info(adev->dev, "Using BACO for runtime pm\n");
-	}
+	amdgpu_driver_set_runtime_pm_mode(adev);
 
  	/* Call ACPI methods: require modeset init
  	 * but failure is not fatal
#3 lore raw

PATCH 2/3 drm/amd: Introduce new enum for BAMACO

In reply to Mario Limonciello

Rather than plumbing module parameter deep into IP declare BAMACO runpm mode at amdgpu_driver_set_runtime_pm_mode() and then detect this mode in consumers.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c        | 2 +-
 drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h        | 1 +
 drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-
 drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 5 +++--
 4 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 29381da08fd5..c6c87ab71d94 100644
@@ -143,7 +143,7 @@ static void amdgpu_driver_set_runtime_pm_mode(struct amdgpu_device *adev)
 	case 2:
 		// TODO: adjust plumbing to be able to pull PP table to check MACO support as well
 		if (amdgpu_device_supports_baco(dev))
-			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BAMACO;
 		else
 			dev_err(adev->dev, "BAMACO is not supported on this ASIC\n");
 		return;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
index d76b0a60db44..3434c31b434b 100644
@@ -50,6 +50,7 @@ enum amdgpu_runpm_mode {
 	AMDGPU_RUNPM_PX,
 	AMDGPU_RUNPM_BOCO,
 	AMDGPU_RUNPM_BACO,
+	AMDGPU_RUNPM_BAMACO,
 };
 
 struct amdgpu_ps {
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
index 5a314d0316c1..64c8783b4118 100644
@@ -1597,7 +1597,7 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
 		case IP_VERSION(11, 0, 11):
 		case IP_VERSION(11, 0, 12):
 		case IP_VERSION(11, 0, 13):
-			if (amdgpu_runtime_pm == 2)
+			if (adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO)
 				ret = smu_cmn_send_smc_msg_with_param(smu,
 								      SMU_MSG_EnterBaco,
 								      D3HOT_BAMACO_SEQUENCE,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +3 -2
index 3c595ac897d6..b77763d6c72f 100644
@@ -2259,7 +2259,8 @@ int smu_v13_0_baco_set_state(struct smu_context *smu,
 	if (state == SMU_BACO_STATE_ENTER) {
 		ret = smu_cmn_send_smc_msg_with_param(smu,
 						      SMU_MSG_EnterBaco,
-						      (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
+						      (smu_baco->maco_support &&
+						      adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) ?
 						      BACO_SEQ_BAMACO : BACO_SEQ_BACO,
 						      NULL);
 	} else {
@@ -2288,7 +2289,7 @@ int smu_v13_0_baco_enter(struct smu_context *smu)
 
 	if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
 		return smu_v13_0_baco_set_armd3_sequence(smu,
-				(smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
+				(smu_baco->maco_support && adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) ?
 					BACO_SEQ_BAMACO : BACO_SEQ_BACO);
 	} else {
 		ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_ENTER);
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/3] drm/amd: Introduce new enum for BAMACO

Quoted 55 lines · Mario Limonciello

Rather than plumbing module parameter deep into IP declare BAMACO runpm mode at amdgpu_driver_set_runtime_pm_mode() and then detect this mode in consumers.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c        | 2 +-
  drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h        | 1 +
  drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c | 2 +-
  drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c | 5 +++--
  4 files changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +1 -1
index 29381da08fd5..c6c87ab71d94 100644
@@ -143,7 +143,7 @@ static void amdgpu_driver_set_runtime_pm_mode(struct amdgpu_device *adev)
  	case 2:
  		// TODO: adjust plumbing to be able to pull PP table to check MACO support as well
  		if (amdgpu_device_supports_baco(dev))
-			adev->pm.rpm_mode = AMDGPU_RUNPM_BACO;
+			adev->pm.rpm_mode = AMDGPU_RUNPM_BAMACO;
  		else
  			dev_err(adev->dev, "BAMACO is not supported on this ASIC\n");
  		return;
drivers/gpu/drm/amd/pm/inc/amdgpu_dpm.h +1 -0
index d76b0a60db44..3434c31b434b 100644
@@ -50,6 +50,7 @@ enum amdgpu_runpm_mode {
  	AMDGPU_RUNPM_PX,
  	AMDGPU_RUNPM_BOCO,
  	AMDGPU_RUNPM_BACO,
+	AMDGPU_RUNPM_BAMACO,
  };
 
  struct amdgpu_ps {
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +1 -1
index 5a314d0316c1..64c8783b4118 100644
@@ -1597,7 +1597,7 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
  		case IP_VERSION(11, 0, 11):
  		case IP_VERSION(11, 0, 12):
  		case IP_VERSION(11, 0, 13):
-			if (amdgpu_runtime_pm == 2)
+			if (adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO)
  				ret = smu_cmn_send_smc_msg_with_param(smu,
  								      SMU_MSG_EnterBaco,
  								      D3HOT_BAMACO_SEQUENCE,
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +0 -0
index 3c595ac897d6..b77763d6c72f 100644

drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c int smu_v13_0_baco_set_state(struct smu_context *smu, · line 2263

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +2 -1
@@ -2259,7 +2259,8 @@ int smu_v13_0_baco_set_state(struct smu_context *smu,
  	if (state == SMU_BACO_STATE_ENTER) {
  		ret = smu_cmn_send_smc_msg_with_param(smu,
  						      SMU_MSG_EnterBaco,
-						      (smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
+						      (smu_baco->maco_support &&
+						      adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) ?

This also doesn't work as per the legacy logic. In legacy logic, BAMACO is given preference if supported or if BACO is not forced when both are supported. As per the new logic, BAMACO is preferred only if forced through module param.

Thanks,
Lijo

Quoted 12 lines
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c +1 -1
  						      BACO_SEQ_BAMACO : BACO_SEQ_BACO,
  						      NULL);
  	} else {
@@ -2288,7 +2289,7 @@ int smu_v13_0_baco_enter(struct smu_context *smu)
 
  	if (adev->in_runpm && smu_cmn_is_audio_func_enabled(adev)) {
  		return smu_v13_0_baco_set_armd3_sequence(smu,
-				(smu_baco->maco_support && amdgpu_runtime_pm != 1) ?
+				(smu_baco->maco_support && adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) ?
  					BACO_SEQ_BAMACO : BACO_SEQ_BACO);
  	} else {
  		ret = smu_v13_0_baco_set_state(smu, SMU_BACO_STATE_ENTER);
#5 lore raw

PATCH 3/3 drm/amd: Drop calls for checking "support" for BACO/BOCO/PX

In reply to Mario Limonciello

As the module parameter can be used to control behavior, all parts of the driver should obey what has been programmed by user or detected by auto mode rather than what "can" be supported.

Drop calls to all functions that check for BACO/BOCO/PX runpm modes and instead use the variable that is programmed when device is probed.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 +++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 34 ++++++++++++----------
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c  |  3 +-
 3 files changed, 24 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -3
index 1181fe4baf0f..8f7377b37f2f 100644
@@ -1822,9 +1822,10 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
 					enum vga_switcheroo_state state)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
+	struct amdgpu_device *adev = drm_to_adev(dev);
 	int r;
 
-	if (amdgpu_device_supports_px(dev) && state == VGA_SWITCHEROO_OFF)
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX && state == VGA_SWITCHEROO_OFF)
 		return;
 
 	if (state == VGA_SWITCHEROO_ON) {
@@ -4244,7 +4245,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
 		vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
 
-	px = amdgpu_device_supports_px(ddev);
+	px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
 	if (px || (!dev_is_removable(&adev->pdev->dev) &&
 				apple_gmux_detect(NULL, NULL)))
@@ -4392,7 +4393,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
 	kfree(adev->fru_info);
 	adev->fru_info = NULL;
 
-	px = amdgpu_device_supports_px(adev_to_drm(adev));
+	px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
 	if (px || (!dev_is_removable(&adev->pdev->dev) &&
 				apple_gmux_detect(NULL, NULL)))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +18 -16
index e39f3a334c9d..12fb8398fb45 100644
@@ -2248,10 +2248,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
 	if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
 		/* only need to skip on ATPX */
-		if (amdgpu_device_supports_px(ddev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
 			dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_NO_DIRECT_COMPLETE);
 		/* we want direct complete for BOCO */
-		if (amdgpu_device_supports_boco(ddev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
 			dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_SMART_PREPARE |
 						DPM_FLAG_SMART_SUSPEND |
 						DPM_FLAG_MAY_SKIP_RESUME);
@@ -2284,7 +2284,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 		 * into D0 state. Then there will be a PMFW-aware D-state
 		 * transition(D0->D3) on runpm suspend.
 		 */
-		if (amdgpu_device_supports_baco(ddev) &&
+		if ((adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+		     adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) &&
 		    !(adev->flags & AMD_IS_APU) &&
 		    (adev->asic_type >= CHIP_NAVI10))
 			amdgpu_get_secondary_funcs(adev);
@@ -2466,7 +2467,7 @@ static int amdgpu_pmops_prepare(struct device *dev)
 	/* Return a positive number here so
 	 * DPM_FLAG_SMART_SUSPEND works properly
 	 */
-	if (amdgpu_device_supports_boco(drm_dev) &&
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO &&
 	    pm_runtime_suspended(dev))
 		return 1;
 
@@ -2664,7 +2665,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 	}
 
 	adev->in_runpm = true;
-	if (amdgpu_device_supports_px(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
 		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
 	/*
@@ -2674,7 +2675,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 	 * platforms.
 	 * TODO: this may be also needed for PX capable platform.
 	 */
-	if (amdgpu_device_supports_boco(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
 		adev->mp1_state = PP_MP1_STATE_UNLOAD;
 
 	ret = amdgpu_device_prepare(drm_dev);
@@ -2683,15 +2684,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 	ret = amdgpu_device_suspend(drm_dev, false);
 	if (ret) {
 		adev->in_runpm = false;
-		if (amdgpu_device_supports_boco(drm_dev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
 			adev->mp1_state = PP_MP1_STATE_NONE;
 		return ret;
 	}
 
-	if (amdgpu_device_supports_boco(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
 		adev->mp1_state = PP_MP1_STATE_NONE;
 
-	if (amdgpu_device_supports_px(drm_dev)) {
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
 		/* Only need to handle PCI state in the driver for ATPX
 		 * PCI core handles it for _PR3.
 		 */
@@ -2700,9 +2701,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
 		pci_ignore_hotplug(pdev);
 		pci_set_power_state(pdev, PCI_D3cold);
 		drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
-	} else if (amdgpu_device_supports_boco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
 		/* nothing to do */
-	} else if (amdgpu_device_supports_baco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+		   adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) {
 		amdgpu_device_baco_enter(drm_dev);
 	}
 
@@ -2725,7 +2727,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
 	if (!pci_device_is_present(adev->pdev))
 		adev->no_hw_access = true;
 
-	if (amdgpu_device_supports_px(drm_dev)) {
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
 		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
 		/* Only need to handle PCI state in the driver for ATPX
@@ -2737,22 +2739,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
 		if (ret)
 			return ret;
 		pci_set_master(pdev);
-	} else if (amdgpu_device_supports_boco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
 		/* Only need to handle PCI state in the driver for ATPX
 		 * PCI core handles it for _PR3.
 		 */
 		pci_set_master(pdev);
-	} else if (amdgpu_device_supports_baco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO) {
 		amdgpu_device_baco_exit(drm_dev);
 	}
 	ret = amdgpu_device_resume(drm_dev, false);
 	if (ret) {
-		if (amdgpu_device_supports_px(drm_dev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
 			pci_disable_device(pdev);
 		return ret;
 	}
 
-	if (amdgpu_device_supports_px(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
 		drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
 	adev->in_runpm = false;
 	return 0;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
index f464610a959f..d7977185f4e2 100644
@@ -1618,7 +1618,8 @@ static int smu_disable_dpms(struct smu_context *smu)
 	bool use_baco = !smu->is_apu &&
 		((amdgpu_in_reset(adev) &&
 		  (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) ||
-		 ((adev->in_runpm || adev->in_s4) && amdgpu_asic_supports_baco(adev)));
+		 ((adev->in_runpm || adev->in_s4) &&
+		 (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO || adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO)));
 
 	/*
 	 * For SMU 13.0.0 and 13.0.7, PMFW will handle the DPM features(disablement or others)
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 3/3] drm/amd: Drop calls for checking "support" for BACO/BOCO/PX

Quoted 4 lines · Mario Limonciello

As the module parameter can be used to control behavior, all parts of the driver should obey what has been programmed by user or detected by auto mode rather than what "can" be supported.

This is also not correct. You can very well disable runpm mode and the rest of the logic will still apply. A substitution like this doesn't work when runpm mode is disabled. Only in cases where the support check is used for runpm related logic, this replacement can be applied.

Thanks,
Lijo

Quoted 180 lines

Drop calls to all functions that check for BACO/BOCO/PX runpm modes and instead use the variable that is programmed when device is probed.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 +++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 34 ++++++++++++----------
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c  |  3 +-
  3 files changed, 24 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -3
index 1181fe4baf0f..8f7377b37f2f 100644
@@ -1822,9 +1822,10 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
  					enum vga_switcheroo_state state)
  {
  	struct drm_device *dev = pci_get_drvdata(pdev);
+	struct amdgpu_device *adev = drm_to_adev(dev);
  	int r;
 
-	if (amdgpu_device_supports_px(dev) && state == VGA_SWITCHEROO_OFF)
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX && state == VGA_SWITCHEROO_OFF)
  		return;
 
  	if (state == VGA_SWITCHEROO_ON) {
@@ -4244,7 +4245,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
  	if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
  		vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
 
-	px = amdgpu_device_supports_px(ddev);
+	px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
  	if (px || (!dev_is_removable(&adev->pdev->dev) &&
  				apple_gmux_detect(NULL, NULL)))
@@ -4392,7 +4393,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
  	kfree(adev->fru_info);
  	adev->fru_info = NULL;
 
-	px = amdgpu_device_supports_px(adev_to_drm(adev));
+	px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
  	if (px || (!dev_is_removable(&adev->pdev->dev) &&
  				apple_gmux_detect(NULL, NULL)))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +18 -16
index e39f3a334c9d..12fb8398fb45 100644
@@ -2248,10 +2248,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
  	if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
  		/* only need to skip on ATPX */
-		if (amdgpu_device_supports_px(ddev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
  			dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_NO_DIRECT_COMPLETE);
  		/* we want direct complete for BOCO */
-		if (amdgpu_device_supports_boco(ddev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
  			dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_SMART_PREPARE |
  						DPM_FLAG_SMART_SUSPEND |
  						DPM_FLAG_MAY_SKIP_RESUME);
@@ -2284,7 +2284,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
  		 * into D0 state. Then there will be a PMFW-aware D-state
  		 * transition(D0->D3) on runpm suspend.
  		 */
-		if (amdgpu_device_supports_baco(ddev) &&
+		if ((adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+		     adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) &&
  		    !(adev->flags & AMD_IS_APU) &&
  		    (adev->asic_type >= CHIP_NAVI10))
  			amdgpu_get_secondary_funcs(adev);
@@ -2466,7 +2467,7 @@ static int amdgpu_pmops_prepare(struct device *dev)
  	/* Return a positive number here so
  	 * DPM_FLAG_SMART_SUSPEND works properly
  	 */
-	if (amdgpu_device_supports_boco(drm_dev) &&
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO &&
  	    pm_runtime_suspended(dev))
  		return 1;
 
@@ -2664,7 +2665,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
  	}
 
  	adev->in_runpm = true;
-	if (amdgpu_device_supports_px(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
  		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
  	/*
@@ -2674,7 +2675,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
  	 * platforms.
  	 * TODO: this may be also needed for PX capable platform.
  	 */
-	if (amdgpu_device_supports_boco(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
  		adev->mp1_state = PP_MP1_STATE_UNLOAD;
 
  	ret = amdgpu_device_prepare(drm_dev);
@@ -2683,15 +2684,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
  	ret = amdgpu_device_suspend(drm_dev, false);
  	if (ret) {
  		adev->in_runpm = false;
-		if (amdgpu_device_supports_boco(drm_dev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
  			adev->mp1_state = PP_MP1_STATE_NONE;
  		return ret;
  	}
 
-	if (amdgpu_device_supports_boco(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
  		adev->mp1_state = PP_MP1_STATE_NONE;
 
-	if (amdgpu_device_supports_px(drm_dev)) {
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
  		/* Only need to handle PCI state in the driver for ATPX
  		 * PCI core handles it for _PR3.
  		 */
@@ -2700,9 +2701,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
  		pci_ignore_hotplug(pdev);
  		pci_set_power_state(pdev, PCI_D3cold);
  		drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
-	} else if (amdgpu_device_supports_boco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
  		/* nothing to do */
-	} else if (amdgpu_device_supports_baco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+		   adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) {
  		amdgpu_device_baco_enter(drm_dev);
  	}
 
@@ -2725,7 +2727,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
  	if (!pci_device_is_present(adev->pdev))
  		adev->no_hw_access = true;
 
-	if (amdgpu_device_supports_px(drm_dev)) {
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
  		drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
  		/* Only need to handle PCI state in the driver for ATPX
@@ -2737,22 +2739,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
  		if (ret)
  			return ret;
  		pci_set_master(pdev);
-	} else if (amdgpu_device_supports_boco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
  		/* Only need to handle PCI state in the driver for ATPX
  		 * PCI core handles it for _PR3.
  		 */
  		pci_set_master(pdev);
-	} else if (amdgpu_device_supports_baco(drm_dev)) {
+	} else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO) {
  		amdgpu_device_baco_exit(drm_dev);
  	}
  	ret = amdgpu_device_resume(drm_dev, false);
  	if (ret) {
-		if (amdgpu_device_supports_px(drm_dev))
+		if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
  			pci_disable_device(pdev);
  		return ret;
  	}
 
-	if (amdgpu_device_supports_px(drm_dev))
+	if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
  		drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
  	adev->in_runpm = false;
  	return 0;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
index f464610a959f..d7977185f4e2 100644
@@ -1618,7 +1618,8 @@ static int smu_disable_dpms(struct smu_context *smu)
  	bool use_baco = !smu->is_apu &&
  		((amdgpu_in_reset(adev) &&
  		  (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) ||
-		 ((adev->in_runpm || adev->in_s4) && amdgpu_asic_supports_baco(adev)));
+		 ((adev->in_runpm || adev->in_s4) &&
+		 (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO || adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO)));
 
  	/*
  	 * For SMU 13.0.0 and 13.0.7, PMFW will handle the DPM features(disablement or others)
#7 lore raw

Re: [PATCH 3/3] drm/amd: Drop calls for checking "support" for BACO/BOCO/PX

Quoted 9 lines · Lijo
Quoted 4 lines · Mario Limonciello

As the module parameter can be used to control behavior, all parts of the driver should obey what has been programmed by user or detected by auto mode rather than what "can" be supported.

Quoted 4 lines

This is also not correct. You can very well disable runpm mode and the rest of the logic will still apply. A substitution like this doesn't work when runpm mode is disabled. Only in cases where the support check is used for runpm related logic, this replacement can be applied.

Right. There are cases where we use BACO for things besides runtime pm. E.g., GPU reset.

Alex

Quoted 184 lines

Thanks,
Lijo

Quoted 180 lines

Drop calls to all functions that check for BACO/BOCO/PX runpm modes and instead use the variable that is programmed when device is probed.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  7 +++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    | 34 ++++++++++++----------
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c  |  3 +-
  3 files changed, 24 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -3
index 1181fe4baf0f..8f7377b37f2f 100644
@@ -1822,9 +1822,10 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
                                      enum vga_switcheroo_state state)
  {
      struct drm_device *dev = pci_get_drvdata(pdev);
+     struct amdgpu_device *adev = drm_to_adev(dev);
      int r;
 
-     if (amdgpu_device_supports_px(dev) && state == VGA_SWITCHEROO_OFF)
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX && state == VGA_SWITCHEROO_OFF)
              return;
 
      if (state == VGA_SWITCHEROO_ON) {
@@ -4244,7 +4245,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
      if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
              vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
 
-     px = amdgpu_device_supports_px(ddev);
+     px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
      if (px || (!dev_is_removable(&adev->pdev->dev) &&
                              apple_gmux_detect(NULL, NULL)))
@@ -4392,7 +4393,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
      kfree(adev->fru_info);
      adev->fru_info = NULL;
 
-     px = amdgpu_device_supports_px(adev_to_drm(adev));
+     px = (adev->pm.rpm_mode == AMDGPU_RUNPM_PX);
 
      if (px || (!dev_is_removable(&adev->pdev->dev) &&
                              apple_gmux_detect(NULL, NULL)))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +18 -16
index e39f3a334c9d..12fb8398fb45 100644
@@ -2248,10 +2248,10 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
 
      if (adev->pm.rpm_mode != AMDGPU_RUNPM_NONE) {
              /* only need to skip on ATPX */
-             if (amdgpu_device_supports_px(ddev))
+             if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
                      dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_NO_DIRECT_COMPLETE);
              /* we want direct complete for BOCO */
-             if (amdgpu_device_supports_boco(ddev))
+             if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
                      dev_pm_set_driver_flags(ddev->dev, DPM_FLAG_SMART_PREPARE |
                                              DPM_FLAG_SMART_SUSPEND |
                                              DPM_FLAG_MAY_SKIP_RESUME);
@@ -2284,7 +2284,8 @@ static int amdgpu_pci_probe(struct pci_dev *pdev,
               * into D0 state. Then there will be a PMFW-aware D-state
               * transition(D0->D3) on runpm suspend.
               */
-             if (amdgpu_device_supports_baco(ddev) &&
+             if ((adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+                  adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) &&
                  !(adev->flags & AMD_IS_APU) &&
                  (adev->asic_type >= CHIP_NAVI10))
                      amdgpu_get_secondary_funcs(adev);
@@ -2466,7 +2467,7 @@ static int amdgpu_pmops_prepare(struct device *dev)
      /* Return a positive number here so
       * DPM_FLAG_SMART_SUSPEND works properly
       */
-     if (amdgpu_device_supports_boco(drm_dev) &&
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO &&
          pm_runtime_suspended(dev))
              return 1;
 
@@ -2664,7 +2665,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
      }
 
      adev->in_runpm = true;
-     if (amdgpu_device_supports_px(drm_dev))
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
              drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
      /*
@@ -2674,7 +2675,7 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
       * platforms.
       * TODO: this may be also needed for PX capable platform.
       */
-     if (amdgpu_device_supports_boco(drm_dev))
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
              adev->mp1_state = PP_MP1_STATE_UNLOAD;
 
      ret = amdgpu_device_prepare(drm_dev);
@@ -2683,15 +2684,15 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
      ret = amdgpu_device_suspend(drm_dev, false);
      if (ret) {
              adev->in_runpm = false;
-             if (amdgpu_device_supports_boco(drm_dev))
+             if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
                      adev->mp1_state = PP_MP1_STATE_NONE;
              return ret;
      }
 
-     if (amdgpu_device_supports_boco(drm_dev))
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO)
              adev->mp1_state = PP_MP1_STATE_NONE;
 
-     if (amdgpu_device_supports_px(drm_dev)) {
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
              /* Only need to handle PCI state in the driver for ATPX
               * PCI core handles it for _PR3.
               */
@@ -2700,9 +2701,10 @@ static int amdgpu_pmops_runtime_suspend(struct device *dev)
              pci_ignore_hotplug(pdev);
              pci_set_power_state(pdev, PCI_D3cold);
              drm_dev->switch_power_state = DRM_SWITCH_POWER_DYNAMIC_OFF;
-     } else if (amdgpu_device_supports_boco(drm_dev)) {
+     } else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
              /* nothing to do */
-     } else if (amdgpu_device_supports_baco(drm_dev)) {
+     } else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO ||
+                adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO) {
              amdgpu_device_baco_enter(drm_dev);
      }
 
@@ -2725,7 +2727,7 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
      if (!pci_device_is_present(adev->pdev))
              adev->no_hw_access = true;
 
-     if (amdgpu_device_supports_px(drm_dev)) {
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX) {
              drm_dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
 
              /* Only need to handle PCI state in the driver for ATPX
@@ -2737,22 +2739,22 @@ static int amdgpu_pmops_runtime_resume(struct device *dev)
              if (ret)
                      return ret;
              pci_set_master(pdev);
-     } else if (amdgpu_device_supports_boco(drm_dev)) {
+     } else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BOCO) {
              /* Only need to handle PCI state in the driver for ATPX
               * PCI core handles it for _PR3.
               */
              pci_set_master(pdev);
-     } else if (amdgpu_device_supports_baco(drm_dev)) {
+     } else if (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO) {
              amdgpu_device_baco_exit(drm_dev);
      }
      ret = amdgpu_device_resume(drm_dev, false);
      if (ret) {
-             if (amdgpu_device_supports_px(drm_dev))
+             if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
                      pci_disable_device(pdev);
              return ret;
      }
 
-     if (amdgpu_device_supports_px(drm_dev))
+     if (adev->pm.rpm_mode == AMDGPU_RUNPM_PX)
              drm_dev->switch_power_state = DRM_SWITCH_POWER_ON;
      adev->in_runpm = false;
      return 0;
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
index f464610a959f..d7977185f4e2 100644
@@ -1618,7 +1618,8 @@ static int smu_disable_dpms(struct smu_context *smu)
      bool use_baco = !smu->is_apu &&
              ((amdgpu_in_reset(adev) &&
                (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)) ||
-              ((adev->in_runpm || adev->in_s4) && amdgpu_asic_supports_baco(adev)));
+              ((adev->in_runpm || adev->in_s4) &&
+              (adev->pm.rpm_mode == AMDGPU_RUNPM_BACO || adev->pm.rpm_mode == AMDGPU_RUNPM_BAMACO)));
 
      /*
       * For SMU 13.0.0 and 13.0.7, PMFW will handle the DPM features(disablement or others)