drm/amdgpu: add helpers to access registers on different AIDs
authorLe Ma <le.ma@amd.com>
Tue, 27 Sep 2022 09:51:33 +0000 (17:51 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Jun 2023 13:48:05 +0000 (09:48 -0400)
SMN address which is larger than 32bit has different indications
through bit[34:32] on different AIDs.

v2: put smn addressing of different AIDs into asic specific place
v3: change to ext_id/ext_offset naming

Signed-off-by: Le Ma <le.ma@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/aqua_vanjaram_reg_init.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/soc15.h
drivers/gpu/drm/amd/amdgpu/soc15_common.h

index e17a369..4c4ce33 100644 (file)
@@ -574,6 +574,8 @@ struct amdgpu_asic_funcs {
        /* query video codecs */
        int (*query_video_codecs)(struct amdgpu_device *adev, bool encode,
                                  const struct amdgpu_video_codecs **codecs);
+       /* encode "> 32bits" smn addressing */
+       u64 (*encode_ext_smn_addressing)(int ext_id);
 };
 
 /*
index 12379c3..2616bdb 100644 (file)
@@ -100,3 +100,22 @@ void aqua_vanjaram_ip_map_init(struct amdgpu_device *adev)
 
        adev->ip_map.logical_to_dev_inst = aqua_vanjaram_logical_to_dev_inst;
 }
+
+/* Fixed pattern for smn addressing on different AIDs:
+ *   bit[34]: indicate cross AID access
+ *   bit[33:32]: indicate target AID id
+ * AID id range is 0 ~ 3 as maximum AID number is 4.
+ */
+u64 aqua_vanjaram_encode_ext_smn_addressing(int ext_id)
+{
+       u64 ext_offset;
+
+       /* local routing and bit[34:32] will be zeros */
+       if (ext_id == 0)
+               return 0;
+
+       /* Initiated from host, accessing to all non-zero aids are cross traffic */
+       ext_offset = ((u64)(ext_id & 0x3) << 32) | (1ULL << 34);
+
+       return ext_offset;
+}
index 29d2e08..206013d 100644 (file)
@@ -873,6 +873,7 @@ static const struct amdgpu_asic_funcs aqua_vanjaram_asic_funcs =
        .supports_baco = &soc15_supports_baco,
        .pre_asic_init = &soc15_pre_asic_init,
        .query_video_codecs = &soc15_query_video_codecs,
+       .encode_ext_smn_addressing = &aqua_vanjaram_encode_ext_smn_addressing,
 };
 
 static int soc15_common_early_init(void *handle)
index 9cc2dda..dd48db0 100644 (file)
@@ -112,6 +112,7 @@ int vega20_reg_base_init(struct amdgpu_device *adev);
 int arct_reg_base_init(struct amdgpu_device *adev);
 int aldebaran_reg_base_init(struct amdgpu_device *adev);
 void aqua_vanjaram_ip_map_init(struct amdgpu_device *adev);
+u64 aqua_vanjaram_encode_ext_smn_addressing(int ext_id);
 
 void vega10_doorbell_index_init(struct amdgpu_device *adev);
 void vega20_doorbell_index_init(struct amdgpu_device *adev);
index 39e4406..1c9e924 100644 (file)
 #define RREG32_SOC15_OFFSET_RLC(ip, inst, reg, offset) \
        __RREG32_SOC15_RLC__((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) + offset, AMDGPU_REGS_RLC, ip##_HWIP)
 
+/* inst equals to ext for some IPs */
+#define RREG32_SOC15_EXT(ip, inst, reg, ext) \
+       RREG32_PCIE_EXT((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) * 4 \
+                       + adev->asic_funcs->encode_ext_smn_addressing(ext)) \
+
+#define WREG32_SOC15_EXT(ip, inst, reg, ext, value) \
+       WREG32_PCIE_EXT((adev->reg_offset[ip##_HWIP][inst][reg##_BASE_IDX] + reg) * 4 \
+                       + adev->asic_funcs->encode_ext_smn_addressing(ext), \
+                       value) \
+
 #endif