Skip to contentSkip to conversation

drm/amdgpu: Split amdgpu_ucode_init/fini_bo into two functions

PATCH Superseded Rex Zhu 5 participants 13 messages Oct 9, 2018 – Oct 10, 2018 8 messages not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Rex Zhu

author
#0 lore raw

PATCH 1/5 drm/amdgpu: Split amdgpu_ucode_init/fini_bo into two functions

1. one is for create/free bo when init/fini
2. one is for fill the bo before fw loading

the ucode bo only need to be created when load driver and free when driver unload.

when resume/reset, driver only need to re-fill the bo if the bo is allocated in vram.

Suggested by Christian.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  3 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c  | 57 +++++++++++++++---------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h  |  3 ++
 3 files changed, 34 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 94c92f5..4787571 100644
@@ -1581,6 +1581,8 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 		}
 	}
 
+	amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/
+
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_blocks[i].status.sw)
 			continue;
@@ -1803,6 +1805,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
 			continue;
 
 		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
+			amdgpu_ucode_free_bo(adev);
 			amdgpu_free_static_csa(adev);
 			amdgpu_device_wb_fini(adev);
 			amdgpu_device_vram_scratch_fini(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +28 -29

81 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +3 -0
index 8f3f111..4c0e5be 100644
@@ -279,6 +279,9 @@ bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
 int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
 int amdgpu_ucode_fini_bo(struct amdgpu_device *adev);
 
+void amdgpu_ucode_create_bo(struct amdgpu_device *adev);
+void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
+
 enum amdgpu_firmware_load_type
 amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1539089023-2360-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/5 drm/amdgpu: Remove amdgpu_ucode_fini_bo

The variable clean is unnecessary.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c     | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h     |  3 +--
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c |  3 ---
 4 files changed, 1 insertion(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index bd397d2..25d2f3e 100644
@@ -452,8 +452,6 @@ static int psp_hw_fini(void *handle)
 	if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
 		return 0;
 
-	amdgpu_ucode_fini_bo(adev);
-
 	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
 	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +0 -19
index 7b6b2f4c..f2604ac 100644
@@ -489,22 +489,3 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
 	}
 	return 0;
 }
-
-int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
-{
-	int i;
-	struct amdgpu_firmware_info *ucode = NULL;
-
-	if (!adev->firmware.fw_size)
-		return 0;
-
-	for (i = 0; i < adev->firmware.max_ucodes; i++) {
-		ucode = &adev->firmware.ucode[i];
-		if (ucode->fw) {
-			ucode->mc_addr = 0;
-			ucode->kaddr = NULL;
-		}
-	}
-
-	return 0;
-}
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +1 -2
index 4c0e5be..05a2c46 100644
@@ -276,9 +276,8 @@ struct amdgpu_firmware {
 int amdgpu_ucode_validate(const struct firmware *fw);
 bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
 				uint16_t hdr_major, uint16_t hdr_minor);
-int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
-int amdgpu_ucode_fini_bo(struct amdgpu_device *adev);
 
+int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
 void amdgpu_ucode_create_bo(struct amdgpu_device *adev);
 void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0 -3
index 6bc8e9c..75b56ae 100644
@@ -109,9 +109,6 @@ static int pp_sw_fini(void *handle)
 
 	hwmgr_sw_fini(hwmgr);
 
-	if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-		amdgpu_ucode_fini_bo(adev);
-
 	release_firmware(adev->pm.fw);
 	adev->pm.fw = NULL;
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1539089023-2360-2-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#4 lore raw

Re: [PATCH 2/5] drm/amdgpu: Remove amdgpu_ucode_fini_bo

Quoted 4 lines · Rex Zhu

The variable clean is unnecessary.

Quoted 79 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c       |  2 --
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c     | 19 -------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h     |  3 +--
 drivers/gpu/drm/amd/powerplay/amd_powerplay.c |  3 ---
 4 files changed, 1 insertion(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index bd397d2..25d2f3e 100644
@@ -452,8 +452,6 @@ static int psp_hw_fini(void *handle)
        if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
                return 0;
 
-       amdgpu_ucode_fini_bo(adev);
-
        psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
        amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +0 -19
index 7b6b2f4c..f2604ac 100644
@@ -489,22 +489,3 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
        }
        return 0;
 }
-
-int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
-{
-       int i;
-       struct amdgpu_firmware_info *ucode = NULL;
-
-       if (!adev->firmware.fw_size)
-               return 0;
-
-       for (i = 0; i < adev->firmware.max_ucodes; i++) {
-               ucode = &adev->firmware.ucode[i];
-               if (ucode->fw) {
-                       ucode->mc_addr = 0;
-                       ucode->kaddr = NULL;
-               }
-       }
-
-       return 0;
-}
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +1 -2
index 4c0e5be..05a2c46 100644
@@ -276,9 +276,8 @@ struct amdgpu_firmware {
 int amdgpu_ucode_validate(const struct firmware *fw);
 bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
                                uint16_t hdr_major, uint16_t hdr_minor);
-int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
-int amdgpu_ucode_fini_bo(struct amdgpu_device *adev);
 
+int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
 void amdgpu_ucode_create_bo(struct amdgpu_device *adev);
 void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
 
drivers/gpu/drm/amd/powerplay/amd_powerplay.c +0 -4
index 6bc8e9c..75b56ae 100644
@@ -109,9 +109,6 @@ static int pp_sw_fini(void *handle)
 
        hwmgr_sw_fini(hwmgr);
 
-       if (adev->firmware.load_type == AMDGPU_FW_LOAD_SMU)
-               amdgpu_ucode_fini_bo(adev);
-
        release_firmware(adev->pm.fw);
        adev->pm.fw = NULL;
 
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#5 lore raw

PATCH 3/5 drm/amdgpu: Extract the function of fw loading out of powerplay

In reply to a message not in the archive

