From patchwork Tue Jun 20 06:19:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 694428 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp143653wrm; Mon, 19 Jun 2023 23:19:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Sv09wAWldBgFE4rFMrmXQswbbTXL0K0KcOsWkAyCYdkd9bBzHBRRm3QkucKr7RHvZNU2V X-Received: by 2002:a5e:8f09:0:b0:77a:ec0c:5907 with SMTP id c9-20020a5e8f09000000b0077aec0c5907mr8531274iok.13.1687241998268; Mon, 19 Jun 2023 23:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687241998; cv=none; d=google.com; s=arc-20160816; b=vIRYM+64Q3Ai7p9zaK6siYSIJI/U69vT6QHql98EiHTSga6EZbd8YSKxWAF78ZAnST lMMZNGGRoYrN5iuVpSxA4RuRZ//zQQSGA/T/GID6SevmOGOJtt1VCs3SuAFS2NKBT3XJ Ns1tUxrnGlBbwaWj9SEkPb6tzIVvIX+6yK/OICsprc9L2CNZ1KtEbro2bNYXB4li6bN1 FbJ3Tg024/WHANsfqPjkaxxeWe7TkEdVsZN91UhqtZHhfXThQIxoEOozqJs09xP4lvj4 VfnpJ/fQAvKGzVUvfUDXG8VV8mNKA+Ziv2TGoCyMK/QqyTKdyU5pUVh5lYrS6fobPLm0 xUGQ== 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=CoXKoGZoDowfsQalNyBZywdDmPy1Iws3Cwle/hL6gUw=; b=CFP5k73mpVNuvsD5cGSZ9ghrfg72M9FZZa9lAA/6P2/3SyqOQaT1jeRomptWpc6B2d c2MmKjNR+O/z67I3INlOFy1O5wV+mRL9w2EfTfmn3um6hiXlTaevm9NkfsUtoKZAvVm1 w9WJ/1yvEUc8P45Kaxfd/aytEIdAlUYUq36gG78704wAZ+VIZIHritZ1kVU7ekASLeu/ S71LfHS6CAA2dZAD+ExVCbpzkxIDvs0sn1jwx+7t0Qq/qgSwwouya8m9v2khEOGWTSDV M4Fwwtmbk1Mt1ONeG2UAS43o/eCwEb8gE/cOJdT0YdZA2538IjOaDD3l3RtGb5qwbUSI fydw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bd7XuQOb; 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 t25-20020a056602181900b0077e28bc0f87si527180ioh.97.2023.06.19.23.19.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 23:19:58 -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=bd7XuQOb; 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 BF1D686259; Tue, 20 Jun 2023 08:19:46 +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="bd7XuQOb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E6AB86341; Tue, 20 Jun 2023 08:19:39 +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-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) (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 38D2085FE5 for ; Tue, 20 Jun 2023 08:19:37 +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-x62d.google.com with SMTP id a640c23a62f3a-9883123260fso294814866b.0 for ; Mon, 19 Jun 2023 23:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687241977; x=1689833977; 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=CoXKoGZoDowfsQalNyBZywdDmPy1Iws3Cwle/hL6gUw=; b=bd7XuQObu19LVgQzeUk7AhTzGi4cKvQwHEXgMzWbuxoSxj/yZyIhzROyXmxEJdzEYx BoNybhhzACviMfPNVL8gQC2+If0QQhQQ4Np3RGOFtty78OEhQqYp/EAnGEgpLmPphsi0 VAYrDsqxB9jPGl5M9nQVgVT77o9lxJ3WAabJyZ3B+NGxjjaPsU+FvYFPwJSRWsfKB5pe hcLxcHjI1MfTDB7QadSwacfQPOUscNleSfUVcRdt5H1W6VWYFS1xgjtLEeAgXYuV8Sb9 QqRXasuw3v8oMVzS+p3HQYwYogfeyIkLjgHDn3V0NFXKTToqF8H9PC5Cn9oCU67mLb+A 5TZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687241977; x=1689833977; 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=CoXKoGZoDowfsQalNyBZywdDmPy1Iws3Cwle/hL6gUw=; b=URyqTwwyaYNJp/8oJ29z4z+MFYBqhg0E7elWWiDraZmxFcHu9gr1AM/W/mZInTfa3+ CpJtrkaTAjyZ3fzej6LjGXUlL2sHuTilwst1JVT/r0KlXBLW4E/TaXzMy78kdTL//nMm wkCSiTEQG+Y1Y0woQw55W8hRzRcuxKFM9c7D/oVdSb1phnD/pM4qGSnAJav/0IIxnaGJ D3JOga1ROgDyXwHqhoeY3YGybwNiWo/uRG/zM6wbgOtYg4Kl4KaP/XfVsgqKCUwzScbr HfUl+h7jnvzxwDVTwukcPX3i7zIdVB6vriMycvDD/iZufIxPI+hnlnKbwALb9lVVnKHZ deHg== X-Gm-Message-State: AC+VfDydV7hHin41TehCjHtQnKqouM+KtcTZmuxxKAk0pJcZTNDmVKa0 fh9uCdhwBeoUAltU0qTYv0JQVCO/ohTlNXnCHNDN+w== X-Received: by 2002:a17:907:3e97:b0:973:344:6a39 with SMTP id hs23-20020a1709073e9700b0097303446a39mr9687665ejc.76.1687241976885; Mon, 19 Jun 2023 23:19:36 -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.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 23:19:36 -0700 (PDT) From: Ilias Apalodimas To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Heinrich Schuchardt Subject: [PATCH 1/4 v2] efi_loader: reconnect drivers on failure Date: Tue, 20 Jun 2023 09:19:28 +0300 Message-Id: <20230620061932.113292-2-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 efi_disconnect_controller() doesn't reconnect drivers in case of failure. Reconnect the disconnected drivers properly Signed-off-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_boottime.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) -- 2.40.1 diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 5006c0e1e4af..d44562d8f4e0 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; }