From: "Ard Biesheuvel" <ardb@kernel.org>
To: Jeremy Linton <jeremy.linton@arm.com>
Cc: edk2-devel-groups-io <devel@edk2.groups.io>,
Peter Batard <pete@akeo.ie>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Leif Lindholm <leif@nuviainc.com>,
Andrei Warkentin <awarkentin@vmware.com>,
Sunny Wang <Sunny.Wang@arm.com>,
Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>
Subject: Re: [PATCH 5/5] Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot
Date: Tue, 5 Oct 2021 12:11:18 +0200 [thread overview]
Message-ID: <CAMj1kXHQ0UStu5pr6JBTiS1B0qWP9kRHbRRpYwQeH1V=QChvpg@mail.gmail.com> (raw)
In-Reply-To: <20211002005238.40280-6-jeremy.linton@arm.com>
On Sat, 2 Oct 2021 at 02:52, Jeremy Linton <jeremy.linton@arm.com> wrote:
>
> In theory we should be properly cleaning up all the device drivers before
> pulling the big switch. Particularly the partition mgr will issue
> flush commands to attached disks as it goes down. This assures that
> devices running in WB mode (that correctly handle flush/sync/etc) commands
> are persisted to physical media before we hit reset.
>
> Without this, there are definitly 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 persistance requests but we can start here.
>
> Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
> ---
> Platform/RaspberryPi/Library/ResetLib/ResetLib.c | 44 ++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
> index a70eee485d..036f619cb5 100644
> --- a/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
> +++ b/Platform/RaspberryPi/Library/ResetLib/ResetLib.c
> @@ -19,11 +19,54 @@
> #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)
> +
> + @retval EFI_SUCCESS The operation was successful.
> +
> +**/
STATIC
> +EFI_STATUS
> +DisconnectAll(
Space before (
> + 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)) {
I understand that this code is copy/pasted but I'd still prefer to
avoid the 'success handling' anti pattern here.
if (EFI_ERROR (Status)) {
return Status;
}
> + for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
> + Status = gBS->DisconnectController (
> + HandleBuffer[HandleIndex],
> + NULL,
> + NULL
> + );
> + }
> + gBS->FreePool(HandleBuffer);
> + }
> + return (EFI_SUCCESS);
No need for ()
> +}
> +
> +
> /**
> Resets the entire platform.
>
> @@ -57,6 +100,7 @@ LibResetSystem (
> if (Delay != 0) {
> DEBUG ((DEBUG_INFO, "Platform will be reset in %d.%d seconds...\n",
> Delay / 1000000, (Delay % 1000000) / 100000));
> + DisconnectAll ();
Capture Status here and ASSERT_EFI_ERROR() ??
Maybe it is overkill, and maybe DisconnectController() fails
spuriously, so I am not entirely sure, but adding a local function
that returns a value and then ignore it seems slightly sloppy to me.
> MicroSecondDelay (Delay);
> }
> }
> --
> 2.13.7
>
next prev parent reply other threads:[~2021-10-05 10:11 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-02 0:52 [PATCH 0/5] Platform/Rpi: Various cleanups Jeremy Linton
2021-10-02 0:52 ` [PATCH 1/5] Platform/RaspberryPi: Fix vfr warning caused by two defaults Jeremy Linton
2021-10-02 1:12 ` Andrei Warkentin
2021-10-02 0:52 ` [PATCH 2/5] Platform/RaspberryPi: Expand locking to cover return data Jeremy Linton
2021-10-02 1:17 ` Andrei Warkentin
2021-10-05 10:12 ` Ard Biesheuvel
2021-10-05 21:19 ` Jeremy Linton
2021-10-06 15:31 ` Ard Biesheuvel
2021-10-02 0:52 ` [PATCH 3/5] Platform/RaspberryPi: Update Linux quirk name Jeremy Linton
2021-10-02 1:13 ` Andrei Warkentin
2021-10-14 21:22 ` Jeremy Linton
2021-10-02 0:52 ` [PATCH 4/5] Platform/RaspberryPi: Normal memory should not be marked as uncached Jeremy Linton
2021-10-02 1:14 ` Andrei Warkentin
2021-10-05 10:05 ` Ard Biesheuvel
2021-10-02 0:52 ` [PATCH 5/5] Platform/RaspberryPi: Disconnect/shutdown all drivers before reboot Jeremy Linton
2021-10-02 1:16 ` Andrei Warkentin
2021-10-05 10:11 ` Ard Biesheuvel [this message]
2021-10-05 21:24 ` Jeremy Linton
2021-10-05 21:35 ` 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='CAMj1kXHQ0UStu5pr6JBTiS1B0qWP9kRHbRRpYwQeH1V=QChvpg@mail.gmail.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