Skip to contentSkip to conversation

drm/amd/pm: drop the incomplete fix for Navi14 runpm issue

PATCH Superseded Evan Quan 2 participants 11 messages Jun 4, 2021 – Jun 8, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH v2 1/5 drm/amd/pm: drop the incomplete fix for Navi14 runpm issue

As the fix by adding PPSMC_MSG_PrepareMp1ForUnload is proved to be incomplete. Another fix(see link below) has been sent out.

Change-Id I2a39688cdf9009885594663cd9ec99d4cfca0088
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       |  5 +---
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 26 +------------------
 2 files changed, 2 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -4
index 55378c6b9722..09ee34312268 100644
@@ -2176,10 +2176,7 @@ static int psp_load_smu_fw(struct psp_context *psp)
 	if ((amdgpu_in_reset(adev) &&
 	     ras && adev->ras_enabled &&
 	     (adev->asic_type == CHIP_ARCTURUS ||
-	      adev->asic_type == CHIP_VEGA20)) ||
-	     (adev->in_runpm &&
-	      adev->asic_type >= CHIP_NAVI10 &&
-	      adev->asic_type <= CHIP_NAVI12)) {
+	      adev->asic_type == CHIP_VEGA20))) {
 		ret = amdgpu_dpm_set_mp1_state(adev, PP_MP1_STATE_UNLOAD);
 		if (ret) {
 			DRM_WARN("Failed to set MP1 state prepare for reload\n");
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +1 -25
index d28236ba0018..32a52c1bea07 100644
@@ -431,30 +431,6 @@ static int navi10_store_powerplay_table(struct smu_context *smu)
 	return 0;
 }
 
-static int navi10_set_mp1_state(struct smu_context *smu,
-				enum pp_mp1_state mp1_state)
-{
-	struct amdgpu_device *adev = smu->adev;
-	uint32_t mp1_fw_flags;
-	int ret = 0;
-
-	ret = smu_cmn_set_mp1_state(smu, mp1_state);
-	if (ret)
-		return ret;
-
-	if (mp1_state == PP_MP1_STATE_UNLOAD) {
-		mp1_fw_flags = RREG32_PCIE(MP1_Public |
-					   (smnMP1_FIRMWARE_FLAGS & 0xffffffff));
-
-		mp1_fw_flags &= ~MP1_FIRMWARE_FLAGS__INTERRUPTS_ENABLED_MASK;
-
-		WREG32_PCIE(MP1_Public |
-			    (smnMP1_FIRMWARE_FLAGS & 0xffffffff), mp1_fw_flags);
-	}
-
-	return 0;
-}
-
 static int navi10_setup_pptable(struct smu_context *smu)
 {
 	int ret = 0;
@@ -3119,7 +3095,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {
 	.get_fan_parameters = navi10_get_fan_parameters,
 	.post_init = navi10_post_smu_init,
 	.interrupt_work = smu_v11_0_interrupt_work,
-	.set_mp1_state = navi10_set_mp1_state,
+	.set_mp1_state = smu_cmn_set_mp1_state,
 };
 
 void navi10_set_ppt_funcs(struct smu_context *smu)
Signature · 6 lines
2.29.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#1 lore raw

PATCH v2 2/5 drm/amd/pm: correct the runpm handling for BACO supported ASIC

Via the fSMC_MSG_ArmD3 message, PMFW can properly act on the Dstate change. Driver involvement for determining the timing for BACO enter/exit is not needed.

Change-Id Id9ab5e308ff1873888d0acd822c71b0a303fbb01

---
V1->V2:
- limit the changes for Navi1x and Sienna_Cichlid which support the fSMC_MSG_ArmD3 message

---
 drivers/gpu/drm/amd/pm/inc/smu_v11_0.h        |  3 +++
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   | 27 +++++++++++++++++--
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   | 27 +++++++++++++++++--
 .../gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c    | 11 ++------
 4 files changed, 55 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/pm/inc/smu_v11_0.h +3 -0
index a3b28979bc82..1962a5877191 100644
@@ -244,6 +244,9 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
 int smu_v11_0_baco_enter(struct smu_context *smu);
 int smu_v11_0_baco_exit(struct smu_context *smu);
 
+int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu,
+				      enum smu_v11_0_baco_seq baco_seq);
+
 int smu_v11_0_mode1_reset(struct smu_context *smu);
 
 int smu_v11_0_get_dpm_ultimate_freq(struct smu_context *smu, enum smu_clk_type clk_type,
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +25 -2
index 32a52c1bea07..afd4bd850c63 100644
@@ -2240,6 +2240,29 @@ static bool navi10_is_baco_supported(struct smu_context *smu)
 	return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false;
 }
 
+static int navi10_baco_enter(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+
+	if (adev->in_runpm)
+		return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);
+	else
+		return smu_v11_0_baco_enter(smu);
+}
+
+static int navi10_baco_exit(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+
+	if (adev->in_runpm) {
+		/* Wait for PMFW handling for the Dstate change */
+		msleep(10);
+		return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
+	} else {
+		return smu_v11_0_baco_exit(smu);
+	}
+}
+
 static int navi10_set_default_od_settings(struct smu_context *smu)
 {
 	OverDriveTable_t *od_table =
@@ -3078,8 +3101,8 @@ static const struct pptable_funcs navi10_ppt_funcs = {
 	.baco_is_support= navi10_is_baco_supported,
 	.baco_get_state = smu_v11_0_baco_get_state,
 	.baco_set_state = smu_v11_0_baco_set_state,
-	.baco_enter = smu_v11_0_baco_enter,
-	.baco_exit = smu_v11_0_baco_exit,
+	.baco_enter = navi10_baco_enter,
+	.baco_exit = navi10_baco_exit,
 	.get_dpm_ultimate_freq = smu_v11_0_get_dpm_ultimate_freq,
 	.set_soft_freq_limited_range = smu_v11_0_set_soft_freq_limited_range,
 	.set_default_od_settings = navi10_set_default_od_settings,
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +25 -2
index 095492bd635f..b4a2bb0f3f4c 100644
@@ -2106,6 +2106,29 @@ static bool sienna_cichlid_is_baco_supported(struct smu_context *smu)
 	return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false;
 }
 
+static int sienna_cichlid_baco_enter(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+
+	if (adev->in_runpm)
+		return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);
+	else
+		return smu_v11_0_baco_enter(smu);
+}
+
+static int sienna_cichlid_baco_exit(struct smu_context *smu)
+{
+	struct amdgpu_device *adev = smu->adev;
+
+	if (adev->in_runpm) {
+		/* Wait for PMFW handling for the Dstate change */
+		msleep(10);
+		return smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_ULPS);
+	} else {
+		return smu_v11_0_baco_exit(smu);
+	}
+}
+
 static bool sienna_cichlid_is_mode1_reset_supported(struct smu_context *smu)
 {
 	struct amdgpu_device *adev = smu->adev;
@@ -3881,8 +3904,8 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = {
 	.baco_is_support= sienna_cichlid_is_baco_supported,
 	.baco_get_state = smu_v11_0_baco_get_state,
 	.baco_set_state = smu_v11_0_baco_set_state,
-	.baco_enter = smu_v11_0_baco_enter,
-	.baco_exit = smu_v11_0_baco_exit,
+	.baco_enter = sienna_cichlid_baco_enter,
+	.baco_exit = sienna_cichlid_baco_exit,
 	.mode1_reset_is_support = sienna_cichlid_is_mode1_reset_supported,
 	.mode1_reset = smu_v11_0_mode1_reset,
 	.get_dpm_ultimate_freq = sienna_cichlid_get_dpm_ultimate_freq,
drivers/gpu/drm/amd/pm/swsmu/smu11/smu_v11_0.c +2 -9
index 362696208fd8..0376bf67ee08 100644
@@ -1474,7 +1474,8 @@ int smu_v11_0_set_azalia_d3_pme(struct smu_context *smu)
 	return smu_cmn_send_smc_msg(smu, SMU_MSG_BacoAudioD3PME, NULL);
 }
 
-static int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu, enum smu_v11_0_baco_seq baco_seq)
+int smu_v11_0_baco_set_armd3_sequence(struct smu_context *smu,
+				      enum smu_v11_0_baco_seq baco_seq)
 {
 	return smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_ArmD3, baco_seq, NULL);
 }
@@ -1578,16 +1579,8 @@ int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state)
 
 int smu_v11_0_baco_enter(struct smu_context *smu)
 {
-	struct amdgpu_device *adev = smu->adev;
 	int ret = 0;
 
-	/* Arcturus does not need this audio workaround */
-	if (adev->asic_type != CHIP_ARCTURUS) {
-		ret = smu_v11_0_baco_set_armd3_sequence(smu, BACO_SEQ_BACO);
-		if (ret)
-			return ret;
-	}
-
 	ret = smu_v11_0_baco_set_state(smu, SMU_BACO_STATE_ENTER);
 	if (ret)
 		return ret;
Signature · 6 lines
2.29.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#2 lore raw

PATCH v2 3/5 drm/amdgpu: correct the audio function initial Dstate

In reply to Evan Quan

On driver loading, the ASIC is in D0 state. The bundled audio function should be in the same state also.

Change-Id I136e196be7633e95883a7f6c33963f7583e9bad1

---
V1->V2:
- Lijo: include the code in a seperate API for better readability
- limit the change for Navi10 and later dGPUs
- comments more about the background

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 40 +++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +40 -0
index c354ffa62483..e9f2161738d1 100644
@@ -123,6 +123,22 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
 	mutex_unlock(&mgpu_info.mutex);
 }
 
+static void amdgpu_get_audio_func(struct amdgpu_device *adev)
+{
+	struct pci_dev *p = NULL;
+
+	p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
+			adev->pdev->bus->number, 1);
+	if (p) {
+		pm_runtime_get_sync(&p->dev);
+
+		pm_runtime_mark_last_busy(&p->dev);
+		pm_runtime_put_autosuspend(&p->dev);
+
+		pci_dev_put(p);
+	}
+}
+
 /**
  * amdgpu_driver_load_kms - Main load function for KMS.
  *
@@ -212,9 +228,33 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
 						DPM_FLAG_MAY_SKIP_RESUME);
 		pm_runtime_use_autosuspend(dev->dev);
 		pm_runtime_set_autosuspend_delay(dev->dev, 5000);
+
 		pm_runtime_allow(dev->dev);
+
 		pm_runtime_mark_last_busy(dev->dev);
 		pm_runtime_put_autosuspend(dev->dev);
+
+		/*
+		 * For runpm implemented via BACO, PMFW will handle the
+		 * timing for BACO in and out:
+		 *   - put ASIC into BACO state only when both video and
+		 *     audio functions are in D3 state.
+		 *   - pull ASIC out of BACO state when either video or
+		 *     audio function is in D0 state.
+		 * Also, at startup, PMFW assumes both functions are in
+		 * D0 state.
+		 *
+		 * So if snd driver was loaded prior to amdgpu driver
+		 * and audio function was put into D3 state behind PMFW's
+		 * back, the BACO may not correctly kicks in and out.
+		 *
+		 * Via amdgpu_get_audio_func() below, the audio function
+		 * is guarded to be in D0 correctly.
+		 */
+		if (amdgpu_device_supports_baco(dev) &&
+		    !(adev->flags & AMD_IS_APU) &&
+		    (adev->asic_type >= CHIP_NAVI10))
+			amdgpu_get_audio_func(adev);
 	}
 
 	if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DRV_LOAD))
Signature · 6 lines
2.29.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#3 lore raw

Re: [PATCH V2 3/5] drm/amdgpu: correct the audio function initial Dstate

Quoted 58 lines · Evan Quan

On driver loading, the ASIC is in D0 state. The bundled audio function should be in the same state also.

Change-Id I136e196be7633e95883a7f6c33963f7583e9bad1

---
V1->V2:
- Lijo: include the code in a seperate API for better readability
- limit the change for Navi10 and later dGPUs
- comments more about the background

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 40 +++++++++++++++++++++++++
  1 file changed, 40 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +26 -0
index c354ffa62483..e9f2161738d1 100644
@@ -123,6 +123,22 @@ void amdgpu_register_gpu_instance(struct amdgpu_device *adev)
  	mutex_unlock(&mgpu_info.mutex);
  }
 
+static void amdgpu_get_audio_func(struct amdgpu_device *adev)
+{
+	struct pci_dev *p = NULL;
+
+	p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev->bus),
+			adev->pdev->bus->number, 1);
+	if (p) {
+		pm_runtime_get_sync(&p->dev);
+
+		pm_runtime_mark_last_busy(&p->dev);
+		pm_runtime_put_autosuspend(&p->dev);
+
+		pci_dev_put(p);
+	}
+}
+
  /**
   * amdgpu_driver_load_kms - Main load function for KMS.
   *
@@ -212,9 +228,33 @@ int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)
  						DPM_FLAG_MAY_SKIP_RESUME);
  		pm_runtime_use_autosuspend(dev->dev);
  		pm_runtime_set_autosuspend_delay(dev->dev, 5000);
+
  		pm_runtime_allow(dev->dev);
+
  		pm_runtime_mark_last_busy(dev->dev);
  		pm_runtime_put_autosuspend(dev->dev);
+
+		/*
+		 * For runpm implemented via BACO, PMFW will handle the
+		 * timing for BACO in and out:
+		 *   - put ASIC into BACO state only when both video and
+		 *     audio functions are in D3 state.
+		 *   - pull ASIC out of BACO state when either video or
+		 *     audio function is in D0 state.

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) · line 253

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +10 -0
+		 * Also, at startup, PMFW assumes both functions are in
+		 * D0 state.
+		 *
+		 * So if snd driver was loaded prior to amdgpu driver
+		 * and audio function was put into D3 state behind PMFW's
+		 * back, the BACO may not correctly kicks in and out.
+		 *
+		 * Via amdgpu_get_audio_func() below, the audio function
+		 * is guarded to be in D0 correctly.
+		 */

On a second look at the comments - should runpm _get on audio dev be done before doing device_init (so that it's in D0 while FW is getting loaded) and put done here?

Thanks,
Lijo

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) · line 260

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
+		if (amdgpu_device_supports_baco(dev) &&
+		    !(adev->flags & AMD_IS_APU) &&
+		    (adev->asic_type >= CHIP_NAVI10))
+			amdgpu_get_audio_func(adev);
  	}
 
  	if (amdgpu_acpi_smart_shift_update(dev, AMDGPU_SS_DRV_LOAD))

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#4 lore raw

