From patchwork Wed Jan 20 16:46:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alex G." X-Patchwork-Id: 1429327 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=FcwvZNJi; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DLWfg3DF4z9sT6 for ; Thu, 21 Jan 2021 03:47:55 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 22BD1829BF; Wed, 20 Jan 2021 17:47:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="FcwvZNJi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DE012827E3; Wed, 20 Jan 2021 17:47:10 +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.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CDC6682831 for ; Wed, 20 Jan 2021 17:47:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mr.nuke.me@gmail.com Received: by mail-ot1-x32f.google.com with SMTP id f6so14745428ots.9 for ; Wed, 20 Jan 2021 08:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YUEwleR0vkxMJnqoDUH17QCm28dS2ovNhEBNBBL/AGI=; b=FcwvZNJiCQNnI1DaZa7ljF0zymnmYTVBYnRBwyo8WKAwYbwEft+gadXEcuZMoQFMSs KoHHgHPsZUkQEY2GWxcy+GyUdpR4dTXBn/cxcrvalfRvCAY4HdPicZ8EqnvVFz578+ye TW0O4DR+/CspZr5EnTqQkdy9MqvGj9Tyxd5SyuX+4FtdesaeOuSaEjrkpmLtTbe71mv7 UdH6G6/Y3E/u6e7hzotntof3smPZUZxtEUIYsGrF2hjYxA+mecWGlS1wnSe185UMwyIi nl4E/ocVyMvtrUn+LyW2MwLIbpWL2g4c2VzmzznqrupKlkbtNmyl6BOaHqgw21mAcHrz mpOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YUEwleR0vkxMJnqoDUH17QCm28dS2ovNhEBNBBL/AGI=; b=Cd98JToes2qtrmXbSexY+8hz+7oP3UphWyrvsYrm3QT7a6QJ/8ePqlKa1RZTVYTkwN 92xhdbgwDbULaHnAEFJjAH1pjDVI+KsqeSbNJPFvQiqQHoEDP6rvh2aPc7GrPXTIpfwQ hvG3Hg9ylsiSY3zx4edKV+Pw+aZ/5rIJixTFW07mMkz/YFGfZuUmtParG8P7UnwAcPf1 z3wqaFUxO8DA90uAhSGtdlD7V96TqA9rNw7nVgC895QgezSAHc9qVk9BC8GdLB18amyE T1zya+XpOHxZ4IXXY/jKxxH/oo647w9AwbB3yXRG2dfo8XgA8pZmO6DCei3jk56psGm5 n9Qg== X-Gm-Message-State: AOAM531zU086z6+yBAq1SJclL605XzvGBm2ClctMOhTzrDgCO7DEN9jo EHzzlQ4qXyRPaDeEair9lbDKwz34XuQ= X-Google-Smtp-Source: ABdhPJwU8mJHXyJEj618oH06QjBt5tmtlmWit1DHj0QV8OFeMSQJmpYUy/QZoFEwudtn+sQVOlamGA== X-Received: by 2002:a9d:20e9:: with SMTP id x96mr2648846ota.193.1611161223274; Wed, 20 Jan 2021 08:47:03 -0800 (PST) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id i9sm462972oii.34.2021.01.20.08.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 08:47:02 -0800 (PST) From: Alexandru Gagniuc To: u-boot@lists.denx.de Cc: Alexandru Gagniuc , trini@konsulko.com, marex@denx.de, sjg@chromium.org Subject: [PATCH v4 5/8] spl: fit: Only look up FIT configuration node once Date: Wed, 20 Jan 2021 10:46:53 -0600 Message-Id: <20210120164656.1396639-6-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210120164656.1396639-1-mr.nuke.me@gmail.com> References: <20210120164656.1396639-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.3 at phobos.denx.de X-Virus-Status: Clean The configuration node a sub node under "/configurations", which describes the components to load from "/images". We only need to locate this node once. However, for each component, spl_fit_get_image_name() would parse the FIT image, looking for the correct node. Such work duplication is not necessary. Instead, once the node is found, cache it, and re-use it. Signed-off-by: Alexandru Gagniuc Reviewed-by: Simon Glass --- common/spl/spl_fit.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index a0bb3f7ad6..a8c54e21d0 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -30,6 +30,7 @@ struct spl_fit_info { const void *fit; /* Pointer to a valid FIT blob */ size_t ext_data_offset; /* Offset to FIT external data (end of FIT) */ int images_node; /* FDT offset to "/images" node */ + int conf_node; /* FDT offset to selected configuration node */ }; __weak void board_spl_fit_post_load(const void *fit) @@ -83,15 +84,10 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx, struct udevice *sysinfo; const char *name, *str; __maybe_unused int node; - int conf_node; int len, i; bool found = true; - conf_node = fit_find_config_node(ctx->fit); - if (conf_node < 0) - return conf_node; - - name = fdt_getprop(ctx->fit, conf_node, type, &len); + name = fdt_getprop(ctx->fit, ctx->conf_node, type, &len); if (!name) { debug("cannot find property '%s': %d\n", type, len); return -EINVAL; @@ -550,12 +546,15 @@ static int spl_simple_fit_read(struct spl_fit_info *ctx, static int spl_simple_fit_parse(struct spl_fit_info *ctx) { - if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) { - int conf_offset = fit_find_config_node(ctx->fit); + /* Find the correct subnode under "/configurations" */ + ctx->conf_node = fit_find_config_node(ctx->fit); + if (ctx->conf_node < 0) + return -EINVAL; + if (IS_ENABLED(CONFIG_SPL_FIT_SIGNATURE)) { printf("## Checking hash(es) for config %s ... ", - fit_get_name(ctx->fit, conf_offset, NULL)); - if (fit_config_verify(ctx->fit, conf_offset)) + fit_get_name(ctx->fit, ctx->conf_node, NULL)); + if (fit_config_verify(ctx->fit, ctx->conf_node)) return -EPERM; puts("OK\n"); }