From patchwork Sun Dec 8 00:21:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 848263 Delivered-To: patch@linaro.org Received: by 2002:a5d:50c2:0:b0:385:e875:8a9e with SMTP id f2csp1467504wrt; Sat, 7 Dec 2024 16:21:28 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUvpj0v8ttEGABXzcSvJXtA79QPttb7vwEuCLYpBwCeydnFJgT2kZMNY7rWo0b4PvFjeScuuA==@linaro.org X-Google-Smtp-Source: AGHT+IGiGINxjqOpshCzSWL3ueVs+fMpcZLq78z6BBwTRqtxf8NuDXOGyeqoVYwUKBHVI4x9weMV X-Received: by 2002:a17:906:314c:b0:aa6:6c46:7ca1 with SMTP id a640c23a62f3a-aa66c467ee9mr154475866b.10.1733617288510; Sat, 07 Dec 2024 16:21:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733617288; cv=none; d=google.com; s=arc-20240605; b=OjotAfRr2uKP2Aaj500s1YXk1em7EbplZ1f3lD0Gkj9dBlQ52j5l4RLFc2V4J5mIBr L8f6tkK2LOcQ0DmcMnPUTscQ72ciKYuaXbdRXWaGIrxL+ID7MZWmVuBEoufCqDL1m2aA r32JwMkt8brOWGzlQyXZ4Ate4JOYL7e8OS4EQZ0lHknK7lIRMAbGVHLFDkn79s3tfxaJ Rgs9xhp5CWzNaRqR/982CmiqY83fR/geddsNm/czXPxYu/dRRLqZ09KlTePBQwnFQfYt ppvjOdceG/Ll5EWA0amk9EknySTT46g6H0/IxuZmK7BdfSlgMvfUWp7MouYwCSkJXX4O M8OA== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=jiCmhmcXsthYp0scSZafimf3HBulTX/uWaZSdo1OnxQ=; fh=SPsKHYKv0b6J89o0oXJThyV1nqvhurJFdhGYafBfOAQ=; b=AvZeezvWQXT6pCFXBg0TrYHRnXtV483kKpbvXVRlpcYMdL50rDpkLwDTfYgKKMG6rs GVu6uvDJnPxLv/SFBopoYwafsmdAGMAyDWHePsYGZxkY4hiqHCxRduVE+kYIzyCg3BHM s9l1UX2K2hrXdBwW88xf1rSddvWbGJXMEv7q3gjhtuTeDimsK6V1i+mX2STP25l/50ZL F5J4AbqqmKMMQ3sG1n0bMpjaRvJe/GaiP/1zxw9M3/3vnFjtzuSixWP1a14wz0vqZ+py DVrBl3qn6drGWpMiGdNmBO/Btk0Sbdl3EeL0pUsttSCeOcL2SUfvO3NFOvzNuv9/WL5p B14Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ChDzB96v; 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 a640c23a62f3a-aa6761d0a2esi29517766b.747.2024.12.07.16.21.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:21:28 -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=ChDzB96v; 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 A64168941D; Sun, 8 Dec 2024 01:21:27 +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="ChDzB96v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD426893EC; Sun, 8 Dec 2024 01:21:26 +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=ham autolearn_force=no version=3.4.2 Received: from mail-ot1-x334.google.com (mail-ot1-x334.google.com [IPv6:2607:f8b0:4864:20::334]) (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 7A62D893D1 for ; Sun, 8 Dec 2024 01:21:24 +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-ot1-x334.google.com with SMTP id 46e09a7af769-71ddeb7f85eso132770a34.0 for ; Sat, 07 Dec 2024 16:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733617283; x=1734222083; darn=lists.denx.de; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jiCmhmcXsthYp0scSZafimf3HBulTX/uWaZSdo1OnxQ=; b=ChDzB96vMh7pjmyBvXJm/RPCQwDTJA7Jof9xbO/BI5WuKhTaHEDbVuUIGyIVpajC62 3PhSyuUdN7QGcjWr3MMmGiD1C5EE8z17toVNEyGyuFJ8VyXyrswHl9A9B3m1szMbk74I jBuoLsgGeYForKVDwT9+t5OQHmwPSw05R/u4I4r2M4CGAnrRsHSeCeniSpSXnXVEMseS THPhbEotVRBI5QGOpkZZW5XTnEAdMMpRNNs3M3MTEOfI4FEb10Fg1zGOQ/0gMLq6S9N5 mYpQzPe3ypW04dfxOsKolZ3zTCKt4eE0gf1HfLY9zWqtKDjVUX0LW7f589zbpHhy5cRM aEsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733617283; x=1734222083; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jiCmhmcXsthYp0scSZafimf3HBulTX/uWaZSdo1OnxQ=; b=df/NHaXCz70p65NuBUiQ2GVnjBm5Pr/nr37nwiCmf6KtmT2a4SAIUuJdej7aIvkKtH oDAlJUUS4bFFuK4CmyZDcntAiwYWphXmMZKEJCCkYMHe40ZklsWglISAx2Ppi3kXWZmC fyP0yTsOnWsqhLmdOxlqCDtxgpNqJnxFXjJZHXgYSRPPopAIs9uH+5k+VbRJ/z1BNre1 85HKcVawS/+8udiqPxhVUuaB6QYY7cDif7LP4fj9X9tiYdEYukHq00V6LuobL9r9ITUY PgMuoKqjw/I7kPleEj9R/fo7zEfe3wTbrN435ZgLD63MzeGhOwpIqkNW3/SPYtVpgBgA Vwiw== X-Forwarded-Encrypted: i=1; AJvYcCXtYUG5oYw4B/o/AlHK9qFwI3aLsia5QJMSPu4C/J9RtM91Nil465l/z/aOaza/gWwrKVZDj+0=@lists.denx.de X-Gm-Message-State: AOJu0Yy13+p4cRXIUCAb6eOJ31dm7hNVq+ys1Q16opmHVtAHbYyMQzhi 7KZtFqgeg5NbtGwvVRmO+bzLoydGri7Rx145CdvbSytJf6B0aJgQOzX4cZoLJKg= X-Gm-Gg: ASbGncsoSDQaLK9J83R4GCI+8uV4jijRhlFPEjeyHPZaq+uHGjkO9dis/+2nuQKPZGs 9fHrTV82gokH46e6O9q3CAgPGKyrZuIPMJoeUcoSCTomnXIFWOGMXXtz9ABUPVFdw0tzf2vlw9D TLyr2GVSRx2U7PFTu540S32XhzvD6TAgk2WGpuSZTqjn/5xRlxDJxeNerAM53rimIfHZslUv2rJ AHXYnYKIs10I8CqkNhV+X+jNpgZbKeJErlfCrsp/Nb4k75K0pbe9pw= X-Received: by 2002:a05:6830:6112:b0:718:18d6:a447 with SMTP id 46e09a7af769-71dcf544b83mr4126581a34.24.1733617283139; Sat, 07 Dec 2024 16:21:23 -0800 (PST) Received: from localhost ([136.62.192.75]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-5f27930470fsm1454491eaf.27.2024.12.07.16.21.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Dec 2024 16:21:22 -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 0/6] lmb: Fix reserving the same region multiple times Date: Sat, 7 Dec 2024 18:21:15 -0600 Message-Id: <20241208002121.31887-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.39.5 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 Since commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE") the lmb_add_region_flags() returns -1 when the caller tries to add the already existing region with !LMB_NONE flags (it was returning 0 before that patch). That causes boot_fdt_reserve_region() function to print erroneous error messages when it's called consequently more than one time. Make lmb_add_region_flags() return -EEXIST when the already added region with !LMB_NONE flags is being added, and then check that error code in boot_fdt_reserve_region() to avoid printing the misleading error messages. I didn't want to change lmb_add_region_flags() behavior back to always returning 0 on attempts to add already existing regions with !LMB_NONE flags, as the unit tests in test/lib/lmb.c would break, and also commit 1d9aa4a283da ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE") specifically states that behavior is expected and required for efi_allocate_pages() calls with type=EFI_ALLOCATE_ADDRESS. All unit tests pass in sandbox U-Boot, with a small test modification in [PATCH 2/6]. I also made a bit of LMB cleanups in this series, while at it. Only [PATCH 6/6] introduces an actual functional change. Sam Protsenko (6): lmb: Fix flags data type in lmb_add_region_flags() lmb: Return -EEXIST in lmb_add_region_flags() if region already added lmb: Make const flag_str[] in lmb_print_region_flags() more const lmb: Improve coding style lmb: Improve kernel-doc comments boot: fdt: Handle already reserved memory in boot_fdt_reserve_region() boot/image-fdt.c | 2 +- include/lmb.h | 125 ++++++++++++++++++++++++++++------------------- lib/lmb.c | 105 +++++++++++++-------------------------- test/lib/lmb.c | 2 +- 4 files changed, 109 insertions(+), 125 deletions(-)