Re: [PATCH] drm/amdgpu: fix radv vulkan fps drop after s3 resume

2021-08-18 Thread Mohan Marimuthu, Yogesh
[Public]

[Why]
After s3, In radv there is huge fps drop in games. This is because
when memory is allocated using radv_amdgpu_winsys_bo_create()
with both AMDGPU_GEM_DOMAIN_VRAM and AMDGPU_GEM_DOMAIN_GTT domains
set, the kernel memory management after resume fails to move the data
back to VRAM. In kernel memory management, ttm_bo_mem_compat()
function returns true and hence data is not moved back to VRAM.

[How]
Implement the idea suggested by Christian Koenig. During suspend
move the data to system RAM instead of GTT. Due to this ttm_bo_mem_compat()
will return false and data will be moved back to VRAM.

Suggested-by: Christian König mailto:christian.koe...@amd.com
Signed-off-by: Yogesh mohan marimuthu mailto:yogesh.mohanmarimu...@amd.com
Reviewed-by: Christian König mailto:christian.koe...@amd.com
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 446943e32..44ec59998 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -136,7 +136,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object 
*bo,
return;
 
case TTM_PL_VRAM:
-   if (!adev->mman.buffer_funcs_enabled) {
+   /* Move data to system memory for S3 so that while resume
+* ttm_bo_mem_compat() will return false and data will be
+* moved back to VRAM also in case of bo with both
+* AMDGPU_GEM_DOMAIN_GTT and AMDGPU_GEM_DOMAIN_VRAM domain
+* set in bo->preferred_domains.
+*/
+   if (!adev->mman.buffer_funcs_enabled || adev->in_s3) {
/* Move to system memory */
amdgpu_bo_placement_from_domain(abo, 
AMDGPU_GEM_DOMAIN_CPU);
} else if (!amdgpu_gmc_vram_full_visible(>gmc) &&
-- 
2.25.1


Re: [PATCH] drm/amdgpu: fix radv vulkan fps drop after s3 resume

2021-08-18 Thread Christian König

Am 17.08.21 um 20:26 schrieb Mohan Marimuthu, Yogesh:


[Public]


[Why]

After s3, In radv there is huge fps drop in games. This is because

when memory is allocated using radv_amdgpu_winsys_bo_create()

with both AMDGPU_GEM_DOMAIN_VRAM and AMDGPU_GEM_DOMAIN_GTT domains

set, the kernel memory management after resume fails to move the data

back to VRAM. In kernel memory management, ttm_bo_mem_compat()

function returns true and hence data is not moved back to VRAM.

[How]

Implement the idea suggested by Christian Koenig. During suspend

move the data to system RAM instead of GTT. Due to this 
ttm_bo_mem_compat()


will return false and data will be moved back to VRAM.

Signed-off-by: Christian König christian.koe...@amd.com 





Suggested-by: would be better here since I wasn't involved in the coding.

Signed-off-by: Yogesh mohan marimuthu yogesh.mohanmarimu...@amd.com 





Reviewed-by: Christian König 


---

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +++-

1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c


index 446943e32..44ec59998 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

@@ -136,7 +136,13 @@ static void amdgpu_evict_flags(struct 
ttm_buffer_object *bo,


    return;

   case TTM_PL_VRAM:

-    if (!adev->mman.buffer_funcs_enabled) {

+   /* Move data to system memory for S3 so 
that while resume


+   * ttm_bo_mem_compat() will return false 
and data will be


+   * moved back to VRAM also in case of bo 
with both


+   * AMDGPU_GEM_DOMAIN_GTT and 
AMDGPU_GEM_DOMAIN_VRAM domain


+   * set in bo->preferred_domains.

+   */

+   if (!adev->mman.buffer_funcs_enabled || 
adev->in_s3) {


/* Move to system memory */

amdgpu_bo_placement_from_domain(abo, AMDGPU_GEM_DOMAIN_CPU);

    } else if 
(!amdgpu_gmc_vram_full_visible(>gmc) &&


--

2.25.1





[PATCH] drm/amdgpu: fix radv vulkan fps drop after s3 resume

2021-08-17 Thread Mohan Marimuthu, Yogesh
[Public]

[Why]
After s3, In radv there is huge fps drop in games. This is because
when memory is allocated using radv_amdgpu_winsys_bo_create()
with both AMDGPU_GEM_DOMAIN_VRAM and AMDGPU_GEM_DOMAIN_GTT domains
set, the kernel memory management after resume fails to move the data
back to VRAM. In kernel memory management, ttm_bo_mem_compat()
function returns true and hence data is not moved back to VRAM.

[How]
Implement the idea suggested by Christian Koenig. During suspend
move the data to system RAM instead of GTT. Due to this ttm_bo_mem_compat()
will return false and data will be moved back to VRAM.

Signed-off-by: Christian König 
christian.koe...@amd.com
Signed-off-by: Yogesh mohan marimuthu 
yogesh.mohanmarimu...@amd.com
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 +++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 446943e32..44ec59998 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -136,7 +136,13 @@ static void amdgpu_evict_flags(struct ttm_buffer_object 
*bo,
return;
   case TTM_PL_VRAM:
-if (!adev->mman.buffer_funcs_enabled) {
+   /* Move data to system memory for S3 so that while 
resume
+   * ttm_bo_mem_compat() will return false and data 
will be
+   * moved back to VRAM also in case of bo with both
+   * AMDGPU_GEM_DOMAIN_GTT and AMDGPU_GEM_DOMAIN_VRAM 
domain
+   * set in bo->preferred_domains.
+   */
+   if (!adev->mman.buffer_funcs_enabled || 
adev->in_s3) {
   /* Move to system memory */
   amdgpu_bo_placement_from_domain(abo, 
AMDGPU_GEM_DOMAIN_CPU);
} else if 
(!amdgpu_gmc_vram_full_visible(>gmc) &&
--
2.25.1