So there is no dependence between gfx/sdma/smu.
and for Vi, after IH hw_init, driver load all the smu/gfx/sdma fw. for AI, fw loading is controlled by PSP, after psp hw init, we call the function to check smu fw version.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 30 ++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              | 11 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c             |  8 ------
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c        | 20 ---------------
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 -
 drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c |  8 ++----
 drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c |  5 ----
 7 files changed, 32 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +30 -0
index 4787571..a6766b3 100644
@@ -1525,6 +1525,24 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
 	return 0;
 }
 
+static int amdgpu_device_fw_loading(struct amdgpu_device *adev, uint32_t index)
+{
+	int r = 0;
+
+	if ((adev->asic_type < CHIP_VEGA10
+	     && (adev->ip_blocks[index].version->type == AMD_IP_BLOCK_TYPE_IH))
+	     || (adev->asic_type >= CHIP_VEGA10
+	     && (adev->ip_blocks[index].version->type == AMD_IP_BLOCK_TYPE_PSP))) {
+		if (adev->powerplay.pp_funcs->load_firmware) {
+			r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
+			if (r) {
+				pr_err("firmware loading failed\n");
+				return r;
+			}
+		}
+	}
+	return 0;
+}
 /**
  * amdgpu_device_ip_init - run init for hardware IPs
  *
@@ -1595,6 +1613,9 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 			return r;
 		}
 		adev->ip_blocks[i].status.hw = true;
+		r = amdgpu_device_fw_loading(adev, i);
+		if (r)
+			return r;
 	}
 
 	amdgpu_xgmi_add_device(adev);
@@ -2030,6 +2051,9 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
 			DRM_INFO("RE-INIT: %s %s\n", block->version->funcs->name, r?"failed":"succeeded");
 			if (r)
 				return r;
+			r = amdgpu_device_fw_loading(adev, i);
+			if (r)
+				return r;
 		}
 	}
 
@@ -2098,6 +2122,9 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)
 					  adev->ip_blocks[i].version->funcs->name, r);
 				return r;
 			}
+			r = amdgpu_device_fw_loading(adev, i);
+			if (r)
+				return r;
 		}
 	}
 
@@ -2134,6 +2161,9 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)
 				  adev->ip_blocks[i].version->funcs->name, r);
 			return r;
 		}
+		r = amdgpu_device_fw_loading(adev, i);
+		if (r)
+			return r;
 	}
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -11
index 8439f9a..3d0f277 100644
@@ -4175,20 +4175,9 @@ static void gfx_v8_0_rlc_start(struct amdgpu_device *adev)
 
 static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
 {
-	int r;
-
 	gfx_v8_0_rlc_stop(adev);
 	gfx_v8_0_rlc_reset(adev);
 	gfx_v8_0_init_pg(adev);
-
-	if (adev->powerplay.pp_funcs->load_firmware) {
-		r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
-		if (r) {
-			pr_err("firmware loading failed\n");
-			return r;
-		}
-	}
-
 	gfx_v8_0_rlc_start(adev);
 
 	return 0;
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -8
index 0bdde7f..6fb3eda 100644
@@ -788,14 +788,6 @@ static int sdma_v3_0_start(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (adev->powerplay.pp_funcs->load_firmware) {
-		r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
-		if (r) {
-			pr_err("firmware loading failed\n");
-			return r;
-		}
-	}
-
 	/* disable sdma engine before programing it */
 	sdma_v3_0_ctx_switch_enable(adev, false);
 	sdma_v3_0_enable(adev, false);
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +0 -20
index d552af2..47ac923 100644
@@ -89,7 +89,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
 	hwmgr_init_default_caps(hwmgr);
 	hwmgr_set_user_specify_caps(hwmgr);
 	hwmgr->fan_ctrl_is_in_default_mode = true;
-	hwmgr->reload_fw = 1;
 	hwmgr_init_workload_prority(hwmgr);
 
 	switch (hwmgr->chip_family) {
@@ -209,17 +208,6 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr)
 {
 	int ret = 0;
 
-	if (!hwmgr || !hwmgr->smumgr_funcs)
-		return -EINVAL;
-
-	if (hwmgr->smumgr_funcs->start_smu) {
-		ret = hwmgr->smumgr_funcs->start_smu(hwmgr);
-		if (ret) {
-			pr_err("smc start failed\n");
-			return -EINVAL;
-		}
-	}
-
 	if (!hwmgr->pm_en)
 		return 0;
 
@@ -301,7 +289,6 @@ int hwmgr_suspend(struct pp_hwmgr *hwmgr)
 	if (!hwmgr || !hwmgr->pm_en)
 		return 0;
 
-	hwmgr->reload_fw = true;
 	phm_disable_smc_firmware_ctf(hwmgr);
 	ret = psm_set_boot_states(hwmgr);
 	if (ret)
@@ -321,13 +308,6 @@ int hwmgr_resume(struct pp_hwmgr *hwmgr)
 	if (!hwmgr)
 		return -EINVAL;
 
-	if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) {
-		if (hwmgr->smumgr_funcs->start_smu(hwmgr)) {
-			pr_err("smc start failed\n");
-			return -EINVAL;
-		}
-	}
-
 	if (!hwmgr->pm_en)
 		return 0;
 
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -1
index 35f2272..e5a60aa 100644
@@ -734,7 +734,6 @@ struct pp_hwmgr {
 	void *smu_backend;
 	const struct pp_smumgr_func *smumgr_funcs;
 	bool is_kicker;
-	bool reload_fw;
 
 	enum PP_DAL_POWERLEVEL dal_power_level;
 	struct phm_dynamic_state_info dyn_state;
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +2 -6
index 99b4e4f..3f51d54 100644
@@ -343,9 +343,6 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 	uint32_t fw_to_load;
 	int r = 0;
 
-	if (!hwmgr->reload_fw)
-		return 0;
-
 	amdgpu_ucode_init_bo(hwmgr->adev);
 
 	if (smu_data->soft_regs_start)
@@ -432,10 +429,9 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 	smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load);
 
 	r = smu7_check_fw_load_finish(hwmgr, fw_to_load);
-	if (!r) {
-		hwmgr->reload_fw = 0;
+	if (!r)
 		return 0;
-	}
+
 	pr_err("SMU load firmware failed\n");
 
 failed:
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -5
index abbf2f2..f836d30 100644
@@ -661,9 +661,6 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 	uint32_t fw_to_check = 0;
 	int ret;
 
-	if (!hwmgr->reload_fw)
-		return 0;
-
 	amdgpu_ucode_init_bo(hwmgr->adev);
 
 	smu8_smu_populate_firmware_entries(hwmgr);
@@ -719,8 +716,6 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
 		return ret;
 	}
 
-	hwmgr->reload_fw = 0;
-
 	return 0;
 }
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1539089023-2360-3-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

#7 lore raw

Re: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Quoted 23 lines · Rex Zhu

So there is no dependence between gfx/sdma/smu.
and for Vi, after IH hw_init, driver load all the smu/gfx/sdma fw. for AI, fw loading is controlled by PSP, after psp hw init, we call the function to check smu fw version.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 30 ++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              | 11 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c             |  8 ------
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c        | 20 ---------------
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 -
 drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c |  8 ++----
 drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c |  5 ----
 7 files changed, 32 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 4787571..a6766b3 100644
@@ -1525,6 +1525,24 @@ static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)
        return 0;

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct amdgpu_device *adev) · line 1535

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -0
 }
 
+static int amdgpu_device_fw_loading(struct amdgpu_device *adev, uint32_t index)
+{
+       int r = 0;
+
+       if ((adev->asic_type < CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type == AMD_IP_BLOCK_TYPE_IH))
+            || (adev->asic_type >= CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type == AMD_IP_BLOCK_TYPE_PSP))) {

This seems kind of fragile. If we change the order again at some point, it will break. How about we check whether hw_init/resume is done or not on the blocks we care about or move the checks into the callers and only call when we need it?

Quoted 214 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +22 -0
+               if (adev->powerplay.pp_funcs->load_firmware) {
+                       r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
+                       if (r) {
+                               pr_err("firmware loading failed\n");
+                               return r;
+                       }
+               }
+       }
+       return 0;
+}
 /**
  * amdgpu_device_ip_init - run init for hardware IPs
  *
@@ -1595,6 +1613,9 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
                        return r;
                }
                adev->ip_blocks[i].status.hw = true;
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        amdgpu_xgmi_add_device(adev);
@@ -2030,6 +2051,9 @@ static int amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)
                        DRM_INFO("RE-INIT: %s %s\n", block->version->funcs->name, r?"failed":"succeeded");
                        if (r)
                                return r;
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2098,6 +2122,9 @@ static int amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)
                                          adev->ip_blocks[i].version->funcs->name, r);
                                return r;
                        }
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2134,6 +2161,9 @@ static int amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)
                                  adev->ip_blocks[i].version->funcs->name, r);
                        return r;
                }
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -11
index 8439f9a..3d0f277 100644
@@ -4175,20 +4175,9 @@ static void gfx_v8_0_rlc_start(struct amdgpu_device *adev)
 
 static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)
 {
-       int r;
-
        gfx_v8_0_rlc_stop(adev);
        gfx_v8_0_rlc_reset(adev);
        gfx_v8_0_init_pg(adev);
-
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        gfx_v8_0_rlc_start(adev);
 
        return 0;
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -8
index 0bdde7f..6fb3eda 100644
@@ -788,14 +788,6 @@ static int sdma_v3_0_start(struct amdgpu_device *adev)
 {
        int r;
 
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev->powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        /* disable sdma engine before programing it */
        sdma_v3_0_ctx_switch_enable(adev, false);
        sdma_v3_0_enable(adev, false);
drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +0 -20
index d552af2..47ac923 100644
@@ -89,7 +89,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
        hwmgr_init_default_caps(hwmgr);
        hwmgr_set_user_specify_caps(hwmgr);
        hwmgr->fan_ctrl_is_in_default_mode = true;
-       hwmgr->reload_fw = 1;
        hwmgr_init_workload_prority(hwmgr);
 
        switch (hwmgr->chip_family) {
@@ -209,17 +208,6 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr)
 {
        int ret = 0;
 
-       if (!hwmgr || !hwmgr->smumgr_funcs)
-               return -EINVAL;
-
-       if (hwmgr->smumgr_funcs->start_smu) {
-               ret = hwmgr->smumgr_funcs->start_smu(hwmgr);
-               if (ret) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
@@ -301,7 +289,6 @@ int hwmgr_suspend(struct pp_hwmgr *hwmgr)
        if (!hwmgr || !hwmgr->pm_en)
                return 0;
 
-       hwmgr->reload_fw = true;
        phm_disable_smc_firmware_ctf(hwmgr);
        ret = psm_set_boot_states(hwmgr);
        if (ret)
@@ -321,13 +308,6 @@ int hwmgr_resume(struct pp_hwmgr *hwmgr)
        if (!hwmgr)
                return -EINVAL;
 
-       if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) {
-               if (hwmgr->smumgr_funcs->start_smu(hwmgr)) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -1
index 35f2272..e5a60aa 100644
@@ -734,7 +734,6 @@ struct pp_hwmgr {
        void *smu_backend;
        const struct pp_smumgr_func *smumgr_funcs;
        bool is_kicker;
-       bool reload_fw;
 
        enum PP_DAL_POWERLEVEL dal_power_level;
        struct phm_dynamic_state_info dyn_state;
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +2 -6
index 99b4e4f..3f51d54 100644
@@ -343,9 +343,6 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
        uint32_t fw_to_load;
        int r = 0;
 
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        if (smu_data->soft_regs_start)
@@ -432,10 +429,9 @@ int smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
        smu7_send_msg_to_smc_with_parameter(hwmgr, PPSMC_MSG_LoadUcodes, fw_to_load);
 
        r = smu7_check_fw_load_finish(hwmgr, fw_to_load);
-       if (!r) {
-               hwmgr->reload_fw = 0;
+       if (!r)
                return 0;
-       }
+
        pr_err("SMU load firmware failed\n");
 
 failed:
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -6
index abbf2f2..f836d30 100644
@@ -661,9 +661,6 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
        uint32_t fw_to_check = 0;
        int ret;
 
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        smu8_smu_populate_firmware_entries(hwmgr);
@@ -719,8 +716,6 @@ static int smu8_request_smu_load_fw(struct pp_hwmgr *hwmgr)
                return ret;
        }
 
-       hwmgr->reload_fw = 0;
-
        return 0;
 }
 
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_NwMRLpqr12KtYt5j67vQfd-5pKN=b8UAU9=G5Nsc_mbA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

author
#9 lore raw

RE: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Quoted 46 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, October 10, 2018 3:28 AM
To: Zhu, Rex <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Quoted 9 lines · Rex Zhu

So there is no dependence between gfx/sdma/smu.
and for Vi, after IH hw_init, driver load all the smu/gfx/sdma fw. for AI, fw loading is controlled by PSP, after psp hw init, we call the function to check smu fw version.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 30

++++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct

Quoted 14 lines
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              | 11 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c             |  8 ------
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c        | 20 ---------------
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 -
 drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c |  8 ++----
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c |  5 ----
 7 files changed, 32 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 4787571..a6766b3 100644
@@ -1525,6 +1525,24 @@ static int amdgpu_device_ip_early_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
        return 0;
 }
 
+static int amdgpu_device_fw_loading(struct amdgpu_device *adev,
+uint32_t index) {
+       int r = 0;
+
+       if ((adev->asic_type < CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type ==

AMD_IP_BLOCK_TYPE_IH))

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct · line 1536

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
+            || (adev->asic_type >= CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type ==
+ AMD_IP_BLOCK_TYPE_PSP))) {

This seems kind of fragile. If we change the order again at some point, it will break. How about we check whether hw_init/resume is done or not on the blocks we care about or move the checks into the callers and only call when we need it?

Hi Alex,

How about split hw_init to hw_init_phase1 and hw_init_phase2 as resume? We loaded fw(call psp_hw_init and start_smu) between phase1 and phase2.

Regards
Rex

Quoted 212 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -0
+               if (adev->powerplay.pp_funcs->load_firmware) {
+                       r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
+                       if (r) {
+                               pr_err("firmware loading failed\n");
+                               return r;
+                       }
+               }
+       }
+       return 0;
+}
 /**
  * amdgpu_device_ip_init - run init for hardware IPs
  *
@@ -1595,6 +1613,9 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                        return r;
                }
                adev->ip_blocks[i].status.hw = true;
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        amdgpu_xgmi_add_device(adev);
@@ -2030,6 +2051,9 @@ static int

amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2051

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                        DRM_INFO("RE-INIT: %s %s\n", block->version->funcs->name,

r?"failed":"succeeded");

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                        if (r)
                                return r;
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2098,6 +2122,9 @@ static int

amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                                          adev->ip_blocks[i].version->funcs->name, r);
                                return r;
                        }
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2134,6 +2161,9 @@ static int

amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)

drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c int smu7_request_smu_load_fw(struct pp_hwmgr

Quoted 128 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                                  adev->ip_blocks[i].version->funcs->name, r);
                        return r;
                }
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -11
index 8439f9a..3d0f277 100644
@@ -4175,20 +4175,9 @@ static void gfx_v8_0_rlc_start(struct
 amdgpu_device *adev)
 
 static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)  {
-       int r;
-
        gfx_v8_0_rlc_stop(adev);
        gfx_v8_0_rlc_reset(adev);
        gfx_v8_0_init_pg(adev);
-
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        gfx_v8_0_rlc_start(adev);
 
        return 0;
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -8
index 0bdde7f..6fb3eda 100644
@@ -788,14 +788,6 @@ static int sdma_v3_0_start(struct amdgpu_device
 *adev)  {
        int r;
 
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        /* disable sdma engine before programing it */
        sdma_v3_0_ctx_switch_enable(adev, false);
        sdma_v3_0_enable(adev, false); diff --git

a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index d552af2..47ac923 100644

drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +0 -20
@@ -89,7 +89,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
        hwmgr_init_default_caps(hwmgr);
        hwmgr_set_user_specify_caps(hwmgr);
        hwmgr->fan_ctrl_is_in_default_mode = true;
-       hwmgr->reload_fw = 1;
        hwmgr_init_workload_prority(hwmgr);
 
        switch (hwmgr->chip_family) {
@@ -209,17 +208,6 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr)  {
        int ret = 0;
 
-       if (!hwmgr || !hwmgr->smumgr_funcs)
-               return -EINVAL;
-
-       if (hwmgr->smumgr_funcs->start_smu) {
-               ret = hwmgr->smumgr_funcs->start_smu(hwmgr);
-               if (ret) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
@@ -301,7 +289,6 @@ int hwmgr_suspend(struct pp_hwmgr *hwmgr)
        if (!hwmgr || !hwmgr->pm_en)
                return 0;
 
-       hwmgr->reload_fw = true;
        phm_disable_smc_firmware_ctf(hwmgr);
        ret = psm_set_boot_states(hwmgr);
        if (ret)
@@ -321,13 +308,6 @@ int hwmgr_resume(struct pp_hwmgr *hwmgr)
        if (!hwmgr)
                return -EINVAL;
 
-       if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) {
-               if (hwmgr->smumgr_funcs->start_smu(hwmgr)) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -1
index 35f2272..e5a60aa 100644
@@ -734,7 +734,6 @@ struct pp_hwmgr {
        void *smu_backend;
        const struct pp_smumgr_func *smumgr_funcs;
        bool is_kicker;
-       bool reload_fw;
 
        enum PP_DAL_POWERLEVEL dal_power_level;
        struct phm_dynamic_state_info dyn_state; diff --git

a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 99b4e4f..3f51d54 100644

drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +0 -0
@@ -343,9 +343,6 @@ int smu7_request_smu_load_fw(struct pp_hwmgr

*hwmgr)

drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c static int smu8_request_smu_load_fw(struct

Quoted 29 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +0 -3
        uint32_t fw_to_load;
        int r = 0;
 
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        if (smu_data->soft_regs_start) @@ -432,10 +429,9 @@ int

smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
smu7_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_LoadUcodes, fw_to_load);

        r = smu7_check_fw_load_finish(hwmgr, fw_to_load);
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +2 -3
-       if (!r) {
-               hwmgr->reload_fw = 0;
+       if (!r)
                return 0;
-       }
+
        pr_err("SMU load firmware failed\n");
 
 failed:
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -0
index abbf2f2..f836d30 100644
@@ -661,9 +661,6 @@ static int smu8_request_smu_load_fw(struct

pp_hwmgr *hwmgr)

Quoted 3 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -0
        uint32_t fw_to_check = 0;
        int ret;
 
Quoted 23 lines

drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c static int smu8_request_smu_load_fw(struct

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -3
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        smu8_smu_populate_firmware_entries(hwmgr);
@@ -719,8 +716,6 @@ static int smu8_request_smu_load_fw(struct

pp_hwmgr *hwmgr)

Quoted 15 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -3
                return ret;
        }
 
-       hwmgr->reload_fw = 0;
-
        return 0;
 }
 
--

1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BYAPR12MB277578DE7CB42DA32FBC190CFBE00-ZGDeBxoHBPmJeBUhB162ZQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#11 lore raw

Re: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Sounds good to me.

Alex

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Zhu, Rex <[email protected]>
Sent: Tuesday, October 9, 2018 9:44 PM
To: Alex Deucher
Cc: amd-gfx list
Subject: RE: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Quoted 44 lines

-----Original Message-----
From: Alex Deucher <[email protected]>
Sent: Wednesday, October 10, 2018 3:28 AM
To: Zhu, Rex <[email protected]>
Cc: amd-gfx list <[email protected]>
Subject: Re: [PATCH 3/5] drm/amdgpu: Extract the function of fw loading out of powerplay

Quoted 9 lines · Rex Zhu

So there is no dependence between gfx/sdma/smu.
and for Vi, after IH hw_init, driver load all the smu/gfx/sdma fw. for AI, fw loading is controlled by PSP, after psp hw init, we call the function to check smu fw version.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c         | 30

++++++++++++++++++++++

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct

Quoted 14 lines
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c              | 11 --------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c             |  8 ------
 drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c        | 20 ---------------
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h          |  1 -
 drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c |  8 ++----
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c |  5 ----
 7 files changed, 32 insertions(+), 51 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 4787571..a6766b3 100644
@@ -1525,6 +1525,24 @@ static int amdgpu_device_ip_early_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct amdgpu_device *adev)

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -0
        return 0;
 }
 
+static int amdgpu_device_fw_loading(struct amdgpu_device *adev,
+uint32_t index) {
+       int r = 0;
+
+       if ((adev->asic_type < CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type ==

AMD_IP_BLOCK_TYPE_IH))

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_early_init(struct · line 1536

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
+            || (adev->asic_type >= CHIP_VEGA10
+            && (adev->ip_blocks[index].version->type ==
+ AMD_IP_BLOCK_TYPE_PSP))) {

This seems kind of fragile. If we change the order again at some point, it will break. How about we check whether hw_init/resume is done or not on the blocks we care about or move the checks into the callers and only call when we need it?

Hi Alex,

How about split hw_init to hw_init_phase1 and hw_init_phase2 as resume? We loaded fw(call psp_hw_init and start_smu) between phase1 and phase2.

Regards
Rex

Quoted 212 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 15 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +10 -0
+               if (adev->powerplay.pp_funcs->load_firmware) {
+                       r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
+                       if (r) {
+                               pr_err("firmware loading failed\n");
+                               return r;
+                       }
+               }
+       }
+       return 0;
+}
 /**
  * amdgpu_device_ip_init - run init for hardware IPs
  *
@@ -1595,6 +1613,9 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                        return r;
                }
                adev->ip_blocks[i].status.hw = true;
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        amdgpu_xgmi_add_device(adev);
@@ -2030,6 +2051,9 @@ static int

amdgpu_device_ip_reinit_early_sriov(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int · line 2051

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                        DRM_INFO("RE-INIT: %s %s\n", block->version->funcs->name,

r?"failed":"succeeded");

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                        if (r)
                                return r;
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2098,6 +2122,9 @@ static int

amdgpu_device_ip_resume_phase1(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                                          adev->ip_blocks[i].version->funcs->name, r);
                                return r;
                        }
+                       r = amdgpu_device_fw_loading(adev, i);
+                       if (r)
+                               return r;
                }
        }
 
@@ -2134,6 +2161,9 @@ static int

amdgpu_device_ip_resume_phase2(struct amdgpu_device *adev)

drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c int smu7_request_smu_load_fw(struct pp_hwmgr

Quoted 128 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
                                  adev->ip_blocks[i].version->funcs->name, r);
                        return r;
                }
+               r = amdgpu_device_fw_loading(adev, i);
+               if (r)
+                       return r;
        }
 
        return 0;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0 -11
index 8439f9a..3d0f277 100644
@@ -4175,20 +4175,9 @@ static void gfx_v8_0_rlc_start(struct
 amdgpu_device *adev)
 
 static int gfx_v8_0_rlc_resume(struct amdgpu_device *adev)  {
-       int r;
-
        gfx_v8_0_rlc_stop(adev);
        gfx_v8_0_rlc_reset(adev);
        gfx_v8_0_init_pg(adev);
-
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        gfx_v8_0_rlc_start(adev);
 
        return 0;
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +0 -8
index 0bdde7f..6fb3eda 100644
@@ -788,14 +788,6 @@ static int sdma_v3_0_start(struct amdgpu_device
 *adev)  {
        int r;
 
-       if (adev->powerplay.pp_funcs->load_firmware) {
-               r = adev->powerplay.pp_funcs->load_firmware(adev-
 powerplay.pp_handle);
-               if (r) {
-                       pr_err("firmware loading failed\n");
-                       return r;
-               }
-       }
-
        /* disable sdma engine before programing it */
        sdma_v3_0_ctx_switch_enable(adev, false);
        sdma_v3_0_enable(adev, false); diff --git