RE: [PATCH V2 3/5] drm/amdgpu: correct the audio function initial Dstate

[AMD Official Use Only]

Quoted 80 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, June 4, 2021 8:24 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH V2 3/5] drm/amdgpu: correct the audio function initial Dstate

Quoted 5 lines · Evan Quan

On driver loading, the ASIC is in D0 state. The bundled audio function should be in the same state also.

Change-Id I136e196be7633e95883a7f6c33963f7583e9bad1
Quoted 7 lines

---
V1->V2:
- Lijo: include the code in a seperate API for better readability
- limit the change for Navi10 and later dGPUs
- comments more about the background

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 40

+++++++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c void amdgpu_register_gpu_instance(struct

Quoted 8 lines
  1 file changed, 40 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +0 -0
index c354ffa62483..e9f2161738d1 100644
@@ -123,6 +123,22 @@ void amdgpu_register_gpu_instance(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct

Quoted 23 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +15 -0
  	mutex_unlock(&mgpu_info.mutex);
  }
 
+static void amdgpu_get_audio_func(struct amdgpu_device *adev) {
+	struct pci_dev *p = NULL;
+
+	p = pci_get_domain_bus_and_slot(pci_domain_nr(adev->pdev-
 bus),
+			adev->pdev->bus->number, 1);
+	if (p) {
+		pm_runtime_get_sync(&p->dev);
+
+		pm_runtime_mark_last_busy(&p->dev);
+		pm_runtime_put_autosuspend(&p->dev);
+
+		pci_dev_put(p);
+	}
+}
+
  /**
   * amdgpu_driver_load_kms - Main load function for KMS.
   *
@@ -212,9 +228,33 @@ int amdgpu_driver_load_kms(struct

amdgpu_device *adev, unsigned long flags)

Quoted 1 line
	DPM_FLAG_MAY_SKIP_RESUME);
Quoted 21 lines
  		pm_runtime_use_autosuspend(dev->dev);
  		pm_runtime_set_autosuspend_delay(dev->dev, 5000);
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +16 -0
+
  		pm_runtime_allow(dev->dev);
+
  		pm_runtime_mark_last_busy(dev->dev);
  		pm_runtime_put_autosuspend(dev->dev);
+
+		/*
+		 * For runpm implemented via BACO, PMFW will handle the
+		 * timing for BACO in and out:
+		 *   - put ASIC into BACO state only when both video and
+		 *     audio functions are in D3 state.
+		 *   - pull ASIC out of BACO state when either video or
+		 *     audio function is in D0 state.
+		 * Also, at startup, PMFW assumes both functions are in
+		 * D0 state.
+		 *
+		 * So if snd driver was loaded prior to amdgpu driver
+		 * and audio function was put into D3 state behind PMFW's
+		 * back, the BACO may not correctly kicks in and out.
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags) · line 253

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
+		 *
+		 * Via amdgpu_get_audio_func() below, the audio function
+		 * is guarded to be in D0 correctly.
+		 */

On a second look at the comments - should runpm _get on audio dev be done before doing device_init (so that it's in D0 while FW is getting loaded) and put done here?

[Quan, Evan] It does not matter as long as all those are performed before .runtime_suspend() kicks.
The issue around here is : if the audio dev is already in D3 state before PMFW alive, during .runtime_suspend there will be no Dstate transfer(D0->D3). Thus no interrupt will go to PMFW and PMFW will be not aware of the audio dev D3 state. With the proper audio dev D3 state, the baco state will never kick in. Via the amdgpu_get_audio_func(), the audio dev is put into D0 state. Then on the succeeding .runtime_suspend(), there will be Dstate transfer(D0->D3) and thus interrupt for PMFW.

BR
Evan

Quoted 4 lines

Thanks,
Lijo

Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c int amdgpu_driver_load_kms(struct amdgpu_device *adev, unsigned long flags)

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +4 -0
+		if (amdgpu_device_supports_baco(dev) &&
+		    !(adev->flags & AMD_IS_APU) &&
+		    (adev->asic_type >= CHIP_NAVI10))
+			amdgpu_get_audio_func(adev);
  	}
 
  	if (amdgpu_acpi_smart_shift_update(dev,

AMDGPU_SS_DRV_LOAD))

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#5 lore raw

PATCH v2 4/5 drm/amd/pm: clear the cached dpm feature status

In reply to Evan Quan

For some ASICs, the real dpm feature disablement job is handled by PMFW during baco reset and custom pptable loading. Cached dpm feature status need to be cleared to pair that.

Change-Id I9e37d80e13599833301c04711b097fb37c2e41f9

---
V1->V2:
- correct the setting for baco bit(pointed out by Lijo)

---
 drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 +++++
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 ++++++++++++--
 .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  1 +
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  1 +
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 25 +++++++++++++++++++
 drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 +++
 drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +
 7 files changed, 54 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
index fb7438224872..3f9b2a839a37 100644
@@ -937,6 +937,12 @@ struct pptable_funcs {
 	 */
 	int (*disable_all_features_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
 
+	/**
+	 * @clear_cached_dpm_feature_status_with_exception: Clear cached dpm feature status with
+	 *                                                  exception to those in &mask.
+	 */
+	int (*clear_cached_dpm_feature_status_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
+
 	/**
 	 * @notify_display_change: Enable fast memory clock switching.
 	 *
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +17 -2
index c9a31556e077..aba475d06507 100644
@@ -1352,6 +1352,16 @@ static int smu_hw_init(void *handle)
 	return 0;
 }
 
+static void smu_reset_cached_dpm_feature_status(struct smu_context *smu)
+{
+	struct smu_feature *feature = &smu->smu_feature;
+
+	mutex_lock(&feature->mutex);
+	bitmap_zero(feature->enabled, feature->feature_num);
+	bitmap_zero(feature->supported, feature->feature_num);
+	mutex_unlock(&feature->mutex);
+}
+
 static int smu_disable_dpms(struct smu_context *smu)
 {
 	struct amdgpu_device *adev = smu->adev;
@@ -1374,16 +1384,21 @@ static int smu_disable_dpms(struct smu_context *smu)
 	 */
 	if (smu->uploading_custom_pp_table &&
 	    (adev->asic_type >= CHIP_NAVI10) &&
-	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH)) {
+		smu_reset_cached_dpm_feature_status(smu);
 		return 0;
+	}
 
 	/*
 	 * For Sienna_Cichlid, PMFW will handle the features disablement properly
 	 * on BACO in. Driver involvement is unnecessary.
 	 */
 	if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
-	     use_baco)
+	     use_baco) {
+		smu_clear_cached_dpm_feature_status_with_exception(smu,
+								   SMU_FEATURE_BACO_BIT);
 		return 0;
+	}
 
 	/*
 	 * For gpu reset, runpm and hibernation through BACO,
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +1 -0
index afd4bd850c63..8c3ea20fb0f6 100644
@@ -3083,6 +3083,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {
 	.get_enabled_mask = smu_cmn_get_enabled_mask,
 	.feature_is_enabled = smu_cmn_feature_is_enabled,
 	.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = smu_cmn_clear_cached_dpm_feature_status_with_exception,
 	.notify_display_change = smu_v11_0_notify_display_change,
 	.set_power_limit = smu_v11_0_set_power_limit,
 	.init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
index b4a2bb0f3f4c..14a14c30ee5e 100644
@@ -3886,6 +3886,7 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = {
 	.get_enabled_mask = smu_cmn_get_enabled_mask,
 	.feature_is_enabled = smu_cmn_feature_is_enabled,
 	.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = smu_cmn_clear_cached_dpm_feature_status_with_exception,
 	.notify_display_change = NULL,
 	.set_power_limit = smu_v11_0_set_power_limit,
 	.init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +25 -0
index 0ceb7329838c..b9c38abc9d37 100644
@@ -594,6 +594,31 @@ int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
 						   0);
 }
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct smu_context *smu,
+							   enum smu_feature_mask mask)
+{
+	struct smu_feature *feature = &smu->smu_feature;
+	uint64_t features_to_disable = U64_MAX;
+	int skipped_feature_id;
+
+	skipped_feature_id = smu_cmn_to_asic_specific_index(smu,
+							    CMN2ASIC_MAPPING_FEATURE,
+							    mask);
+	if (skipped_feature_id < 0)
+		return -EINVAL;
+
+	features_to_disable &= ~(1ULL << skipped_feature_id);
+
+	mutex_lock(&feature->mutex);
+	bitmap_andnot(feature->enabled, feature->enabled,
+			(unsigned long *)(&features_to_disable), SMU_FEATURE_MAX);
+	bitmap_andnot(feature->supported, feature->supported,
+			(unsigned long *)(&features_to_disable), SMU_FEATURE_MAX);
+	mutex_unlock(&feature->mutex);
+
+	return 0;
+}
+
 int smu_cmn_get_smc_version(struct smu_context *smu,
 			    uint32_t *if_version,
 			    uint32_t *smu_version)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
index da6ff6f024f9..12ad07132d15 100644
@@ -77,6 +77,9 @@ int smu_cmn_set_pp_feature_mask(struct smu_context *smu,
 int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
 						enum smu_feature_mask mask);
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct smu_context *smu,
+							   enum smu_feature_mask mask);
+
 int smu_cmn_get_smc_version(struct smu_context *smu,
 			    uint32_t *if_version,
 			    uint32_t *smu_version);
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
index 33101dc93bcc..b12dcfab55fe 100644
@@ -58,6 +58,7 @@
 #define smu_feature_get_enabled_mask(smu, mask, num)			smu_ppt_funcs(get_enabled_mask, 0, smu, mask, num)
 #define smu_feature_is_enabled(smu, mask)				smu_ppt_funcs(feature_is_enabled, 0, smu, mask)
 #define smu_disable_all_features_with_exception(smu, mask)		smu_ppt_funcs(disable_all_features_with_exception, 0, smu, mask)
+#define smu_clear_cached_dpm_feature_status_with_exception(smu, mask)	smu_ppt_funcs(clear_cached_dpm_feature_status_with_exception, 0, smu, mask)
 #define smu_is_dpm_running(smu)						smu_ppt_funcs(is_dpm_running, 0 , smu)
 #define smu_notify_display_change(smu)					smu_ppt_funcs(notify_display_change, 0, smu)
 #define smu_populate_umd_state_clk(smu)					smu_ppt_funcs(populate_umd_state_clk, 0, smu)
Signature · 6 lines
2.29.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#6 lore raw

Re: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

Quoted 24 lines · Evan Quan

For some ASICs, the real dpm feature disablement job is handled by PMFW during baco reset and custom pptable loading. Cached dpm feature status need to be cleared to pair that.

Change-Id I9e37d80e13599833301c04711b097fb37c2e41f9

---
V1->V2:
- correct the setting for baco bit(pointed out by Lijo)

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 +++++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 ++++++++++++--
  .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  1 +
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  1 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 25 +++++++++++++++++++
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 +++
  drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +
  7 files changed, 54 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
index fb7438224872..3f9b2a839a37 100644

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 945

Quoted 9 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +6 -0
@@ -937,6 +937,12 @@ struct pptable_funcs {
  	 */
  	int (*disable_all_features_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
 
+	/**
+	 * @clear_cached_dpm_feature_status_with_exception: Clear cached dpm feature status with
+	 *                                                  exception to those in &mask.
+	 */
+	int (*clear_cached_dpm_feature_status_with_exception)(struct smu_context *smu, enum smu_feature_mask mask);
+

Since this is a just a utility function which clears sw bitmask without touching hardware, do we need a ppt_func? In case that is needed, we already have this - smu_cmn_disable_all_features_with_exception. So, can't this remain as a standalone smu_cmn function which can be called from anywhere? Nowadays, I get a red alert when a ppt_func gets added :)

Thanks,
Lijo

Quoted 128 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
  	/**
  	 * @notify_display_change: Enable fast memory clock switching.
  	 *
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +17 -2
index c9a31556e077..aba475d06507 100644
@@ -1352,6 +1352,16 @@ static int smu_hw_init(void *handle)
  	return 0;
  }
 
+static void smu_reset_cached_dpm_feature_status(struct smu_context *smu)
+{
+	struct smu_feature *feature = &smu->smu_feature;
+
+	mutex_lock(&feature->mutex);
+	bitmap_zero(feature->enabled, feature->feature_num);
+	bitmap_zero(feature->supported, feature->feature_num);
+	mutex_unlock(&feature->mutex);
+}
+
  static int smu_disable_dpms(struct smu_context *smu)
  {
  	struct amdgpu_device *adev = smu->adev;
@@ -1374,16 +1384,21 @@ static int smu_disable_dpms(struct smu_context *smu)
  	 */
  	if (smu->uploading_custom_pp_table &&
  	    (adev->asic_type >= CHIP_NAVI10) &&
-	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH)) {
+		smu_reset_cached_dpm_feature_status(smu);
  		return 0;
+	}
 
  	/*
  	 * For Sienna_Cichlid, PMFW will handle the features disablement properly
  	 * on BACO in. Driver involvement is unnecessary.
  	 */
  	if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
-	     use_baco)
+	     use_baco) {
+		smu_clear_cached_dpm_feature_status_with_exception(smu,
+								   SMU_FEATURE_BACO_BIT);
  		return 0;
+	}
 
  	/*
  	 * For gpu reset, runpm and hibernation through BACO,
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +1 -0
index afd4bd850c63..8c3ea20fb0f6 100644
@@ -3083,6 +3083,7 @@ static const struct pptable_funcs navi10_ppt_funcs = {
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = smu_v11_0_notify_display_change,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +1 -0
index b4a2bb0f3f4c..14a14c30ee5e 100644
@@ -3886,6 +3886,7 @@ static const struct pptable_funcs sienna_cichlid_ppt_funcs = {
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception = smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = NULL,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks = smu_v11_0_init_max_sustainable_clocks,
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +25 -0
index 0ceb7329838c..b9c38abc9d37 100644
@@ -594,6 +594,31 @@ int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
  						   0);
  }
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct smu_context *smu,
+							   enum smu_feature_mask mask)
+{
+	struct smu_feature *feature = &smu->smu_feature;
+	uint64_t features_to_disable = U64_MAX;
+	int skipped_feature_id;
+
+	skipped_feature_id = smu_cmn_to_asic_specific_index(smu,
+							    CMN2ASIC_MAPPING_FEATURE,
+							    mask);
+	if (skipped_feature_id < 0)
+		return -EINVAL;
+
+	features_to_disable &= ~(1ULL << skipped_feature_id);
+
+	mutex_lock(&feature->mutex);
+	bitmap_andnot(feature->enabled, feature->enabled,
+			(unsigned long *)(&features_to_disable), SMU_FEATURE_MAX);
+	bitmap_andnot(feature->supported, feature->supported,
+			(unsigned long *)(&features_to_disable), SMU_FEATURE_MAX);
+	mutex_unlock(&feature->mutex);
+
+	return 0;
+}
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +3 -0
index da6ff6f024f9..12ad07132d15 100644
@@ -77,6 +77,9 @@ int smu_cmn_set_pp_feature_mask(struct smu_context *smu,
  int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,
  						enum smu_feature_mask mask);
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct smu_context *smu,
+							   enum smu_feature_mask mask);
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version);
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
index 33101dc93bcc..b12dcfab55fe 100644

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 64

Quoted 7 lines
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
@@ -58,6 +58,7 @@
  #define smu_feature_get_enabled_mask(smu, mask, num)			smu_ppt_funcs(get_enabled_mask, 0, smu, mask, num)
  #define smu_feature_is_enabled(smu, mask)				smu_ppt_funcs(feature_is_enabled, 0, smu, mask)
  #define smu_disable_all_features_with_exception(smu, mask)		smu_ppt_funcs(disable_all_features_with_exception, 0, smu, mask)
+#define smu_clear_cached_dpm_feature_status_with_exception(smu, mask)	smu_ppt_funcs(clear_cached_dpm_feature_status_with_exception, 0, smu, mask)
  #define smu_is_dpm_running(smu)						smu_ppt_funcs(is_dpm_running, 0 , smu)
  #define smu_notify_display_change(smu)					smu_ppt_funcs(notify_display_change, 0, smu)
  #define smu_populate_umd_state_clk(smu)					smu_ppt_funcs(populate_umd_state_clk, 0, smu)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#7 lore raw

RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[AMD Official Use Only]

Hi Lijo,

I got your concern. However, the problem is what amdgpu_smu.c can see is SMU_FEATURE_xxxxx_BIT(e.g. SMU_FEATURE_BACO_BIT) related.
While the bit mask stored in feature->enabled is FEATURE_xxxxx_BIT(e.g. FEATURE_BACO_BIT which is asic specific) related.
So, a SMU_FEATURE_BACO_BIT to FEATURE_BACO_BIT transfer is needed and for now this asic specific operation is performed in smu_cmn.c(smu_cmn_to_asic_specific_index).

The possible way to get this optimized I can see is either
1. try to fit this into smu_cmn_disable_all_features_with_exception()
2. make the bitmasks stored in feature->enabled are non asic specific ones. This will involve extra efforts and risks. I personally prefer the approach 1 above.

Any thoughts?

BR
Evan

Quoted 223 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, June 4, 2021 7:56 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

Quoted 4 lines · Evan Quan

For some ASICs, the real dpm feature disablement job is handled by PMFW during baco reset and custom pptable loading. Cached dpm feature status need to be cleared to pair that.

Quoted 8 lines
Change-Id I9e37d80e13599833301c04711b097fb37c2e41f9

---
V1->V2:
- correct the setting for baco bit(pointed out by Lijo)

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 +++++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 ++++++++++++-

-

Quoted 3 lines
  .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  1 +
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  1 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 25

+++++++++++++++++++

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 938

Quoted 12 lines
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 +++
  drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +
  7 files changed, 54 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
index fb7438224872..3f9b2a839a37 100644
@@ -937,6 +937,12 @@ struct pptable_funcs {
  	 */
  	int (*disable_all_features_with_exception)(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 942

Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
 enum smu_feature_mask mask);
 
