{"id":2225277,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2225277/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20260420192520.1444749-6-rs@ti.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/1.2/projects/18/?format=json","name":"U-Boot","link_name":"uboot","list_id":"u-boot.lists.denx.de","list_email":"u-boot@lists.denx.de","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260420192520.1444749-6-rs@ti.com>","list_archive_url":null,"date":"2026-04-20T19:25:19","name":"[PATCHv4,5/6] efi_mem_sort: use list_for_each_entry_safe instead","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d1e9a0e147512dc6b3ae31d8675b3ce923cce1d2","submitter":{"id":88727,"url":"http://patchwork.ozlabs.org/api/1.2/people/88727/?format=json","name":"Randolph Sapp","email":"rs@ti.com"},"delegate":{"id":68728,"url":"http://patchwork.ozlabs.org/api/1.2/users/68728/?format=json","username":"xypron","first_name":"Heinrich","last_name":"Schuchardt","email":"xypron.glpk@gmx.de"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20260420192520.1444749-6-rs@ti.com/mbox/","series":[{"id":500668,"url":"http://patchwork.ozlabs.org/api/1.2/series/500668/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/list/?series=500668","date":"2026-04-20T19:25:18","name":"various memory related fixups","version":1,"mbox":"http://patchwork.ozlabs.org/series/500668/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2225277/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2225277/checks/","tags":{},"related":[],"headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256\n header.s=selector1 header.b=SX8gQDR7;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de\n (client-ip=85.214.62.61; helo=phobos.denx.de;\n envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org)","phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com","phobos.denx.de;\n spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de","phobos.denx.de;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=ti.com header.i=@ti.com header.b=\"SX8gQDR7\";\n\tdkim-atps=neutral","phobos.denx.de;\n dmarc=pass (p=quarantine dis=none) header.from=ti.com","phobos.denx.de; spf=pass smtp.mailfrom=rs@ti.com"],"Received":["from phobos.denx.de (phobos.denx.de [85.214.62.61])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fzwSs5XyTz1yHB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 05:26:05 +1000 (AEST)","from h2850616.stratoserver.net (localhost [IPv6:::1])\n\tby phobos.denx.de (Postfix) with ESMTP id 7B1DD8439E;\n\tMon, 20 Apr 2026 21:25:36 +0200 (CEST)","by phobos.denx.de (Postfix, from userid 109)\n id C087B8435B; Mon, 20 Apr 2026 21:25:33 +0200 (CEST)","from BYAPR05CU005.outbound.protection.outlook.com\n (mail-westusazlp170100001.outbound.protection.outlook.com\n [IPv6:2a01:111:f403:c000::1])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))\n (No client certificate requested)\n by phobos.denx.de (Postfix) with ESMTPS id 404A884368\n for <u-boot@lists.denx.de>; Mon, 20 Apr 2026 21:25:31 +0200 (CEST)","from MW4PR04CA0307.namprd04.prod.outlook.com (2603:10b6:303:82::12)\n by CH0PR10MB5132.namprd10.prod.outlook.com (2603:10b6:610:c2::22)\n with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9818.33; Mon, 20 Apr\n 2026 19:25:26 +0000","from MWH0EPF000C6193.namprd02.prod.outlook.com\n (2603:10b6:303:82:cafe::ba) by MW4PR04CA0307.outlook.office365.com\n (2603:10b6:303:82::12) with Microsoft SMTP Server (version=TLS1_3,\n cipher=TLS_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Mon,\n 20 Apr 2026 19:25:25 +0000","from lewvzet201.ext.ti.com (198.47.23.195) by\n MWH0EPF000C6193.mail.protection.outlook.com (10.167.249.107) with Microsoft\n SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n 15.20.9791.48 via Frontend Transport; Mon, 20 Apr 2026 19:25:25 +0000","from DLEE214.ent.ti.com (157.170.170.117) by lewvzet201.ext.ti.com\n (10.4.14.104) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 20 Apr\n 2026 14:25:23 -0500","from DLEE203.ent.ti.com (157.170.170.78) by DLEE214.ent.ti.com\n (157.170.170.117) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20; Mon, 20 Apr\n 2026 14:25:23 -0500","from lelvem-mr05.itg.ti.com (10.180.75.9) by DLEE203.ent.ti.com\n (157.170.170.78) with Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.20 via Frontend\n Transport; Mon, 20 Apr 2026 14:25:23 -0500","from rs-desk.dhcp.ti.com (rs-desk.dhcp.ti.com [128.247.81.39])\n by lelvem-mr05.itg.ti.com (8.18.1/8.18.1) with ESMTP id 63KJPNh83399024;\n Mon, 20 Apr 2026 14:25:23 -0500"],"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,DKIMWL_WL_HIGH,\n DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,\n RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,T_SPF_PERMERROR autolearn=ham\n autolearn_force=no version=3.4.2","ARC-Seal":"i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=UIN7/rv3WeivsgIKm8943Hq78yIPajUKZ+4ITH3kmttrPgqESuUVUFOX0oGHeFbwuHJc/lBLSZ+Si87XjaAGq2+AuhKNTXYxwzME5b1YMqF3I4ZhmOAppMTsddw8lj+hud25WCbLVmwIzJdHMI+emvO8qpWVQ3pAWDw8w8YN2ArUbuIyNy//PSWdu6PcVub2bSV/xZQ1neDGv9xwVLo+yJC0FG2QVidMsEqtUWrvYb5E8Hx99NDVRoDgYNHDo0MN/JhyJMPATdGCDaxszG0geGZmJJAfqwvm4COvi+SrANAqD5HLJnkh6ZJF48G/2v+5cv/mKRVCArqwHkgLMXs9Tw==","ARC-Message-Signature":"i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;\n bh=TdcTv0+2zoc9+J4qVs/bczbAwtIlqvAH2DxqeUNyNWo=;\n b=NfB1an6cuAVT/NvCjyXeUh48PwEoc7XXkYyzC+0+AjoauqoExgxsGoMqVE3QRYO1YGyWRfldfLLx44W8x9J6F3g84huVv3UaDy+WU4/OxyeZO6b0tiUvTe0uXb8U5/P0yfVZH6xWtzKhxSvT5t/Qh5H2Trb+IgKzdZW02Cdnj/lL7UVnGCzePSRLCaA0kHUwf1UJ4/Obpn5+bRAnDE30XMvY7hf30BXabReOKHXbbryVuIRSbEnLhHpzGMXTTQ3tBW2JpzYCrzABqFgucwUZVxLqSI6co7GkicVaTHf5LryuIl+ftZrNZpBCXKni7Fcli8SRoIDczj9nn8AJDHnCcw==","ARC-Authentication-Results":"i=1; mx.microsoft.com 1; spf=pass (sender ip is\n 198.47.23.195) smtp.rcpttodomain=lists.denx.de smtp.mailfrom=ti.com;\n dmarc=pass (p=quarantine sp=none pct=100) action=none header.from=ti.com;\n dkim=none (message not signed); arc=none (0)","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=TdcTv0+2zoc9+J4qVs/bczbAwtIlqvAH2DxqeUNyNWo=;\n b=SX8gQDR7MODMh//tOgMW6x0i/HwhadZz1EOKDlpx82qagZPca/v6ij/re5ttTFbWtdu5lqLHx2zmGw7WaTzq8UR42ffgVBMTB4NdBwuBYP04QeGZP9SouVahgb7ThkBNHW86EoPXI7rmnadEz47IiAkesIuwEfXoBVDPEpNEvvs=","X-MS-Exchange-Authentication-Results":"spf=pass (sender IP is 198.47.23.195)\n smtp.mailfrom=ti.com; dkim=none (message not signed) header.d=none;\n dmarc=pass\n action=none header.from=ti.com;","Received-SPF":"Pass (protection.outlook.com: domain of ti.com designates\n 198.47.23.195 as permitted sender) receiver=protection.outlook.com;\n client-ip=198.47.23.195; helo=lewvzet201.ext.ti.com; pr=C","From":"<rs@ti.com>","To":"<robertcnelson@gmail.com>, <ayush@beagleboard.org>,\n <Erik.Welsh@octavosystems.com>, <anshuld@ti.com>, <bb@ti.com>,\n <trini@konsulko.com>, <afd@ti.com>, <xypron.glpk@gmx.de>,\n <ilias.apalodimas@linaro.org>","CC":"<u-boot@lists.denx.de>","Subject":"[PATCHv4 5/6] efi_mem_sort: use list_for_each_entry_safe instead","Date":"Mon, 20 Apr 2026 14:25:19 -0500","Message-ID":"<20260420192520.1444749-6-rs@ti.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260420192520.1444749-1-rs@ti.com>","References":"<20260420192520.1444749-1-rs@ti.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Content-Type":"text/plain","X-C2ProcessedOrg":"333ef613-75bf-4e12-a4b1-8e3623f5dcea","X-EOPAttributedMessage":"0","X-MS-PublicTrafficType":"Email","X-MS-TrafficTypeDiagnostic":"MWH0EPF000C6193:EE_|CH0PR10MB5132:EE_","X-MS-Office365-Filtering-Correlation-Id":"5ac5c7c3-8f49-4274-0a65-08de9f12931c","X-MS-Exchange-SenderADCheck":"1","X-MS-Exchange-AntiSpam-Relay":"0","X-Microsoft-Antispam":"BCL:0;\n ARA:13230040|82310400026|1800799024|36860700016|376014|18002099003|56012099003|22082099003;","X-Microsoft-Antispam-Message-Info":"\n HvVJJ83oPnTpPxUUqYY3IGHC7ECJi4ZR124bJr+cyu0wk60xUMHSubLeW031T3KLk+mw/ZlocHjKqNrxhNhIB54VMtT79YvDkg0yKhH0tYbtCQISkKpYs5B9iCx/I2l3KLHOaSnhBGP37mdO/XcUt1ROIv1RMxC6KqHmTfWcx7gWEvC5G9c+1gJhTqARRH+ooO8BrcuFT0vEPmnfywYiDaTz//2BBrCRoz1NwzlJrej9RZxjscRVPLOj6ZpO0GGMFcjwnzSwhQj+OBXB93KtYbmJ23B3Y8e/JLxV36odlHp2CnotzsnP/OVmWa0EfHrt0zgI6/cWybd83xuR3IvfeY/4NL1SEfuAyRl4egICRPyKeM/3O3hY4JvYvFvQS1r4DMlYjkilWNj1rLAyUivI3O4o0W/H0OigLxHoc/mSCqVSXGBB0m9p/WlMj7d3w5lc+UYaBAm54uE4JH8C+mmO8tDHGGJKaQ+JAXT3NrIgEFDZyRsNZyjlzkh6g5EZxmyjvlkrVXTXQ4ZTeRtMAOWCqDEq39joQ7x7jXLnj+hMWXos2fpPBeaIssJtJNE2KFijnYGKOMxZHzLVQzqDua17NlvwcNW+oL3M6ktR0EqUv5TsVepH/MTIjZznB4UBMSFhIN2KEQ3Jz/9o8hG31ukO3u7CRX9gqb/uiOxaS0ldIfhQV4uSFfgEvkYmWpI4co4h3zZ8W+SMo7whiaU3O+YKnWTS0il35RcO4H2AnY9Aan65YCJqLMIVVrJGpIn95WWj3H1ahK0GYRp5+akPrJgjxg==","X-Forefront-Antispam-Report":"CIP:198.47.23.195; CTRY:US; LANG:en; SCL:1; SRV:;\n IPV:NLI; SFV:NSPM; H:lewvzet201.ext.ti.com; PTR:InfoDomainNonexistent;\n CAT:NONE;\n SFS:(13230040)(82310400026)(1800799024)(36860700016)(376014)(18002099003)(56012099003)(22082099003);\n DIR:OUT; SFP:1101;","X-MS-Exchange-AntiSpam-MessageData-ChunkCount":"1","X-MS-Exchange-AntiSpam-MessageData-0":"\n VHzDLU8q+fCAEaZSlOkx9w6peIMR3QyNmronxsbLMfqu6F6/pMJhrsJKnfxJkIBc2lNu9z+7GuWpQ8YX2MEdNfwMvofbk4GaMo99A9uNre08nwKw+PifWVZP9SNNyeEwHZCwm5kkBfSFAzlJagZbUcIRFeMqm9Jd5fnBPPfOrqBMXCa9ws35BhbVdYM/TMyRTV81odgsGou4+0QGG3dIAhASvb9IZ9EdGSdJ3iTJZ21+/ANlVJ9K+fZ4OTNbhEYw66WizqzrGB/LvHSX/XaR/Ad2xzgqQtZCRo4dyKi6xUtJkJsQe/eSlDAaR1qCY7UATooGqXnfj4Ltxvj5dwwj1f4tgOsuYoruNTwa1rhndSxIygQZbHapXFD3RFY97m+SEY7pqZ/5MjlUdMPZPfoJUWh7U5NJMnvQSDsMPE80O3gXn+MLqrR7u/cdCASb7Gnd","X-OriginatorOrg":"ti.com","X-MS-Exchange-CrossTenant-OriginalArrivalTime":"20 Apr 2026 19:25:25.8227 (UTC)","X-MS-Exchange-CrossTenant-Network-Message-Id":"\n 5ac5c7c3-8f49-4274-0a65-08de9f12931c","X-MS-Exchange-CrossTenant-Id":"e5b49634-450b-4709-8abb-1e2b19b982b7","X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp":"\n TenantId=e5b49634-450b-4709-8abb-1e2b19b982b7; Ip=[198.47.23.195];\n Helo=[lewvzet201.ext.ti.com]","X-MS-Exchange-CrossTenant-AuthSource":"\n MWH0EPF000C6193.namprd02.prod.outlook.com","X-MS-Exchange-CrossTenant-AuthAs":"Anonymous","X-MS-Exchange-CrossTenant-FromEntityHeader":"HybridOnPrem","X-MS-Exchange-Transport-CrossTenantHeadersStamped":"CH0PR10MB5132","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.39","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<https://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n <mailto:u-boot-request@lists.denx.de?subject=subscribe>","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>","X-Virus-Scanned":"clamav-milter 0.103.8 at phobos.denx.de","X-Virus-Status":"Clean"},"content":"From: Randolph Sapp <rs@ti.com>\n\nUse list_for_each_entry_safe and comparisons against the current and\nnext efi_mem_desc. This reduces the computation required for merging\nregions, prevents unnecessary additional iterations of the list, and\nrequires less temporary values.\n\nSigned-off-by: Randolph Sapp <rs@ti.com>\nReviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>\nReviewed-by: Simon Glass <sjg@chromium.org>\n---\n lib/efi_loader/efi_memory.c | 47 +++++++++++++------------------------\n 1 file changed, 16 insertions(+), 31 deletions(-)","diff":"diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\nindex b77c2f980cc..046a2bb4641 100644\n--- a/lib/efi_loader/efi_memory.c\n+++ b/lib/efi_loader/efi_memory.c\n@@ -128,44 +128,29 @@ static uint64_t desc_get_end(struct efi_mem_desc *desc)\n  */\n static void efi_mem_sort(void)\n {\n-\tstruct efi_mem_list *lmem;\n-\tstruct efi_mem_list *prevmem = NULL;\n-\tbool merge_again = true;\n+\tstruct efi_mem_list *curmem, *nextmem = NULL;\n \n \tlist_sort(NULL, &efi_mem, efi_mem_cmp);\n \n \t/* Now merge entries that can be merged */\n-\twhile (merge_again) {\n-\t\tmerge_again = false;\n-\t\tlist_for_each_entry(lmem, &efi_mem, link) {\n-\t\t\tstruct efi_mem_desc *prev;\n-\t\t\tstruct efi_mem_desc *cur;\n-\t\t\tuint64_t pages;\n+\tlist_for_each_entry_safe(curmem, nextmem, &efi_mem, link) {\n+\t\tstruct efi_mem_desc *cur;\n+\t\tstruct efi_mem_desc *next;\n \n-\t\t\tif (!prevmem) {\n-\t\t\t\tprevmem = lmem;\n-\t\t\t\tcontinue;\n-\t\t\t}\n+\t\t/* Exit when we've got nothing to compare with */\n+\t\tif (&nextmem->link == &efi_mem)\n+\t\t\tbreak;\n \n-\t\t\tcur = &lmem->desc;\n-\t\t\tprev = &prevmem->desc;\n-\n-\t\t\tif ((desc_get_end(cur) == prev->physical_start) &&\n-\t\t\t    (prev->type == cur->type) &&\n-\t\t\t    (prev->attribute == cur->attribute)) {\n-\t\t\t\t/* There is an existing map before, reuse it */\n-\t\t\t\tpages = cur->num_pages;\n-\t\t\t\tprev->num_pages += pages;\n-\t\t\t\tprev->physical_start -= pages << EFI_PAGE_SHIFT;\n-\t\t\t\tprev->virtual_start -= pages << EFI_PAGE_SHIFT;\n-\t\t\t\tlist_del(&lmem->link);\n-\t\t\t\tfree(lmem);\n-\n-\t\t\t\tmerge_again = true;\n-\t\t\t\tbreak;\n-\t\t\t}\n+\t\tcur = &curmem->desc;\n+\t\tnext = &nextmem->desc;\n \n-\t\t\tprevmem = lmem;\n+\t\tif ((cur->physical_start == desc_get_end(next)) &&\n+\t\t    (cur->type == next->type) &&\n+\t\t    (cur->attribute == next->attribute)) {\n+\t\t\t/* There is another similar map coming up, reuse it */\n+\t\t\tnext->num_pages += cur->num_pages;\n+\t\t\tlist_del(&curmem->link);\n+\t\t\tfree(curmem);\n \t\t}\n \t}\n }\n","prefixes":["PATCHv4","5/6"]}