From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (NAM04-CO1-obe.outbound.protection.outlook.com [40.107.69.74]) by mx.groups.io with SMTP id smtpd.web11.33.1589213867067414964 for ; Mon, 11 May 2020 09:17:47 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@vmware.com header.s=selector2 header.b=1oJJx1cw; spf=pass (domain: vmware.com, ip: 40.107.69.74, mailfrom: awarkentin@vmware.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gGYfUaSrkw0CwMN4zTX8K8UHEH4fvASPDdyD3f8RkFyRSS+0P2L5kuln09RRyhCE1+o4CDsO5P4uN+YZej2DXA0miXq5jEQykc8Fis5ApsGqb8/e7mlgm8YAjzOosU4zvI6NOoevqRCYdMP9CGgt28lWufO9VARt5G39M1XHTdJFj5nqatEkFzpCsUR5nKoGw8bBTGSG1R4RuEEWqVh4EFWvkj0RLE6AD35x4mZ67Y90QrwwGaBvZyd/3mHhlGpS9Paq+XNuK52L9ZJvnkd/Ayz1N+HkD8jtWx/kYVrDHUPLeTAwFLrNtmqlZnCAvCC21MzQyXxh5cIDF6ZyR2dUsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nFHmOifhPxODzXST8vBpmWZSynfacnVxC+D3mIwoN0g=; b=KmVl4mYCndBNHR0kcCWH66aWQ1Ss6VOZMSNqF8DrmhpbAWWrEPlO+dH80MOL7istfEJjeNDKCkGltL1mjfhU3vSpHOE6Rdo1yRBnioLaKnfFSiINjWI8F2g0e4WvaElE4FmYaVWG/3ao1xMUNz7FvnLcUk9Sl8Vu4OeKY5yVj/ESYVr5vU4u3z52XXa0oNn7dkhGVx9+N71mZxZ1knLaf6f2jw6g5pQoDpkfV6lP3fWOXVDSX28J6dGPHLR8WpO44VOGpQ7tUgiE8TmPVk+/3vR2bjmeatnD5ROhog4fSFsuSLKQkKWGH2ZdOuPQwna1ZJQEw0PBUCCQzkpoIqoqRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nFHmOifhPxODzXST8vBpmWZSynfacnVxC+D3mIwoN0g=; b=1oJJx1cwpxrID7BOyJU8wby0boJJbF7NowTB9V/fnmEdTl7ve8NA5O7Q5fzlRpMKXpWJaepWghD73Q5Z15PNuBR5IzmNG+nl1t1Joi8lJ4azy/wbGiVMX+4fxQULMujrZYQxUp6Rx80ehpP62JCdojHL1/ua4ISnBKMj1cezq5g= Received: from BN6PR05MB3411.namprd05.prod.outlook.com (2603:10b6:405:43::23) by BN6PR05MB3297.namprd05.prod.outlook.com (2603:10b6:405:43::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.14; Mon, 11 May 2020 16:17:45 +0000 Received: from BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::f463:db64:43d8:5a0f]) by BN6PR05MB3411.namprd05.prod.outlook.com ([fe80::f463:db64:43d8:5a0f%3]) with mapi id 15.20.3000.016; Mon, 11 May 2020 16:17:44 +0000 From: "Andrei Warkentin" To: Ard Biesheuvel , "devel@edk2.groups.io" CC: Pete Batard , Jared McNeill , Samer El-Haj-Mahmoud , Jeremy Linton Subject: Re: [PATCH edk2-platforms v4 8/9] Silicon/Broadcom/BcmGenetDxe: add unload support Thread-Topic: [PATCH edk2-platforms v4 8/9] Silicon/Broadcom/BcmGenetDxe: add unload support Thread-Index: AQHWJ6RHDAbpCFEOQ0eHfrByNWYsi6ijDVLl Date: Mon, 11 May 2020 16:17:44 +0000 Message-ID: References: <20200511145527.23453-1-ard.biesheuvel@arm.com>,<20200511145527.23453-9-ard.biesheuvel@arm.com> In-Reply-To: <20200511145527.23453-9-ard.biesheuvel@arm.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=vmware.com; x-originating-ip: [98.214.99.181] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: d13f6490-f49e-4987-4c4c-08d7f5c6d6a9 x-ms-traffictypediagnostic: BN6PR05MB3297: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4502; x-forefront-prvs: 04004D94E2 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: PF+xFKgLQlR7+qpf51VGS/eWvuSaKFoEWjnQpWRE9rIgsGegqj0ta1MfTlSLgqg2hldePyhz6R0lZ1T8MFGSS1IS4LZZ8AiNQBYR1AGC/0GRgm2BXp+Q91HJ915QYZbaIVxHpHyFcaD+xXyiq6o63GJzqXwHg9CVlKK0PyDiYvKT2sP2GbdddVGT3mOOSWJQHVi3avRURD5M7p6Ek/15i+7j2IXESquajuspeGWq+eNCLSoi1zcrCIrTa2TmLbi+B+7Mx6u+c0H6UifnJWJ1LCmOpSCsAFNbhlU402QyN6NQJYSaOmzYJAMOU3G+K59KVR+1E22HQJ93ycKl12NaSTEyXaYXlnA/kXbBzEPQunPwGlH33H++oJq/0Xy+86tk+rspBpRGbzztXhr/fCLxzE0PY9jytMrF53LG/xvumiowQTAgRc3aixZvwk4VTDGbTsNdrh+ZKggQdwYAKSLXUUGW4JT1Nt+y1udA/Y9lQ5BCwaEHUZjqDUiSlWL5AnVJtSZkd3ZyLPtuOHDBIRH2Mg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN6PR05MB3411.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(396003)(39860400002)(376002)(346002)(366004)(33430700001)(19627235002)(9686003)(316002)(53546011)(33440700001)(6506007)(8676002)(54906003)(86362001)(76116006)(5660300002)(4326008)(66476007)(64756008)(66946007)(66556008)(2906002)(66446008)(110136005)(478600001)(33656002)(52536014)(7696005)(71200400001)(186003)(8936002)(26005)(19627405001)(55016002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: /XmUzk9BsoWMfWOInM+G4n4AV/B1wZaGFjotRe7IOqXi5sixV3zmXdErX5nQt+Dhb3IDxyF1rlgJqw4IsCT3u8nNckGk5ZqIjhdQdhktIbuqkrkbVLkJoIzSHbJx14y7o1IZh8HHUuT6B2b4qJu7WuRT/YI4U0q1E4M/Rrhgy2Hjq7RN9vLsDlzKz7if94VaRyr2FYdcfefflUcw0xf8OJ2GqnpxATUnajgNQJZQHGR+ZPiPKOTuuVeiqnFOvTEUyH5LhCiJQFCGOhZmoeQPl4TfCewWmo17jHKcm5sBmnz6tQmafVHXrA9/Ved1r83iL2y+gukw8anUOvShlk9btTodAiGM9jVpvVFaenLb0lVl27gc+A2hDS2zCT/xEE5jsOpi9aeS4mLeqqF/m3VPoUgmKBsF9kKfP3FoeA0hcCEzhgyUNGYjWgslzHL7eRUznywVkQ+TX0drbBAO9+4Z6yIC0wxUEhoskn/5diohWp4= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: d13f6490-f49e-4987-4c4c-08d7f5c6d6a9 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2020 16:17:44.9553 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: bSEfFiep4obkN4mDvT1QpJKqby9kVUv4Gn4RtMJ2ybx74UW9/sjF+eS0Y1LYmL6JS4zfo4IyZbpzAUyJPSUM3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR05MB3297 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BN6PR05MB34119FD215F5075101D03733B9A10BN6PR05MB3411namp_" --_000_BN6PR05MB34119FD215F5075101D03733B9A10BN6PR05MB3411namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ard, Can DisconnectController fail? Should this check for that? Other than that and the USB comment, looks fine... A ________________________________ From: Ard Biesheuvel Sent: Monday, May 11, 2020 9:55 AM To: devel@edk2.groups.io Cc: Ard Biesheuvel ; Pete Batard ; Ja= red McNeill ; Andrei Warkentin ; Samer El-Haj-Mahmoud ; Jeremy Linton Subject: [PATCH edk2-platforms v4 8/9] Silicon/Broadcom/BcmGenetDxe: add un= load support Add unload support to the GENET driver Signed-off-by: Ard Biesheuvel --- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf | 1 + Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 60 ++++++++++++= ++++++++ 2 files changed, 61 insertions(+) diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf index e3e4ebbddb93..3e98983c6b07 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf @@ -16,6 +16,7 @@ [Defines] MODULE_TYPE =3D UEFI_DRIVER VERSION_STRING =3D 1.0 ENTRY_POINT =3D GenetEntryPoint + UNLOAD_IMAGE =3D GenetUnload [Sources] ComponentName.c diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c index 630a92ef210b..238b336d55f6 100644 --- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c +++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c @@ -340,3 +340,63 @@ GenetEntryPoint ( return EFI_SUCCESS; } + +/** + Unload function of GENET UEFI Driver. + + @param ImageHandle The allocated handle for the EFI image + + @retval EFI_SUCCESS The driver was unloaded successfully + @retval EFI_INVALID_PARAMETER ImageHandle is not a valid image handle. + +**/ +EFI_STATUS +EFIAPI +GenetUnload ( + IN EFI_HANDLE ImageHandle + ) +{ + EFI_STATUS Status; + EFI_HANDLE *HandleBuffer; + UINTN HandleCount; + UINTN Index; + + // + // Retrieve all USB I/O handles in the handle database + // + Status =3D gBS->LocateHandleBuffer (ByProtocol, + &gBcmGenetPlatformDeviceProtocolGuid, + NULL, + &HandleCount, + &HandleBuffer); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Disconnect the driver from the handles in the handle database + // + for (Index =3D 0; Index < HandleCount; Index++) { + Status =3D gBS->DisconnectController (HandleBuffer[Index], + gImageHandle, + NULL); + } + + // + // Free the handle array + // + gBS->FreePool (HandleBuffer); + + // + // Uninstall protocols installed by the driver in its entrypoint + // + Status =3D EfiLibUninstallDriverBindingComponentName2 ( + &mGenetDriverBinding, + &gGenetComponentName, + &gGenetComponentName2 + ); + + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} -- 2.17.1 --_000_BN6PR05MB34119FD215F5075101D03733B9A10BN6PR05MB3411namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Hi Ard,

Can DisconnectController fail? Should this check for that?

Other than that and the USB comment, looks fine...

A

From: Ard Biesheuvel <ar= d.biesheuvel@arm.com>
Sent: Monday, May 11, 2020 9:55 AM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>; Pete Batard <p= ete@akeo.ie>; Jared McNeill <jmcneill@invisible.ca>; Andrei Warken= tin <awarkentin@vmware.com>; Samer El-Haj-Mahmoud <Samer.El-Haj-Ma= hmoud@arm.com>; Jeremy Linton <jeremy.linton@arm.com>
Subject: [PATCH edk2-platforms v4 8/9] Silicon/Broadcom/BcmGenetDxe:= add unload support
 
Add unload support to the GENET driver

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
---
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf |  1 &#= 43;
 Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c | 60 +&#= 43;++++++++++++++&#= 43;+++
 2 files changed, 61 insertions(+)

diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf
index e3e4ebbddb93..3e98983c6b07 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf<= br> @@ -16,6 +16,7 @@ [Defines]
   MODULE_TYPE        &nb= sp;           =3D UEFI_DR= IVER
   VERSION_STRING        =          =3D 1.0
   ENTRY_POINT        &nb= sp;           =3D GenetEn= tryPoint
+  UNLOAD_IMAGE        &nb= sp;          =3D GenetUnload  
 [Sources]
   ComponentName.c
diff --git a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c b/Sil= icon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
index 630a92ef210b..238b336d55f6 100644
--- a/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c
+++ b/Silicon/Broadcom/Drivers/Net/BcmGenetDxe/DriverBinding.c<= br> @@ -340,3 +340,63 @@ GenetEntryPoint (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Unload function of GENET UEFI Driver.
+
+  @param  ImageHandle      &nb= sp;     The allocated handle for the EFI image
+
+  @retval EFI_SUCCESS       &n= bsp;    The driver was unloaded successfully
+  @retval EFI_INVALID_PARAMETER  ImageHandle is not a valid = image handle.
+
+**/
+EFI_STATUS
+EFIAPI
+GenetUnload (
+  IN EFI_HANDLE  ImageHandle
+  )
+{
+  EFI_STATUS  Status;
+  EFI_HANDLE  *HandleBuffer;
+  UINTN       HandleCount;
+  UINTN       Index;
+
+  //
+  // Retrieve all USB I/O handles in the handle database
+  //
+  Status =3D gBS->LocateHandleBuffer (ByProtocol,
+           &nbs= p;            &= nbsp;           &gBcm= GenetPlatformDeviceProtocolGuid,
+           &nbs= p;            &= nbsp;           NULL,
+           &nbs= p;            &= nbsp;           &Hand= leCount,
+           &nbs= p;            &= nbsp;           &Hand= leBuffer);
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+
+  //
+  // Disconnect the driver from the handles in the handle databas= e
+  //
+  for (Index =3D 0; Index < HandleCount; Index++) { +    Status =3D gBS->DisconnectController (HandleBuff= er[Index],
+           &nbs= p;            &= nbsp;           &nbs= p;   gImageHandle,
+           &nbs= p;            &= nbsp;           &nbs= p;   NULL);
+  }
+
+  //
+  // Free the handle array
+  //
+  gBS->FreePool (HandleBuffer);
+
+  //
+  // Uninstall protocols installed by the driver in its entrypoin= t
+  //
+  Status =3D EfiLibUninstallDriverBindingComponentName2 (
+           &nbs= p; &mGenetDriverBinding,
+           &nbs= p; &gGenetComponentName,
+           &nbs= p; &gGenetComponentName2
+           &nbs= p; );
+
+  ASSERT_EFI_ERROR (Status);
+
+  return EFI_SUCCESS;
+}
--
2.17.1

--_000_BN6PR05MB34119FD215F5075101D03733B9A10BN6PR05MB3411namp_--