From mboxrd@z Thu Jan 1 00:00:00 1970 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 53BE2C004D4 for ; Thu, 19 Jan 2023 08:39:01 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D074B85670; Thu, 19 Jan 2023 09:38:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.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=collabora.com header.i=@collabora.com header.b="GwVcyuaJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8C9285656; Thu, 19 Jan 2023 09:38:28 +0100 (CET) Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1C53A8565F for ; Thu, 19 Jan 2023 09:38:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjoerd@collabora.com Received: from beast.luon.net (unknown [IPv6:2a10:3781:2531:0:26cc:6c0f:ebfb:d967]) (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) (Authenticated sender: sjoerd) by madras.collabora.co.uk (Postfix) with ESMTPSA id AA1E4660086B; Thu, 19 Jan 2023 08:38:25 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1674117505; bh=3U/LJnQZhzBlzepATl92N4Z4+dF5YyBGDNmN1DM/xlA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GwVcyuaJZu0yDeSouPVJRqFSB9+8nJUmLvd3ezXWV/2NURoKVNf/ZuEqKWC89e7Vz jpblcdxWhZb567IySel1eUZUDxY5tIGCLf527augjYRA9ojMKlchQJT9vz7o6NAofR RObdXNBXt6ZeZv/HwTyiMU+uttZ6LdKYu3rrM8EQojPsuR/gkaJVgsqNhQ6F31pDv4 stSU8qAsVKr/5bCxHosZY72gBH3QS5y5qzo3ia93u3hs6fn1THMIDNxu0JtUcuU16F URLwxrPH/DTf4PA7lhfrQuSIliMaI+eE/wNFlcW7qQEFkgxurkdeejf8+9Y0/NKUZv 6lyXC8Y6JAqxw== Received: by beast.luon.net (Postfix, from userid 1000) id 7356861ACB11; Thu, 19 Jan 2023 09:38:23 +0100 (CET) From: Sjoerd Simons To: u-boot@lists.denx.de Cc: Ashok Reddy Soma , Heinrich Schuchardt , Michal Simek , Patrice Chotard Subject: [PATCH 3/3] lmb: Treat a region which is a subset as equal Date: Thu, 19 Jan 2023 09:38:19 +0100 Message-Id: <20230119083820.2656710-4-sjoerd@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230119083820.2656710-1-sjoerd@collabora.com> References: <20230119083820.2656710-1-sjoerd@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 In various cases logical memory blocks are coalesced; As a result doing a strict check whether memory blocks are the same doesn't necessarily work as a previous addition of a given block might have been merged into a bigger block. Fix this by considering a block is already registered if it's a pure subset of one of the existing blocks. Signed-off-by: Sjoerd Simons --- lib/lmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lmb.c b/lib/lmb.c index f447c639a60..b09a043f4c2 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -248,7 +248,7 @@ static long lmb_add_region_flags(struct lmb_region *rgn, phys_addr_t base, phys_size_t rgnsize = rgn->region[i].size; phys_size_t rgnflags = rgn->region[i].flags; - if (rgnbase == base && rgnsize == size) { + if (rgnbase <= base && rgnbase + rgnsize >= base + size) { if (flags == rgnflags) /* Already have this region, so we're done */ return 0; -- 2.39.0