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 68AB9C433F5 for ; Wed, 5 Oct 2022 15:26:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 590EA84D8E; Wed, 5 Oct 2022 17:26:29 +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="G9ofu9Yd"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4E38F84D96; Wed, 5 Oct 2022 17:26:27 +0200 (CEST) Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) (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 9A88C84D79 for ; Wed, 5 Oct 2022 17:26:24 +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=ilias.apalodimas@linaro.org Received: by mail-ed1-x536.google.com with SMTP id u21so19300499edi.9 for ; Wed, 05 Oct 2022 08:26:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=Ibqk35fL78XwF61LwGa/eGEXz+9PF0DYHgPd7NLX7RU=; b=G9ofu9YdSE+nQ89dkh78ziZJSA71HvZ9EvCUTbrZxaGy3Q5En8kuLzo8rhvcQ+3MRg +uVp5rHj0z2Yf+5wlVuwuUKIK8UlfUWj2zUd0xyAAOtR2erGUOtfSKsKp2VeIlJ9iMiJ PCzsbMQ564mfTHRuucSHMZnaZcK62WoYQvm3vpill/PB7bDN7ZYSOazs1gsXSgQL7dwo WFt8v/XyBq3DfZ6F1uV3IRXInolz6hlY+K/nYwrXgUQHBb0Ymf3U/jmrM/p1DFpPBsRX oVggFFxFt0ZVQuNbuXeSAHhLb0kqgUheBEUwyN5cLFpR6ilqPF/XvO8csbfVmS7Fl8os Wr8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=Ibqk35fL78XwF61LwGa/eGEXz+9PF0DYHgPd7NLX7RU=; b=VuZuiiDZ4Vu6lp49BPWkP0c6aokiIjZX/MxrDWWgb1ZDsHdfDAMF6LeMhfW6/XQ85E VTGDGbw4q/ms/PIY+zo4ataen7x5uyMNz/SgTSEWmTXzFW9y/MctjNU2dzOxualb3i8I nnYp1auTzOWk7ADJXFGxN2Q8RRDlWy7+wp/JA2U7iWjyFsPPu6yaESt23tAX8jQagHA3 QMG1NMBKolYDhyV2sPAcLC3Q9jIBy0/uiyu72m/SoU5NROihX67U5JGit4v1pd4LTJxP LlEyWdO58Dnvs1shkCKEBbcMI91ED4SWmJEAJm4zT5ZvD1cKHXNRyVYs4vZa5rmchec6 9hkw== X-Gm-Message-State: ACrzQf0UskERsaO9NcSxGgitvOYfKaMPaCeZITNhpzj7jVf7OJGXmRZ7 qh32ACViO8hO0xv5is0MYgQdhA== X-Google-Smtp-Source: AMsMyM5Qx1L3GDz1WjPFJLxNNKGrb6/Mb2BxnZA0Hpcp/VCQa33AC1zbyVzm/ptNaaAaO31B4GHaPg== X-Received: by 2002:a05:6402:169a:b0:458:fe61:d3b4 with SMTP id a26-20020a056402169a00b00458fe61d3b4mr305967edv.140.1664983584208; Wed, 05 Oct 2022 08:26:24 -0700 (PDT) Received: from hades.. (ppp046103015185.access.hol.gr. [46.103.15.185]) by smtp.gmail.com with ESMTPSA id n15-20020aa7c78f000000b00458d50b4a24sm3918815eds.96.2022.10.05.08.26.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 08:26:23 -0700 (PDT) From: Ilias Apalodimas To: xypron.glpk@gmx.de Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: [RFC PATCH 0/2] Clean up protocol installation API Date: Wed, 5 Oct 2022 18:26:00 +0300 Message-Id: <20221005152603.3085754-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.34.1 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 This RFC is trying to clean up the usage of the internal functions used to manage the protocol and handle lifetimes. Currently we arbitrarily use either InstallProtocol, InstallMultipleProtocol and a combination of efi_add_protocol, efi_create_handle, efi_delete_handle(). The latter is the most problematic one since it blindly removes all protocols from a handle and finally the handle itself. This is prone to coding errors Since someone might inadvertently delete a handle while other consumers still use a protocol. InstallProtocol is also ambiguous since the EFI spec only demands InstallMultipleProtocol to test and guarantee a duplicate device path is not inadvertently installed on two different handles. So this patch series is preparing the ground in order for InstallMultipleProtocol and UnInstallMultipleProtocol to be used internally in U-Boot. There is an example on bootefi.c demonstrating how the cleanup would eventually look like. If we agree on the direction, I'll clean up the remaining callsites with InstallMultipleProtocol. Size differences between old/new binary show that eventually we will manage to reduce the overall code size by getting rid all the unneeded EFI_CALL invocations add/remove: 4/0 grow/shrink: 1/6 up/down: 1128/-892 (236) Function old new delta __efi_install_multiple_protocol_interfaces - 496 +496 __efi_uninstall_multiple_protocol_interfaces - 412 +412 efi_uninstall_multiple_protocol_interfaces_ext - 108 +108 efi_install_multiple_protocol_interfaces_ext - 108 +108 efi_run_image 288 292 +4 efi_initrd_register 220 212 -8 efi_console_register 344 336 -8 efi_disk_add_dev.part 644 632 -12 efi_root_node_register 256 240 -16 efi_uninstall_multiple_protocol_interfaces 472 84 -388 efi_install_multiple_protocol_interfaces 544 84 -460 Total: Before=547442, After=547678, chg +0.04% add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) Data old new delta Total: Before=101061, After=101061, chg +0.00% add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0) RO Data old new delta Total: Before=42925, After=42925, chg +0.00% Ilias Apalodimas (2): efi_loader: define internal implementation of install/uninstallmultiple cmd: replace efi_create_handle/add_protocol with InstallMultipleProtocol cmd/bootefi.c | 13 ++- include/efi.h | 2 + include/efi_loader.h | 6 +- lib/efi_loader/efi_boottime.c | 180 ++++++++++++++++++++++++------- lib/efi_loader/efi_capsule.c | 15 +-- lib/efi_loader/efi_console.c | 14 +-- lib/efi_loader/efi_disk.c | 10 +- lib/efi_loader/efi_load_initrd.c | 15 ++- lib/efi_loader/efi_root_node.c | 44 ++++---- 9 files changed, 203 insertions(+), 96 deletions(-) -- 2.34.1