Add a helper to extract the AID revision from adev->rev_id, matching
the existing SOC_V1_0_DIE_REV_XCD(), and use it instead of open-coded
rev_id bit checks for AID A1 in gmc_v12_1 and kfd_svm.

Signed-off-by: Mukul Joshi <[email protected]>
Reviewed-by: David Yat Sin <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 3 ++-
 drivers/gpu/drm/amd/amdgpu/soc_v1_0.h  | 2 ++
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c   | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
index 839d76183755..e056eb80b3a3 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
@@ -23,6 +23,7 @@
 #include "amdgpu.h"
 #include "gmc_v12_1.h"
 #include "soc15_common.h"
+#include "soc_v1_0.h"
 #include "soc_v1_0_enum.h"
 #include "oss/osssys_7_1_0_offset.h"
 #include "oss/osssys_7_1_0_sh_mask.h"
@@ -627,7 +628,7 @@ static void gmc_v12_1_get_mtypes(struct amdgpu_device *adev,
                                 unsigned int *mtype_local,
                                 unsigned int *mtype_remote)
 {
-       bool is_aid_a1 = (adev->rev_id & 0x10);
+       bool is_aid_a1 = SOC_V1_0_DIE_REV_AID(adev->rev_id) == 1;
 
        /* Local memory: ASIC default depends on the AID stepping. */
        *mtype_local = is_aid_a1 ? MTYPE_RW : MTYPE_NC;
diff --git a/drivers/gpu/drm/amd/amdgpu/soc_v1_0.h 
b/drivers/gpu/drm/amd/amdgpu/soc_v1_0.h
index 9bff7cc60121..861862bd85b9 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc_v1_0.h
+++ b/drivers/gpu/drm/amd/amdgpu/soc_v1_0.h
@@ -46,6 +46,8 @@ extern const struct amdgpu_ip_block_version 
soc_v1_0_common_ip_block;
         ((xcd) << SOC_V1_0_DIE_REV_XCD__SHIFT))
 #define SOC_V1_0_DIE_REV_XCD(rev_id)          \
        (((rev_id) & SOC_V1_0_DIE_REV_XCD__MASK) >> SOC_V1_0_DIE_REV_XCD__SHIFT)
+#define SOC_V1_0_DIE_REV_AID(rev_id)          \
+       (((rev_id) & SOC_V1_0_DIE_REV_AID__MASK) >> SOC_V1_0_DIE_REV_AID__SHIFT)
 
 void soc_v1_0_grbm_select(struct amdgpu_device *adev,
                          u32 me, u32 pipe,
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index a99dbedf3cd4..f99cb18e8e11 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -34,6 +34,7 @@
 #include "amdgpu.h"
 #include "amdgpu_xgmi.h"
 #include "amdgpu_reset.h"
+#include "soc_v1_0.h"
 #include "kfd_priv.h"
 #include "kfd_svm.h"
 #include "kfd_migrate.h"
@@ -1341,7 +1342,7 @@ 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):
-               is_aid_a1 = (node->adev->rev_id & 0x10);
+               is_aid_a1 = SOC_V1_0_DIE_REV_AID(node->adev->rev_id) == 1;
                is_local = (domain == SVM_RANGE_VRAM_DOMAIN) &&
                                (bo_node->adev == node->adev);
 
-- 
2.55.0

Reply via email to