From: "Pete Batard" <pete@akeo.ie>
To: Ard Biesheuvel <ard.biesheuvel@arm.com>, devel@edk2.groups.io
Cc: Jared McNeill <jmcneill@invisible.ca>,
Andrei Warkentin <awarkentin@vmware.com>,
Samer El-Haj-Mahmoud <samer.el-haj-mahmoud@arm.com>,
Leif Lindholm <leif@nuviainc.com>,
Jeremy Linton <lintonrjeremy@gmail.com>
Subject: Re: [PATCH edk2-platforms 1/3] Silicon/Broadcom/BcmGenetDxe: program MAC also when not connected
Date: Thu, 4 Jun 2020 13:27:06 +0100 [thread overview]
Message-ID: <56e6019e-5527-f67c-afad-3ac2b313a978@akeo.ie> (raw)
In-Reply-To: <20200604095007.45693-2-ard.biesheuvel@arm.com>
Note: For some reason, I am getting extra empty lines in this patch
series, which makes applying those patches problematic.
Apart from that, I have no notes on the proposal.
On 2020.06.04 10:50, Ard Biesheuvel wrote:
> In preparation of removing the EfiBootManagerConnectAll() from the
> ordinary boot path, ensure that the MAC programming of the GENET
> occurs even if the SNP driver for it is never invoked by the BDS.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
> ---
> Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 66 ++++++++++++++++++++
> 1 file changed, 66 insertions(+)
>
> diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> index f37da3b65511..7f93c68cd608 100644
> --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
> @@ -12,6 +12,7 @@
> #include <Uefi.h>
>
> #include <Library/BaseMemoryLib.h>
>
> #include <Library/DebugLib.h>
>
> +#include <Library/IoLib.h>
>
> #include <Library/MemoryAllocationLib.h>
>
> #include <Library/NetLib.h>
>
> #include <Library/UefiBootServicesTableLib.h>
>
> @@ -20,6 +21,9 @@
>
>
> #include "BcmGenetDxe.h"
>
>
>
> +STATIC EFI_EVENT mProtocolNotifyEvent;
>
> +STATIC VOID *mProtocolNotifyEventRegistration;
>
> +
>
> /**
>
> Tests to see if this driver supports a given controller.
>
>
>
> @@ -305,6 +309,57 @@ STATIC EFI_DRIVER_BINDING_PROTOCOL mGenetDriverBinding = {
> NULL
>
> };
>
>
>
> +STATIC
>
> +VOID
>
> +EFIAPI
>
> +OnProtocolNotify (
>
> + IN EFI_EVENT Event,
>
> + IN VOID *Context
>
> + )
>
> +{
>
> + BCM_GENET_PLATFORM_DEVICE_PROTOCOL *GenetDevice;
>
> + EFI_STATUS Status;
>
> + EFI_HANDLE *HandleBuffer;
>
> + UINTN HandleCount;
>
> + UINTN Index;
>
> + UINT32 Mac0, Mac1;
>
> +
>
> + while (TRUE) {
>
> + Status = gBS->LocateHandleBuffer (ByRegisterNotify, NULL,
>
> + mProtocolNotifyEventRegistration, &HandleCount,
>
> + &HandleBuffer);
>
> + if (EFI_ERROR (Status)) {
>
> + break;
>
> + }
>
> +
>
> + for (Index = 0; Index < HandleCount; Index++) {
>
> + Status = gBS->HandleProtocol (HandleBuffer[Index],
>
> + &gBcmGenetPlatformDeviceProtocolGuid,
>
> + (VOID **)&GenetDevice);
>
> + ASSERT_EFI_ERROR (Status);
>
> +
>
> + Mac0 = (GenetDevice->MacAddress.Addr[3]) |
>
> + (GenetDevice->MacAddress.Addr[2] << 8) |
>
> + (GenetDevice->MacAddress.Addr[1] << 16) |
>
> + (GenetDevice->MacAddress.Addr[0] << 24);
>
> + Mac1 = (GenetDevice->MacAddress.Addr[5]) |
>
> + (GenetDevice->MacAddress.Addr[4] << 8);
>
> +
>
> + MmioOr32 (GenetDevice->BaseAddress + GENET_SYS_RBUF_FLUSH_CTRL,
>
> + GENET_SYS_RBUF_FLUSH_RESET);
>
> + gBS->Stall (10);
>
> + MmioAnd32 (GenetDevice->BaseAddress + GENET_SYS_RBUF_FLUSH_CTRL,
>
> + ~GENET_SYS_RBUF_FLUSH_RESET);
>
> +
>
> + MemoryFence ();
>
> +
>
> + MmioWrite32 (GenetDevice->BaseAddress + GENET_UMAC_MAC0, Mac0);
>
> + MmioWrite32 (GenetDevice->BaseAddress + GENET_UMAC_MAC1, Mac1);
>
> + }
>
> + FreePool (HandleBuffer);
>
> + }
>
> +}
>
> +
>
> /**
>
> The entry point of GENET UEFI Driver.
>
>
>
> @@ -336,6 +391,17 @@ GenetEntryPoint (
>
>
> ASSERT_EFI_ERROR (Status);
>
>
>
> + //
>
> + // We need to program the MAC address into each existing controller,
>
> + // regardless of whether UEFI ever makes use of the interface, so that
>
> + // the OS driver will not have to care about this.
>
> + //
>
> + mProtocolNotifyEvent = EfiCreateProtocolNotifyEvent (
>
> + &gBcmGenetPlatformDeviceProtocolGuid,
>
> + TPL_CALLBACK, OnProtocolNotify, NULL,
>
> + &mProtocolNotifyEventRegistration);
>
> + ASSERT (mProtocolNotifyEvent != NULL);
>
> +
>
> DEBUG ((DEBUG_INIT | DEBUG_INFO, "Installed GENET UEFI driver!\n"));
>
>
>
> return EFI_SUCCESS;
>
Reviewed-By: Pete Batard <pete@akeo.ie>
next prev parent reply other threads:[~2020-06-04 12:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 9:50 [PATCH edk2-platforms 0/3] Platform/RaspberryPi: omit ConnectAll() on regular boot Ard Biesheuvel
2020-06-04 9:50 ` [PATCH edk2-platforms 1/3] Silicon/Broadcom/BcmGenetDxe: program MAC also when not connected Ard Biesheuvel
2020-06-04 12:27 ` Pete Batard [this message]
2020-06-04 14:53 ` Leif Lindholm
2020-06-04 14:57 ` Ard Biesheuvel
2020-06-04 15:00 ` Leif Lindholm
2020-06-04 9:50 ` [PATCH edk2-platforms 2/3] Platform/RaspberryPi: add UEFI Shell to boot manager menu Ard Biesheuvel
2020-06-04 12:27 ` Pete Batard
2020-06-04 9:50 ` [PATCH edk2-platforms 3/3] Platform/RaspberryPi: don't connect all devices on an ordinary boot Ard Biesheuvel
2020-06-04 12:27 ` Pete Batard
2020-06-05 8:10 ` 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=56e6019e-5527-f67c-afad-3ac2b313a978@akeo.ie \
--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