Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: update GPU addresses for SMU and PSP

add amdgpu_bo_fb_aper_addr() and update the cached GPU addresses to use
the FB aperture address for SMU and PSP.

2 reasons for this change:
1. when pdb0 is enabled, gpu addr from amdgpu_bo_create_kernel() is GART
aperture address, it is not compatible with SMU and PSP, it need to be
updated to use FB aperture address.
2. Since FB aperture address will change after switching to new GPU
index after hibernation, it need to be updated on resume.

Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
Signed-off-by: Samuel Zhang <guoqing.zhang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Samuel Zhang and committed by
Alex Deucher
18b66a6c 0f566f0e

+65
+20
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
··· 1473 1473 } 1474 1474 1475 1475 /** 1476 + * amdgpu_bo_fb_aper_addr - return FB aperture GPU offset of the VRAM bo 1477 + * @bo: amdgpu VRAM buffer object for which we query the offset 1478 + * 1479 + * Returns: 1480 + * current FB aperture GPU offset of the object. 1481 + */ 1482 + u64 amdgpu_bo_fb_aper_addr(struct amdgpu_bo *bo) 1483 + { 1484 + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); 1485 + uint64_t offset, fb_base; 1486 + 1487 + WARN_ON_ONCE(bo->tbo.resource->mem_type != TTM_PL_VRAM); 1488 + 1489 + fb_base = adev->gmc.fb_start; 1490 + fb_base += adev->gmc.xgmi.physical_node_id * adev->gmc.xgmi.node_segment_size; 1491 + offset = (bo->tbo.resource->start << PAGE_SHIFT) + fb_base; 1492 + return amdgpu_gmc_sign_extend(offset); 1493 + } 1494 + 1495 + /** 1476 1496 * amdgpu_bo_gpu_offset_no_check - return GPU offset of bo 1477 1497 * @bo: amdgpu object for which we query the offset 1478 1498 *
+1
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
··· 304 304 bool intr); 305 305 int amdgpu_bo_sync_wait(struct amdgpu_bo *bo, void *owner, bool intr); 306 306 u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo); 307 + u64 amdgpu_bo_fb_aper_addr(struct amdgpu_bo *bo); 307 308 u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo); 308 309 uint32_t amdgpu_bo_mem_stats_placement(struct amdgpu_bo *bo); 309 310 uint32_t amdgpu_bo_get_preferred_domain(struct amdgpu_device *adev,
+23
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
··· 872 872 &psp->tmr_bo, &psp->tmr_mc_addr, 873 873 pptr); 874 874 } 875 + if (amdgpu_virt_xgmi_migrate_enabled(psp->adev) && psp->tmr_bo) 876 + psp->tmr_mc_addr = amdgpu_bo_fb_aper_addr(psp->tmr_bo); 875 877 876 878 return ret; 877 879 } ··· 1272 1270 1273 1271 psp_copy_fw(psp, context->bin_desc.start_addr, 1274 1272 context->bin_desc.size_bytes); 1273 + 1274 + if (amdgpu_virt_xgmi_migrate_enabled(psp->adev) && 1275 + context->mem_context.shared_bo) 1276 + context->mem_context.shared_mc_addr = 1277 + amdgpu_bo_fb_aper_addr(context->mem_context.shared_bo); 1275 1278 1276 1279 psp_prep_ta_load_cmd_buf(cmd, psp->fw_pri_mc_addr, context); 1277 1280 ··· 2345 2338 return false; 2346 2339 } 2347 2340 2341 + static void psp_update_gpu_addresses(struct amdgpu_device *adev) 2342 + { 2343 + struct psp_context *psp = &adev->psp; 2344 + 2345 + if (psp->cmd_buf_bo && psp->cmd_buf_mem) { 2346 + psp->fw_pri_mc_addr = amdgpu_bo_fb_aper_addr(psp->fw_pri_bo); 2347 + psp->fence_buf_mc_addr = amdgpu_bo_fb_aper_addr(psp->fence_buf_bo); 2348 + psp->cmd_buf_mc_addr = amdgpu_bo_fb_aper_addr(psp->cmd_buf_bo); 2349 + } 2350 + if (adev->firmware.rbuf && psp->km_ring.ring_mem) 2351 + psp->km_ring.ring_mem_mc_addr = amdgpu_bo_fb_aper_addr(adev->firmware.rbuf); 2352 + } 2353 + 2348 2354 static int psp_hw_start(struct psp_context *psp) 2349 2355 { 2350 2356 struct amdgpu_device *adev = psp->adev; 2351 2357 int ret; 2358 + 2359 + if (amdgpu_virt_xgmi_migrate_enabled(adev)) 2360 + psp_update_gpu_addresses(adev); 2352 2361 2353 2362 if (!amdgpu_sriov_vf(adev)) { 2354 2363 if ((is_psp_fw_valid(psp->kdb)) &&
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
··· 1155 1155 adev->firmware.max_ucodes = AMDGPU_UCODE_ID_MAXIMUM; 1156 1156 } 1157 1157 1158 + if (amdgpu_virt_xgmi_migrate_enabled(adev) && adev->firmware.fw_buf) 1159 + adev->firmware.fw_buf_mc = amdgpu_bo_fb_aper_addr(adev->firmware.fw_buf); 1160 + 1158 1161 for (i = 0; i < adev->firmware.max_ucodes; i++) { 1159 1162 ucode = &adev->firmware.ucode[i]; 1160 1163 if (ucode->fw) {
+18
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c
··· 1004 1004 return 0; 1005 1005 } 1006 1006 1007 + static void smu_update_gpu_addresses(struct smu_context *smu) 1008 + { 1009 + struct smu_table_context *smu_table = &smu->smu_table; 1010 + struct smu_table *pm_status_table = smu_table->tables + SMU_TABLE_PMSTATUSLOG; 1011 + struct smu_table *driver_table = &(smu_table->driver_table); 1012 + struct smu_table *dummy_read_1_table = &smu_table->dummy_read_1_table; 1013 + 1014 + if (pm_status_table->bo) 1015 + pm_status_table->mc_address = amdgpu_bo_fb_aper_addr(pm_status_table->bo); 1016 + if (driver_table->bo) 1017 + driver_table->mc_address = amdgpu_bo_fb_aper_addr(driver_table->bo); 1018 + if (dummy_read_1_table->bo) 1019 + dummy_read_1_table->mc_address = amdgpu_bo_fb_aper_addr(dummy_read_1_table->bo); 1020 + } 1021 + 1007 1022 /** 1008 1023 * smu_alloc_memory_pool - allocate memory pool in the system memory 1009 1024 * ··· 1794 1779 { 1795 1780 struct amdgpu_device *adev = smu->adev; 1796 1781 int ret = 0; 1782 + 1783 + if (amdgpu_virt_xgmi_migrate_enabled(adev)) 1784 + smu_update_gpu_addresses(smu); 1797 1785 1798 1786 smu->smc_fw_state = SMU_FW_INIT; 1799 1787