]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: Update MTYPE for GFX12.1
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Thu, 29 Jan 2026 19:17:22 +0000 (14:17 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 17 Mar 2026 14:31:49 +0000 (10:31 -0400)
Update MTYPE for GFX12.1 for AID A0 and A1

Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Reviewed-by: Philip.Yang <Philip.Yang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c

index c49112d8300e2f54eeef4ff2f3bed3600dd9cdc5..bc86e6c8e063ab2885daf4fa5c8975b8f48ad0c8 100644 (file)
@@ -524,13 +524,16 @@ static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev,
        bool ext_coherent = bo->flags & AMDGPU_GEM_CREATE_EXT_COHERENT;
        uint32_t gc_ip_version = amdgpu_ip_version(adev, GC_HWIP, 0);
        bool uncached = bo->flags & AMDGPU_GEM_CREATE_UNCACHED;
-       unsigned int mtype, mtype_local;
+       unsigned int mtype, mtype_local, mtype_remote;
        bool snoop = false;
        bool is_local = false;
 
        switch (gc_ip_version) {
        case IP_VERSION(12, 1, 0):
-               mtype_local = MTYPE_RW;
+               bool is_aid_a1 = (adev->rev_id & 0x10);
+
+               mtype_local = is_aid_a1 ? MTYPE_RW : MTYPE_NC;
+               mtype_remote = is_aid_a1 ? MTYPE_NC : MTYPE_UC;
                if (amdgpu_mtype_local == 1) {
                        DRM_INFO_ONCE("Using MTYPE_NC for local memory\n");
                        mtype_local = MTYPE_NC;
@@ -547,10 +550,7 @@ static void gmc_v12_1_get_coherence_flags(struct amdgpu_device *adev,
                } else if (ext_coherent) {
                        mtype = is_local ? mtype_local : MTYPE_UC;
                } else {
-                       if (is_local)
-                               mtype = mtype_local;
-                       else
-                               mtype = MTYPE_NC;
+                       mtype = is_local ? mtype_local : mtype_remote;
                }
                break;
        default:
index 080242f9981b0f8ee2863439265bf814496ffa7b..1aea31c007fd82faf0d36091d0d8a6a6e2cc2f28 100644 (file)
@@ -1219,7 +1219,7 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm,
        bool snoop = (domain != SVM_RANGE_VRAM_DOMAIN);
        bool coherent = flags & (KFD_IOCTL_SVM_FLAG_COHERENT | KFD_IOCTL_SVM_FLAG_EXT_COHERENT);
        bool ext_coherent = flags & KFD_IOCTL_SVM_FLAG_EXT_COHERENT;
-       unsigned int mtype_local;
+       unsigned int mtype_local, mtype_remote;
 
        if (domain == SVM_RANGE_VRAM_DOMAIN)
                bo_node = prange->svm_bo->node;
@@ -1307,20 +1307,23 @@ svm_range_get_pte_flags(struct kfd_node *node, struct amdgpu_vm *vm,
                mapping_flags |= AMDGPU_VM_MTYPE_NC;
                break;
        case IP_VERSION(12, 1, 0):
+               bool is_aid_a1 = (node->adev->rev_id & 0x10);
+               bool is_local = (domain == SVM_RANGE_VRAM_DOMAIN) &&
+                               (bo_node->adev == node->adev);
+
+               mtype_local = amdgpu_mtype_local == 1 ? AMDGPU_VM_MTYPE_NC :
+                                                       is_aid_a1 ?
+                                                       AMDGPU_VM_MTYPE_RW : AMDGPU_VM_MTYPE_NC;
+               mtype_remote = is_aid_a1 ? AMDGPU_VM_MTYPE_NC : AMDGPU_VM_MTYPE_UC;
                snoop = true;
-               if (domain == SVM_RANGE_VRAM_DOMAIN) {
-                       mtype_local = amdgpu_mtype_local == 1 ? AMDGPU_VM_MTYPE_NC :
-                                                               AMDGPU_VM_MTYPE_RW;
-                       /* local HBM  */
-                       if (bo_node->adev == node->adev)
-                               mapping_flags |= mtype_local;
-                       /* Remote GPU memory */
-                       else
-                               mapping_flags |= ext_coherent ? AMDGPU_VM_MTYPE_UC :
-                                                               AMDGPU_VM_MTYPE_NC;
-               /* system memory accessed by the dGPU */
+
+               if (is_local) /* local HBM  */ {
+                       mapping_flags |= mtype_local;
+               } else if (ext_coherent) {
+                       mapping_flags |= AMDGPU_VM_MTYPE_UC;
                } else {
-                       mapping_flags |= ext_coherent ? AMDGPU_VM_MTYPE_UC : AMDGPU_VM_MTYPE_NC;
+                       /* system memory or remote VRAM */
+                       mapping_flags |= mtype_remote;
                }
                break;
        default: