From 16bd8addd4b17b290dc660e6ea203df03adc1700 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 11 Jul 2018 13:24:53 -0500 Subject: [PATCH] drm/amdgpu/pp/smu7: only kmap smu buffers when needed Rather than having a persistent kmap. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=105760 Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c | 65 +++++++++++++--------- drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h | 3 - 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index d644a9bb9078..6252a359e595 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c @@ -379,8 +379,9 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) { struct smu7_smumgr *smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend); uint32_t fw_to_load; - int result = 0; + int r = 0; struct SMU_DRAMData_TOC *toc; + void *kptr; if (!hwmgr->reload_fw) { pr_info("skip reloading...\n"); @@ -421,41 +422,60 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) + UCODE_ID_CP_MEC_JT2_MASK; } - toc = (struct SMU_DRAMData_TOC *)smu_data->header; + if (smu_data->header_buffer.handle == NULL) + return -ENOMEM; + + r = amdgpu_bo_reserve(smu_data->header_buffer.handle, false); + if (r) + return r; + + r = amdgpu_bo_kmap(smu_data->header_buffer.handle, &kptr); + if (r) + goto unreserve; + + toc = (struct SMU_DRAMData_TOC *)kptr; toc->num_entries = 0; toc->structure_version = 1; PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_RLC_G, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_CE, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_PFP, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_ME, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_MEC, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_MEC_JT1, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_CP_MEC_JT2, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_SDMA0, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_SDMA1, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); if (!hwmgr->not_vf) PP_ASSERT_WITH_CODE(0 == smu7_populate_single_firmware_entry(hwmgr, UCODE_ID_MEC_STORAGE, &toc->entry[toc->num_entries++]), - "Failed to Get Firmware Entry.", return -EINVAL); + "Failed to Get Firmware Entry.", r = -EINVAL; goto unmap); +unmap: + amdgpu_bo_kunmap(smu_data->header_buffer.handle); + kptr = NULL; +unreserve: + amdgpu_bo_unreserve(smu_data->header_buffer.handle); + + if (r) + return r; smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_HI, upper_32_bits(smu_data->header_buffer.mc_addr)); smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_DRV_DRAM_ADDR_LO, lower_32_bits(smu_data->header_buffer.mc_addr)); @@ -463,7 +483,7 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr) if (smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load)) pr_err("Fail to Request SMU Load uCode"); - return result; + return r; } /* Check if the FW has been loaded, SMU will not return if loading has not finished. */ @@ -570,7 +590,6 @@ int smu7_setup_pwr_virus(struct pp_hwmgr *hwmgr) int smu7_init(struct pp_hwmgr *hwmgr) { struct smu7_smumgr *smu_data; - uint64_t mc_addr = 0; int r; /* Allocate memory for backend private data */ smu_data = (struct smu7_smumgr *)(hwmgr->smu_backend); @@ -584,15 +603,12 @@ int smu7_init(struct pp_hwmgr *hwmgr) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, &smu_data->header_buffer.handle, - &mc_addr, - &smu_data->header_buffer.kaddr); + &smu_data->header_buffer.mc_addr, + NULL); if (r) return -EINVAL; - smu_data->header = smu_data->header_buffer.kaddr; - smu_data->header_buffer.mc_addr = mc_addr; - if (!hwmgr->not_vf) return 0; @@ -602,16 +618,15 @@ int smu7_init(struct pp_hwmgr *hwmgr) PAGE_SIZE, AMDGPU_GEM_DOMAIN_VRAM, &smu_data->smu_buffer.handle, - &mc_addr, - &smu_data->smu_buffer.kaddr); + &smu_data->smu_buffer.mc_addr, + NULL); if (r) { amdgpu_bo_free_kernel(&smu_data->header_buffer.handle, &smu_data->header_buffer.mc_addr, - &smu_data->header_buffer.kaddr); + NULL); return -EINVAL; } - smu_data->smu_buffer.mc_addr = mc_addr; if (smum_is_hw_avfs_present(hwmgr)) hwmgr->avfs_supported = true; @@ -626,12 +641,12 @@ int smu7_smu_fini(struct pp_hwmgr *hwmgr) amdgpu_bo_free_kernel(&smu_data->header_buffer.handle, &smu_data->header_buffer.mc_addr, - &smu_data->header_buffer.kaddr); + NULL); if (hwmgr->not_vf) amdgpu_bo_free_kernel(&smu_data->smu_buffer.handle, &smu_data->smu_buffer.mc_addr, - &smu_data->smu_buffer.kaddr); + NULL); kfree(hwmgr->smu_backend); hwmgr->smu_backend = NULL; diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h index 39c9bfda0ab4..80a4139696d2 100644 --- a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h +++ b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.h @@ -32,13 +32,10 @@ struct smu7_buffer_entry { uint32_t data_size; uint64_t mc_addr; - void *kaddr; struct amdgpu_bo *handle; }; struct smu7_smumgr { - uint8_t *header; - uint8_t *mec_image; struct smu7_buffer_entry smu_buffer; struct smu7_buffer_entry header_buffer; -- 2.13.6