drm/amdgpu: set UMC PA per NPS mode when PA is 0
authorTao Zhou <tao.zhou1@amd.com>
Wed, 6 Nov 2024 08:36:50 +0000 (16:36 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Dec 2024 15:26:48 +0000 (10:26 -0500)
The shift bit of PA varys according to NPS mode due to
different address format.

Signed-off-by: Tao Zhou <tao.zhou1@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/umc_v12_0.c

index 30ee4cb9aaabffca530e6af619ba815b68576eae..a7b9c358a2d4c5101a815131c6f0387fbc1ea55e 100644 (file)
@@ -467,6 +467,8 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,
        uint64_t err_addr, pa_addr = 0;
        struct ras_ecc_err *ecc_err;
        struct ta_ras_query_address_output addr_out;
+       enum amdgpu_memory_partition nps = AMDGPU_NPS1_PARTITION_MODE;
+       uint32_t shift_bit = UMC_V12_0_PA_C4_BIT;
        int count, ret, i;
 
        hwid = REG_GET_FIELD(ipid, MCMP1_IPIDT0, HardwareID);
@@ -511,9 +513,14 @@ static int umc_v12_0_update_ecc_status(struct amdgpu_device *adev,
        ecc_err->pa_pfn = pa_addr >> AMDGPU_GPU_PAGE_SHIFT;
        ecc_err->channel_idx = addr_out.pa.channel_idx;
 
+       if (adev->gmc.gmc_funcs->query_mem_partition_mode)
+               nps = adev->gmc.gmc_funcs->query_mem_partition_mode(adev);
+       if (nps == AMDGPU_NPS4_PARTITION_MODE)
+               shift_bit = UMC_V12_0_PA_B0_BIT;
+
        /* If converted pa_pfn is 0, use pa C4 pfn. */
        if (!ecc_err->pa_pfn)
-               ecc_err->pa_pfn = BIT_ULL(UMC_V12_0_PA_C4_BIT) >> AMDGPU_GPU_PAGE_SHIFT;
+               ecc_err->pa_pfn = BIT_ULL(shift_bit) >> AMDGPU_GPU_PAGE_SHIFT;
 
        ret = amdgpu_umc_logs_ecc_err(adev, &con->umc_ecc_log.de_page_tree, ecc_err);
        if (ret) {