]> Git Repo - linux.git/commitdiff
drm/amdgpu: add helpers to access registers on different AIDs
authorLe Ma <[email protected]>
Tue, 27 Sep 2022 09:51:33 +0000 (17:51 +0800)
committerAlex Deucher <[email protected]>
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 <[email protected]>
Reviewed-by: Lijo Lazar <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
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 e17a3697a23f2979bf9965aef8a78580d7571c5a..4c4ce33c83598301e404423cc9377aad39a8674a 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 12379c374457fbee448485404943bc562ac67f7e..2616bdb40418e78b7014615083545fae2b87044c 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 29d2e08834c787ae24337070f0e6afba17137861..206013d276c1a9a8871bb534ddd6feecd69cf5ac 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 9cc2dda087c4da096d37ea1189474bb694ac3702..dd48db09aa51117894185e6438ab4948b2fd3971 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 39e4406da4aee1cafd943ecf9652e57a7cba0d3c..1c9e924b5f8cdf990a128755e7da4ac61362a5f0 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
This page took 0.084282 seconds and 4 git commands to generate.