From nobody Tue Feb 10 20:48:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+82254+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82254+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=arm.com ARC-Seal: i=1; a=rsa-sha256; t=1634590296; cv=none; d=zohomail.com; s=zohoarc; b=mZyrT3UysCUJ6k8YMj6ISmN7YstiOscnsf0T+fNf9IMXaiYwJkEK0OmVSufc38UyO2TKhzKWN+Cqj9M/P3769xkzUUgIpncjYjTLZK3/tvVb2TiZxd+eCRNpz0SvthLpRF98Eu8dFDXjooYds2M1oqEzwRt4/Sr/CMfdsWHjXjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1634590296; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=hCc5VTO0spZs33MhBb4pmtq6JgxBr8GYg0duaH3Z+fE=; b=VMrsIHqoUq3TKtiqErH23qH+gOETsMqy+b48+p/bzvT4YMX4yieEBquW7tx6hiVq4cigfN79uRBaEoUkC8va0i3XSjtETu4+FJKIloCzC/NOjZASZwXjxTQFjr7s2lRj0xbRH2WIXvlqdVDJ/3UtKS2mpnkMC+p/kmUgCQKGaWw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+82254+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634590296722911.02634900516; Mon, 18 Oct 2021 13:51:36 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kS83YY1788612xZWK2N7yTVo; Mon, 18 Oct 2021 13:51:36 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.155.1634590295534584673 for ; Mon, 18 Oct 2021 13:51:35 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 364B6D6E; Mon, 18 Oct 2021 13:51:35 -0700 (PDT) X-Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D20293F73D; Mon, 18 Oct 2021 13:51:34 -0700 (PDT) From: "Jeremy Linton" To: devel@edk2.groups.io Cc: pete@akeo.ie, ardb+tianocore@kernel.org, leif@nuviainc.com, awarkentin@vmware.com, Sunny.Wang@arm.com, samer.el-haj-mahmoud@arm.com, kettenis@openbsd.org, Jeremy Linton Subject: [edk2-devel] [PATCH v2 5/5] Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot Date: Mon, 18 Oct 2021 15:51:27 -0500 Message-Id: <20211018205127.7099-6-jeremy.linton@arm.com> In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com> References: <20211018205127.7099-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jeremy.linton@arm.com X-Gm-Message-State: GNazCZAcEJumSUM2BKQ4YfCnx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634590296; bh=Jpk+QfP0hpSfLmA0dyWrcHIDViqHUsn9kKkrkrqyjwA=; h=Cc:Date:From:Reply-To:Subject:To; b=psMcsy2Pe7fpd2LVp7c6mbV5Ml+LQZGqhUMWUPv/iWCJBx5QZzW8PlTWpmbhG9j7MNQ CDIPzI6meaxRqt593fZTj5jmdcNPM8bcB5wmug+uyyBwKgn4FstnYW1VhTO8RSomDXqpF v1DVi4mt+e0VBJKgrdmhWYv6mizAfuK4cwk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634590298770100021 Content-Type: text/plain; charset="utf-8" In theory we should be properly cleaning up all the device drivers before hitting the big reset. The partition manager will issue flush commands to attached disks as it goes down. This assures that devices running in WB mod= e, which correctly handle flush/sync/etc commands, are persisted to physical media before reset. Without this, there are definitely cases where the relevant specifications don't guarantee persistence of data in their buffers in the face of reset conditions. We can't really do anything about the many devices that don't honor persistence requests, but we can start here. Signed-off-by: Jeremy Linton --- Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 42 ++++++++++++++++++++= ++++ 1 file changed, 42 insertions(+) diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/Ra= spberryPi/Library/ResetLib/ResetLib.c index a70eee485d..2bcef8d4db 100644 --- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c +++ b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c @@ -19,11 +19,51 @@ #include #include #include +#include #include #include =20 #include =20 + +/** + Disconnect everything. + Modified from the UEFI 2.3 spec (May 2009 version) + +**/ +STATIC +VOID +DisconnectAll ( + VOID + ) +{ + EFI_STATUS Status; + UINTN HandleCount; + EFI_HANDLE *HandleBuffer; + UINTN HandleIndex; + + /* + * Retrieve the list of all handles from the handle database + */ + Status =3D gBS->LocateHandleBuffer ( + AllHandles, + NULL, + NULL, + &HandleCount, + &HandleBuffer + ); + if (EFI_ERROR (Status)) { + return; + } + + for (HandleIndex =3D 0; HandleIndex < HandleCount; HandleIndex++) { + gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL); + } + + gBS->FreePool(HandleBuffer); +} + + /** Resets the entire platform. =20 @@ -53,6 +93,8 @@ LibResetSystem ( */ EfiEventGroupSignal (&gRaspberryPiEventResetGuid); =20 + DisconnectAll (); + Delay =3D PcdGet32 (PcdPlatformResetDelay); if (Delay !=3D 0) { DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n", --=20 2.13.7 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#82254): https://edk2.groups.io/g/devel/message/82254 Mute This Topic: https://groups.io/mt/86424965/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-