From nobody Mon Feb 9 11:32:03 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59055+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59055+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1589180834; cv=none; d=zohomail.com; s=zohoarc; b=KvRf9dQw7ZK8Onlzi7tOk7gB8lqBJJzF31DjeDJg6c1NTxL/4jvnHVLuz6RlUTc+lfKG8qM15IhNRHRYh1McrSiyq6nfJbLQoshrho80KNp2EzE3rMbVFsZ/Vqv22F6nksw2jdklQh9tXKrA4nh7ThcKXD4OwHksY0CGME4cA1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589180834; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=fudFCtH8iX8FuJkj8C6SD/Y2EbgHYyrSZ3sXFbYI6eM=; b=bKhuK3Mv69kztsaAQJ64UVBnvcCp8d2XTKbwJL4kQocThz7kcuGBv5a4vZh4YqSVj3nBJ8Unw1R9eH+AqAEiZ25xvz9Y5NqkzLrnlYJ8JimuLZbBswsBcF0ihzW2+JtcTYLEKRFV1DCsTdE9rV0ohhQbCjO5u9XHUa2ukcpzqak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59055+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589180834381669.0740920234433; Mon, 11 May 2020 00:07:14 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id aDaUYY1788612x5Lq2h1UBKX; Mon, 11 May 2020 00:07:13 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.7681.1589180833333018341 for ; Mon, 11 May 2020 00:07:13 -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 0216A101E; Mon, 11 May 2020 00:07:13 -0700 (PDT) X-Received: from e123331-lin.nice.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BADD23F68F; Mon, 11 May 2020 00:07:11 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Pete Batard , Jared McNeill , Andrei Warkentin , Samer El-Haj-Mahmoud Subject: [edk2-devel] [PATCH edk2-platforms v3 5/5] Silicon/Broadcom/BcmGenetDxe: shut down devices on ExitBootServices() Date: Mon, 11 May 2020 09:06:56 +0200 Message-Id: <20200511070656.32141-6-ard.biesheuvel@arm.com> In-Reply-To: <20200511070656.32141-1-ard.biesheuvel@arm.com> References: <20200511070656.32141-1-ard.biesheuvel@arm.com> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@arm.com X-Gm-Message-State: Uw1PytLnjBWYQ4ZWPmpl4knMx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589180833; bh=LbMQHJRbYCjUAPcBXZ+ZaF3o4vtz59SkjYymOU9DchM=; h=Cc:Date:From:Reply-To:Subject:To; b=o8DXCDB3CT/xDkajzjPYMvVeZJ8eUfgfEH8Uay3Tgl6T5MNwtmUh+952LvQ5w6kWU3B LrHT0+TkBdbIr7BPzCfmaA6Af9A9cUvvmcGlU1ebd7L2ks9WJMS5B+3YRaCJ2itR6NPGk bCVDPJv37zv/gFUMBPXAJNRq8Rh+CC7t++I= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When the OS takes over the machine, it calls ExitBootServices() in order to shut down all resident services and event notifications so that all asynchronous activity is stopped. At this point, any DMA masters that are still active should be shut down. This is especially important for network controllers, since any activity on the network will trigger DMA writes into memory, which will no longer be reserved for this purpose once the OS takes over. So register for the ExitBootServices event, and shut down the controller at this point if it was started before. Signed-off-by: Ard Biesheuvel --- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf | 4 +++ Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h | 1 + Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 31 ++++++++++++= ++++++++ 3 files changed, 36 insertions(+) diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf index 3cabc5936562..a287f0495ff9 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf @@ -42,6 +42,7 @@ [LibraryClasses] IoLib MemoryAllocationLib NetLib + UefiBootServicesTableLib UefiDriverEntryPoint UefiLib =20 @@ -50,6 +51,9 @@ [Protocols] gEfiDevicePathProtocolGuid ## BY_START gEfiSimpleNetworkProtocolGuid ## BY_START =20 +[Guids] + gEfiEventExitBootServicesGuid + [Pcd] gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h b/Silicon= /Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h index 1dc7a51a1ca6..d03bf8daed58 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/GenetUtil.h @@ -203,6 +203,7 @@ typedef struct { EFI_HANDLE ControllerHandle; =20 EFI_LOCK Lock; + EFI_EVENT ExitBootServicesEvent; =20 EFI_SIMPLE_NETWORK_PROTOCOL Snp; EFI_SIMPLE_NETWORK_MODE SnpMode; diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c index a6102421cc26..29753d8ac754 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c @@ -76,6 +76,23 @@ GenetDriverBindingSupported ( return Status; } =20 +/** + Callback function to shut down the network device at ExitBootServices + + @param Event Pointer to this event + @param Context Event handler private data + +**/ +STATIC +VOID +EFIAPI +GenetNotifyExitBootServices ( + EFI_EVENT Event, + VOID *Context + ) +{ + GenetDisableTxRx ((GENET_PRIVATE_DATA *)Context); +} =20 /** Starts a device controller or a bus controller. @@ -173,6 +190,17 @@ GenetDriverBindingStart ( CopyMem (&Genet->SnpMode.CurrentAddress, &Genet->Dev->MacAddress, sizeof(EFI_MAC_ADDRESS)); =20 + Status =3D gBS->CreateEventEx (EVT_NOTIFY_SIGNAL, TPL_CALLBACK, + GenetNotifyExitBootServices, Genet, + &gEfiEventExitBootServicesGuid, + &Genet->ExitBootServicesEvent); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, + "GenetDriverBindingStart: failed to register for ExitBootServices ev= ent - %r\n", + Status)); + goto FreeDevice; + } + Status =3D gBS->InstallMultipleProtocolInterfaces (&ControllerHandle, &gEfiSimpleNetworkProtocolGuid, &Genet->Snp, NULL); @@ -251,6 +279,9 @@ GenetDriverBindingStop ( return Status; } =20 + Status =3D gBS->CloseEvent (Genet->ExitBootServicesEvent); + ASSERT_EFI_ERROR (Status); + GenetDmaFree (Genet); =20 Status =3D gBS->CloseProtocol (ControllerHandle, --=20 2.17.1 -=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 (#59055): https://edk2.groups.io/g/devel/message/59055 Mute This Topic: https://groups.io/mt/74130979/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-