+	/**
+	 * @clear_cached_dpm_feature_status_with_exception: Clear

cached dpm feature status with

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 945

Quoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+	 *                                                  exception to those in &mask.
+	 */
+	int (*clear_cached_dpm_feature_status_with_exception)(struct
+smu_context *smu, enum smu_feature_mask mask);
+

Since this is a just a utility function which clears sw bitmask without touching hardware, do we need a ppt_func? In case that is needed, we already have this - smu_cmn_disable_all_features_with_exception. So, can't this remain as a standalone smu_cmn function which can be called from anywhere? Nowadays, I get a red alert when a ppt_func gets added :)

Thanks,
Lijo

Quoted 15 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
  	/**
  	 * @notify_display_change: Enable fast memory clock switching.
  	 *
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index c9a31556e077..aba475d06507 100644
@@ -1352,6 +1352,16 @@ static int smu_hw_init(void *handle)
  	return 0;
  }
 
+static void smu_reset_cached_dpm_feature_status(struct smu_context
+*smu) {
+	struct smu_feature *feature = &smu->smu_feature;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_hw_init(void *handle) · line 1367

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -0
+
+	mutex_lock(&feature->mutex);
+	bitmap_zero(feature->enabled, feature->feature_num);
+	bitmap_zero(feature->supported, feature->feature_num);
+	mutex_unlock(&feature->mutex);
+}
+
  static int smu_disable_dpms(struct smu_context *smu)
  {
  	struct amdgpu_device *adev = smu->adev; @@ -1374,16 +1384,21

@@

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 12 lines

static int smu_disable_dpms(struct smu_context *smu)
*/
if (smu->uploading_custom_pp_table &&
(adev->asic_type >= CHIP_NAVI10) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -1
-	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH)) {
+		smu_reset_cached_dpm_feature_status(smu);
  		return 0;
+	}
 
  	/*
  	 * For Sienna_Cichlid, PMFW will handle the features disablement

properly

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 6 lines

* on BACO in. Driver involvement is unnecessary. */
if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
-	     use_baco)
+	     use_baco) {
+

smu_clear_cached_dpm_feature_status_with_exception(smu,

Quoted 1 line

+

SMU_FEATURE_BACO_BIT);

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c static const struct pptable_funcs

Quoted 11 lines

return 0;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -0
+	}
 
  	/*
  	 * For gpu reset, runpm and hibernation through BACO, diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index afd4bd850c63..8c3ea20fb0f6 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +0 -0
@@ -3083,6 +3083,7 @@ static const struct pptable_funcs

navi10_ppt_funcs = {

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception =
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception =
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = smu_v11_0_notify_display_change,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =

smu_v11_0_init_max_sustainable_clocks,

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
index b4a2bb0f3f4c..14a14c30ee5e 100644
@@ -3886,6 +3886,7 @@ static const struct pptable_funcs

sienna_cichlid_ppt_funcs = {

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

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception =
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception =
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = NULL,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =

smu_v11_0_init_max_sustainable_clocks,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 0ceb7329838c..b9c38abc9d37 100644
@@ -594,6 +594,31 @@ int

smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 597

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
  						   0);
  }
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 598

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+							   enum

smu_feature_mask mask) {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, · line 609

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+	struct smu_feature *feature = &smu->smu_feature;
+	uint64_t features_to_disable = U64_MAX;
+	int skipped_feature_id;
+
+	skipped_feature_id = smu_cmn_to_asic_specific_index(smu,
+

CMN2ASIC_MAPPING_FEATURE,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9 -0
+							    mask);
+	if (skipped_feature_id < 0)
+		return -EINVAL;
+
+	features_to_disable &= ~(1ULL << skipped_feature_id);
+
+	mutex_lock(&feature->mutex);
+	bitmap_andnot(feature->enabled, feature->enabled,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 615

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -0
+	bitmap_andnot(feature->supported, feature->supported,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+	mutex_unlock(&feature->mutex);
+
+	return 0;
+}
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
index da6ff6f024f9..12ad07132d15 100644
@@ -77,6 +77,9 @@ int smu_cmn_set_pp_feature_mask(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 77

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  int smu_cmn_disable_all_features_with_exception(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 78

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  						enum smu_feature_mask

mask);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 79

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 80

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+							   enum

smu_feature_mask mask);

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 58

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version);
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
index 33101dc93bcc..b12dcfab55fe 100644
@@ -58,6 +58,7 @@
  #define smu_feature_get_enabled_mask(smu, mask, num)

smu_ppt_funcs(get_enabled_mask, 0, smu, mask, num)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 59

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_feature_is_enabled(smu, mask)

smu_ppt_funcs(feature_is_enabled, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 60

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_disable_all_features_with_exception(smu, mask)

smu_ppt_funcs(disable_all_features_with_exception, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 61

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
+#define smu_clear_cached_dpm_feature_status_with_exception(smu,
Quoted 9 lines

mask) smu_ppt_funcs(clear_cached_dpm_feature_status_with_exception,
0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 62

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_is_dpm_running(smu)

smu_ppt_funcs(is_dpm_running, 0 , smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 63

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_notify_display_change(smu)

smu_ppt_funcs(notify_display_change, 0, smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 64

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_populate_umd_state_clk(smu)

smu_ppt_funcs(populate_umd_state_clk, 0, smu)

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw

RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[Public]

What about separating to smu_cmn_utils.c/smu_utils.c or similar which is meant for software based common/util functions? In general, it will have sw based common funcs (not ASIC specific) and may be used outside (for ex: in amdgpu_smu.c). smu_cmn continues to have the hw based common/ppt_func routines.

smu_cmn_to_asic_specific_index is also a good candidate for such a function as it fetches the sw lookup map (may be moved later).

Thanks,
Lijo

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Monday, June 7, 2021 1:04 PM
To: Lazar, Lijo <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[AMD Official Use Only]

Hi Lijo,

I got your concern. However, the problem is what amdgpu_smu.c can see is SMU_FEATURE_xxxxx_BIT(e.g. SMU_FEATURE_BACO_BIT) related.
While the bit mask stored in feature->enabled is FEATURE_xxxxx_BIT(e.g. FEATURE_BACO_BIT which is asic specific) related.
So, a SMU_FEATURE_BACO_BIT to FEATURE_BACO_BIT transfer is needed and for now this asic specific operation is performed in smu_cmn.c(smu_cmn_to_asic_specific_index).

The possible way to get this optimized I can see is either 1. try to fit this into smu_cmn_disable_all_features_with_exception()
2. make the bitmasks stored in feature->enabled are non asic specific ones. This will involve extra efforts and risks. I personally prefer the approach 1 above.

Any thoughts?

BR
Evan

Quoted 223 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, June 4, 2021 7:56 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

Quoted 4 lines · Evan Quan

For some ASICs, the real dpm feature disablement job is handled by PMFW during baco reset and custom pptable loading. Cached dpm feature status need to be cleared to pair that.

Quoted 8 lines
Change-Id I9e37d80e13599833301c04711b097fb37c2e41f9

---
V1->V2:
- correct the setting for baco bit(pointed out by Lijo)

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 +++++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19 ++++++++++++-

-

Quoted 3 lines
  .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  1 +
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  1 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 25

+++++++++++++++++++

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 938

Quoted 12 lines
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 +++
  drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +
  7 files changed, 54 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
index fb7438224872..3f9b2a839a37 100644
@@ -937,6 +937,12 @@ struct pptable_funcs {
  	 */
  	int (*disable_all_features_with_exception)(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 942

Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
 enum smu_feature_mask mask);
 
