[PATCH 16/23] amd/amdgpu: Set MTYPE_UC for access over PCIe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Amber Lin <Amber.Lin@xxxxxxx>

For GFX v9_4_3, set MTYPE_UC for memory access over PCIe.

v4 - add missing indentation pointed out by Felix and add his
reviewed-by tag.
v3 - add missing logic for the svm path.
v2 - add amdgpu_xgmi_same_hive to separate access over xgmi from pcie

Reviewed-by: Felix Kuehling <Felix.Kuehling@xxxxxxx>
Signed-off-by: Amber Lin <Amber.Lin@xxxxxxx>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@xxxxxxx>
Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 29 ++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index 8bd9d88655b8..efd2bffbb892 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -1192,16 +1192,29 @@ svm_range_get_pte_flags(struct kfd_node *node,
 		//e.g. NPS4. Current approch is only applicable without memory
 		//partitions.
 		snoop = true;
-		if (uncached)
+		if (uncached) {
 			mapping_flags |= AMDGPU_VM_MTYPE_UC;
-		/* local HBM region close to partition*/
-		else if (bo_node == node)
-			mapping_flags |= AMDGPU_VM_MTYPE_RW;
-		/* local HBM region far from partition or remote XGMI GPU or
-		 * system memory
-		 */
-		else
+		} else if (domain == SVM_RANGE_VRAM_DOMAIN) {
+			/* local HBM region close to partition with a workaround
+			 * for Endpoint systems.
+			 */
+			if (bo_node == node)
+				mapping_flags |=
+					(node->adev->flags & AMD_IS_APU) ?
+					AMDGPU_VM_MTYPE_RW : AMDGPU_VM_MTYPE_NC;
+			/* local HBM region far from partition or remote XGMI GPU */
+			else if (svm_nodes_in_same_hive(bo_node, node))
+				mapping_flags |= AMDGPU_VM_MTYPE_NC;
+			/* PCIe P2P */
+			else
+				mapping_flags |= AMDGPU_VM_MTYPE_UC;
+		/* system memory accessed by the APU */
+		} else if (node->adev->flags & AMD_IS_APU) {
 			mapping_flags |= AMDGPU_VM_MTYPE_NC;
+		/* system memory accessed by the dGPU */
+		} else {
+			mapping_flags |= AMDGPU_VM_MTYPE_UC;
+		}
 		break;
 	default:
 		mapping_flags |= coherent ?
-- 
2.39.2




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux