From patchwork Mon Jan 2 12:20:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 638428 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp801499pvb; Mon, 2 Jan 2023 04:21:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXuklh4WpyeguDraUnc40vOWdyHuIVanrsj9O25mr/MAoaSJN05cDNSDWV3Hgtv2TaUBvUGY X-Received: by 2002:a05:6808:238e:b0:361:2f47:433 with SMTP id bp14-20020a056808238e00b003612f470433mr24998802oib.27.1672662080010; Mon, 02 Jan 2023 04:21:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672662079; cv=none; d=google.com; s=arc-20160816; b=HMH8kRI0GBjmcnfG6fdkgYdXjfF0Cvp8N6UDyEc0A34n9nX0AfDh8hhNJBGomG6N4u /DWwwSpfLFYdMD9jScBdNp0Ky4YLUWG8xFyfDJ36j/0aB1idhgKK9g8V2wmuB+di33OZ GJKOHalAI+fo6Js71+8O5entFsREVxc53dYrskUOOmoRO9qXvU96D6LW/iV1+WYE3ODA FPvAhxo+PacMMxszhpg4oy+p/ZWSGVfOmBASwZ9AOwxgbmQcsh6XqUZQt2hGTgrCzx/P A14qi60yANc8YT4DiKsygEVsXVAqqCeIZCs+54nX72w4eYwsotclrS93WsxiW/zmorg6 UNuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=vtiu9d74ttQYs1K/jmbp0+DgIp3ljBT3hsyOXFsM6rM=; b=nDgvXEi6bGVCYwsajpGSDH6BFRnMYyq0xypEpoyfcucDy3EeGD4zWtIVbZ9sHb2nSC IIyJ1B5AhIW2RjW2nQAsvzuglfYmbuFKRhKNuSzrJpH4IhfXbROP7EOYwxoYRWFLVPaq kR98R+rm3o42s8It33RsLmZyYbHoVSyy82Zn/rgYX5Z5d1aGFwxhmviUbBwgb5rQcXLh 4un0aNcwJ2j9wwVZUJP+lBgwGqIhMg+uNIPZIlEV6MM1exIKP6N97M2OU0Mj1eU1aOH+ oCrWWdTutuQj+C3VhzajREqx89o3rXXe+UBW5p9y7LR3EZhp6iDO+GQVduI/c1TsPsdO eK0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GbjqPUaS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id z9-20020aca3309000000b00355785aa693si20827677oiz.43.2023.01.02.04.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Jan 2023 04:21:19 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GbjqPUaS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 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 Reviewed-by: Fabio Estevam --- 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)) {