From: "Jeremy Linton" <jeremy.linton@arm.com>
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 <jeremy.linton@arm.com>
Subject: [PATCH v2 5/5] Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot
Date: Mon, 18 Oct 2021 15:51:27 -0500 [thread overview]
Message-ID: <20211018205127.7099-6-jeremy.linton@arm.com> (raw)
In-Reply-To: <20211018205127.7099-1-jeremy.linton@arm.com>
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 mode,
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 <jeremy.linton@arm.com>
---
Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 42 ++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/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 <Library/TimerLib.h>
#include <Library/EfiResetSystemLib.h>
#include <Library/ArmSmcLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeLib.h>
#include <IndustryStandard/ArmStdSmc.h>
+
+/**
+ 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 = gBS->LocateHandleBuffer (
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
+ gBS->DisconnectController (HandleBuffer[HandleIndex], NULL, NULL);
+ }
+
+ gBS->FreePool(HandleBuffer);
+}
+
+
/**
Resets the entire platform.
@@ -53,6 +93,8 @@ LibResetSystem (
*/
EfiEventGroupSignal (&gRaspberryPiEventResetGuid);
+ DisconnectAll ();
+
Delay = PcdGet32 (PcdPlatformResetDelay);
if (Delay != 0) {
DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
--
2.13.7
next prev parent reply other threads:[~2021-10-18 20:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-18 20:51 [PATCH v2 0/5] Platform/Rpi: Various cleanups + DT booting Jeremy Linton
2021-10-18 20:51 ` [PATCH v2 1/5] Platform/RaspberryPi: Always use non translating DMA in DT mode Jeremy Linton
2021-10-18 20:51 ` [PATCH v2 2/5] Platform/RaspberryPi: Fix vfr warning caused by two defaults Jeremy Linton
2021-10-18 20:51 ` [PATCH v2 3/5] Platform/RaspberryPi: Expand locking to cover return data Jeremy Linton
2021-10-18 20:51 ` [PATCH v2 4/5] Platform/RaspberryPi: Normal memory should not be marked as uncached Jeremy Linton
2021-10-18 20:51 ` Jeremy Linton [this message]
2021-10-19 7:23 ` [PATCH v2 0/5] Platform/Rpi: Various cleanups + DT booting Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211018205127.7099-6-jeremy.linton@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox