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 B0C3DCAC5B1 for ; Tue, 23 Sep 2025 13:09:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 075CB835CB; Tue, 23 Sep 2025 15:09:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="C3I8YgVH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E41F983510; Tue, 23 Sep 2025 15:09:17 +0200 (CEST) Received: from lelvem-ot02.ext.ti.com (lelvem-ot02.ext.ti.com [198.47.23.235]) (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 1439C834E1 for ; Tue, 23 Sep 2025 15:09:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=anshuld@ti.com Received: from lelvem-sh02.itg.ti.com ([10.180.78.226]) by lelvem-ot02.ext.ti.com (8.15.2/8.15.2) with ESMTP id 58ND9B621480040; Tue, 23 Sep 2025 08:09:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1758632951; bh=Nb5BKfEPXEB5G+AXCD87wYVBU/1vWplJIZ5DLoF4RVM=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=C3I8YgVHSsuwZxDvxYi7ZoR9CZEtL1FohooFf7DcPKml6eepRz8ktSVFNcFdk4ht0 K1zvKHbV8mpW1x7b70XIaisa5VxWQyswRWL4hVTG/ERXpUBNfFhgPg+co+hELLZoPI zcG7/jCm/GXF7bgyZ8uJ9rcgjOoedYNr11rN/iqk= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelvem-sh02.itg.ti.com (8.18.1/8.18.1) with ESMTPS id 58ND9Bv71679957 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA256 bits=128 verify=FAIL); Tue, 23 Sep 2025 08:09:11 -0500 Received: from DFLE204.ent.ti.com (10.64.6.62) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.55; Tue, 23 Sep 2025 08:09:11 -0500 Received: from lelvem-mr05.itg.ti.com (10.180.75.9) by DFLE204.ent.ti.com (10.64.6.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend Transport; Tue, 23 Sep 2025 08:09:11 -0500 Received: from localhost (dhcp-172-24-233-105.dhcp.ti.com [172.24.233.105]) by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 58ND9APY341164; Tue, 23 Sep 2025 08:09:10 -0500 From: Anshul Dalal To: CC: Anshul Dalal , , , , , , , , , , , , Subject: [PATCH v2 4/8] spl: ubi: refactor spl_ubi_load_image for falcon mode Date: Tue, 23 Sep 2025 18:38:56 +0530 Message-ID: <20250923130901.705124-5-anshuld@ti.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250923130901.705124-1-anshuld@ti.com> References: <20250923130901.705124-1-anshuld@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-C2ProcessedOrg: 333ef613-75bf-4e12-a4b1-8e3623f5dcea 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.8 at phobos.denx.de X-Virus-Status: Clean This patch moves the falcon mode handling logic out of spl_ubi_load_image to spl_ubi_load_image_os, this allows for cleaner handling for fallback to U-Boot in case falcon mode fails. Signed-off-by: Anshul Dalal --- common/spl/spl_ubi.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/common/spl/spl_ubi.c b/common/spl/spl_ubi.c index a8d3f43b452..162ec0f2f9b 100644 --- a/common/spl/spl_ubi.c +++ b/common/spl/spl_ubi.c @@ -11,6 +11,32 @@ #include #include +#if CONFIG_IS_ENABLED(OS_BOOT) +int spl_ubi_load_image_os(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, + struct ubispl_info *info) +{ + struct legacy_img_hdr *header; + struct ubispl_load volumes[2]; + int err; + + volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID; + volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR; + volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID; + volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; + + err = ubispl_load_volumes(info, volumes, 2); + if (err) + return err; + + header = (struct legacy_img_hdr *)volumes[0].load_addr; + spl_parse_image_header(spl_image, bootdev, header); + puts("Linux loaded.\n"); + + return 0; +} +#endif + int spl_ubi_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { @@ -46,21 +72,14 @@ int spl_ubi_load_image(struct spl_image_info *spl_image, #if CONFIG_IS_ENABLED(OS_BOOT) if (!spl_start_uboot()) { - volumes[0].vol_id = CONFIG_SPL_UBI_LOAD_KERNEL_ID; - volumes[0].load_addr = (void *)CONFIG_SYS_LOAD_ADDR; - volumes[1].vol_id = CONFIG_SPL_UBI_LOAD_ARGS_ID; - volumes[1].load_addr = (void *)CONFIG_SPL_PAYLOAD_ARGS_ADDR; + ret = spl_ubi_load_image_os(spl_image, bootdev, &info); + if (!ret) + return 0; - ret = ubispl_load_volumes(&info, volumes, 2); - if (!ret) { - header = (struct legacy_img_hdr *)volumes[0].load_addr; - spl_parse_image_header(spl_image, bootdev, header); - puts("Linux loaded.\n"); - goto out; - } puts("Loading Linux failed, falling back to U-Boot.\n"); } #endif + header = spl_get_load_buffer(-sizeof(*header), sizeof(header)); #ifdef CONFIG_SPL_UBI_LOAD_BY_VOLNAME volumes[0].vol_id = -1; -- 2.51.0