From patchwork Wed Oct 23 15:22:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 837819 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1f12:b0:37d:45d0:187 with SMTP id hh18csp527975wrb; Wed, 23 Oct 2024 08:22:29 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXZiXIL8WPKssOoWFACqsUboXrXMrrVswrfY6oyOX7bwJ3UiQEHVXHWYDeQ+0wsc3hF7n5hRw==@linaro.org X-Google-Smtp-Source: AGHT+IGMS7f1bDW/eCC1sESb1uDOulDM1DnuWmcHiyUtK7hwHG6V4JGTOoKzKoJTmMFbxJEjjAnG X-Received: by 2002:a05:6512:2807:b0:539:eb82:d45b with SMTP id 2adb3069b0e04-53b1a36e099mr1789903e87.56.1729696949359; Wed, 23 Oct 2024 08:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729696949; cv=none; d=google.com; s=arc-20240605; b=epLmEZ9pj8E/z1RWhGRxk9k8NcEtS+MO8JYwTeEejNBhCZibgl30nRUqmFWfZUoM5Z dSUCbhDBUNwieiPCRZ2YsVJT9dkT5tdlbXX8UX7MjSiAPxY1kIuBhjLeev+ASMH6HuwG RjOAWvpC6srvTnNdFx+ddldJp5HMxO6dPE05am1ZM+Dh3/FCJgF7biuhp0Dopql80JL0 5Q9RrrcrrlumDut2SNrhmMqdIth73VnDdHaOxr1mdTYB7Oa13mdf8yhsSD7ntOImi2rH BdY8nL7KpADCBvAutJ1usAS6w6lnEdQZNj3wrxkUj4Izgz5M27AyhafhQKt2XM3JjYkz 9N3w== 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; fh=Vsi50gmnwzRUUgnfgcbL78rgNdpVy2Is5Y2mM2LVZI0=; b=aXRKjW0uxM+alkpKIyN7f1TavmkdVUFEVBADKWs+Wri5K/wEep2RRih/3m7oHPNR63 uLORczwTeXr5WGh8Cw/ulfHwuBXBIdIXiVM+iCKON4qmvID3CI5xmFk/gaad9IrMggHH 7FAV7f6DuZ43mtJlasbhyCT4On37bB47vGRrtLyKY3nRKgyCUy6Qg1JpCS+9+HN8/whN ZK2Z4ezBMRMGNQ1n/USWiajcAetiqj9ygUorZOAKeaWW0q9wa7ImIPleGtrXUZhQgRbY Ii7YsZfxic9V4RIUoYrg7oQvSMnUoyf+p4plYHJpod0zQkArmJLyHfWJ3Z2UJLe1JarH uSLw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ObN5ukY8; 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 2adb3069b0e04-53a22426249si2739875e87.268.2024.10.23.08.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22: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; dkim=pass header.i=@linaro.org header.s=google header.b=ObN5ukY8; 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 75E238919C; Wed, 23 Oct 2024 17:22:25 +0200 (CEST) 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="ObN5ukY8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1A2CE892CF; Wed, 23 Oct 2024 17:22:19 +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=-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-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (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 4BC87892CF for ; Wed, 23 Oct 2024 17:22:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a9abe139088so153479566b.1 for ; Wed, 23 Oct 2024 08:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729696930; x=1730301730; 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; b=ObN5ukY8Y1rKtzxMclPt+M3gdP7ziqztrrjo3XbtyLy8TbDQySo1r8VEuEyGccLxYP yPoxAwhuJdrygi5cqVAO9oIaelRVqOPUEKbmGPZGfCzKShJY2hmhlt4fCtupu5Tu9Rty 915wMqoqkZeSN+gep4tDry8URAd5VcdZyI/l6I0hp7vkMuJAYJdAMUWZ5gyqcsmDBpGt xOU2nlZ0lIkqN8diOkqCg11laCxI/t8CNDmFluaLa/oDKv1C6bbb/vcbUYkZ3dIyy/qj o5NycIKZ4rVwlSDqK1YJ8xrUt0eqr/KVC3DOpk4HxZbWflaa0uc90MHiBlvwMiuozq42 fqUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729696930; x=1730301730; 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=yi5zxJzn0EZ8cZJYy+huwu4x2mZWmwvGL6NSdSIM8xQ=; b=YZy8btdF9PHAErsbxYI6HNHGS+7oXZa2ts9WOOcGJxnSCV3zQe8xUvTy1ZnnHz0ebc PRrOXfOH9d3+/Gw2lwVEaDIJ8DY+nrEaaXuD+Kuw+mF8aYfqhUrghOHqnnaar6UT0OFw CBqZoXLOGy/Udbt9fjcBt2POzeMk4wkWJARnBrvsoxG5pWPlsVwcjXjiEXsbJU79oN6Y DI0DQjAZ1u81V8BvCUNGn1VRUvAijB/V8vhwJBiSX7OQAdx6w9kFCkaIa4yw/B1DRVdW Lu3Jz+tUv8g/JPTbcD1XEI5Lvq0PZXTMkmnDXMy72RRYStj6sPR7Jadbia8l9LtjmajN 9S3A== X-Forwarded-Encrypted: i=1; AJvYcCUWpwxM0Kyd97vZ6hLrD2IwHtUCBMD6d966BLJ4SuWYtqxWQMpUrw/Oi5NXcbZJ+48/50BNEz4=@lists.denx.de X-Gm-Message-State: AOJu0YxPA3O+N3s8PNjegFSE4HBD5JHnPzhdD2/QTNg+zgT/Fns7gM8C /RkWpk2hHBblVt+BNALJl4OPrBeTRCDWEXbNFxVEc3byMeMXhdBhhaphQ3RAE4o= X-Received: by 2002:a17:907:2ce1:b0:a99:f29a:bc9a with SMTP id a640c23a62f3a-a9abf8491c3mr276344266b.7.1729696929568; Wed, 23 Oct 2024 08:22:09 -0700 (PDT) Received: from localhost.localdomain (ppp176092143132.access.hol.gr. [176.92.143.132]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9a912edfedsm489242766b.72.2024.10.23.08.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 08:22:09 -0700 (PDT) From: Ilias Apalodimas To: sughosh.ganu@linaro.org Cc: Ilias Apalodimas , Tom Rini , Simon Glass , Marek Vasut , Laurent Pinchart , Julien Masson , Guillaume La Roque , Mattijs Korpershoek , Matthias Schiffer , u-boot@lists.denx.de Subject: [PATCH 2/2] lmb: Simplify lmb_should_notify usage Date: Wed, 23 Oct 2024 18:22:01 +0300 Message-ID: <20241023152203.1218242-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241023152203.1218242-1-ilias.apalodimas@linaro.org> References: <20241023152203.1218242-1-ilias.apalodimas@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 We never call lmb_map_update_notify() without checking the result of lmb_should_notify(). Instead of running that function everytime fold it in there and add the additional flags parameter Signed-off-by: Ilias Apalodimas --- lib/lmb.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/lib/lmb.c b/lib/lmb.c index 8ce58fcb9224..69001ad57373 100644 --- a/lib/lmb.c +++ b/lib/lmb.c @@ -40,7 +40,7 @@ static bool lmb_should_notify(enum lmb_flags flags) static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, phys_size_t size, - u8 op) + u8 op, enum lmb_flags flags) { u64 efi_addr; u64 pages; @@ -51,6 +51,9 @@ static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, return -1; } + if (!lmb_should_notify(flags)) + return 0; + efi_addr = (uintptr_t)map_sysmem(addr, 0); pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK)); efi_addr &= ~EFI_PAGE_MASK; @@ -64,9 +67,9 @@ static int __maybe_unused lmb_map_update_notify(phys_addr_t addr, log_err("%s: LMB Map notify failure %lu\n", __func__, status & ~EFI_ERROR_MASK); return -1; - } else { - return 0; } + + return 0; } static void lmb_print_region_flags(enum lmb_flags flags) @@ -490,10 +493,7 @@ long lmb_add(phys_addr_t base, phys_size_t size) if (ret) return ret; - if (lmb_should_notify(LMB_NONE)) - return lmb_map_update_notify(base, size, MAP_OP_ADD); - - return 0; + return lmb_map_update_notify(base, size, MAP_OP_ADD, LMB_NONE); } static long _lmb_free(phys_addr_t base, phys_size_t size) @@ -566,10 +566,7 @@ long lmb_free_flags(phys_addr_t base, phys_size_t size, if (ret < 0) return ret; - if (lmb_should_notify(flags)) - return lmb_map_update_notify(base, size, MAP_OP_FREE); - - return ret; + return lmb_map_update_notify(base, size, MAP_OP_FREE, flags); } long lmb_free(phys_addr_t base, phys_size_t size) @@ -586,10 +583,7 @@ long lmb_reserve_flags(phys_addr_t base, phys_size_t size, enum lmb_flags flags) if (ret) return ret; - if (lmb_should_notify(flags)) - return lmb_map_update_notify(base, size, MAP_OP_RESERVE); - - return ret; + return lmb_map_update_notify(base, size, MAP_OP_RESERVE, flags); } long lmb_reserve(phys_addr_t base, phys_size_t size) @@ -621,7 +615,6 @@ static phys_addr_t lmb_align_down(phys_addr_t addr, phys_size_t size) static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, phys_addr_t max_addr, enum lmb_flags flags) { - u8 op; int ret; long i, rgn; phys_addr_t base = 0; @@ -654,13 +647,11 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align, size, flags)) return 0; - if (lmb_should_notify(flags)) { - op = MAP_OP_RESERVE; - ret = lmb_map_update_notify(base, size, - op); - if (ret) - return ret; - } + ret = lmb_map_update_notify(base, size, + MAP_OP_RESERVE, + flags); + if (ret) + return ret; return base; }