drm/amdkfd: Correct the GFX12 memory type setting
Subsystems (2)
PATCH 1/1 drm/amdkfd: Correct the GFX12 memory type setting
This patch fixes the GFX12 memory type to NC. Since the Memory type can be overwritten by the previous operations, the GFX12 MTYPE bits need to be clear before setting to NC.
--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2 -1
@@ -534,7 +534,8 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,/* WA for HW bug */ if (is_system || ((bo_adev != adev) && coherent)) - *flags |=AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); + *flags |= (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK ) | +AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); }
Signature · 1 line
2.25.1
Quoted 17 lines · Shane Xiao
This patch fixes the GFX12 memory type to NC. Since the Memory type can be overwritten by the previous operations, the GFX12 MTYPE bits need to be clear before setting to NC.
Signed-off-by longlyao <[email protected]>Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev, · line 538
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2
-1@@ -534,7 +534,8 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,/* WA for HW bug */ if (is_system || ((bo_adev != adev) && coherent)) - *flags |=AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); + *flags |= (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK ) | +AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC );
Maybe we should make the AMDGPU_PTE_MTYPE_GFX12() macro clear the current field before setting the new one? That would align with the similar register field macros.
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-1} --2.25.1
Quoted 20 lines · Alex Deucher
Quoted 18 lines · Shane Xiao
This patch fixes the GFX12 memory type to NC. Since the Memory type can be overwritten by the previous operations, the GFX12 MTYPE bits need to be clear before setting to NC.
Signed-off-by longlyao <[email protected]>Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-0@@ -534,7 +534,8 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev, · line 538
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2
-1/* WA for HW bug */ if (is_system || ((bo_adev != adev) && coherent)) - *flags |=AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); + *flags |= (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK ) | +AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC );Maybe we should make the
AMDGPU_PTE_MTYPE_GFX12()macro clear the current field before setting the new one? That would align with the similar register field macros.
Same comment for all of the MTYPE macros for all generations.
Alex
Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-1} --2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 30 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, May 17, 2024 11:52 PM
To: Xiao, Shane <[email protected]>
Cc: [email protected]; Kuehling, Felix <[email protected]>; Somasekharan, Sreekant <[email protected]>; Liu, Aaron <[email protected]>; Yao, Longlong <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: Correct the GFX12 memory type settingQuoted 19 lines · Shane Xiao
This patch fixes the GFX12 memory type to NC. Since the Memory type can be overwritten by the previous operations, the GFX12 MTYPE bits need to be clear before setting to NC.
Signed-off-by longlyao <[email protected]>Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-0@@ -534,7 +534,8 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev, · line 538
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2
-1/* WA for HW bug */ if (is_system || ((bo_adev != adev) && coherent)) - *flags |=AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); + *flags |= (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK ) | +AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC );Maybe we should make the
AMDGPU_PTE_MTYPE_GFX12()macro clear the current field before setting the new one? That would align with the similar register field macros.
The AMDGPU_PTE_MTYPE_GFX12() macro is used mtype as input, if we align with Register field setting, we need use uint64 flags as input.
If we do like below:
-#define AMDGPU_PTE_MTYPE_GFX12(a) ((uint64_t)(a) << 54)
-#define AMDGPU_PTE_MTYPE_GFX12_MASK AMDGPU_PTE_MTYPE_GFX12(3ULL) +#define AMDGPU_PTE_MTYPE_GFX12_SHIFT(mtype) ((uint64_t)(mytype) << 54) +#define AMDGPU_PTE_MTYPE_GFX12_MASK AMDGPU_PTE_MTYPE_GFX12_SHIFT(3ULL)
+#define AMDGPU_PTE_MTYPE_GFX12(flags) \
+ ((flags) & ((~AMDGPU_PTE_MTYPE_GFX12_MASK)) | (flags))
We need to change the memory type setting from AMDGPU_PTE_MTYPE_GFX12(MTYPE_NC) to AMDGPU_PTE_MTYPE_GFX12(AMDGPU_PTE_MTYPE_GFX12_SHIFT(MTYPE_NC)).
This makes the code look more complicated.
Another way is to add one more macro AMDGPU_UPDATE/SET_PTE _MTYPE_GFX12.
#define AMDGPU_ UPDATE_PTE_MTYPE_GFX12(flags) \
((flags) & ((~AMDGPU_PTE_MTYPE_GFX12_MASK)) | (flags))Which of the above two methods do you think is more suitable?
If neither of these methods are suitable, do you have any other suggestions?
Best Regards,
Shane
Quoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-1} --2.25.1
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 66 lines
-----Original Message-----
From: Xiao, Shane
Sent: Monday, May 20, 2024 4:21 PM
To: Alex Deucher <[email protected]>
Cc: [email protected]; Kuehling, Felix <[email protected]>; Somasekharan, Sreekant <[email protected]>; Liu, Aaron <[email protected]>; Yao, Longlong <[email protected]>
Subject: RE: [PATCH] drm/amdkfd: Correct the GFX12 memory type settingQuoted 7 lines
-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Friday, May 17, 2024 11:52 PM
To: Xiao, Shane <[email protected]>
Cc: [email protected]; Kuehling, Felix <[email protected]>; Somasekharan, Sreekant <[email protected]>; Liu, Aaron <[email protected]>;Yao,
Quoted 4 lines
Longlong <[email protected]>
Subject: Re: [PATCH] drm/amdkfd: Correct the GFX12 memory type settingOn Fri, May 17, 2024 at 3:07 AM Shane Xiao <[email protected]>
Quoted 19 lines · wrote:
Quoted 19 lines
This patch fixes the GFX12 memory type to NC. Since the Memory type can be overwritten by the previous operations, the GFX12 MTYPE bits need to be clear before setting to NC.
Signed-off-by longlyao <[email protected]>Signed-off-by Shane Xiao <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-0@@ -534,7 +534,8 @@ static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev,Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c static void gmc_v12_0_get_vm_pte(struct amdgpu_device *adev, · line 538
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +2
-1/* WA for HW bug */ if (is_system || ((bo_adev != adev) && coherent)) - *flags |=AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC ); + *flags |= (*flags & ~AMDGPU_PTE_MTYPE_GFX12_MASK ) | +AMDGPU_PTE_MTYPE_GFX12 (MTYPE_NC );Maybe we should make the
AMDGPU_PTE_MTYPE_GFX12()macro clear the current field before setting the new one? That would align with the similar register field macros.The
AMDGPU_PTE_MTYPE_GFX12()macro is used mtype as input, if we align with Register field setting, we need use uint64 flags as input.If we do like below:
(quoted diff) +0
-2-#define AMDGPU_PTE_MTYPE_GFX12(a) ((uint64_t)(a) << 54) -#define AMDGPU_PTE_MTYPE_GFX12_MASK
AMDGPU_PTE_MTYPE_GFX12(3ULL)
+#defineAMDGPU_PTE_MTYPE_GFX12_SHIFT(mtype)((uint64_t)(mytype) << 54)
+#defineAMDGPU_PTE_MTYPE_GFX12_MASKAMDGPU_PTE_MTYPE_GFX12_SHIFT(3ULL)
Review
Quoted 2 lines
(quoted diff) +2
-0+#define AMDGPU_PTE_MTYPE_GFX12(flags) \ + ((flags) & ((~AMDGPU_PTE_MTYPE_GFX12_MASK)) | (flags))
Just igore my comment before. We need both flags and MTYPE as input.
I will send V2 version for this.
Quoted 33 lines
We need to change the memory type setting from
AMDGPU_PTE_MTYPE_GFX12(MTYPE_NC)toAMDGPU_PTE_MTYPE_GFX12(AMDGPU_PTE_MTYPE_GFX12_SHIFT(MTYPE_ NC)).
This makes the code look more complicated.Another way is to add one more macro AMDGPU_UPDATE/SET_PTE
_MTYPE_GFX12.#define AMDGPU_ UPDATE_PTE_MTYPE_GFX12(flags) \ ((flags) & ((~AMDGPU_PTE_MTYPE_GFX12_MASK)) | (flags))Which of the above two methods do you think is more suitable?
If neither of these methods are suitable, do you have any other suggestions?Best Regards,
ShaneQuoted 9 lines
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gmc_v12_0.c +0
-1} --2.25.1