From nobody Sat Sep 21 01:20:56 2024 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+51829+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+51829+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1575630141; cv=none; d=zohomail.com; s=zohoarc; b=nrT2c4ncOzDD9CbUdfC0uR8YAJzxzd43eP2/CmXbQzeHKCOYLzf4binwTZMHm+EbwRS0sP4AZ5i7LXmpjjkE7chNxP0ecxL37bCaQbChYySKjHshTcU+wPfDBGlpBW/AIghycdeLpQbU8PF2iaK6LTg2mTWhAEnWtQmZI661whE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575630141; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=5J/oai3oDIQBxvm4fUXz256z5hn4mzbx70TmJUy4uT0=; b=a95CFiHZZmlrAhz06XMHBCcW87/ExC1odMlqnbF7F5YX2DSEC26nThMxIHGUPI65cST5O925E1NQcI/z2AY1mCAZgFvWEM4DqqK+z0W2y9DRZi5I//U4v93lOSJVJIrPtqV69BEN9Cs/xUCRFsZxcFSdPhiRYBORe3Xz61o4K/8= 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+51829+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 157563014124566.72215061765542; Fri, 6 Dec 2019 03:02:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id QQ5wYY1788612xbWZyUaxEN7; Fri, 06 Dec 2019 03:02:20 -0800 X-Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by mx.groups.io with SMTP id smtpd.web10.2145.1575630139973117739 for ; Fri, 06 Dec 2019 03:02:20 -0800 X-Received: by mail-wm1-f65.google.com with SMTP id p17so6911297wmi.3 for ; Fri, 06 Dec 2019 03:02:19 -0800 (PST) X-Gm-Message-State: vDndbypieTVl4t8FxbtyIU4ix1787277AA= X-Google-Smtp-Source: APXvYqy9LqaPBTqSRxgRJS5SlHAPjlrhrjKAbvccJEVZpkSR6zSKO9cXe5fGxLqMWBWpD1wjcbCf2Q== X-Received: by 2002:a1c:6207:: with SMTP id w7mr10349542wmb.16.1575630137717; Fri, 06 Dec 2019 03:02:17 -0800 (PST) X-Received: from e123331-lin.cambridge.arm.com (fw-tnat-cam5.arm.com. [217.140.106.53]) by smtp.gmail.com with ESMTPSA id g2sm303001wrw.76.2019.12.06.03.02.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 03:02:16 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Laszlo Ersek , Leif Lindholm Subject: [edk2-devel] [PATCH edk2-platforms 1/2] Platform/ARM/ArmJunoDxe: make mAcpiRegistration STATIC Date: Fri, 6 Dec 2019 11:02:18 +0000 Message-Id: <20191206110219.32190-2-ard.biesheuvel@linaro.org> In-Reply-To: <20191206110219.32190-1-ard.biesheuvel@linaro.org> References: <20191206110219.32190-1-ard.biesheuvel@linaro.org> 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@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1575630140; bh=Iwj2PCo67hic0E6luUZt/DSbUPI/BAch7tm989jz+iU=; h=Cc:Date:From:Reply-To:Subject:To; b=kO7Ik+5Z1r+AYj3Jm4qW8G9eY2zPAy+E1jRIm72K1FjBVsdqE8MCbbVYfFaLZSfi2d7 4chxLNVtAQvys+EGyMA71zT0MVmY7jesDTQEmH5zZHUyJBwt319HP/WUeV1d+09nTERob 4H7JaXvg3sGtHsF+jUurcUTpfSaGKa9uR+4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Generally, variables should only have external linkage if needed, so make mAcpiRegistration STATIC, given that static linkage suffices for it. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm Reviewed-by: Laszlo Ersek Tested-by: Sami Mujawar --- Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/Platfor= m/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c index ea7591d70443..c0ad7ced2959 100644 --- a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c +++ b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c @@ -64,7 +64,7 @@ STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mPciRootComp= lexDevicePath =3D { } }; =20 -EFI_EVENT mAcpiRegistration =3D NULL; +STATIC EFI_EVENT mAcpiRegistration =3D NULL; =20 /** This function reads PCI ID of the controller. --=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 (#51829): https://edk2.groups.io/g/devel/message/51829 Mute This Topic: https://groups.io/mt/67467392/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- From nobody Sat Sep 21 01:20:56 2024 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+51830+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+51830+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1575630142; cv=none; d=zohomail.com; s=zohoarc; b=HKzyzVCBAWcdCZGwnBpUhndpl3n5CH/FHYt+tmpwFRTcZDBF+FI08yXvjPPoYvspHrQe7wbiyjjFBXc4f2EZzSg2NpYYLfqrkfwT0+dwdTZVTj8XY4pCW8nFo5FSmpzzxp1q0mnDNv/jzTJr/4HE0+Huzf3DIZ1PFJYkusHoZHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1575630142; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=BxxiKamEmOEDJuc9UF7bPQLos1uNbtPJR7fFak3QGF8=; b=j5zlHsVgZ6tBQuMx46UJWhMUaDwTeyrM7ifl57WGmhBbCqY6h2prLP1hUZeRcJEUpDmtXVBNNoJdetn26si74TumNlzvqDko4y/c3OXk9bZfhRDkKpKI6ROQrEg68s9A0NcxgH0OlJ582osULDkW4CDdfK3LG68DQoGEVdBQ4Jc= 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+51830+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1575630142003664.3260462227381; Fri, 6 Dec 2019 03:02:22 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id EZhGYY1788612xAsXYfOqXaT; Fri, 06 Dec 2019 03:02:21 -0800 X-Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by mx.groups.io with SMTP id smtpd.web10.2146.1575630140382569745 for ; Fri, 06 Dec 2019 03:02:20 -0800 X-Received: by mail-wm1-f66.google.com with SMTP id p9so7385421wmg.0 for ; Fri, 06 Dec 2019 03:02:20 -0800 (PST) X-Gm-Message-State: QMuCdeYYL2OnowKtzILJAa0Fx1787277AA= X-Google-Smtp-Source: APXvYqyxW/SDFQr6/XjrGscHsWEhMvNtc/JdJ5viqd82Jc2FAVdloo/orqE5c6dJH+B764X4OjB6eQ== X-Received: by 2002:a1c:7203:: with SMTP id n3mr9496397wmc.119.1575630138618; Fri, 06 Dec 2019 03:02:18 -0800 (PST) X-Received: from e123331-lin.cambridge.arm.com (fw-tnat-cam5.arm.com. [217.140.106.53]) by smtp.gmail.com with ESMTPSA id g2sm303001wrw.76.2019.12.06.03.02.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 03:02:17 -0800 (PST) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Laszlo Ersek , Leif Lindholm Subject: [edk2-devel] [PATCH edk2-platforms 2/2] Platform/ARM/ArmJunoDxe: use PciIo protocol notify to program the MAC Date: Fri, 6 Dec 2019 11:02:19 +0000 Message-Id: <20191206110219.32190-3-ard.biesheuvel@linaro.org> In-Reply-To: <20191206110219.32190-1-ard.biesheuvel@linaro.org> References: <20191206110219.32190-1-ard.biesheuvel@linaro.org> 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@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1575630141; bh=ujlTAenP37K1Cy4VHcaabiOBqBI4FP9f5rIySWydOT0=; h=Cc:Date:From:Reply-To:Subject:To; b=SFJvcJ28qxhm1bcL3TyvTOy9MCSyqHAIlY5Clg3Rq5RnqykUpVt7rV0eoviLmmJPNU1 n3pzo46PW2wVRu8C+9qUtj5i/CierBu9dxtYGG7YZc95yBcgq9SJ1IfYWCjUQbVEGNrLx m1rao2r8KeGd5/CIlpQ25fFDTJ8M3q+fd+E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Instead of connecting and thus enumerating the PCIe topology in a platform driver, just so that we can grab the PciIo protocol that belongs to the Marvell Yukon NIC and program its MAC address, rely on a protocol notification handler to do this whenever the core code decides to enumerate the PCIe. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm Reviewed-by: Laszlo Ersek Tested-by: Sami Mujawar --- Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c | 161 ++++---------= ------- Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf | 1 - 2 files changed, 30 insertions(+), 132 deletions(-) diff --git a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c b/Platfor= m/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c index c0ad7ced2959..ebaf2aa134da 100644 --- a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c +++ b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.c @@ -32,39 +32,8 @@ STATIC CONST EFI_GUID mJunoAcpiTableFile =3D { 0xa1dd808e, 0x1e95, 0x4399,= { 0xab, 0xc0, 0x65, 0x3c, 0x82, 0xe8, 0x53, 0x0c } }; #endif =20 -typedef struct { - ACPI_HID_DEVICE_PATH AcpiDevicePath; - PCI_DEVICE_PATH PciDevicePath; - EFI_DEVICE_PATH_PROTOCOL EndDevicePath; -} EFI_PCI_ROOT_BRIDGE_DEVICE_PATH; - -STATIC CONST EFI_PCI_ROOT_BRIDGE_DEVICE_PATH mPciRootComplexDevicePath =3D= { - { - { ACPI_DEVICE_PATH, - ACPI_DP, - { (UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), - (UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) } - }, - EISA_PNP_ID (0x0A03), - 0 - }, - { - { HARDWARE_DEVICE_PATH, - HW_PCI_DP, - { (UINT8) (sizeof (PCI_DEVICE_PATH)), - (UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) } - }, - 0, - 0 - }, - { - END_DEVICE_PATH_TYPE, - END_ENTIRE_DEVICE_PATH_SUBTYPE, - { END_DEVICE_PATH_LENGTH, 0 } - } -}; - STATIC EFI_EVENT mAcpiRegistration =3D NULL; +STATIC EFI_EVENT mPciIoNotificationRegistration =3D NULL; =20 /** This function reads PCI ID of the controller. @@ -99,59 +68,6 @@ ReadMarvellYoukonPciId ( return EFI_SUCCESS; } =20 -/** - This function searches for Marvell Yukon NIC on the Juno - platform and returns PCI IO protocol handle for the controller. - - @param[out] PciIo PCI IO protocol handle -**/ -STATIC -EFI_STATUS -GetMarvellYukonPciIoProtocol ( - OUT EFI_PCI_IO_PROTOCOL **PciIo - ) -{ - UINTN HandleCount; - EFI_HANDLE *HandleBuffer; - UINTN HIndex; - EFI_STATUS Status; - - Status =3D gBS->LocateHandleBuffer ( - ByProtocol, - &gEfiPciIoProtocolGuid, - NULL, - &HandleCount, - &HandleBuffer); - if (EFI_ERROR (Status)) { - return (Status); - } - - for (HIndex =3D 0; HIndex < HandleCount; ++HIndex) { - // If PciIo opened with EFI_OPEN_PROTOCOL_GET_PROTOCOL, the CloseProto= col() is not required - Status =3D gBS->OpenProtocol ( - HandleBuffer[HIndex], - &gEfiPciIoProtocolGuid, - (VOID **) PciIo, - NULL, - NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL); - if (EFI_ERROR (Status)) { - continue; - } - - Status =3D ReadMarvellYoukonPciId (*PciIo, JUNO_MARVELL_YUKON_ID); - if (EFI_ERROR (Status)) { - continue; - } else { - break; - } - } - - gBS->FreePool (HandleBuffer); - - return Status; -} - /** This function restore the original controller attributes =20 @@ -326,18 +242,14 @@ WriteMacAddress ( **/ STATIC EFI_STATUS -ArmJunoSetNicMacAddress () +ArmJunoSetNicMacAddress ( + IN EFI_PCI_IO_PROTOCOL *PciIo + ) { UINT64 OldPciAttr; - EFI_PCI_IO_PROTOCOL* PciIo; UINT32 PciRegBase; EFI_STATUS Status; =20 - Status =3D GetMarvellYukonPciIoProtocol (&PciIo); - if (EFI_ERROR (Status)) { - return Status; - } - PciRegBase =3D 0; Status =3D InitPciDev (PciIo, &PciRegBase, &OldPciAttr); if (EFI_ERROR (Status)) { @@ -352,14 +264,8 @@ ArmJunoSetNicMacAddress () } =20 /** - Notification function of the event defined as belonging to the - EFI_END_OF_DXE_EVENT_GROUP_GUID event group that was created in - the entry point of the driver. - - This function is called when an event belonging to the - EFI_END_OF_DXE_EVENT_GROUP_GUID event group is signalled. Such an - event is signalled once at the end of the dispatching of all - drivers (end of the so called DXE phase). + This function is called when a gEfiPciIoProtocolGuid protocol instance is + registered in the protocol database. =20 @param[in] Event Event declared in the entry point of the driver who= se notification function is being invoked. @@ -367,33 +273,30 @@ ArmJunoSetNicMacAddress () **/ STATIC VOID -OnEndOfDxe ( +PciIoNotificationEvent ( IN EFI_EVENT Event, IN VOID *Context ) { - EFI_DEVICE_PATH_PROTOCOL* PciRootComplexDevicePath; - EFI_HANDLE Handle; - EFI_STATUS Status; + EFI_STATUS Status; + EFI_PCI_IO_PROTOCOL *PciIo; =20 - // - // PCI Root Complex initialization - // At the end of the DXE phase, we should get all the driver dispatched. - // Force the PCI Root Complex to be initialized. It allows the OS to skip - // this step. - // - PciRootComplexDevicePath =3D (EFI_DEVICE_PATH_PROTOCOL*) &mPciRootComple= xDevicePath; - Status =3D gBS->LocateDevicePath (&gEfiPciRootBridgeIoProtocolGuid, - &PciRootComplexDevicePath, - &Handle); + Status =3D gBS->LocateProtocol (&gEfiPciIoProtocolGuid, + mPciIoNotificationRegistration, (VOID **)&PciIo); + if (EFI_ERROR (Status)) { + return; + } =20 - Status =3D gBS->ConnectController (Handle, NULL, PciRootComplexDevicePat= h, FALSE); - ASSERT_EFI_ERROR (Status); + Status =3D ReadMarvellYoukonPciId (PciIo, JUNO_MARVELL_YUKON_ID); + if (EFI_ERROR (Status)) { + return; + } =20 - Status =3D ArmJunoSetNicMacAddress (); + Status =3D ArmJunoSetNicMacAddress (PciIo); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "ArmJunoDxe: Failed to set Marvell Yukon NIC MAC = address\n")); } + gBS->CloseEvent (Event); } =20 EFI_STATUS @@ -408,7 +311,6 @@ ArmJunoEntryPoint ( CHAR16 *TextDevicePath; UINTN TextDevicePathSize; UINT32 JunoRevision; - EFI_EVENT EndOfDxeEvent; =20 // // Register the OHCI and EHCI controllers as non-coherent @@ -497,20 +399,17 @@ ArmJunoEntryPoint ( PcdSetBoolS (PcdPciDisableBusEnumeration, FALSE); =20 // - // Create an event belonging to the "gEfiEndOfDxeEventGroupGuid" group. - // The "OnEndOfDxe()" function is declared as the call back function. - // It will be called at the end of the DXE phase when an event of the - // same group is signalled to inform about the end of the DXE phase. - // Install the INSTALL_FDT_PROTOCOL protocol. + // Create a protocol notification event handler on the PciIo protocol + // so we can set the MAC address on the Marvell Yukon as soon as it + // appears. // - Status =3D gBS->CreateEventEx ( - EVT_NOTIFY_SIGNAL, - TPL_CALLBACK, - OnEndOfDxe, - NULL, - &gEfiEndOfDxeEventGroupGuid, - &EndOfDxeEvent - ); + EfiCreateProtocolNotifyEvent ( + &gEfiPciIoProtocolGuid, + TPL_NOTIFY, + PciIoNotificationEvent, + NULL, + &mPciIoNotificationRegistration + ); =20 #ifndef DYNAMIC_TABLES_FRAMEWORK // Declare the related ACPI Tables diff --git a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf b/Platf= orm/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf index 7c118d9c9c6b..d016967c3c37 100644 --- a/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf +++ b/Platform/ARM/JunoPkg/Drivers/ArmJunoDxe/ArmJunoDxe.inf @@ -44,7 +44,6 @@ [LibraryClasses] UefiDriverEntryPoint =20 [Guids] - gEfiEndOfDxeEventGroupGuid gEfiFileInfoGuid =20 [Protocols] --=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 (#51830): https://edk2.groups.io/g/devel/message/51830 Mute This Topic: https://groups.io/mt/67467393/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-