Skip to contentSkip to conversation

drm/amdgpu: skip vram operation for BAMACO runtime

PATCH In review Likun Gao 4 participants 4 messages Dec 14, 2020 – Dec 17, 2020

Subsystems (3)
lore
Share & tools
lore

Likun Gao

author
#0 lore raw

PATCH v2 1/1 drm/amdgpu: skip vram operation for BAMACO runtime

From: Likun Gao <[email protected]>

Skip vram related operation for bamaco rumtime suspend and resume as vram is alive when BAMACO.
It can save about 32ms when suspend and about 15ms when resume.

v2: add local adev variable for maco enablement which checked by device MACO support cap and runtime method parameter to have a mix of devices that support different runtime pm modes.

Change-Id I99cbaf720bfeecdc6682057b238d29c4e41cf155
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  9 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 72 +++++++++++--------
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  7 +-
 4 files changed, 56 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index eed5410947e9..288c41e0b61f 100644
@@ -1027,6 +1027,7 @@ struct amdgpu_device {
 	/* enable runtime pm on the device */
 	bool                            runpm;
 	bool                            in_runpm;
+	bool				runpm_maco_en;
 
 	bool                            pm_sysfs_en;
 	bool                            ucode_sysfs_en;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
index 0ec7c28c4d5a..0c608b903ec3 100644
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
 	amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
 	amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-	amdgpu_device_fill_reset_magic(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_device_fill_reset_magic(adev);
 
 	r = amdgpu_device_enable_mgpu_fan_boost();
 	if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	amdgpu_amdkfd_suspend(adev, !fbcon);
 
 	/* evict vram memory */
-	amdgpu_bo_evict_vram(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_bo_evict_vram(adev);
 
 	amdgpu_fence_driver_suspend(adev);
 
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	 * This second call to evict vram is to evict the gart page table
 	 * using the CPU.
 	 */
-	amdgpu_bo_evict_vram(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_bo_evict_vram(adev);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +44 -28

152 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +5 -2
index db0f2a476c23..fc8db9d69817 100644
@@ -302,9 +302,12 @@ static int sienna_cichlid_check_powerplay_table(struct smu_context *smu)
 		table_context->power_play_table;
 	struct smu_baco_context *smu_baco = &smu->smu_baco;
 
-	if (powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_BACO ||
-	    powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_MACO)
+	if (powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_BACO) {
 		smu_baco->platform_support = true;
+		if ((powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_MACO) &&
+		    (amdgpu_runtime_pm == 2))
+			smu->adev->runpm_maco_en = true;
+	}
 
 	table_context->thermal_controller_type =
 		powerplay_table->thermal_controller_type;
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer Reviewed-by on v2 1/1
#1 lore raw

[AMD Official Use Only - Internal Distribution Only]

Best Regards
Kenneth

-----Original Message-----
From: Gao, Likun <[email protected]>
Sent: Monday, December 14, 2020 3:38 PM
To: [email protected]
Cc: Zhang, Hawking <[email protected]>; Deucher, Alexander <[email protected]>; Feng, Kenneth <[email protected]>; Gao, Likun <[email protected]>
Subject: [v2] drm/amdgpu: skip vram operation for BAMACO runtime

From: Likun Gao <[email protected]>

Skip vram related operation for bamaco rumtime suspend and resume as vram is alive when BAMACO. It can save about 32ms when suspend and about 15ms when resume.

v2: add local adev variable for maco enablement which checked by device MACO support cap and runtime method parameter to have a mix of devices that support different runtime pm modes.

Change-Id I99cbaf720bfeecdc6682057b238d29c4e41cf155
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  9 ++-
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 72 +++++++++++--------
 .../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  7 +-
 4 files changed, 56 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index eed5410947e9..288c41e0b61f 100644
@@ -1027,6 +1027,7 @@ struct amdgpu_device {
 	/* enable runtime pm on the device */
 	bool                            runpm;
 	bool                            in_runpm;
+	bool				runpm_maco_en;
 
 	bool                            pm_sysfs_en;
 	bool                            ucode_sysfs_en;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
index 0ec7c28c4d5a..0c608b903ec3 100644
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)
 	amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
 	amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-	amdgpu_device_fill_reset_magic(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_device_fill_reset_magic(adev);
 
 	r = amdgpu_device_enable_mgpu_fan_boost();
 	if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	amdgpu_amdkfd_suspend(adev, !fbcon);
 
 	/* evict vram memory */
-	amdgpu_bo_evict_vram(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_bo_evict_vram(adev);
 
 	amdgpu_fence_driver_suspend(adev);
 
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)
 	 * This second call to evict vram is to evict the gart page table
 	 * using the CPU.
 	 */
-	amdgpu_bo_evict_vram(adev);
+	if (!adev->runpm_maco_en || !adev->in_runpm)
+		amdgpu_bo_evict_vram(adev);
 
 	return 0;
 }
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +44 -28

152 lines not on this page · raw message

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +6 -2
index db0f2a476c23..fc8db9d69817 100644
@@ -302,9 +302,12 @@ static int sienna_cichlid_check_powerplay_table(struct smu_context *smu)
 		table_context->power_play_table;
 	struct smu_baco_context *smu_baco = &smu->smu_baco;
 
-	if (powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_BACO ||
-	    powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_MACO)
+	if (powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_BACO) 
+{
 		smu_baco->platform_support = true;
+		if ((powerplay_table->platform_caps & SMU_11_0_7_PP_PLATFORM_CAP_MACO) &&
+		    (amdgpu_runtime_pm == 2))
+			smu->adev->runpm_maco_en = true;
+	}
 
 	table_context->thermal_controller_type =

powerplay_table->thermal_controller_type;
--
2.25.1
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
In reply to Likun Gao

[AMD Public Use]

Quoted 37 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Likun Gao
Sent: Monday, December 14, 2020 1:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Gao, Likun <[email protected]>; Feng, Kenneth <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [v2] drm/amdgpu: skip vram operation for BAMACO runtime

[CAUTION: External Email]

From: Likun Gao <[email protected]>

Skip vram related operation for bamaco rumtime suspend and resume as vram is alive when BAMACO.
It can save about 32ms when suspend and about 15ms when resume.

v2: add local adev variable for maco enablement which checked by device MACO support cap and runtime method parameter to have a mix of devices that support different runtime pm modes.

Change-Id I99cbaf720bfeecdc6682057b238d29c4e41cf155

---

drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  9 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 72 +++++++++++--------
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  7 +-
4 files changed, 56 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index eed5410947e9..288c41e0b61f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1033

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1027,6 +1027,7 @@ struct amdgpu_device {
       /* enable runtime pm on the device */
       bool                            runpm;
       bool                            in_runpm;
+       bool                            runpm_maco_en;
 
       bool                            pm_sysfs_en;
       bool                            ucode_sysfs_en;

Isn't it better to move pm related variables to amdgpu_pm (at least going forward) instead of keeping too many in adev?

Quoted 237 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
index 0ec7c28c4d5a..0c608b903ec3 100644
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct
 amdgpu_device *adev)
       amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
       amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-       amdgpu_device_fill_reset_magic(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_device_fill_reset_magic(adev);
       r = amdgpu_device_enable_mgpu_fan_boost();
       if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
       amdgpu_amdkfd_suspend(adev, !fbcon);
 
       /* evict vram memory */
-       amdgpu_bo_evict_vram(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_bo_evict_vram(adev);
 
       amdgpu_fence_driver_suspend(adev);
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
        * This second call to evict vram is to evict the gart page table
        * using the CPU.
        */
-       amdgpu_bo_evict_vram(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_bo_evict_vram(adev);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -2
index 523d22db094b..a198bc5d6a68 100644
@@ -397,10 +397,12 @@ static int psp_tmr_init(struct psp_context *psp)
               }
       }
 
-       pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
-       ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
+               ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
+ PSP_TMR_SIZE,
                                     AMDGPU_GEM_DOMAIN_VRAM,
                                     &psp->tmr_bo, &psp->tmr_mc_addr, pptr);
+       }
 
       return ret;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -2
@@ -504,8 +506,10 @@ static int psp_tmr_terminate(struct psp_context
 *psp)
               return ret;
 
       /* free TMR memory buffer */
-       pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
-       amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
+               amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr,
 pptr);
+       }
 
       return 0;
}
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -7
@@ -795,9 +799,10 @@ int psp_xgmi_terminate(struct psp_context *psp)
       psp->xgmi_context.initialized = 0;
 
       /* free xgmi shared memory */
-       amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,
-                       &psp->xgmi_context.xgmi_shared_mc_addr,
-                       &psp->xgmi_context.xgmi_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,
+                               &psp->xgmi_context.xgmi_shared_mc_addr,
+                               &psp->xgmi_context.xgmi_shared_buf);
 
       return 0;
 }
@@ -812,7 +817,8 @@ int psp_xgmi_initialize(struct psp_context *psp)
           !psp->adev->psp.ta_xgmi_start_addr)
               return -ENOENT;
 
-       if (!psp->xgmi_context.initialized) {
+       if (!psp->xgmi_context.initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_xgmi_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1122,9 +1128,10 @@ static int psp_ras_terminate(struct psp_context
 *psp)
       psp->ras.ras_initialized = false;
 
       /* free ras shared memory */
-       amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,
-                       &psp->ras.ras_shared_mc_addr,
-                       &psp->ras.ras_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,
+                               &psp->ras.ras_shared_mc_addr,
+                               &psp->ras.ras_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -2
@@ -1145,7 +1152,8 @@ static int psp_ras_initialize(struct psp_context *psp)
               return 0;
       }
 
-       if (!psp->ras.ras_initialized) {
+       if (!psp->ras.ras_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_ras_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1257,7 +1265,8 @@ static int psp_hdcp_initialize(struct psp_context
 *psp)
               return 0;
       }
 
-       if (!psp->hdcp_context.hdcp_initialized) {
+       if (!psp->hdcp_context.hdcp_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_hdcp_init_shared_buf(psp);
               if (ret)
                       return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -3
@@ -1325,9 +1334,10 @@ static int psp_hdcp_terminate(struct psp_context
 *psp)
       psp->hdcp_context.hdcp_initialized = false;
 
       /* free hdcp shared memory */
-       amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,
-                             &psp->hdcp_context.hdcp_shared_mc_addr,
-                             &psp->hdcp_context.hdcp_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,
+                                     &psp->hdcp_context.hdcp_shared_mc_addr,
+
+ &psp->hdcp_context.hdcp_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
@@ -1404,7 +1414,8 @@ static int psp_dtm_initialize(struct psp_context
 *psp)
               return 0;
       }
 
-       if (!psp->dtm_context.dtm_initialized) {
+       if (!psp->dtm_context.dtm_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_dtm_init_shared_buf(psp);
               if (ret)
                       return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -3
@@ -1472,9 +1483,10 @@ static int psp_dtm_terminate(struct psp_context
 *psp)
       psp->dtm_context.dtm_initialized = false;
 
       /* free hdcp shared memory */
-       amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,
-                             &psp->dtm_context.dtm_shared_mc_addr,
-                             &psp->dtm_context.dtm_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,
+                                     &psp->dtm_context.dtm_shared_mc_addr,
+                                     &psp->dtm_context.dtm_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -4
@@ -1563,7 +1575,8 @@ static int psp_rap_initialize(struct psp_context *psp)
               return 0;
       }
 
-       if (!psp->rap_context.rap_initialized) {
+       if (!psp->rap_context.rap_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_rap_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1602,9 +1615,10 @@ static int psp_rap_terminate(struct psp_context
 *psp)
       psp->rap_context.rap_initialized = false;
 
       /* free rap shared memory */
-       amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,
-                             &psp->rap_context.rap_shared_mc_addr,
-                             &psp->rap_context.rap_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,
+                                     &psp->rap_context.rap_shared_mc_addr,
+                                     &psp->rap_context.rap_shared_buf);
 
       return ret;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -4
@@ -2261,10 +2275,12 @@ static int psp_resume(void *handle)
 
       DRM_INFO("PSP is resuming...\n");
 
-       ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
-       if (ret) {
-               DRM_ERROR("Failed to process memory training!\n");
-               return ret;
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
+               if (ret) {
+                       DRM_ERROR("Failed to process memory training!\n");
+                       return ret;
+               }
       }
 
       mutex_lock(&adev->firmware.mutex);
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -1
index db0f2a476c23..fc8db9d69817 100644
@@ -302,9 +302,12 @@ static int
 sienna_cichlid_check_powerplay_table(struct smu_context *smu)
               table_context->power_play_table;
       struct smu_baco_context *smu_baco = &smu->smu_baco;
 
-       if (powerplay_table->platform_caps &

SMU_11_0_7_PP_PLATFORM_CAP_BACO ||
- powerplay_table->platform_caps &
SMU_11_0_7_PP_PLATFORM_CAP_MACO)

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +3 -0
+       if (powerplay_table->platform_caps &
+ SMU_11_0_7_PP_PLATFORM_CAP_BACO) {
               smu_baco->platform_support = true;
+               if ((powerplay_table->platform_caps &

SMU_11_0_7_PP_PLATFORM_CAP_MACO) &&

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_check_powerplay_table(struct smu_context *smu) · line 310

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +3 -0
+                   (amdgpu_runtime_pm == 2))
+                       smu->adev->runpm_maco_en = true;
+       }

Consider BOCO path also in runtime suspend flow. Also, variable may be named more generic like mem_alive (or similar) for any other suspend/resume that could retain vram - S0ix.

Thanks,
Lijo

Quoted 5 lines
       table_context->thermal_controller_type =
               powerplay_table->thermal_controller_type;

--
2.25.1

Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.f
reedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C5d3ad5208b1e412a016 808d8a0034a97%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63743 5283286148631%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJ QIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=VmVF w6%2FGsbwRUzXHG26DUut7y8MceVib6M7t84mM7YQ%3D&amp;reserved=0

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

#3 lore raw
Quoted 24 lines · Lijo

[AMD Public Use]

Quoted 21 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Likun Gao
Sent: Monday, December 14, 2020 1:08 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Gao, Likun <[email protected]>; Feng, Kenneth <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [v2] drm/amdgpu: skip vram operation for BAMACO runtime

[CAUTION: External Email]

From: Likun Gao <[email protected]>

Skip vram related operation for bamaco rumtime suspend and resume as vram is alive when BAMACO.
It can save about 32ms when suspend and about 15ms when resume.

v2: add local adev variable for maco enablement which checked by device MACO support cap and runtime method parameter to have a mix of devices that support different runtime pm modes.

Something else just occurred to me, we need to handle DPM_FLAG_NO_DIRECT_COMPLETE properly with the *MA* variants. We need to make sure set that flag if there are any cases where we will lose the contents of memory and not have it backed up.

Alex

Quoted 287 lines
Quoted 16 lines
Change-Id I99cbaf720bfeecdc6682057b238d29c4e41cf155

---

drivers/gpu/drm/amd/amdgpu/amdgpu.h           |  1 +
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c    |  9 ++-
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       | 72 +++++++++++--------
.../amd/pm/swsmu/smu11/sienna_cichlid_ppt.c   |  7 +-
4 files changed, 56 insertions(+), 33 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
index eed5410947e9..288c41e0b61f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu.h struct amdgpu_device { · line 1033

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
@@ -1027,6 +1027,7 @@ struct amdgpu_device {
       /* enable runtime pm on the device */
       bool                            runpm;
       bool                            in_runpm;
+       bool                            runpm_maco_en;
 
       bool                            pm_sysfs_en;
       bool                            ucode_sysfs_en;

Isn't it better to move pm related variables to amdgpu_pm (at least going forward) instead of keeping too many in adev?

Quoted 237 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
index 0ec7c28c4d5a..0c608b903ec3 100644
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct
 amdgpu_device *adev)
       amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);
       amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);
 
-       amdgpu_device_fill_reset_magic(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_device_fill_reset_magic(adev);
       r = amdgpu_device_enable_mgpu_fan_boost();
       if (r)
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
       amdgpu_amdkfd_suspend(adev, !fbcon);
 
       /* evict vram memory */
-       amdgpu_bo_evict_vram(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_bo_evict_vram(adev);
 
       amdgpu_fence_driver_suspend(adev);
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device
 *dev, bool fbcon)
        * This second call to evict vram is to evict the gart page table
        * using the CPU.
        */
-       amdgpu_bo_evict_vram(adev);
+       if (!adev->runpm_maco_en || !adev->in_runpm)
+               amdgpu_bo_evict_vram(adev);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -2
index 523d22db094b..a198bc5d6a68 100644
@@ -397,10 +397,12 @@ static int psp_tmr_init(struct psp_context *psp)
               }
       }
 
-       pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
-       ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
+               ret = amdgpu_bo_create_kernel(psp->adev, tmr_size,
+ PSP_TMR_SIZE,
                                     AMDGPU_GEM_DOMAIN_VRAM,
                                     &psp->tmr_bo, &psp->tmr_mc_addr, pptr);
+       }
 
       return ret;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -2
@@ -504,8 +506,10 @@ static int psp_tmr_terminate(struct psp_context
 *psp)
               return ret;
 
       /* free TMR memory buffer */
-       pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
-       amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
+               amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr,
 pptr);
+       }
 
       return 0;
}
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -7
@@ -795,9 +799,10 @@ int psp_xgmi_terminate(struct psp_context *psp)
       psp->xgmi_context.initialized = 0;
 
       /* free xgmi shared memory */
-       amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,
-                       &psp->xgmi_context.xgmi_shared_mc_addr,
-                       &psp->xgmi_context.xgmi_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,
+                               &psp->xgmi_context.xgmi_shared_mc_addr,
+                               &psp->xgmi_context.xgmi_shared_buf);
 
       return 0;
 }
@@ -812,7 +817,8 @@ int psp_xgmi_initialize(struct psp_context *psp)
           !psp->adev->psp.ta_xgmi_start_addr)
               return -ENOENT;
 
-       if (!psp->xgmi_context.initialized) {
+       if (!psp->xgmi_context.initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_xgmi_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1122,9 +1128,10 @@ static int psp_ras_terminate(struct psp_context
 *psp)
       psp->ras.ras_initialized = false;
 
       /* free ras shared memory */
-       amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,
-                       &psp->ras.ras_shared_mc_addr,
-                       &psp->ras.ras_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,
+                               &psp->ras.ras_shared_mc_addr,
+                               &psp->ras.ras_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -2
@@ -1145,7 +1152,8 @@ static int psp_ras_initialize(struct psp_context *psp)
               return 0;
       }
 
-       if (!psp->ras.ras_initialized) {
+       if (!psp->ras.ras_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_ras_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1257,7 +1265,8 @@ static int psp_hdcp_initialize(struct psp_context
 *psp)
               return 0;
       }
 
-       if (!psp->hdcp_context.hdcp_initialized) {
+       if (!psp->hdcp_context.hdcp_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_hdcp_init_shared_buf(psp);
               if (ret)
                       return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +5 -3
@@ -1325,9 +1334,10 @@ static int psp_hdcp_terminate(struct psp_context
 *psp)
       psp->hdcp_context.hdcp_initialized = false;
 
       /* free hdcp shared memory */
-       amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,
-                             &psp->hdcp_context.hdcp_shared_mc_addr,
-                             &psp->hdcp_context.hdcp_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,
+                                     &psp->hdcp_context.hdcp_shared_mc_addr,
+
+ &psp->hdcp_context.hdcp_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -1
@@ -1404,7 +1414,8 @@ static int psp_dtm_initialize(struct psp_context
 *psp)
               return 0;
       }
 
-       if (!psp->dtm_context.dtm_initialized) {
+       if (!psp->dtm_context.dtm_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_dtm_init_shared_buf(psp);
               if (ret)
                       return ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +4 -3
@@ -1472,9 +1483,10 @@ static int psp_dtm_terminate(struct psp_context
 *psp)
       psp->dtm_context.dtm_initialized = false;
 
       /* free hdcp shared memory */
-       amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,
-                             &psp->dtm_context.dtm_shared_mc_addr,
-                             &psp->dtm_context.dtm_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,
+                                     &psp->dtm_context.dtm_shared_mc_addr,
+                                     &psp->dtm_context.dtm_shared_buf);
 
       return 0;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -4
@@ -1563,7 +1575,8 @@ static int psp_rap_initialize(struct psp_context *psp)
               return 0;
       }
 
-       if (!psp->rap_context.rap_initialized) {
+       if (!psp->rap_context.rap_initialized &&
+           (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)) {
               ret = psp_rap_init_shared_buf(psp);
               if (ret)
                       return ret;
@@ -1602,9 +1615,10 @@ static int psp_rap_terminate(struct psp_context
 *psp)
       psp->rap_context.rap_initialized = false;
 
       /* free rap shared memory */
-       amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,
-                             &psp->rap_context.rap_shared_mc_addr,
-                             &psp->rap_context.rap_shared_buf);
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm)
+               amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,
+                                     &psp->rap_context.rap_shared_mc_addr,
+                                     &psp->rap_context.rap_shared_buf);
 
       return ret;

}

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -4
@@ -2261,10 +2275,12 @@ static int psp_resume(void *handle)
 
       DRM_INFO("PSP is resuming...\n");
 
-       ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
-       if (ret) {
-               DRM_ERROR("Failed to process memory training!\n");
-               return ret;
+       if (!psp->adev->runpm_maco_en || !psp->adev->in_runpm) {
+               ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);
+               if (ret) {
+                       DRM_ERROR("Failed to process memory training!\n");
+                       return ret;
+               }
       }
 
       mutex_lock(&adev->firmware.mutex);
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +0 -1
index db0f2a476c23..fc8db9d69817 100644
@@ -302,9 +302,12 @@ static int
 sienna_cichlid_check_powerplay_table(struct smu_context *smu)
               table_context->power_play_table;
       struct smu_baco_context *smu_baco = &smu->smu_baco;
 
-       if (powerplay_table->platform_caps &

SMU_11_0_7_PP_PLATFORM_CAP_BACO ||
- powerplay_table->platform_caps &
SMU_11_0_7_PP_PLATFORM_CAP_MACO)

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +3 -0
+       if (powerplay_table->platform_caps &
+ SMU_11_0_7_PP_PLATFORM_CAP_BACO) {
               smu_baco->platform_support = true;
+               if ((powerplay_table->platform_caps &

SMU_11_0_7_PP_PLATFORM_CAP_MACO) &&

drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c static int sienna_cichlid_check_powerplay_table(struct smu_context *smu) · line 310

Quoted 3 lines
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c +3 -0
+                   (amdgpu_runtime_pm == 2))
+                       smu->adev->runpm_maco_en = true;
+       }

Consider BOCO path also in runtime suspend flow. Also, variable may be named more generic like mem_alive (or similar) for any other suspend/resume that could retain vram - S0ix.

Thanks,
Lijo

Quoted 5 lines
       table_context->thermal_controller_type =
               powerplay_table->thermal_controller_type;

--
2.25.1

Quoted 10 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.f
reedesktop.org%2Fmailman%2Flistinfo%2Famd- gfx&amp;data=04%7C01%7Clijo.lazar%40amd.com%7C5d3ad5208b1e412a016 808d8a0034a97%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63743 5283286148631%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJ QIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=VmVF w6%2FGsbwRUzXHG26DUut7y8MceVib6M7t84mM7YQ%3D&amp;reserved=0

Quoted 4 lines

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

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