+	/**
+	 * @clear_cached_dpm_feature_status_with_exception: Clear

cached dpm feature status with

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 945

Quoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+	 *                                                  exception to those in &mask.
+	 */
+	int (*clear_cached_dpm_feature_status_with_exception)(struct
+smu_context *smu, enum smu_feature_mask mask);
+

Since this is a just a utility function which clears sw bitmask
without touching hardware, do we need a ppt_func? In case that is
needed, we already have this -
smu_cmn_disable_all_features_with_exception. So, can't this remain as a standalone smu_cmn function which can be called from anywhere? Nowadays, I get a red alert when a ppt_func gets added :)

Thanks,
Lijo

Quoted 15 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
  	/**
  	 * @notify_display_change: Enable fast memory clock switching.
  	 *
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index c9a31556e077..aba475d06507 100644
@@ -1352,6 +1352,16 @@ static int smu_hw_init(void *handle)
  	return 0;
  }
 
+static void smu_reset_cached_dpm_feature_status(struct smu_context
+*smu) {
+	struct smu_feature *feature = &smu->smu_feature;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_hw_init(void *handle) · line 1367

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -0
+
+	mutex_lock(&feature->mutex);
+	bitmap_zero(feature->enabled, feature->feature_num);
+	bitmap_zero(feature->supported, feature->feature_num);
+	mutex_unlock(&feature->mutex);
+}
+
  static int smu_disable_dpms(struct smu_context *smu)
  {
  	struct amdgpu_device *adev = smu->adev; @@ -1374,16 +1384,21

@@

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 12 lines

static int smu_disable_dpms(struct smu_context *smu)
*/
if (smu->uploading_custom_pp_table &&
(adev->asic_type >= CHIP_NAVI10) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -1
-	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH)) {
+		smu_reset_cached_dpm_feature_status(smu);
  		return 0;
+	}
 
  	/*
  	 * For Sienna_Cichlid, PMFW will handle the features disablement

properly

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 6 lines

* on BACO in. Driver involvement is unnecessary. */
if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
-	     use_baco)
+	     use_baco) {
+

smu_clear_cached_dpm_feature_status_with_exception(smu,

Quoted 1 line

+

SMU_FEATURE_BACO_BIT);

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c static const struct pptable_funcs

Quoted 11 lines

return 0;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -0
+	}
 
  	/*
  	 * For gpu reset, runpm and hibernation through BACO, diff --git 

a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index afd4bd850c63..8c3ea20fb0f6 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +0 -0
@@ -3083,6 +3083,7 @@ static const struct pptable_funcs

navi10_ppt_funcs = {

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception = 
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = 
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = smu_v11_0_notify_display_change,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =

smu_v11_0_init_max_sustainable_clocks,

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
index b4a2bb0f3f4c..14a14c30ee5e 100644
@@ -3886,6 +3886,7 @@ static const struct pptable_funcs

sienna_cichlid_ppt_funcs = {

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

Quoted 16 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception = 
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception = 
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = NULL,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =

smu_v11_0_init_max_sustainable_clocks,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 0ceb7329838c..b9c38abc9d37 100644
@@ -594,6 +594,31 @@ int

smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 597

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
  						   0);
  }
 
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 598

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+							   enum

smu_feature_mask mask) {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, · line 609

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+	struct smu_feature *feature = &smu->smu_feature;
+	uint64_t features_to_disable = U64_MAX;
+	int skipped_feature_id;
+
+	skipped_feature_id = smu_cmn_to_asic_specific_index(smu,
+

CMN2ASIC_MAPPING_FEATURE,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9 -0
+							    mask);
+	if (skipped_feature_id < 0)
+		return -EINVAL;
+
+	features_to_disable &= ~(1ULL << skipped_feature_id);
+
+	mutex_lock(&feature->mutex);
+	bitmap_andnot(feature->enabled, feature->enabled,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 615

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -0
+	bitmap_andnot(feature->supported, feature->supported,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+	mutex_unlock(&feature->mutex);
+
+	return 0;
+}
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
index da6ff6f024f9..12ad07132d15 100644
@@ -77,6 +77,9 @@ int smu_cmn_set_pp_feature_mask(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 77

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  int smu_cmn_disable_all_features_with_exception(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 78

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  						enum smu_feature_mask

mask);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 79

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+int smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 80

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+							   enum

smu_feature_mask mask);

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 58

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version);
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
index 33101dc93bcc..b12dcfab55fe 100644
@@ -58,6 +58,7 @@
  #define smu_feature_get_enabled_mask(smu, mask, num)

smu_ppt_funcs(get_enabled_mask, 0, smu, mask, num)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 59

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_feature_is_enabled(smu, mask)

smu_ppt_funcs(feature_is_enabled, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 60

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_disable_all_features_with_exception(smu, mask)

smu_ppt_funcs(disable_all_features_with_exception, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 61

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
+#define smu_clear_cached_dpm_feature_status_with_exception(smu,
Quoted 9 lines

mask) smu_ppt_funcs(clear_cached_dpm_feature_status_with_exception,
0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 62

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_is_dpm_running(smu)

smu_ppt_funcs(is_dpm_running, 0 , smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 63

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_notify_display_change(smu)

smu_ppt_funcs(notify_display_change, 0, smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 64

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_populate_umd_state_clk(smu)

smu_ppt_funcs(populate_umd_state_clk, 0, smu)

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#9 lore raw

RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[Public]

Hi Lijo,

Per original design, all non ASIC specific code goes to amdgpu_smu.c. To me, it sounds you want to separate some of them(from amdgpu_smu.c) into a new file. I'm OK with that. However as I said, to do that, we may need to make the bitmasks stored in feature->enabled non asic bundled/specific. I need more time to consider and will put that on my TODO list. For this specific patch, I will update it with code fit into smu_cmn_disable_all_features_with_exception(). Are you OK with that?

BR
Evan

Quoted 275 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Monday, June 7, 2021 4:05 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[Public]

What about separating to smu_cmn_utils.c/smu_utils.c or similar which is meant for software based common/util functions? In general, it will have sw based common funcs (not ASIC specific) and may be used outside (for ex: in amdgpu_smu.c). smu_cmn continues to have the hw based common/ppt_func routines.

smu_cmn_to_asic_specific_index is also a good candidate for such a function as it fetches the sw lookup map (may be moved later).

Thanks,
Lijo

-----Original Message-----
From: Quan, Evan <[email protected]>
Sent: Monday, June 7, 2021 1:04 PM
To: Lazar, Lijo <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

[AMD Official Use Only]

Hi Lijo,

I got your concern. However, the problem is what amdgpu_smu.c can see is SMU_FEATURE_xxxxx_BIT(e.g. SMU_FEATURE_BACO_BIT) related. While the bit mask stored in feature->enabled is FEATURE_xxxxx_BIT(e.g. FEATURE_BACO_BIT which is asic specific) related.
So, a SMU_FEATURE_BACO_BIT to FEATURE_BACO_BIT transfer is needed and for now this asic specific operation is performed in smu_cmn.c(smu_cmn_to_asic_specific_index).

The possible way to get this optimized I can see is either 1. try to fit this into smu_cmn_disable_all_features_with_exception()
2. make the bitmasks stored in feature->enabled are non asic specific ones. This will involve extra efforts and risks.
I personally prefer the approach 1 above.

Any thoughts?

BR
Evan

Quoted 10 lines

-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Friday, June 4, 2021 7:56 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH V2 4/5] drm/amd/pm: clear the cached dpm feature status

Quoted 13 lines
Quoted 12 lines · Evan Quan

For some ASICs, the real dpm feature disablement job is handled by PMFW during baco reset and custom pptable loading. Cached dpm feature status need to be cleared to pair that.

Change-Id I9e37d80e13599833301c04711b097fb37c2e41f9

---
V1->V2:
- correct the setting for baco bit(pointed out by Lijo)

---
  drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h       |  6 +++++
  drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c     | 19

++++++++++++-

Quoted 23 lines

-

Quoted 3 lines
  .../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c   |  1 +
  .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  1 +
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c        | 25

+++++++++++++++++++

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 938

Quoted 12 lines
  drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h        |  3 +++
  drivers/gpu/drm/amd/pm/swsmu/smu_internal.h   |  1 +
  7 files changed, 54 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
index fb7438224872..3f9b2a839a37 100644
@@ -937,6 +937,12 @@ struct pptable_funcs {
  	 */
  	int (*disable_all_features_with_exception)(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 942

Quoted 4 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +2 -0
 enum smu_feature_mask mask);
 
