Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA341C3DA7A for ; Mon, 2 Jan 2023 12:21:18 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2044185355; Mon, 2 Jan 2023 13:21:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="GbjqPUaS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 43046854D0; Mon, 2 Jan 2023 13:21:14 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8ED0484F66 for ; Mon, 2 Jan 2023 13:21:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=shawnguo@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AC0EA60F63; Mon, 2 Jan 2023 12:21:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA792C433D2; Mon, 2 Jan 2023 12:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672662069; bh=+PJzqf4YrY9VeXjvASwg3yW/xcqWi1cJp6/OVWJQuiM=; h=From:To:Cc:Subject:Date:From; b=GbjqPUaSpDj0uoMkRNF2mUDgynygr2X9p9dtxsSVMKht/E8PRG1lS5b8a1nijZDZV +PlndIDzEVM+ejLYKAW6J0LGw794gaj902CfvUQ6mFRj0Qwqs4bTwU5jCuUeJ5ntQu 2YKPRJZnWyt8hK9Q6vCj8Wil3A1No5tbospgxS7F4Cxoh+sdxh5xljE9UkBKguWysh WzIFz9XWivmyCv/jKBJYthpZdFq4AXefXNxI33eZEj7kNCEB9mUC8hIwD0RZgdl4+w 86QIsotPLeUZGiVu378qSzaVNG26ZOabicjHSJ52TFUc0ay401ATyvP2vUFpvlOrV6 BEG1EbRcRtcEg== From: Shawn Guo To: u-boot@lists.denx.de Cc: Alper Nebi Yasak , Peng Fan , Ye Li , Loic Poulain , Shawn Guo Subject: [PATCH] ddr: imx: Save the FW loading if it hasn't changed Date: Mon, 2 Jan 2023 20:20:34 +0800 Message-Id: <20230102122034.32686-1-shawnguo@kernel.org> X-Mailer: git-send-email 2.17.1 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean From: Shawn Guo 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. Signed-off-by: Shawn Guo --- drivers/ddr/imx/phy/helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/ddr/imx/phy/helper.c b/drivers/ddr/imx/phy/helper.c index e9e0294f87d3..508e1f0de34f 100644 --- a/drivers/ddr/imx/phy/helper.c +++ b/drivers/ddr/imx/phy/helper.c @@ -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)) { -- 2.17.1