Skip to contentSkip to conversation

ddr: imx: Save the FW loading if it hasn't changed

PATCH In review Shawn Guo 2 participants 2 messages Jan 2, 2023 Arm i.MX and Layerscape

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH 1/1 ddr: imx: Save the FW loading if it hasn't changed

From: Shawn Guo <[email protected]>

Function ddr_load_train_firmware() is called 4 times in a loop by ddr_cfg_phy(). The first 3 calls are all '1D' type and just loading the same FWs. Let's add a type check and save 2 of them. This helps to reduce DDRPHY training time from 269 ms down to 212 ms, and thus speed up boot time ~ 50 ms.

---
 drivers/ddr/imx/phy/helper.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/ddr/imx/phy/helper.c +7 -0
index e9e0294f87d3..508e1f0de34f 100644
@@ -49,6 +49,13 @@ void ddr_load_train_firmware(enum fw_type type)
 	unsigned long imem_start = (unsigned long)&_end + fw_offset;
 	unsigned long dmem_start;
 	unsigned long imem_len = IMEM_LEN, dmem_len = DMEM_LEN;
+	static enum fw_type last_type = -1;
+
+	/* If FW doesn't change, we can save the loading. */
+	if (last_type == type)
+		return;
+
+	last_type = type;
 
 #ifdef CONFIG_SPL_OF_CONTROL
 	if (gd->fdt_blob && !fdt_check_header(gd->fdt_blob)) {
Signature · 1 line
2.17.1
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Shawn Guo

From: Shawn Guo <[email protected]>

Function ddr_load_train_firmware() is called 4 times in a loop by ddr_cfg_phy(). The first 3 calls are all '1D' type and just loading the same FWs. Let's add a type check and save 2 of them. This helps to reduce DDRPHY training time from 269 ms down to 212 ms, and thus speed up boot time ~ 50 ms.