a/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
b/drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c
index d552af2..47ac923 100644

drivers/gpu/drm/amd/powerplay/hwmgr/hwmgr.c +0 -20
@@ -89,7 +89,6 @@ int hwmgr_early_init(struct pp_hwmgr *hwmgr)
        hwmgr_init_default_caps(hwmgr);
        hwmgr_set_user_specify_caps(hwmgr);
        hwmgr->fan_ctrl_is_in_default_mode = true;
-       hwmgr->reload_fw = 1;
        hwmgr_init_workload_prority(hwmgr);
 
        switch (hwmgr->chip_family) {
@@ -209,17 +208,6 @@ int hwmgr_hw_init(struct pp_hwmgr *hwmgr)  {
        int ret = 0;
 
-       if (!hwmgr || !hwmgr->smumgr_funcs)
-               return -EINVAL;
-
-       if (hwmgr->smumgr_funcs->start_smu) {
-               ret = hwmgr->smumgr_funcs->start_smu(hwmgr);
-               if (ret) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
@@ -301,7 +289,6 @@ int hwmgr_suspend(struct pp_hwmgr *hwmgr)
        if (!hwmgr || !hwmgr->pm_en)
                return 0;
 
-       hwmgr->reload_fw = true;
        phm_disable_smc_firmware_ctf(hwmgr);
        ret = psm_set_boot_states(hwmgr);
        if (ret)
@@ -321,13 +308,6 @@ int hwmgr_resume(struct pp_hwmgr *hwmgr)
        if (!hwmgr)
                return -EINVAL;
 
-       if (hwmgr->smumgr_funcs && hwmgr->smumgr_funcs->start_smu) {
-               if (hwmgr->smumgr_funcs->start_smu(hwmgr)) {
-                       pr_err("smc start failed\n");
-                       return -EINVAL;
-               }
-       }
-
        if (!hwmgr->pm_en)
                return 0;
 
drivers/gpu/drm/amd/powerplay/inc/hwmgr.h +0 -1
index 35f2272..e5a60aa 100644
@@ -734,7 +734,6 @@ struct pp_hwmgr {
        void *smu_backend;
        const struct pp_smumgr_func *smumgr_funcs;
        bool is_kicker;
-       bool reload_fw;
 
        enum PP_DAL_POWERLEVEL dal_power_level;
        struct phm_dynamic_state_info dyn_state; diff --git

a/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c index 99b4e4f..3f51d54 100644

drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +0 -0
@@ -343,9 +343,6 @@ int smu7_request_smu_load_fw(struct pp_hwmgr

*hwmgr)

drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c static int smu8_request_smu_load_fw(struct

Quoted 29 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +0 -3
        uint32_t fw_to_load;
        int r = 0;
 
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        if (smu_data->soft_regs_start) @@ -432,10 +429,9 @@ int

smu7_request_smu_load_fw(struct pp_hwmgr *hwmgr)
smu7_send_msg_to_smc_with_parameter(hwmgr,
PPSMC_MSG_LoadUcodes, fw_to_load);

        r = smu7_check_fw_load_finish(hwmgr, fw_to_load);
drivers/gpu/drm/amd/powerplay/smumgr/smu7_smumgr.c +2 -3
-       if (!r) {
-               hwmgr->reload_fw = 0;
+       if (!r)
                return 0;
-       }
+
        pr_err("SMU load firmware failed\n");
 
 failed:
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -0
index abbf2f2..f836d30 100644
@@ -661,9 +661,6 @@ static int smu8_request_smu_load_fw(struct

pp_hwmgr *hwmgr)

Quoted 3 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -0
        uint32_t fw_to_check = 0;
        int ret;
 
Quoted 23 lines

drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c static int smu8_request_smu_load_fw(struct

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -3
-       if (!hwmgr->reload_fw)
-               return 0;
-
        amdgpu_ucode_init_bo(hwmgr->adev);
 
        smu8_smu_populate_firmware_entries(hwmgr);
@@ -719,8 +716,6 @@ static int smu8_request_smu_load_fw(struct

pp_hwmgr *hwmgr)

Quoted 15 lines
drivers/gpu/drm/amd/powerplay/smumgr/smu8_smumgr.c +0 -3
                return ret;
        }
 
-       hwmgr->reload_fw = 0;
-
        return 0;
 }
 
--

1.9.1

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#12 lore raw

PATCH 4/5 drm/amdgpu: Fix unnecessary warning in dmesg

In reply to a message not in the archive

Fix the warning message:
"-1 is not supported on VI"
the -1 is the default fw load type, mean auto.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -1
index f2604ac..e5b13b2 100644
@@ -297,7 +297,7 @@ enum amdgpu_firmware_load_type
 	case CHIP_POLARIS11:
 	case CHIP_POLARIS12:
 	case CHIP_VEGAM:
-		if (load_type != AMDGPU_FW_LOAD_SMU)
+		if (load_type != AMDGPU_FW_LOAD_DIRECT || load_type == AMDGPU_FW_LOAD_PSP)
 			pr_warning("%d is not supported on VI\n", load_type);
 		return AMDGPU_FW_LOAD_SMU;
 	case CHIP_VEGA10:
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1539089023-2360-4-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

#14 lore raw

Re: [PATCH 4/5] drm/amdgpu: Fix unnecessary warning in dmesg

Quoted 14 lines · Rex Zhu

Fix the warning message:
"-1 is not supported on VI"
the -1 is the default fw load type, mean auto.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +0 -0
index f2604ac..e5b13b2 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c enum amdgpu_firmware_load_type · line 300

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -1
@@ -297,7 +297,7 @@ enum amdgpu_firmware_load_type
 	case CHIP_POLARIS11:
 	case CHIP_POLARIS12:
 	case CHIP_VEGAM:
-		if (load_type != AMDGPU_FW_LOAD_SMU)
+		if (load_type != AMDGPU_FW_LOAD_DIRECT || load_type == AMDGPU_FW_LOAD_PSP)

AMDGPU_FW_LOAD_PSP == 2 != AMDGPU_FW_LOAD_DIRECT == 0

I suspect you meant something else here.

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 15af5a1b-ea73-c779-5f30-e6da0192d504-otUistvHUpPR7s880joybQ@public.gmane.org

author
#16 lore raw

RE: [PATCH 4/5] drm/amdgpu: Fix unnecessary warning in dmesg

Quoted 32 lines

-----Original Message-----
From: Michel Dänzer <[email protected]>
Sent: Tuesday, October 9, 2018 9:19 PM
To: Zhu, Rex <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH 4/5] drm/amdgpu: Fix unnecessary warning in dmesg

Review

Quoted 10 lines · Rex Zhu

Fix the warning message:
"-1 is not supported on VI"
the -1 is the default fw load type, mean auto.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c enum amdgpu_firmware_load_type · line 300

Quoted 9 lines

index f2604ac..e5b13b2 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +1 -1
@@ -297,7 +297,7 @@ enum amdgpu_firmware_load_type
 	case CHIP_POLARIS11:
 	case CHIP_POLARIS12:
 	case CHIP_VEGAM:
-		if (load_type != AMDGPU_FW_LOAD_SMU)
+		if (load_type != AMDGPU_FW_LOAD_DIRECT || load_type ==

AMDGPU_FW_LOAD_PSP)

Quoted 3 lines

AMDGPU_FW_LOAD_PSP == 2 != AMDGPU_FW_LOAD_DIRECT == 0

I suspect you meant something else here.

Yes, it should be
- if (load_type != AMDGPU_FW_LOAD_SMU)
+ if (load_type == AMDGPU_FW_LOAD_DIRECT || load_type == AMDGPU_FW_LOAD_PSP)

Typo when split the patches.
Thanks for pointing it out.

Best Regards
Rex

Quoted 4 lines

--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#17 lore raw

PATCH 5/5 drm/amdgpu: Remove the direct fw loading support for sdma2.4

In reply to a message not in the archive

sdma2.4 is only for iceland. For Vi, we don't maintain the direct fw loading.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 42 ----------------------------------
 1 file changed, 42 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -42
index cd781ab..2d4770e 100644
@@ -504,41 +504,6 @@ static int sdma_v2_4_rlc_resume(struct amdgpu_device *adev)
 	return 0;
 }
 
-/**
- * sdma_v2_4_load_microcode - load the sDMA ME ucode
- *
- * @adev: amdgpu_device pointer
- *
- * Loads the sDMA0/1 ucode.
- * Returns 0 for success, -EINVAL if the ucode is not available.
- */
-static int sdma_v2_4_load_microcode(struct amdgpu_device *adev)
-{
-	const struct sdma_firmware_header_v1_0 *hdr;
-	const __le32 *fw_data;
-	u32 fw_size;
-	int i, j;
-
-	/* halt the MEs */
-	sdma_v2_4_enable(adev, false);
-
-	for (i = 0; i < adev->sdma.num_instances; i++) {
-		if (!adev->sdma.instance[i].fw)
-			return -EINVAL;
-		hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data;
-		amdgpu_ucode_print_sdma_hdr(&hdr->header);
-		fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
-		fw_data = (const __le32 *)
-			(adev->sdma.instance[i].fw->data +
-			 le32_to_cpu(hdr->header.ucode_array_offset_bytes));
-		WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0);
-		for (j = 0; j < fw_size; j++)
-			WREG32(mmSDMA0_UCODE_DATA + sdma_offsets[i], le32_to_cpup(fw_data++));
-		WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], adev->sdma.instance[i].fw_version);
-	}
-
-	return 0;
-}
 
 /**
  * sdma_v2_4_start - setup and start the async dma engines
@@ -552,13 +517,6 @@ static int sdma_v2_4_start(struct amdgpu_device *adev)
 {
 	int r;
 
-
-	if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
-		r = sdma_v2_4_load_microcode(adev);
-		if (r)
-			return r;
-	}
-
 	/* halt the engine before programing */
 	sdma_v2_4_enable(adev, false);
 
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1539089023-2360-5-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#19 lore raw

Re: [PATCH 5/5] drm/amdgpu: Remove the direct fw loading support for sdma2.4

Quoted 5 lines · Rex Zhu

sdma2.4 is only for iceland. For Vi, we don't maintain the direct fw loading.

Quoted 67 lines
---
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 42 ----------------------------------
 1 file changed, 42 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +0 -43
index cd781ab..2d4770e 100644
@@ -504,41 +504,6 @@ static int sdma_v2_4_rlc_resume(struct amdgpu_device *adev)
        return 0;
 }
 
-/**
- * sdma_v2_4_load_microcode - load the sDMA ME ucode
- *
- * @adev: amdgpu_device pointer
- *
- * Loads the sDMA0/1 ucode.
- * Returns 0 for success, -EINVAL if the ucode is not available.
- */
-static int sdma_v2_4_load_microcode(struct amdgpu_device *adev)
-{
-       const struct sdma_firmware_header_v1_0 *hdr;
-       const __le32 *fw_data;
-       u32 fw_size;
-       int i, j;
-
-       /* halt the MEs */
-       sdma_v2_4_enable(adev, false);
-
-       for (i = 0; i < adev->sdma.num_instances; i++) {
-               if (!adev->sdma.instance[i].fw)
-                       return -EINVAL;
-               hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data;
-               amdgpu_ucode_print_sdma_hdr(&hdr->header);
-               fw_size = le32_to_cpu(hdr->header.ucode_size_bytes) / 4;
-               fw_data = (const __le32 *)
-                       (adev->sdma.instance[i].fw->data +
-                        le32_to_cpu(hdr->header.ucode_array_offset_bytes));
-               WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], 0);
-               for (j = 0; j < fw_size; j++)
-                       WREG32(mmSDMA0_UCODE_DATA + sdma_offsets[i], le32_to_cpup(fw_data++));
-               WREG32(mmSDMA0_UCODE_ADDR + sdma_offsets[i], adev->sdma.instance[i].fw_version);
-       }
-
-       return 0;
-}
 
 /**
  * sdma_v2_4_start - setup and start the async dma engines
@@ -552,13 +517,6 @@ static int sdma_v2_4_start(struct amdgpu_device *adev)
 {
        int r;
 
-
-       if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT) {
-               r = sdma_v2_4_load_microcode(adev);
-               if (r)
-                       return r;
-       }
-
        /* halt the engine before programing */
        sdma_v2_4_enable(adev, false);
 
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#20 lore raw
In reply to a message not in the archive

Am 09.10.2018 um 14:43 schrieb Rex Zhu:

Quoted 44 lines

1. one is for create/free bo when init/fini
2. one is for fill the bo before fw loading

the ucode bo only need to be created when load driver and free when driver unload.

when resume/reset, driver only need to re-fill the bo if the bo is allocated in vram.

Suggested by Christian.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  3 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c  | 57 +++++++++++++++---------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h  |  3 ++
  3 files changed, 34 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
index 94c92f5..4787571 100644
@@ -1581,6 +1581,8 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
  		}
  	}
 
+	amdgpu_ucode_create_bo(adev); /* create ucode bo when sw_init complete*/
+
  	for (i = 0; i < adev->num_ip_blocks; i++) {
  		if (!adev->ip_blocks[i].status.sw)
  			continue;
@@ -1803,6 +1805,7 @@ static int amdgpu_device_ip_fini(struct amdgpu_device *adev)
  			continue;
 
  		if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
+			amdgpu_ucode_free_bo(adev);
  			amdgpu_free_static_csa(adev);
  			amdgpu_device_wb_fini(adev);
  			amdgpu_device_vram_scratch_fini(adev);
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +0 -0
index adfeb93..7b6b2f4c 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode, · line 427

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +3 -0
@@ -422,32 +422,41 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode,
  	return 0;
  }
 
+void amdgpu_ucode_create_bo(struct amdgpu_device *adev)
+{
+	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT) {

Better use early bailout here, e.g. in this case a return statement.

Apart from that looks good to me,
Christian.

Quoted 82 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +25 -29
+		amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE,
+			amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT,
+			&adev->firmware.fw_buf,
+			&adev->firmware.fw_buf_mc,
+			&adev->firmware.fw_buf_ptr);
+		if (!adev->firmware.fw_buf) {
+			dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n");
+			adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT;
+		} else if (amdgpu_sriov_vf(adev)) {
+			memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
+		}
+	}
+}
+
+void amdgpu_ucode_free_bo(struct amdgpu_device *adev)
+{
+	if (adev->firmware.load_type != AMDGPU_FW_LOAD_DIRECT)
+		amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
+		&adev->firmware.fw_buf_mc,
+		&adev->firmware.fw_buf_ptr);
+}
+
  int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  {
  	uint64_t fw_offset = 0;
-	int i, err;
+	int i;
  	struct amdgpu_firmware_info *ucode = NULL;
  	const struct common_firmware_header *header = NULL;
 
-	if (!adev->firmware.fw_size) {
-		dev_warn(adev->dev, "No ip firmware need to load\n");
+ /* for baremetal, the ucode is allocated in gtt, so don't need to fill the bo when reset/suspend */
+	if (!amdgpu_sriov_vf(adev) && (adev->in_gpu_reset || adev->in_suspend))
  		return 0;
-	}
-
-	if (!adev->in_gpu_reset && !adev->in_suspend) {
-		err = amdgpu_bo_create_kernel(adev, adev->firmware.fw_size, PAGE_SIZE,
-					amdgpu_sriov_vf(adev) ? AMDGPU_GEM_DOMAIN_VRAM : AMDGPU_GEM_DOMAIN_GTT,
-					&adev->firmware.fw_buf,
-					&adev->firmware.fw_buf_mc,
-					&adev->firmware.fw_buf_ptr);
-		if (err) {
-			dev_err(adev->dev, "failed to create kernel buffer for firmware.fw_buf\n");
-			goto failed;
-		}
-	}
-
-	memset(adev->firmware.fw_buf_ptr, 0, adev->firmware.fw_size);
-
  	/*
  	 * if SMU loaded firmware, it needn't add SMC, UVD, and VCE
  	 * ucode info here
@@ -479,12 +488,6 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  		}
  	}
  	return 0;
-
-failed:
-	if (err)
-		adev->firmware.load_type = AMDGPU_FW_LOAD_DIRECT;
-
-	return err;
  }
 
  int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
@@ -503,9 +506,5 @@ int amdgpu_ucode_fini_bo(struct amdgpu_device *adev)
  		}
  	}
 
-	amdgpu_bo_free_kernel(&adev->firmware.fw_buf,
-				&adev->firmware.fw_buf_mc,
-				&adev->firmware.fw_buf_ptr);
-
  	return 0;
  }
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +0 -0
index 8f3f111..4c0e5be 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr, · line 287

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h +3 -0
@@ -279,6 +279,9 @@ bool amdgpu_ucode_hdr_version(union amdgpu_firmware_header *hdr,
  int amdgpu_ucode_init_bo(struct amdgpu_device *adev);
  int amdgpu_ucode_fini_bo(struct amdgpu_device *adev);
 
+void amdgpu_ucode_create_bo(struct amdgpu_device *adev);
+void amdgpu_ucode_free_bo(struct amdgpu_device *adev);
+
  enum amdgpu_firmware_load_type
  amdgpu_ucode_get_load_type(struct amdgpu_device *adev, int load_type);
 

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx