<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Instead of checking the global parameters everywhere, let's check the runtime pm parameter and then set a local adev variable per device. That way we can have a mix of devices that support different runtime pm modes in the same system and everything works.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Alex</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> amd-gfx <amd-gfx-bounces@lists.freedesktop.org> on behalf of Likun Gao <likun.gao@amd.com><br>
<b>Sent:</b> Friday, December 11, 2020 4:04 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Gao, Likun <Likun.Gao@amd.com>; Feng, Kenneth <Kenneth.Feng@amd.com>; Zhang, Hawking <Hawking.Zhang@amd.com><br>
<b>Subject:</b> [PATCH] drm/amdgpu: skip vram operation for BAMACO runtime</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">From: Likun Gao <Likun.Gao@amd.com><br>
<br>
Skip vram related operation for bamaco rumtime suspend and resume as<br>
vram is alive when BAMACO.<br>
It can save about 32ms when suspend and about 15ms when resume.<br>
<br>
Signed-off-by: Likun Gao <Likun.Gao@amd.com><br>
Change-Id: I6ad39765de5ed1aac2dc51e96ed7a21a727272cd<br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++-<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 72 +++++++++++++---------<br>
2 files changed, 50 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index 0ec7c28c4d5a..66b790dfb151 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -2464,7 +2464,8 @@ static int amdgpu_device_ip_late_init(struct amdgpu_device *adev)<br>
amdgpu_device_set_cg_state(adev, AMD_CG_STATE_GATE);<br>
amdgpu_device_set_pg_state(adev, AMD_PG_STATE_GATE);<br>
<br>
- amdgpu_device_fill_reset_magic(adev);<br>
+ if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)<br>
+ amdgpu_device_fill_reset_magic(adev);<br>
<br>
r = amdgpu_device_enable_mgpu_fan_boost();<br>
if (r)<br>
@@ -3706,7 +3707,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)<br>
amdgpu_amdkfd_suspend(adev, !fbcon);<br>
<br>
/* evict vram memory */<br>
- amdgpu_bo_evict_vram(adev);<br>
+ if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)<br>
+ amdgpu_bo_evict_vram(adev);<br>
<br>
amdgpu_fence_driver_suspend(adev);<br>
<br>
@@ -3718,7 +3720,8 @@ int amdgpu_device_suspend(struct drm_device *dev, bool fbcon)<br>
* This second call to evict vram is to evict the gart page table<br>
* using the CPU.<br>
*/<br>
- amdgpu_bo_evict_vram(adev);<br>
+ if ((amdgpu_runtime_pm != 2) || !adev->in_runpm)<br>
+ amdgpu_bo_evict_vram(adev);<br>
<br>
return 0;<br>
}<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
index 523d22db094b..67e74b43a1ab 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c<br>
@@ -397,10 +397,12 @@ static int psp_tmr_init(struct psp_context *psp)<br>
}<br>
}<br>
<br>
- pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;<br>
- ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm) {<br>
+ pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;<br>
+ ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,<br>
AMDGPU_GEM_DOMAIN_VRAM,<br>
&psp->tmr_bo, &psp->tmr_mc_addr, pptr);<br>
+ }<br>
<br>
return ret;<br>
}<br>
@@ -504,8 +506,10 @@ static int psp_tmr_terminate(struct psp_context *psp)<br>
return ret;<br>
<br>
/* free TMR memory buffer */<br>
- pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;<br>
- amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr);<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm) {<br>
+ pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;<br>
+ amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr);<br>
+ }<br>
<br>
return 0;<br>
}<br>
@@ -795,9 +799,10 @@ int psp_xgmi_terminate(struct psp_context *psp)<br>
psp->xgmi_context.initialized = 0;<br>
<br>
/* free xgmi shared memory */<br>
- amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,<br>
- &psp->xgmi_context.xgmi_shared_mc_addr,<br>
- &psp->xgmi_context.xgmi_shared_buf);<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)<br>
+ amdgpu_bo_free_kernel(&psp->xgmi_context.xgmi_shared_bo,<br>
+ &psp->xgmi_context.xgmi_shared_mc_addr,<br>
+ &psp->xgmi_context.xgmi_shared_buf);<br>
<br>
return 0;<br>
}<br>
@@ -812,7 +817,8 @@ int psp_xgmi_initialize(struct psp_context *psp)<br>
!psp->adev->psp.ta_xgmi_start_addr)<br>
return -ENOENT;<br>
<br>
- if (!psp->xgmi_context.initialized) {<br>
+ if (!psp->xgmi_context.initialized &&<br>
+ ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {<br>
ret = psp_xgmi_init_shared_buf(psp);<br>
if (ret)<br>
return ret;<br>
@@ -1122,9 +1128,10 @@ static int psp_ras_terminate(struct psp_context *psp)<br>
psp->ras.ras_initialized = false;<br>
<br>
/* free ras shared memory */<br>
- amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,<br>
- &psp->ras.ras_shared_mc_addr,<br>
- &psp->ras.ras_shared_buf);<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)<br>
+ amdgpu_bo_free_kernel(&psp->ras.ras_shared_bo,<br>
+ &psp->ras.ras_shared_mc_addr,<br>
+ &psp->ras.ras_shared_buf);<br>
<br>
return 0;<br>
}<br>
@@ -1145,7 +1152,8 @@ static int psp_ras_initialize(struct psp_context *psp)<br>
return 0;<br>
}<br>
<br>
- if (!psp->ras.ras_initialized) {<br>
+ if (!psp->ras.ras_initialized &&<br>
+ ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {<br>
ret = psp_ras_init_shared_buf(psp);<br>
if (ret)<br>
return ret;<br>
@@ -1257,7 +1265,8 @@ static int psp_hdcp_initialize(struct psp_context *psp)<br>
return 0;<br>
}<br>
<br>
- if (!psp->hdcp_context.hdcp_initialized) {<br>
+ if (!psp->hdcp_context.hdcp_initialized &&<br>
+ ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {<br>
ret = psp_hdcp_init_shared_buf(psp);<br>
if (ret)<br>
return ret;<br>
@@ -1325,9 +1334,10 @@ static int psp_hdcp_terminate(struct psp_context *psp)<br>
psp->hdcp_context.hdcp_initialized = false;<br>
<br>
/* free hdcp shared memory */<br>
- amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,<br>
- &psp->hdcp_context.hdcp_shared_mc_addr,<br>
- &psp->hdcp_context.hdcp_shared_buf);<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)<br>
+ amdgpu_bo_free_kernel(&psp->hdcp_context.hdcp_shared_bo,<br>
+ &psp->hdcp_context.hdcp_shared_mc_addr,<br>
+ &psp->hdcp_context.hdcp_shared_buf);<br>
<br>
return 0;<br>
}<br>
@@ -1404,7 +1414,8 @@ static int psp_dtm_initialize(struct psp_context *psp)<br>
return 0;<br>
}<br>
<br>
- if (!psp->dtm_context.dtm_initialized) {<br>
+ if (!psp->dtm_context.dtm_initialized &&<br>
+ ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {<br>
ret = psp_dtm_init_shared_buf(psp);<br>
if (ret)<br>
return ret;<br>
@@ -1472,9 +1483,10 @@ static int psp_dtm_terminate(struct psp_context *psp)<br>
psp->dtm_context.dtm_initialized = false;<br>
<br>
/* free hdcp shared memory */<br>
- amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,<br>
- &psp->dtm_context.dtm_shared_mc_addr,<br>
- &psp->dtm_context.dtm_shared_buf);<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)<br>
+ amdgpu_bo_free_kernel(&psp->dtm_context.dtm_shared_bo,<br>
+ &psp->dtm_context.dtm_shared_mc_addr,<br>
+ &psp->dtm_context.dtm_shared_buf);<br>
<br>
return 0;<br>
}<br>
@@ -1563,7 +1575,8 @@ static int psp_rap_initialize(struct psp_context *psp)<br>
return 0;<br>
}<br>
<br>
- if (!psp->rap_context.rap_initialized) {<br>
+ if (!psp->rap_context.rap_initialized &&<br>
+ ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm)) {<br>
ret = psp_rap_init_shared_buf(psp);<br>
if (ret)<br>
return ret;<br>
@@ -1602,9 +1615,10 @@ static int psp_rap_terminate(struct psp_context *psp)<br>
psp->rap_context.rap_initialized = false;<br>
<br>
/* free rap shared memory */<br>
- amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,<br>
- &psp->rap_context.rap_shared_mc_addr,<br>
- &psp->rap_context.rap_shared_buf);<br>
+ if ((amdgpu_runtime_pm !=2) || !psp->adev->in_runpm)<br>
+ amdgpu_bo_free_kernel(&psp->rap_context.rap_shared_bo,<br>
+ &psp->rap_context.rap_shared_mc_addr,<br>
+ &psp->rap_context.rap_shared_buf);<br>
<br>
return ret;<br>
}<br>
@@ -2261,10 +2275,12 @@ static int psp_resume(void *handle)<br>
<br>
DRM_INFO("PSP is resuming...\n");<br>
<br>
- ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);<br>
- if (ret) {<br>
- DRM_ERROR("Failed to process memory training!\n");<br>
- return ret;<br>
+ if ((amdgpu_runtime_pm != 2) || !psp->adev->in_runpm) {<br>
+ ret = psp_mem_training(psp, PSP_MEM_TRAIN_RESUME);<br>
+ if (ret) {<br>
+ DRM_ERROR("Failed to process memory training!\n");<br>
+ return ret;<br>
+ }<br>
}<br>
<br>
mutex_lock(&adev->firmware.mutex);<br>
-- <br>
2.25.1<br>
<br>
_______________________________________________<br>
amd-gfx mailing list<br>
amd-gfx@lists.freedesktop.org<br>
<a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Calexander.deucher%40amd.com%7C0bee5882ad6142eb967c08d89db4018b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637432743751698480%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1AU6gN6Yqp8yZT%2BHDWfAwFh9UuWh7XoJg2kD%2F%2BbwZjA%3D&reserved=0">https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Calexander.deucher%40amd.com%7C0bee5882ad6142eb967c08d89db4018b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637432743751698480%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1AU6gN6Yqp8yZT%2BHDWfAwFh9UuWh7XoJg2kD%2F%2BbwZjA%3D&reserved=0</a><br>
</div>
</span></font></div>
</div>
</body>
</html>