+	/**
+	 * @clear_cached_dpm_feature_status_with_exception: Clear

cached dpm feature status with

Quoted 10 lines

drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h struct pptable_funcs { · line 945

Quoted 5 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +5 -0
+	 *                                                  exception to those in &mask.
+	 */
+	int (*clear_cached_dpm_feature_status_with_exception)(struct
+smu_context *smu, enum smu_feature_mask mask);
+

Since this is a just a utility function which clears sw bitmask without touching hardware, do we need a ppt_func? In case that is needed, we already have this - smu_cmn_disable_all_features_with_exception. So, can't this remain as a

standalone smu_cmn function which can be called from anywhere?

Quoted 65 lines

Nowadays, I get a red alert when a ppt_func gets added :)

Thanks,
Lijo

Quoted 15 lines
drivers/gpu/drm/amd/pm/inc/amdgpu_smu.h +0 -0
  	/**
  	 * @notify_display_change: Enable fast memory clock switching.
  	 *
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -0
index c9a31556e077..aba475d06507 100644
@@ -1352,6 +1352,16 @@ static int smu_hw_init(void *handle)
  	return 0;
  }
 
+static void smu_reset_cached_dpm_feature_status(struct smu_context
+*smu) {
+	struct smu_feature *feature = &smu->smu_feature;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_hw_init(void *handle) · line 1367

Quoted 10 lines
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +7 -0
+
+	mutex_lock(&feature->mutex);
+	bitmap_zero(feature->enabled, feature->feature_num);
+	bitmap_zero(feature->supported, feature->feature_num);
+	mutex_unlock(&feature->mutex);
+}
+
  static int smu_disable_dpms(struct smu_context *smu)
  {
  	struct amdgpu_device *adev = smu->adev; @@ -1374,16 +1384,21

@@

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 12 lines

static int smu_disable_dpms(struct smu_context *smu)
*/
if (smu->uploading_custom_pp_table &&
(adev->asic_type >= CHIP_NAVI10) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +3 -1
-	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH))
+	    (adev->asic_type <= CHIP_DIMGREY_CAVEFISH)) {
+		smu_reset_cached_dpm_feature_status(smu);
  		return 0;
+	}
 
  	/*
  	 * For Sienna_Cichlid, PMFW will handle the features disablement

properly

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c static int smu_disable_dpms(struct smu_context *smu)

Quoted 6 lines

* on BACO in. Driver involvement is unnecessary. */
if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
-	     use_baco)
+	     use_baco) {
+

smu_clear_cached_dpm_feature_status_with_exception(smu,

Quoted 1 line

+

SMU_FEATURE_BACO_BIT);

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c static const struct pptable_funcs

Quoted 11 lines

return 0;

drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +1 -0
+	}
 
  	/*
  	 * For gpu reset, runpm and hibernation through BACO, diff --git

a/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
b/drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
index afd4bd850c63..8c3ea20fb0f6 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +0 -0
@@ -3083,6 +3083,7 @@ static const struct pptable_funcs

navi10_ppt_funcs = {

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception =
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception =
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = smu_v11_0_notify_display_change,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =

smu_v11_0_init_max_sustainable_clocks,
diff --git

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

Quoted 15 lines

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static const struct pptable_funcs

Quoted 5 lines

b/drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c index b4a2bb0f3f4c..14a14c30ee5e 100644

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -0
@@ -3886,6 +3886,7 @@ static const struct pptable_funcs

sienna_cichlid_ppt_funcs = {

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +2 -0
  	.get_enabled_mask = smu_cmn_get_enabled_mask,
  	.feature_is_enabled = smu_cmn_feature_is_enabled,
  	.disable_all_features_with_exception =
 smu_cmn_disable_all_features_with_exception,
+	.clear_cached_dpm_feature_status_with_exception =
+smu_cmn_clear_cached_dpm_feature_status_with_exception,
  	.notify_display_change = NULL,
  	.set_power_limit = smu_v11_0_set_power_limit,
  	.init_max_sustainable_clocks =
Quoted 12 lines

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

Quoted 7 lines

smu_v11_0_init_max_sustainable_clocks,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +0 -0
index 0ceb7329838c..b9c38abc9d37 100644
@@ -594,6 +594,31 @@ int

smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

Quoted 4 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
  						   0);
  }
 
+int

smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

Quoted 38 lines

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 598

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +1 -0
+							   enum

smu_feature_mask mask) {

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu, · line 609

Quoted 6 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +6 -0
+	struct smu_feature *feature = &smu->smu_feature;
+	uint64_t features_to_disable = U64_MAX;
+	int skipped_feature_id;
+
+	skipped_feature_id = smu_cmn_to_asic_specific_index(smu,
+

CMN2ASIC_MAPPING_FEATURE,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int smu_cmn_disable_all_features_with_exception(struct smu_context *smu,

Quoted 9 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +9 -0
+							    mask);
+	if (skipped_feature_id < 0)
+		return -EINVAL;
+
+	features_to_disable &= ~(1ULL << skipped_feature_id);
+
+	mutex_lock(&feature->mutex);
+	bitmap_andnot(feature->enabled, feature->enabled,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c int · line 615

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +2 -0
+	bitmap_andnot(feature->supported, feature->supported,
+			(unsigned long *)(&features_to_disable),

SMU_FEATURE_MAX);

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct

Quoted 14 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.c +5 -0
+	mutex_unlock(&feature->mutex);
+
+	return 0;
+}
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version)
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
index da6ff6f024f9..12ad07132d15 100644
@@ -77,6 +77,9 @@ int smu_cmn_set_pp_feature_mask(struct

smu_context *smu,

Quoted 6 lines

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 77

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  int smu_cmn_disable_all_features_with_exception(struct smu_context

*smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 78

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +0 -0
  						enum smu_feature_mask

mask);

Quoted 2 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+int

smu_cmn_clear_cached_dpm_feature_status_with_exception(struct

Quoted 15 lines

smu_context *smu,

drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h int smu_cmn_set_pp_feature_mask(struct · line 80

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+							   enum

smu_feature_mask mask);

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 58

Quoted 11 lines
drivers/gpu/drm/amd/pm/swsmu/smu_cmn.h +1 -0
+
  int smu_cmn_get_smc_version(struct smu_context *smu,
  			    uint32_t *if_version,
  			    uint32_t *smu_version);
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
index 33101dc93bcc..b12dcfab55fe 100644
@@ -58,6 +58,7 @@
  #define smu_feature_get_enabled_mask(smu, mask, num)

smu_ppt_funcs(get_enabled_mask, 0, smu, mask, num)

Quoted 15 lines
Quoted 6 lines

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 59

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_feature_is_enabled(smu, mask)

smu_ppt_funcs(feature_is_enabled, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 60

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_disable_all_features_with_exception(smu, mask)

smu_ppt_funcs(disable_all_features_with_exception, 0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 61

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +1 -0
+#define smu_clear_cached_dpm_feature_status_with_exception(smu,

mask)

smu_ppt_funcs(clear_cached_dpm_feature_status_with_exception,

Quoted 8 lines

0, smu, mask)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 62

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_is_dpm_running(smu)

smu_ppt_funcs(is_dpm_running, 0 , smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 63

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_notify_display_change(smu)

smu_ppt_funcs(notify_display_change, 0, smu)

drivers/gpu/drm/amd/pm/swsmu/smu_internal.h line 64

Quoted 1 line
drivers/gpu/drm/amd/pm/swsmu/smu_internal.h +0 -0
  #define smu_populate_umd_state_clk(smu)

smu_ppt_funcs(populate_umd_state_clk, 0, smu)

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#10 lore raw

PATCH v2 5/5 drm/amd/pm: correct the dpm features disablement for Navi1x

In reply to Evan Quan

For BACO scenario, PMFW will handle the dpm features disablement and interaction with RLC properly. Driver involvement is unnecessary and error prone.

Change-Id I19363fc08568be4b7d3f2ec6eba21ccf8fff6c37
---
 drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +2 -1
index aba475d06507..0fac45012e16 100644
@@ -1393,7 +1393,8 @@ static int smu_disable_dpms(struct smu_context *smu)
 	 * For Sienna_Cichlid, PMFW will handle the features disablement properly
 	 * on BACO in. Driver involvement is unnecessary.
 	 */
-	if ((adev->asic_type == CHIP_SIENNA_CICHLID) &&
+	if (((adev->asic_type == CHIP_SIENNA_CICHLID) ||
+	     ((adev->asic_type >= CHIP_NAVI10) && (adev->asic_type <= CHIP_NAVI12))) &&
 	     use_baco) {
 		smu_clear_cached_dpm_feature_status_with_exception(smu,
 								   SMU_FEATURE_BACO_BIT);
Signature · 6 lines
2.29.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx