From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web11.15809.1591282424218059152 for ; Thu, 04 Jun 2020 07:53:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20150623.gappssmtp.com header.s=20150623 header.b=2NQAzine; spf=pass (domain: nuviainc.com, ip: 209.85.221.68, mailfrom: leif@nuviainc.com) Received: by mail-wr1-f68.google.com with SMTP id l10so6422504wrr.10 for ; Thu, 04 Jun 2020 07:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=rfH30tgNd6e8RpdRpFd8W09J4MIVeVVZUic96UCzwmE=; b=2NQAzinedH7QafNUHGtB5+UTzjYcOvVZUiNGBLsi8EBd6UZypdTM6ToF+E5CMX2ptl 5kD7AU9s624bNVnnOnL/OYiW1oMNnxAFlIEFnWMrLVBuE+z/QyY1lK55kcChHaOgKpGT P+/c5RFBxstOHj/MrEjY4cJKNgtp+aM5N4fiSxavBX91A8k7EJ7P1Z1qm1HmqtfdzYdu rSd69QZsSPV2PosbdS2A9cY3LfPThsjIoE0kNcfFBd0zzoF1DDIEAHhQ4fXV6b7EKv/P FiTkvjqNXiYuW/Slcs9Xqf7t6EoIXDOsT6jVVKMIEqLKbcaw1LVvZXYyXY57g8uVggQN hI3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rfH30tgNd6e8RpdRpFd8W09J4MIVeVVZUic96UCzwmE=; b=a7J14NeguG+QxUNWj6PwTSDWbzRGVG+9i8rw4HfJ89d07FXskAMwvUzkme0y+MTojc oXGDamdS033F05JosRbrt7hNU4IpXsSp9JiMxIahOL31LPKsxxCA/JR9MrCcNFvAS1tQ B76gDgsv6tedua+fRq8Ts12tYtRe+xBrceDI8HBJTUjT5HCvl22OGllL0Y5qux0v0q35 1GOOH9dWsULy9rL5gW7bAI5PbvbSDaSrnGLIj9hSMnCWtuFBqLVy7VZqc859RRPQUCCP y8qDvLqB4CZe3ZQiccfMrgpzCWAlhJfKdzXAea8XqdvOoBuZP4Mk0unebGLMqWSO5PJJ JoYQ== X-Gm-Message-State: AOAM532wCGOPexSP76Jvmet8DLmQaUqm05mlkxpYzWbtU22dNGpp+vC6 MQLTIq/ampg+AytGqZufe7e67A== X-Google-Smtp-Source: ABdhPJzbnrfNzKaNmtnD/ZFw6MLM71N/dYMSPmVCiEUWC3FZeUIBoyn+NHlV61n4CbMGqQ/VKvLHPA== X-Received: by 2002:adf:e692:: with SMTP id r18mr4601477wrm.192.1591282422798; Thu, 04 Jun 2020 07:53:42 -0700 (PDT) Return-Path: Received: from vanye ([2001:470:1f09:12f0:b26e:bfff:fea9:f1b8]) by smtp.gmail.com with ESMTPSA id h15sm7950322wrt.73.2020.06.04.07.53.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jun 2020 07:53:41 -0700 (PDT) Date: Thu, 4 Jun 2020 15:53:39 +0100 From: "Leif Lindholm" To: Ard Biesheuvel Cc: devel@edk2.groups.io, Jared McNeill , Andrei Warkentin , Samer El-Haj-Mahmoud , Pete Batard , Jeremy Linton Subject: Re: [PATCH edk2-platforms 1/3] Silicon/Broadcom/BcmGenetDxe: program MAC also when not connected Message-ID: <20200604145339.GX28566@vanye> References: <20200604095007.45693-1-ard.biesheuvel@arm.com> <20200604095007.45693-2-ard.biesheuvel@arm.com> MIME-Version: 1.0 In-Reply-To: <20200604095007.45693-2-ard.biesheuvel@arm.com> User-Agent: Mutt/1.10.1 (2018-07-13) Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 04, 2020 at 11:50:05 +0200, 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. Does this not cause a behaviour change if the driver *has* been invoked, and the MAC address has been modified with SNP.StationAddress()? / Leif > Signed-off-by: Ard Biesheuvel > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -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; > -- > 2.26.2 >