From patchwork Tue Jun 20 06:19:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 694431 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp143804wrm; Mon, 19 Jun 2023 23:20:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5fXwYQHiU13VrQM1QLbuj3m06LO8N1y31mX2Ci+vURQ3f9KPb3g+FxIWV41WAfNFBXXTjI X-Received: by 2002:a92:cac8:0:b0:342:3364:f089 with SMTP id m8-20020a92cac8000000b003423364f089mr6049913ilq.11.1687242030724; Mon, 19 Jun 2023 23:20:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687242030; cv=none; d=google.com; s=arc-20160816; b=frU7tjivcRxixSkz3PxDLGlJP6k65L9ZNVmlknttsbt9T56nUmSbWLLiTnQDLLoayC FJxMYo7UgNAGhP0P7MnSNitgQjwdL/D1rna85ycuhKdi5Cf9stM6okEbYUFUhHS+dYcz DhVD4q+YIKOTFxVUoV578Ktm561I4yCMaT9V3n0PZJyUPmpXcLYMslt+076VemdsJDsB M3P1KslGpBnD9hj3wt28zQpYfjreLGnurJ6CJuvkEqkxmW+zDZyvDhKyiBizl77IvUyq 3ORcTIekfMU25RJJMkhsvZ79+k+Ug6zVnO0fBJ5x27btFfwLJr3Iw3Zbum3RfBwXMnwd Su1g== 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:dkim-signature; bh=LiDqNeZhZLIM3D16KTYBWODvOmJ+EKbVPW9xfazmhGY=; b=Oi57ceUiu4O3CkZY+8GuYctYVa+esje1yl5HB2TV48ztXS2S1DDeQy6Y6qYrSCE0qA 2nFD+KEBWoF4w1iEbOr1UfZuTad5BfZ9V93VU1QhSzaUL1Mpv3id+etf1yt+AoTjZFvf rR/h5fAt4Hv+JUYPc83Ep53o6kIqRZBOO2EyrNwZYhkeD3QqMnnlZUZJeXJsBgyiwugD 0okyQJ5ssodACSTv9XFUfjwHNQVTsAtvCZwzcxcYt969VymeopCichmRo1Al1yn6QiQz gcX3/zQ2mYpcvK+TCFIEixYyQ0XzjV0wMwtcC31PGGUj0/etAIOIKJ0wqiro2BaPy8/G kOug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CgoLlrhS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id y15-20020a92c98f000000b0033bd634fe03si563869iln.155.2023.06.19.23.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 23:20:30 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CgoLlrhS; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (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 3435686372; Tue, 20 Jun 2023 08:19:56 +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="CgoLlrhS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F24C85FE5; Tue, 20 Jun 2023 08:19:44 +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-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 390C286341 for ; Tue, 20 Jun 2023 08:19:40 +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-ej1-x630.google.com with SMTP id a640c23a62f3a-983f499fc81so521122366b.3 for ; Mon, 19 Jun 2023 23:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687241980; x=1689833980; 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=LiDqNeZhZLIM3D16KTYBWODvOmJ+EKbVPW9xfazmhGY=; b=CgoLlrhSL3LeBDkNy1sjiiyccUlFoWNtLaWyPnWDZcbd7mLJkt4+vBC9zsDpFyqwvn T2goWvAh1+AfgeBEdahMPwWY6F4DLou/7tcbMjOCu+Va4cIgxFiUWgTuc2q/+ByjKaX7 OhK9wjsKvAgxJFg25mZ2K3jl5zjyVAVpEUKLP7nVvwpbJdApnbDszt8Iqb+azEphEMos 3cOtFM5nFWYTpn2WPLPaypQ3RtZ2FmMmHxW+KOa+TJoNC6IOqrGXRxptXeDRog9ZLlD2 ly3HpmdofitxbTSqjajKC0WMqI1oPfLvaXXhkYKtRQR0MfC4NBJoPgUvcUDsCwE7Wx83 gyyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687241980; x=1689833980; 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=LiDqNeZhZLIM3D16KTYBWODvOmJ+EKbVPW9xfazmhGY=; b=YbN/JbD60ezrEVLFxpgJBSLqa6VRrRx/cuX9Rs1396iLMGfZBaVHSesg7UYNBVBbaA ndEdixc2op9qrlfp46cGuTpHFWZJ/uf4rlCvmnHr8M55UfljzfFJ766KSsZ3xPg1Hgrm aWZ+N71bzfhMwfpDaQVHzGmOl+cbvscViTEqtYQyK59MmNrxxSWSig5s/taz6qyjinh/ wv50xXcErzBXlQCYXhZjNGisrCZHb20u0z3tPltF14sQxI+xWPl3Hd0itCkTZMJBhbZH todTzQYblVH//zNuSibnu64Vr2mkuL5UKwR8eEHxZKhTe6XX5iht+OXH4myAGBHWk3Cz 9E8Q== X-Gm-Message-State: AC+VfDxAypDpGxVpQAziyZhwqDbq77gPGPvSPAutwe7J1+qQPQgEKLzu 1zFdO8+5LSGS3wu3A/3T9D21pRcYd+/cS/RBzwgw2g== X-Received: by 2002:a17:907:934e:b0:989:5d0:3189 with SMTP id bv14-20020a170907934e00b0098905d03189mr2477362ejc.33.1687241979837; Mon, 19 Jun 2023 23:19:39 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id a22-20020a1709063a5600b00988e699d07fsm729988ejf.112.2023.06.19.23.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 23:19:39 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 4/4 v2] efi_selftests: add extra testcases on controller handling Date: Tue, 20 Jun 2023 09:19:31 +0300 Message-Id: <20230620061932.113292-5-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230620061932.113292-1-ilias.apalodimas@linaro.org> References: <20230620061932.113292-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 recently fixed a few issues wrt to controller handling. Add a few test cases to cover the new code. - return EFI_DEVICE_ERROR the first time the protocol interface of the controller is uninstalled, after all the children have been disconnected. This should make the drivers reconnect - add tests to verify controllers are reconnected when uninstalling a protocol fails - add tests to make sure EFI_NOT_FOUND is returned if a non existent interface is being removed Signed-off-by: Ilias Apalodimas --- lib/efi_selftest/efi_selftest_controllers.c | 44 +++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) -- 2.40.1 diff --git a/lib/efi_selftest/efi_selftest_controllers.c b/lib/efi_selftest/efi_selftest_controllers.c index 79bc86fb0c3a..513c9868fda9 100644 --- a/lib/efi_selftest/efi_selftest_controllers.c +++ b/lib/efi_selftest/efi_selftest_controllers.c @@ -28,6 +28,7 @@ static efi_guid_t guid_child_controller = static efi_handle_t handle_controller; static efi_handle_t handle_child_controller[NUMBER_OF_CHILD_CONTROLLERS]; static efi_handle_t handle_driver; +static bool allow_removal; /* * Count child controllers @@ -85,8 +86,8 @@ static efi_status_t EFIAPI supported( controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER); switch (ret) { case EFI_ACCESS_DENIED: - case EFI_ALREADY_STARTED: return ret; + case EFI_ALREADY_STARTED: case EFI_SUCCESS: break; default: @@ -124,8 +125,8 @@ static efi_status_t EFIAPI start( controller_handle, EFI_OPEN_PROTOCOL_BY_DRIVER); switch (ret) { case EFI_ACCESS_DENIED: - case EFI_ALREADY_STARTED: return ret; + case EFI_ALREADY_STARTED: case EFI_SUCCESS: break; default: @@ -238,6 +239,9 @@ static efi_status_t EFIAPI stop( if (ret != EFI_SUCCESS) efi_st_error("Cannot free buffer\n"); + if (!allow_removal) + return EFI_DEVICE_ERROR; + /* Detach driver from controller */ ret = boottime->close_protocol( controller_handle, &guid_controller, @@ -342,6 +346,7 @@ static int execute(void) return EFI_ST_FAILURE; } /* Destroy remaining child controllers and disconnect controller */ + allow_removal = true; ret = boottime->disconnect_controller(handle_controller, NULL, NULL); if (ret != EFI_SUCCESS) { efi_st_error("Failed to disconnect controller\n"); @@ -393,7 +398,40 @@ static int execute(void) efi_st_error("Number of children %u != %u\n", (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); } - /* Uninstall controller protocol */ + + allow_removal = false; + /* Try to uninstall controller protocol using the wrong interface */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller, + &interface1); + if (ret != EFI_NOT_FOUND) { + efi_st_error("Interface not checked when uninstalling protocol\n"); + return EFI_ST_FAILURE; + } + + /* + * Uninstall a protocol while Disconnect controller won't + * allow it. + */ + ret = boottime->uninstall_protocol_interface(handle_controller, + &guid_controller, + &interface2); + if (ret != EFI_ACCESS_DENIED) { + efi_st_error("Uninstall protocol interface failed\n"); + return EFI_ST_FAILURE; + } + /* + * Check number of child controllers and make sure children have + * been reconnected + */ + ret = count_child_controllers(handle_controller, &guid_controller, + &count); + if (ret != EFI_SUCCESS || count != NUMBER_OF_CHILD_CONTROLLERS) { + efi_st_error("Number of children %u != %u\n", + (unsigned int)count, NUMBER_OF_CHILD_CONTROLLERS); + } + + allow_removal = true; ret = boottime->uninstall_protocol_interface(handle_controller, &guid_controller, &interface2);