From patchwork Tue Jun 13 13:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 1794514 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=pmiIV1Ve; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QgTlN2JYhz20Vx for ; Tue, 13 Jun 2023 23:23:28 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EF67F862E2; Tue, 13 Jun 2023 15:23:17 +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="pmiIV1Ve"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DC864862E5; Tue, 13 Jun 2023 15:23:15 +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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (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 6BFE58628C for ; Tue, 13 Jun 2023 15:23:13 +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-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f8d2bfed53so3779235e9.1 for ; Tue, 13 Jun 2023 06:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686662593; x=1689254593; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=54Do8NQATp82mIxijRfBlbXtkfEKl/vEv0a9qNHhw14=; b=pmiIV1Ve/XUNg0KwOy09UYL7P7EYhBN4siQqQXoc7rMyG16fF4rjEgZtv1Dh+XdRqx 6HKFBytdVOGYFrByKc1afKSIFEnYhFEeZqwFA9a95lzgC1J+LqC54NCSBB4A9RXp/lMQ RvMdezK/kL0Q1w5HfmHZrnWcDuI6astCdymQ4UVEK+HZEg4FCL3rXAGGonkvm9w3CBIl Yxgd0K4Kjf+qURqJPKq7aRmItcXv5xpogp0P0gTIF+9h0JdF4GRX0QMD3ysK5Y/0C1Su 8E65HAt+Ze7JJ1vDKQVCe7+gKJdR9/l2jgfQjHyMvU0uqBzxGWJp1FdXsw6karI6dQ1w k1qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686662593; x=1689254593; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=54Do8NQATp82mIxijRfBlbXtkfEKl/vEv0a9qNHhw14=; b=ZcLEiCatr3FuAEq1KAet1nUn8Na/9wgl4yuYWSSyG7Zm7edbeh7ZcSscWyQy/p3FI3 NUG2V9IkbWs3k1YeExAlfhPhBHk57AgCsrUG8ukSXI06BHZdmJPNV0k4lGN7dHdkkKRV s2V06yVh+x6C0H77nfgZqN3f+r/XZi5jWjkMEv8Fz73wecPwwlGncbkTOxXySGEEZcZH /VMZzj59I0Q7p7fF+PijpkdkhgSI9y0p6ei7FLFdH8KDWR6uLnWcxB/bmiDDbaz7h1Mk qO8cIoLItfGtqasQhsZMhSZSMzbK75brvLCATGtjUBig9Udd0UpT2eJuZfdYgO/y2qdQ dq0Q== X-Gm-Message-State: AC+VfDwT3tqL9tiUc//u7qpcTgFFocQSK2Vbv86hBgMgiSJk4kWA2Zte 8/AjXjwsnzKWe9VUlF8HWDcrW+F9hQVt8sKKxVuMMA== X-Google-Smtp-Source: ACHHUZ73aRy0ziQuXbKUo2NZCZtzz9QLahEQtfHUetbEGoAfk53s2uXJ9qFQfiKJxPFZbYstq7yGIw== X-Received: by 2002:a05:600c:3508:b0:3f8:651:4b37 with SMTP id h8-20020a05600c350800b003f806514b37mr10250870wmq.2.1686662592845; Tue, 13 Jun 2023 06:23:12 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id q25-20020a7bce99000000b003f17848673fsm14410930wmj.27.2023.06.13.06.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 06:23:12 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH] efi_selftests: fix controllers repeated selftesting Date: Tue, 13 Jun 2023 16:23:05 +0300 Message-Id: <20230613132306.83940-1-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 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 Running the controller selftest more than one times fails with => setenv efi_selftest 'controllers' && bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' Setting up 'controllers' succeeded Executing 'controllers' Executing 'controllers' succeeded Summary: 0 failures => bootefi selftest Testing EFI API implementation Selected test: 'controllers' Setting up 'controllers' lib/efi_selftest/efi_selftest_controllers.c(280): ERROR: InstallProtocolInterface failed lib/efi_selftest/efi_selftest.c(89): ERROR: Setting up 'controllers' failed Summary: 1 failures There are multiple reason for this. We don't uninstall the binding interface from the controller handle and we don't reset the handle pointers either. So let's uninstall all the protocols properly and reset the handles to NULL on setup(). While at it add a forgotten check when uninstalling protocols from the handle_controller and make sure the number of child controllers is 0 Signed-off-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_controllers.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c index d2bbd1c4f65b..07a17ed866a9 100644 --- a/lib/efi_selftest/efi_selftest_controllers.c +++ b/lib/efi_selftest/efi_selftest_controllers.c @@ -271,6 +271,8 @@ static int setup(const efi_handle_t img_handle, efi_status_t ret; boottime = systable->boottime; + handle_controller = NULL; + handle_driver = NULL; /* Create controller handle */ ret = boottime->install_protocol_interface( @@ -402,8 +404,18 @@ static int execute(void) /* Check number of child controllers */ ret = count_child_controllers(handle_controller, &guid_controller, &count); - if (ret == EFI_SUCCESS) + if (ret == EFI_SUCCESS || count != 0) efi_st_error("Uninstall failed\n"); + + /* Uninstall binding protocol */ + ret = boottime->uninstall_protocol_interface(handle_driver, + &guid_driver_binding_protocol, + &binding_interface); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to uninstall protocols\n"); + return EFI_ST_FAILURE; + } + return EFI_ST_SUCCESS; }