drm/amdgpu: add safeguards for querying GMC CG state
Subsystems (2)
PATCH v2 1/1 drm/amdgpu: add safeguards for querying GMC CG state
We observed a GPU hang when querying GMC CG state(i.e., cat amdgpu_pm_info) on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.
Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but cg_flags are not set. Use GC IP version instead of cg_flags to determine whether GMC CG is supported or not.
v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10 -0
@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +3 -0
@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3 -0
@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3 -0
@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);
Signature · 1 line
2.25.1
Quoted 55 lines · Lang Yu
We observed a GPU hang when querying GMC CG
state(i.e., cat amdgpu_pm_info)on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but
cg_flagsare not set. Use GC IP version instead ofcg_flagsto determine whether GMC CG is supported or not.v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10
-0@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1
-0@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1161
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +3
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +
I think Christian suggested amdgpu_gmc_cg_enabled function assuming it's a common logic for all ASICs based on flags. Now that assumption has changed. Now the logic is a specific IP version doesn't enable CG which is known beforehand. So we could maintain the check in the specific IP version block itself (gmc 10 in this example). No need to call another common function which checks IP version again.
Thanks,
Lijo
Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3
-0@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);
Quoted 61 lines · Lijo
Quoted 58 lines · Lang Yu
We observed a GPU hang when querying GMC CG
state(i.e., cat amdgpu_pm_info)on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but
cg_flagsare not set. Use GC IP version instead ofcg_flagsto determine whether GMC CG is supported or not.v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10
-0@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1
-0@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ;
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1160
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+I think Christian suggested
amdgpu_gmc_cg_enabledfunction assuming it's a common logic for all ASICs based on flags. Now that assumption has changed. Now the logic is a specific IP version doesn't enable CG which is known beforehand. So we could maintain the check in the specific IP version block itself (gmc 10 in this example). No need to call another common function which checks IP version again.
Thanks. You mean just like this?
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +3 -0
@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (10 ,1 ,3 )) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))
Regards,
Lang
Quoted 30 lines
Thanks,
LijoQuoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3
-0@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);
Quoted 78 lines · Lang Yu
Quoted 61 lines · Lijo
Quoted 58 lines · Lang Yu
We observed a GPU hang when querying GMC CG
state(i.e., cat amdgpu_pm_info)on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but
cg_flagsare not set. Use GC IP version instead ofcg_flagsto determine whether GMC CG is supported or not.v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10
-0@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1
-0@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ;Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1161
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+I think Christian suggested
amdgpu_gmc_cg_enabledfunction assuming it's a common logic for all ASICs based on flags. Now that assumption has changed. Now the logic is a specific IP version doesn't enable CG which is known beforehand. So we could maintain the check in the specific IP version block itself (gmc 10 in this example). No need to call another common function which checks IP version again.Thanks. You mean just like this?
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1159
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (10 ,1 ,3 ))
*flags = 0;
Yes, add the above line also.
Thanks,
Lijo
Quoted 39 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0+return ; + adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))Regards,
LangQuoted 30 lines
Thanks,
LijoQuoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3
-0@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);
Quoted 84 lines · Lijo
Quoted 81 lines · Lang Yu
Quoted 61 lines · Lijo
Quoted 58 lines · Lang Yu
We observed a GPU hang when querying GMC CG
state(i.e., cat amdgpu_pm_info)on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but
cg_flagsare not set. Use GC IP version instead ofcg_flagsto determine whether GMC CG is supported or not.v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10
-0@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1
-0@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ;Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1161
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+I think Christian suggested
amdgpu_gmc_cg_enabledfunction assuming it's a common logic for all ASICs based on flags. Now that assumption has changed. Now the logic is a specific IP version doesn't enable CG which is known beforehand. So we could maintain the check in the specific IP version block itself (gmc 10 in this example). No need to call another common function which checks IP version again.Thanks. You mean just like this?
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1159
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+if (adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (10 ,1 ,3 ))*flags = 0;Yes, add the above line also.
It may clear CG mask of other IP block. Does it make sense? Thanks!
Regards,
Lang
Quoted 41 lines
Thanks,
LijoQuoted 39 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0+return ; + adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))Regards,
LangQuoted 30 lines
Thanks,
LijoQuoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3
-0@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);
Quoted 85 lines · Lang Yu
Quoted 84 lines · Lijo
Quoted 81 lines · Lang Yu
Quoted 61 lines · Lijo
Quoted 58 lines · Lang Yu
We observed a GPU hang when querying GMC CG
state(i.e., cat amdgpu_pm_info)on cyan skillfish. Acctually, cyan skillfish doesn't support any CG features.Only allow ASICs which support GMC CG features accessing related registers. As some ASICs support GMC CG but
cg_flagsare not set. Use GC IP version instead ofcg_flagsto determine whether GMC CG is supported or not.v2:
- Use a function to encapsulate more functionality.(Christian)
- Use IP verion to determine whether CG is supported or not.(Lijo)Signed-off-by Lang Yu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 + drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c | 3 +++ drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c | 3 +++ 5 files changed, 20 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10
-0@@ -876,3 +876,13 @@ int amdgpu_gmc_vram_checking(struct amdgpu_device *adev)return 0 ; } + +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev) +{ +switch (adev->ip_versions[GC_HWIP ][0 ]) { +case IP_VERSION (10 ,1 ,3 ): +return false; +default : +return true; + } +}drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1
-0@@ -338,4 +338,5 @@ uint64_t amdgpu_gmc_vram_mc2pa(struct amdgpu_device *adev, uint64_t mc_addr);uint64_t amdgpu_gmc_vram_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);uint64_t amdgpu_gmc_vram_cpu_pa (struct amdgpu_device *adev,struct amdgpu_bo *bo);int amdgpu_gmc_vram_checking (struct amdgpu_device *adev); +bool amdgpu_gmc_cg_enabled (struct amdgpu_device *adev);#endif drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ;Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1161
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+I think Christian suggested
amdgpu_gmc_cg_enabledfunction assuming it's a common logic for all ASICs based on flags. Now that assumption has changed. Now the logic is a specific IP version doesn't enable CG which is known beforehand. So we could maintain the check in the specific IP version block itself (gmc 10 in this example). No need to call another common function which checks IP version again.Thanks. You mean just like this?
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0@@ -1156,6 +1156,9 @@ static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle;
Quoted 7 lines
Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c static void gmc_v10_0_get_clockgating_state(void *handle, u32 *flags) · line 1159
Quoted 1 line
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +1
-0+if (adev->ip_versions[GC_HWIP ][0 ] ==IP_VERSION (10 ,1 ,3 ))*flags = 0;Yes, add the above line also.
It may clear CG mask of other IP block. Does it make sense? Thanks!
Ah! right. No need to clear the flags.
Thanks,
Lijo
Quoted 44 lines
Regards,
LangQuoted 41 lines
Thanks,
LijoQuoted 39 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +2
-0+return ; + adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))Regards,
LangQuoted 30 lines
Thanks,
LijoQuoted 27 lines
drivers/gpu/drm/amd/amdgpu/gmc_v10_0.c +0
-0adev->mmhub.funcs->get_clockgating (adev, flags);if (adev->ip_versions[ATHUB_HWIP ][0 ] >=IP_VERSION (2 ,1 ,0 ))drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c +3
-0@@ -1695,6 +1695,9 @@ static void gmc_v8_0_get_clockgating_state(void *handle, u32 *flags)struct amdgpu_device *adev = (struct amdgpu_device *)handle;int data; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; +if (amdgpu_sriov_vf (adev)) *flags =0 ;drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +3
-0@@ -1952,6 +1952,9 @@ static void gmc_v9_0_get_clockgating_state(void *handle, u32 *flags) {struct amdgpu_device *adev = (struct amdgpu_device *)handle; +if (!amdgpu_gmc_cg_enabled (adev)) +return ; + adev->mmhub.funcs->get_clockgating (adev, flags);athub_v1_0_get_clockgating (adev, flags);