From patchwork Thu Jun 15 14:39:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 693007 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp562519wru; Thu, 15 Jun 2023 07:40:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53VI48G4d3bwVm4PQkMJIeh5IhJbwGSfAJhtoE5VUfBFP/Bo3hLyrTIbFpQh9HW8Qn1Oho X-Received: by 2002:a17:90a:194b:b0:259:3e7f:c60d with SMTP id 11-20020a17090a194b00b002593e7fc60dmr3710686pjh.3.1686840041409; Thu, 15 Jun 2023 07:40:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686840041; cv=none; d=google.com; s=arc-20160816; b=phQcdJUKKGvLSKDy9SXtl6QMXIw4A3jhAlrjyzINlplNjlfp6NPQ42g7vsUk1R5U3B tpIhiJRKKno6UUDXmsO0BWcdD55McQXVsBv9HFYFHSNjX8Cn/BxqkuEhyizrGHvobR25 xU1J4jjYFGY8bTMWL/txejHQrEuUQhgg2EsaXnw3/drs8QmYywnrfJVb+6W+LncFAUeu LrRq0i1/pRcfLg8/EZHMAM8Lb9pFBYDk9TsAzuSzKiYsPiGZLVMPdF4SmstnpSxAl3q2 DzZss7KOnF8fLaIRl3Yb/az4W0gAFIPfDGsOHgHY8zqMG7AU9MwMKRFCpX5jMs5V4kRA Abeg== 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=fbwvwbeDI9nBaOweht4hMIYAMDnYkpzLkEsM8MQ+5wzIyamdxY4kQdlhMpPE5KiKhp pjMzVr+K9GdFD6i3mMSWclZRsmAXTAmlI7ZUFnQHmzVxZLLu8SbTLO4s3uPc1YAsktab CrPVmHmCoAvhEvxS0WGZ3Ek2bvJUXEp8mm3TtrmF4Jh5vw1ZcsfGe2ts76LzYp2MTNYn xtqv4BTzcYNK151qb1jis/3V6PgdyV19SGo3fn2MeG4fv1U9B80DNRZODOOmd78r8GwP razGZaASpWBdYeUrSpw0xUy/E2aDN3S1PLDa47/9I+4kUr7BdgKisUZMgUusKXFoAGqU OqGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pzQrAJ3N; 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 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 w11-20020a17090a528b00b0025998ebdc4csi12770917pjh.60.2023.06.15.07.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:40:41 -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=pzQrAJ3N; 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 Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 301458632B; Thu, 15 Jun 2023 16:40:00 +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="pzQrAJ3N"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 09DC4862D4; Thu, 15 Jun 2023 16:39:52 +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-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) (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 D6A768631B for ; Thu, 15 Jun 2023 16:39:45 +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-x32e.google.com with SMTP id 5b1f17b1804b1-3f8d5262dc8so7029745e9.0 for ; Thu, 15 Jun 2023 07:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686839985; x=1689431985; 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=pzQrAJ3NDmZhn/7jkwhU0LDsbQLkw4tqOR9d8Hn0ckCXEcmtOHWqKu6VoL1CkyZKag jWLidf8a8KVYDV0jPWbpvRaQpMA1GJfTO/QdvFvnvEh3sO8QUwwtY6kB2ppO7B/Ur1MH yxxSRwjF//YTcccO9QDLNbV/+hcOfJ8ee5UmJPxOb6CZtDlVjZciqCv3/4FI13m7vl45 iKM1BRJHFgxzbIUPPHDtZb/DTGp68IaxgbEhlpxIm88FnBZ7gonmPiZnoV/iBG6p1vee IS1vKbWDuiaVFhHP6TgBjbbMJqGvstb7VIe8v2fTsH/0QSO60Lc2ulI8WiWFevWseluN H5iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686839985; x=1689431985; 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=CnbZStYkLf9ECvqWuRXKiiZrhgROkdKIkBlm89rxikI=; b=YZSIHp0tpEXPXhyzW6m2svUp2sTO5KjX/KWiCJX64MyfGRxsY1/MEm8F1bEnX0TC0B MNLV2EYvvyrDAPvPUx/g9kBNpXR+q9hBVxLyaGBf6607cuHC33KgZy8hqeyyfBImTE/B OnGUiSy9sahyAgaJNyG1rSr5viS8TIY/PHDL+ITFcYKIE1M/Fdd7QkXZWp61oBgEDOYb 70ZZd5cN3jwWWmGUp6rIL7n8j+Jy+o6daaVf9aN1GE4VTCCpuqRpbNqBPhXB5frY8iZG 2pRkHteTtOY/wjA5zqKcX/wp7QhuJxZudlQFFvdDTooIBHrHnwi7XXIG/mJonCf7AUEW /1Qw== X-Gm-Message-State: AC+VfDzTgYqr1JuCkBwQiOtOsDHElP3f2r3xks+i/R0BNuNk7ufdzv4H nTkIA7jILQXsPnqM89fzRDFjniP2FklEMDY+Lsf64Q== X-Received: by 2002:a05:600c:2197:b0:3f6:d90:3db with SMTP id e23-20020a05600c219700b003f60d9003dbmr4240171wme.3.1686839985263; Thu, 15 Jun 2023 07:39:45 -0700 (PDT) Received: from localhost.localdomain (ppp089210114029.access.hol.gr. [89.210.114.29]) by smtp.gmail.com with ESMTPSA id w11-20020a1cf60b000000b003f7ff6b1201sm20601273wmc.29.2023.06.15.07.39.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jun 2023 07:39:44 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 2/5] efi_loader: reconnect drivers on failure Date: Thu, 15 Jun 2023 17:39:38 +0300 Message-Id: <20230615143941.416924-2-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615143941.416924-1-ilias.apalodimas@linaro.org> References: <20230615143941.416924-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 efi_disconnect_controller() doesn't reconnect drivers in case of failure. Reconnect the disconnected drivers properly Signed-off-by: Ilias Apalodimas --- lib/efi_loader/efi_boottime.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 68198e6b5ff6..df675d0ad488 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -97,6 +97,12 @@ static efi_status_t EFIAPI efi_disconnect_controller( efi_handle_t driver_image_handle, efi_handle_t child_handle); +static efi_status_t EFIAPI efi_connect_controller( + efi_handle_t controller_handle, + efi_handle_t *driver_image_handle, + struct efi_device_path *remain_device_path, + bool recursive); + /* Called on every callback entry */ int __efi_entry_check(void) { @@ -1298,7 +1304,7 @@ static efi_status_t efi_disconnect_all_drivers const efi_guid_t *protocol, efi_handle_t child_handle) { - efi_uintn_t number_of_drivers; + efi_uintn_t number_of_drivers, tmp; efi_handle_t *driver_handle_buffer; efi_status_t r, ret; @@ -1308,15 +1314,30 @@ static efi_status_t efi_disconnect_all_drivers return ret; if (!number_of_drivers) return EFI_SUCCESS; - ret = EFI_NOT_FOUND; + + tmp = number_of_drivers; while (number_of_drivers) { - r = EFI_CALL(efi_disconnect_controller( + ret = EFI_CALL(efi_disconnect_controller( handle, driver_handle_buffer[--number_of_drivers], child_handle)); - if (r == EFI_SUCCESS) - ret = r; + if (ret != EFI_SUCCESS) + goto reconnect; } + + free(driver_handle_buffer); + return ret; + +reconnect: + /* Reconnect all disconnected drivers */ + for (; number_of_drivers < tmp; number_of_drivers++) { + r = EFI_CALL(efi_connect_controller(handle, + &driver_handle_buffer[number_of_drivers], + NULL, true)); + if (r != EFI_SUCCESS) + EFI_PRINT("Failed to reconnect controller\n"); + } + free(driver_handle_buffer); return ret; }