From patchwork Tue Jul 30 11:11:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 815303 Delivered-To: patch@linaro.org Received: by 2002:a5d:4acf:0:b0:367:895a:4699 with SMTP id y15csp242881wrs; Tue, 30 Jul 2024 04:12:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX3f3YXqCmdRsn1mD00lOwtR+xQwwE++1pQKNQ3Tj3qmhHzrrnelnA/H49qc3Ch6mwJlDhh4Y0+6S9xSrEJx48+ X-Google-Smtp-Source: AGHT+IFsCQJyOSEqh4K1GJBFDK9tU6x76cA5nohBiw/6LupIBXBlZSirXrM8zmDsKg/hJFmV/bl9 X-Received: by 2002:a05:6512:1052:b0:52e:9882:2cd8 with SMTP id 2adb3069b0e04-5309b26984fmr8728655e87.4.1722337949254; Tue, 30 Jul 2024 04:12:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722337949; cv=none; d=google.com; s=arc-20160816; b=B6gz7GcX//Eb0NKR108j6mL9TJlm2zTcAkIzJ6zGnRQi6DPZ56Ou56WYhfmvvSPYQi lWTEr+eQyLj3JfUpMmN44f2kDdlbiL9HeEAnDdSm4FFDMVxYQ5PSNC0fKG/sv4/tXfOs xwemMI9L5dibzhCl0zB0Egu7rXn0pTah19xxaUb/fcH0QWiNxgR4yHI5jBG8GoeXnnvP SWSWtgYsK8C7qfVbje3Uf02odc649Rpfcl5DROWIBPmZf+65ULp3rFTnCjh8TgMEdtS0 Fzbhcp9mFnTA92S4A92qnwJ4npiVIrMoqNg7o5oMeETAtgr28FRiha5MP9J/JHj/AkDn PKpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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; bh=QRunljcUp2lS50AxiFegUEub9hR9BRlKZe4lBtqjy9o=; fh=c60fu1IChZaOc2lQYQAOoRysAfBqXosZh6e58mdWpwk=; b=Z12TkoGlJ5bWO1Z/sSiuz0J3Pzdgqk4zXpy8ny7lmQniZAUkOEqLD4x8WlqK7JMmm5 uAvoXk33/FtH0FhZVpHxt/tV8hlZIlvxa/Rdtj8M732Sfi83zITWWvBJ3aHqwegj6tpS cY8ZL5TCxYtrVUgKrJpd1HxTdk3J8SAQsom9PXdxknf6KDL//ZGpSBihrDG+hnka2QCN wFuBjweBzM7GwKx+JRXGVk/sNa/dcUB37X1RItjCmbM18KwoJX2HlpjIKPcrjR5L4Kmf eNKhzzsAlAwNKpa9S5wO9fzPS79ByNys6+GdptLC0h1tWg4A0uafQotUCZ9VFfXIQ8Z5 dI7w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=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-a7acacc50ddsi755589466b.1025.2024.07.30.04.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 04:12:29 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39C1F8881F; Tue, 30 Jul 2024 13:12:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 65B0C8881F; Tue, 30 Jul 2024 13:12:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 31EEE87A55 for ; Tue, 30 Jul 2024 13:12:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 316561007; Tue, 30 Jul 2024 04:12:27 -0700 (PDT) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DC84A3F5A1; Tue, 30 Jul 2024 04:11:59 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt , Simon Glass , Sughosh Ganu Subject: [PATCH 4/5] efi_memory: get the efi_mem_list node directly Date: Tue, 30 Jul 2024 16:41:31 +0530 Message-Id: <20240730111132.1097315-4-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730111132.1097315-1-sughosh.ganu@linaro.org> References: <20240730111132.1097315-1-sughosh.ganu@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 Use the list_for_each_entry() API to get the efi_mem_list node directly, instead of making an additional call to list_entry(). Signed-off-by: Sughosh Ganu Reviewed-by: Heinrich Schuchardt Reviewed-by: Ilias Apalodimas --- lib/efi_loader/efi_memory.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index 8d4f6e339d..6819c2ec90 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -127,7 +127,7 @@ static uint64_t desc_get_end(struct efi_mem_desc *desc) */ static void efi_mem_sort(void) { - struct list_head *lhandle; + struct efi_mem_list *lmem; struct efi_mem_list *prevmem = NULL; bool merge_again = true; @@ -136,13 +136,11 @@ static void efi_mem_sort(void) /* Now merge entries that can be merged */ while (merge_again) { merge_again = false; - list_for_each(lhandle, &efi_mem) { - struct efi_mem_list *lmem; + list_for_each_entry(lmem, &efi_mem, link) { struct efi_mem_desc *prev; struct efi_mem_desc *cur; uint64_t pages; - lmem = list_entry(lhandle, struct efi_mem_list, link); if (!prevmem) { prevmem = lmem; continue; @@ -269,7 +267,7 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, int memory_type, bool overlap_only_ram) { - struct list_head *lhandle; + struct efi_mem_list *lmem; struct efi_mem_list *newlist; bool carve_again; uint64_t carved_pages = 0; @@ -309,11 +307,9 @@ static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages, /* Add our new map */ do { carve_again = false; - list_for_each(lhandle, &efi_mem) { - struct efi_mem_list *lmem; + list_for_each_entry(lmem, &efi_mem, link) { s64 r; - lmem = list_entry(lhandle, struct efi_mem_list, link); r = efi_mem_carve_out(lmem, &newlist->desc, overlap_only_ram); switch (r) { @@ -445,7 +441,7 @@ static efi_status_t efi_check_allocated(u64 addr, bool must_be_allocated) */ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr) { - struct list_head *lhandle; + struct efi_mem_list *lmem; /* * Prealign input max address, so we simplify our matching @@ -453,9 +449,7 @@ static uint64_t efi_find_free_memory(uint64_t len, uint64_t max_addr) */ max_addr &= ~EFI_PAGE_MASK; - list_for_each(lhandle, &efi_mem) { - struct efi_mem_list *lmem = list_entry(lhandle, - struct efi_mem_list, link); + list_for_each_entry(lmem, &efi_mem, link) { struct efi_mem_desc *desc = &lmem->desc; uint64_t desc_len = desc->num_pages << EFI_PAGE_SHIFT; uint64_t desc_end = desc->physical_start + desc_len; @@ -745,7 +739,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, { int map_entries; efi_uintn_t map_size = 0; - struct list_head *lhandle; + struct efi_mem_list *lmem; efi_uintn_t provided_map_size; if (!memory_map_size) @@ -774,10 +768,7 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, /* Copy list into array */ /* Return the list in ascending order */ memory_map = &memory_map[map_entries - 1]; - list_for_each(lhandle, &efi_mem) { - struct efi_mem_list *lmem; - - lmem = list_entry(lhandle, struct efi_mem_list, link); + list_for_each_entry(lmem, &efi_mem, link) { *memory_map = lmem->desc; memory_map--; }