From patchwork Sun Dec 8 00:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 848269 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1467722wrt; Sat, 7 Dec 2024 16:22:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXTFcuBKC8Q9dvyR95/8vCXNiPkJF84gqR5i4Zt8gO6R5X1Cd7efN9QUNfhUq3iT5T5Dv89PQ==@linaro.org X-Google-Smtp-Source: AGHT+IE1En6uSxb8WUnvJF1eEyQmYki8Ycm9MNfrnu5QEiutsVV+nEuUsT/BT7jCPg9fXtdXq3a2 X-Received: by 2002:a05:6402:3205:b0:5d0:b2c8:8d04 with SMTP id 4fb4d7f45d1cf-5d3be6e629dmr9168701a12.18.1733617340706; Sat, 07 Dec 2024 16:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733617340; cv=none; d=google.com; s=arc-20240605; b=BWq6R5oqUULUqHvhkjbe1tbXUyZPlxYR0pnAJYhNZrnsScDzIcTYzZZpPp9P+/BfmC /DDVTmPCmMJp8iXqUw0gtIvstRGapZ3kyflqPi9lxPqigEb7Cx1oAddhVMOkgMd6jkvu YkfykFdHKyssWmi4kHAGm1o9HNE6t3l5WT3AIZvIBlsfd+MqHZN/oOqpZ2LYBKaIr8GA ls02RJXc1CjVELFIuu+jNyZM48x6ayLHgu3SM3eyNIoRa2P4dCVbmr965e54zN386MlY MerKyJSlBFA1reFhssS5ASE9B/78vGTRdiMhXrFWgnmgGl2SGfScJU8PhnlAsZUP1RD7 bVGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SCeNms7zpNG0jTcbTNzWVxUF1LXhhvIVR0PAeT2Txe8=; fh=lLMxwtKpFWYwGS3WwGnGI8GgAJ7/hnvDiCNdcYSxi30=; b=FwTM48yjJkdsjrVf/BnTTkODgEraShqIXQUwpLwI6rcCH0nX45ENLRVTJgcUBaGFXk NO4q+EkmbAwHfxO14puLx+5J6GpYdDYCnXZ7+IPXeaWg/Kd/RmPQoXOGPLH1YBYVyYbC jTp4aZDb6vlhCVb+yz4t58zG7dNg2Ku1I2pKbQz06fpTg+xqFhNffbDudtOqhPjHcaqb WPWX48KkPIiV0syiKHuqNEl00tCxxyEhs5z1hbYQX0N8gmS3/qnmIw9JtLm7i6fcLKUU QZay8Uo2VSxzVul/HJuktAVzqlPXIf5raGOyQP+EeOeSLBanRhQ8wIHqMI+S5ORA7VPQ DKGg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UkzV+egO; 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=linaro.org; dara=neutral header.i=@linaro.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 4fb4d7f45d1cf-5d14b6078a5si4601266a12.71.2024.12.07.16.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:22:20 -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=@linaro.org header.s=google header.b=UkzV+egO; 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=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5192893EC; Sun, 8 Dec 2024 01:21:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.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=linaro.org header.i=@linaro.org header.b="UkzV+egO"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A8D59893D4; Sun, 8 Dec 2024 01:21:36 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) (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 E488489477 for ; Sun, 8 Dec 2024 01:21:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=semen.protsenko@linaro.org Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3eb38f8a178so237207b6e.0 for ; Sat, 07 Dec 2024 16:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733617290; x=1734222090; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SCeNms7zpNG0jTcbTNzWVxUF1LXhhvIVR0PAeT2Txe8=; b=UkzV+egO1Wvd9INkNKvo9OJeMY9CWPkczOmv/7DI9jXB/7ZxyP2kuDs42KBhfVgCmw igYosOicjxpV+9H+ondyMTwLgduH8ZrP6rw/FuRyhtZvjjqe1olgxyoOhS18KqNYbDnM WdrsrnflW7bG/jD4imJec+QF1/rfw3uFt3A1PA4eM6JcFLBpQGUOXldr3c9WShXKyLoW 3qh/y6ScSSI1FAOqgRpgcIft1CjaxsLM7LVeUl0CXvaX/PZD9nQJY+OLKxIwKGc2JE+o RuSf2tOMOIwI9nJVLpuW31Jp5yDTZXAJ0uNs5PDHrvsdqXeHTHZJPetWip5BtCUk2Kps sJDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733617290; x=1734222090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SCeNms7zpNG0jTcbTNzWVxUF1LXhhvIVR0PAeT2Txe8=; b=KCGRO+hbySDj12NuvBuLIXyOX91F6AwfvQTKnROjaznxHXqSSCjxiYk6HvcOXCEVIu qrSy45y85sN5fJxGHZ3YhZ/aERnPsWm1cKPYfynwSnSxOgW0arQXen09KlJ4+SvU9mxu jWd8a7FaIsnSDPX3pw8N7ho3aWl2gqNXc1pbjHaXcHPPROOEO1z9aimzrSzD+jBakP3n PGS9rodwh01KtI090r9e9sjCfLddK+8+Z+v/pRiN/t6EGJU/kS9TN3a+YgEnWYgfpWd4 vDcy9xBAIy94Uoefu6jt/rWBNLRj58oMB78mFX9N2C1caa0a1DGvghgF9O4wunqPnmhu N/lA== X-Forwarded-Encrypted: i=1; AJvYcCWp1ncinWivaTxXzE02rTken7XWznH9+lI4u6Po6CfNbC7TkTr9w8kAYG8MJZHPCIJCiqRpIEE=@lists.denx.de X-Gm-Message-State: AOJu0YxrpICFCKOek+rAqDXej5WCHszceybkKG/VrMXtDikJaMUi5MWa SpLQqLpE91sM5Musmtv+MtyvZeDAp8OeDcaYB5dSEkajbE9RzuYIUe3uQHwip1w= X-Gm-Gg: ASbGncvpAD6ZmFpU7LU2OeVaOM23vSqWZOMnIYJLGulpMqstebzqgWyuUkrZG3L7jhX I36mVLbGvD0lGI4JOOClu699mfRE+z32P1oafGtkynVwsK0jhn69TWX0d8n8CcgDBF4sboYye4j iZr1YTtKYHv2AsYyr7KSwNXl1IDPUw1zvYDzSkxyz6Fky5xNheXHrwHrUxTK9UX/7fXE7IQqIaW UM5OPBpa4aTaEN+mrGCh5/DnzV5LTyeYcpvmVoJunz6DzY+YS+S3Jk= X-Received: by 2002:a05:6808:f13:b0:3ea:6a8b:a40f with SMTP id 5614622812f47-3eb19d0e1b7mr3432623b6e.25.1733617290703; Sat, 07 Dec 2024 16:21:30 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71dc493b1e3sm1547118a34.1.2024.12.07.16.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:21:30 -0800 (PST) From: Sam Protsenko To: Tom Rini Cc: Ilias Apalodimas , Sughosh Ganu , Heinrich Schuchardt , Simon Glass , Caleb Connolly , Marek Vasut , Laurent Pinchart , Patrick Delaunay , u-boot@lists.denx.de Subject: [PATCH 6/6] boot: fdt: Handle already reserved memory in boot_fdt_reserve_region() Date: Sat, 7 Dec 2024 18:21:21 -0600 Message-Id: <20241208002121.31887-7-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241208002121.31887-1-semen.protsenko@linaro.org> References: <20241208002121.31887-1-semen.protsenko@linaro.org> MIME-Version: 1.0 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 The boot_fdt_add_mem_rsv_regions() function can be called twice, e.g. first time during the board init (as a part of LMB init), and then when booting the OS with 'booti' command: lmb_add_region_flags lmb_reserve_flags boot_fdt_reserve_region boot_fdt_add_mem_rsv_regions ^ | +-----------------------+ | (1) | (2) lmb_reserve_common image_setup_linux lmb_init ... initr_lmb do_booti board_init_r 'booti' That consequently leads to the attempt of reserving the same memory areas (described in the 'reserved-memory' dts node) in LMB. The lmb_add_region_flags() returns -EEXIST error code in such cases, but boot_fdt_reserve_region() handles all negative error codes as a failure to reserve fdt memory region, printing corresponding error messages, which are essentially harmless, but misleading. For example, this is the output of 'booti' command on E850-96 board: => booti $loadaddr - $fdtaddr ... ERROR: reserving fdt memory region failed (addr=bab00000 size=5500000 flags=2) ERROR: reserving fdt memory region failed (addr=f0000000 size=200000 flags=4) ... Starting kernel ... The mentioned false positive error messages are observed starting with commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE"), which removes the check for the already added memory regions in lmb_add_region_flags(), making it return -1 for !LMB_NONE cases. Another commit 827dee587b75 ("fdt: lmb: add reserved regions as no-overwrite") changes flags used for reserving memory in boot_fdt_add_mem_rsv_regions() from LMB_NONE to LMB_NOOVERWRITE. So together with the patch mentioned earlier, it makes lmb_add_region_flags() return -1 when called from boot_fdt_reserve_region(). Since then, the different patch was implemented, adding the check back and returning -EEXIST error code in described cases, which is: lmb: Return -EEXIST in lmb_add_region_flags() if region already added Handle -EEXIST error code as a normal (successful) case in lmb_reserve_flags() and don't print any messages. Fixes: 1d9aa4a283da ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE") Signed-off-by: Sam Protsenko Reviewed-by: Ilias Apalodimas --- boot/image-fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/image-fdt.c b/boot/image-fdt.c index 3d5b6f9e2dc7..73c43c30684f 100644 --- a/boot/image-fdt.c +++ b/boot/image-fdt.c @@ -77,7 +77,7 @@ static void boot_fdt_reserve_region(u64 addr, u64 size, enum lmb_flags flags) debug(" reserving fdt memory region: addr=%llx size=%llx flags=%x\n", (unsigned long long)addr, (unsigned long long)size, flags); - } else { + } else if (ret != -EEXIST) { puts("ERROR: reserving fdt memory region failed "); printf("(addr=%llx size=%llx flags=%x)\n", (unsigned long long)addr,