OvmfPkg: AcpiPlatformDxe: PCI enumeration may be disabled
A message that is not in the archive (sent off-list or not yet received): [email protected]
Wei Liu
Tested-byQuoted 16 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
Quoted 8 lines
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>
This patch fixes the bug I have. Thanks!
Wei.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 23 lines · Wei Liu
Quoted 22 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.
Quoted 6 lines
Quoted 2 lines
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>This patch fixes the bug I have. Thanks!
Tested-by Wei Liu <[email protected]>
Thanks. If Jordan is okay with the patch too, I'll push it.
Sorry about the regression, too.
Cheers
Laszlo
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 27 lines · Laszlo Ersek
Quoted 26 lines · Wei Liu
Quoted 24 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>
Quoted 8 lines
Quoted 3 lines
This patch fixes the bug I have. Thanks!
Tested-by Wei Liu <[email protected]>Thanks. If Jordan is okay with the patch too, I'll push it.
Sorry about the regression, too.
Thanks for the fix. No need to be sorry. It happens. :-)
I wish I had setup a regression test side on our side earlier. Now things are getting into shape (our bisector is working on bisecting OVMF but I figured it would be faster if I just did the work myself) and hopefully we can catch regressions earlier in the future with our test system.
Wei.
Quoted 2 lines
Cheers
Laszlo
I think gEfiPciEnumerationCompleteProtocolGuid should be installed by MdeModulePkg/Bus/Pci/PciBusDxe, even when PcdPciDisableBusEnumeration is set.
Ray's main feedback seemed to be that we need to make sure PciBusDxe only installs the protocol once. (I'll also reply to the other related patch thread.)
-Jordan
Quoted 186 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>--- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 4 +- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 84 +++++++++++++++++++++++------ 2 files changed, 72 insertions(+), 16 deletions(-)OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +3
-1@@ -56,16 +56,18 @@ [Protocols] gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED [Guids] gEfiXenInfoGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress [Depex] - gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid + gEfiAcpiTableProtocolGuidOvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +69
-15@@ -12,6 +12,7 @@**/ +#include <Protocol/PciEnumerationComplete.h> #include "AcpiPlatform.h" EFI_STATUS @@ -221,6 +222,47 @@ FindAcpiTablesInFv (return EFI_SUCCESS ; } +STATIC +EFI_STATUS +EFIAPI +InstallTables ( +VOID + ) +{ +EFI_STATUS Status; +EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, +NULL /* Registration */ , (VOID **)&AcpiTable); +if (EFI_ERROR (Status)) { +return EFI_ABORTED ; + } + +if (XenDetected ()) { + Status =InstallXenTables (AcpiTable); + }else { + Status =InstallAllQemuLinkedTables (AcpiTable); + } + +if (EFI_ERROR (Status)) { + Status =FindAcpiTablesInFv (AcpiTable); + } + +return Status; +} + +STATIC +VOID +EFIAPI +OnPciEnumerated ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ +InstallTables (); + gBS->CloseEvent (Event); +} +/** Entrypoint of Acpi Platform driver. @@ -239,31 +281,43 @@ AcpiPlatformEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { -EFI_STATUS Status; -EFI_ACPI_TABLE_PROTOCOL *AcpiTable; +EFI_STATUS Status; +VOID *Interface; +EFI_EVENT PciEnumerated; +VOID *Registration;// -// Find the AcpiTable protocol +// If PCI enumeration has been disabled, or it has already completed, install +// the tables at once, and let the entry point's return code reflect the full +// functionality. // - Status = gBS->LocateProtocol ( - &gEfiAcpiTableProtocolGuid, -NULL , - (VOID **)&AcpiTable - ); -if (EFI_ERROR (Status)) { -return EFI_ABORTED ; +if (PcdGetBool (PcdPciDisableBusEnumeration)) { +return InstallTables (); } -if (XenDetected ()) { - Status =InstallXenTables (AcpiTable); - }else { - Status =InstallAllQemuLinkedTables (AcpiTable); + Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, +NULL /* Registration */ , &Interface); +if (!EFI_ERROR (Status)) { +return InstallTables (); } +ASSERT (Status ==EFI_NOT_FOUND ); +// +// Otherwise, delay the installation until PCI enumeration is complete. The +// entry point's return status will only reflect the callback setup. +// + Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL ,TPL_CALLBACK , OnPciEnumerated, +NULL /* Context */ , &PciEnumerated);if (EFI_ERROR (Status)) { - Status =FindAcpiTablesInFv (AcpiTable); +return Status; } + Status = gBS->RegisterProtocolNotify ( + &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated, + &Registration); +if (EFI_ERROR (Status)) { + gBS->CloseEvent (PciEnumerated); + }return Status; }Signature · 13 lines
1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): 20150212205340.11478.91715@jljusten-hsw
Quoted 7 lines · Jordan Justen
I think gEfiPciEnumerationCompleteProtocolGuid should be installed by MdeModulePkg/Bus/Pci/PciBusDxe, even when PcdPciDisableBusEnumeration is set.
Ray's main feedback seemed to be that we need to make sure PciBusDxe only installs the protocol once. (I'll also reply to the other related patch thread.)
First, I now agree that this patch of mine should not go in, hence:
Self-NAK
Second, I tend to disagree that that gEfiPciEnumerationCompleteProtocolGuid should be installed even if full enumeration was eschewed. This might slightly change the de-facto meaning of the protocol (because no resource allocation took place). In general I think we should not try to touch MdeModulePkg/Bus/Pci/PciBusDxe for our need here.
So let's think again what we need.
We want to delay the download and installation of ACPI tables on virt platforms until PCI enumeration is complete, *except* in some cases:
(1) When OVMF runs on Xen.
In that case PcdPciDisableBusEnumeration is TRUE, and the PCI bus driver does not install gEfiPciEnumerationCompleteProtocolGuid (in my opinion:
correctly, because no resource allocation takes place, which is the de-facto meaning of the completion protocol).
This means that the depex in "OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf" is no longer correct:
[Depex]
gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid
(2) When the platform in question lacks PCI.
Right now this means ArmVirtualizationQemu. However, that is about to change (I've mostly ported PCI support to ArmVirtualizationQemu; virtio-pci, USB keyboard, std-VGA work). Importantly, presence of PCI on ARM will become a *dynamic* question, dependent on the QEMU version. Current master QEMU does not provide PCI hardware for arm/mach-virt, but Alex Graf's patches in Peter Maydell's target-arm.next branch do, and so will master soon.
This means that the depex in "OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf" will also break:
[Depex]
gEfiAcpiTableProtocolGuid
[Depex.IA32, Depex.X64]
gEfiPciEnumerationCompleteProtocolGuid
because on ARM we might or might not want to wait for enumeration completion dependent on whether the DTB ultimately describes a PCI root bridge or not.
So here's what I propose. (Again, the above is *all* motivated by OvmfPkg/AcpiPlatformDxe/.) In my PCI-for-ArmVirtualizationQemu patchset, I will introduce a new protocol GUID (with NULL structure) that will simply say "OvmfPkg's AcpiPlatformDxe should not wait for PCI enumeration". Then, *both* INF files under OvmfPkg/AcpiPlatformDxe shall receive the following depex:
[Depex]
gEfiAcpiTableProtocolGuid AND
(gEfiPciEnumerationCompleteProtocolGuid OR
gOvmfAcpiPlatformNoPciEnumerationProtocolGuid
)
Then each particular platform driver shall unblock AcpiPlatformDxe in its own way:
- OVMF on QEMU will do nothing special, it'll just go with the usual gEfiPciEnumerationCompleteProtocolGuid, installed by PciBusDxe.
- OVMF on Xen will install gOvmfAcpiPlatformNoPciEnumerationProtocolGuid
-- Wei, could you post a patch for this later? I think the protocol should be installed in XenBusDxeDriverBindingStart(), when it succeeds.
It would be probably prudent to coordinate with Ard, wrt. Ard's series that brings Xen to ArmVirtualizationQemu.
- In my PCI-for-ArmVirtualizationQemu series, I'll install gOvmfAcpiPlatformNoPciEnumerationProtocolGuid in case PCI is unavailable on the particular QEMU version.
My main point is, our *real* target is OvmfPkg/AcpiPlatformDxe here, and the conditions whether to delay or not to delay its work until PCI enumeration is complete are platform dependent and *dynamic*. We should let all platform-specific drivers decide for themselves, and we should steer clear of drivers that are central to edk2, like PciBusDxe.
What do you guys think?
Thanks!
Laszlo
Quoted 190 lines
-Jordan
Quoted 186 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>--- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 4 +- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 84 +++++++++++++++++++++++------ 2 files changed, 72 insertions(+), 16 deletions(-)OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +3
-1@@ -56,16 +56,18 @@ [Protocols] gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED [Guids] gEfiXenInfoGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress [Depex] - gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid + gEfiAcpiTableProtocolGuidOvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +69
-15@@ -12,6 +12,7 @@**/ +#include <Protocol/PciEnumerationComplete.h> #include "AcpiPlatform.h" EFI_STATUS @@ -221,6 +222,47 @@ FindAcpiTablesInFv (return EFI_SUCCESS ; } +STATIC +EFI_STATUS +EFIAPI +InstallTables ( +VOID + ) +{ +EFI_STATUS Status; +EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, +NULL /* Registration */ , (VOID **)&AcpiTable); +if (EFI_ERROR (Status)) { +return EFI_ABORTED ; + } + +if (XenDetected ()) { + Status =InstallXenTables (AcpiTable); + }else { + Status =InstallAllQemuLinkedTables (AcpiTable); + } + +if (EFI_ERROR (Status)) { + Status =FindAcpiTablesInFv (AcpiTable); + } + +return Status; +} + +STATIC +VOID +EFIAPI +OnPciEnumerated ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ +InstallTables (); + gBS->CloseEvent (Event); +} +/** Entrypoint of Acpi Platform driver. @@ -239,31 +281,43 @@ AcpiPlatformEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { -EFI_STATUS Status; -EFI_ACPI_TABLE_PROTOCOL *AcpiTable; +EFI_STATUS Status; +VOID *Interface; +EFI_EVENT PciEnumerated; +VOID *Registration;// -// Find the AcpiTable protocol +// If PCI enumeration has been disabled, or it has already completed, install +// the tables at once, and let the entry point's return code reflect the full +// functionality. // - Status = gBS->LocateProtocol ( - &gEfiAcpiTableProtocolGuid, -NULL , - (VOID **)&AcpiTable - ); -if (EFI_ERROR (Status)) { -return EFI_ABORTED ; +if (PcdGetBool (PcdPciDisableBusEnumeration)) { +return InstallTables (); } -if (XenDetected ()) { - Status =InstallXenTables (AcpiTable); - }else { - Status =InstallAllQemuLinkedTables (AcpiTable); + Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, +NULL /* Registration */ , &Interface); +if (!EFI_ERROR (Status)) { +return InstallTables (); } +ASSERT (Status ==EFI_NOT_FOUND ); +// +// Otherwise, delay the installation until PCI enumeration is complete. The +// entry point's return status will only reflect the callback setup. +// + Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL ,TPL_CALLBACK , OnPciEnumerated, +NULL /* Context */ , &PciEnumerated);if (EFI_ERROR (Status)) { - Status =FindAcpiTablesInFv (AcpiTable); +return Status; } + Status = gBS->RegisterProtocolNotify ( + &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated, + &Registration); +if (EFI_ERROR (Status)) { + gBS->CloseEvent (PciEnumerated); + }return Status; }Signature · 13 lines
1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 9 lines · Laszlo Ersek
Quoted 7 lines · Jordan Justen
I think gEfiPciEnumerationCompleteProtocolGuid should be installed by MdeModulePkg/Bus/Pci/PciBusDxe, even when PcdPciDisableBusEnumeration is set.
Ray's main feedback seemed to be that we need to make sure PciBusDxe only installs the protocol once. (I'll also reply to the other related patch thread.)
Quoted 8 lines
First, I now agree that this patch of mine should not go in, hence:
Self-NAK
Second, I tend to disagree that that gEfiPciEnumerationCompleteProtocolGuid should be installed even if full enumeration was eschewed. This might slightly change the de-facto meaning of the protocol (because no resource allocation took place).
De-facto seems the correct term here, since the PI1.2 spec says very little about the protocol.
My interpretation of the protocol is that it is a signal that the EFI knows about the basic PCI topology, and has installed most PciIo instances.
Maybe PcdPciDisableBusEnumeration wasn't the best name. Perhaps PcdPciBusPreEnumerated would have been better.
At any rate, in the case of Xen, the hypervisor has pre-enumerated the bus. PciBusDxe uses this and 'enumerates' PCI devices by simply scanning the pre-enumerated topology.
So, I still think PciBusDxe should install gEfiPciEnumerationCompleteProtocolGuid, because it still seems like it acurately reflects the phase of the boot process.
Regarding the ACPI tables issue, would a callback for the ReadyToBoot event work?
-Jordan
Quoted 278 lines
In general I think we should not try to touch
MdeModulePkg/Bus/Pci/PciBusDxe for our need here.So let's think again what we need.
We want to delay the download and installation of ACPI tables on virt platforms until PCI enumeration is complete, *except* in some cases:
(1) When OVMF runs on Xen.
In that case PcdPciDisableBusEnumeration is TRUE, and the PCI bus driver does not install gEfiPciEnumerationCompleteProtocolGuid (in my opinion:
correctly, because no resource allocation takes place, which is the de-facto meaning of the completion protocol).This means that the depex in "OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf" is no longer correct:
[Depex]
gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid(2) When the platform in question lacks PCI.
Right now this means ArmVirtualizationQemu. However, that is about to change (I've mostly ported PCI support to ArmVirtualizationQemu; virtio-pci, USB keyboard, std-VGA work). Importantly, presence of PCI on ARM will become a *dynamic* question, dependent on the QEMU version. Current master QEMU does not provide PCI hardware for arm/mach-virt, but Alex Graf's patches in Peter Maydell's target-arm.next branch do, and so will master soon.
This means that the depex in "OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpiPlatformDxe.inf" will also break:
[Depex]
gEfiAcpiTableProtocolGuid[Depex.IA32, Depex.X64]
gEfiPciEnumerationCompleteProtocolGuidbecause on ARM we might or might not want to wait for enumeration completion dependent on whether the DTB ultimately describes a PCI root bridge or not.
So here's what I propose. (Again, the above is *all* motivated by OvmfPkg/AcpiPlatformDxe/.) In my PCI-for-ArmVirtualizationQemu patchset, I will introduce a new protocol GUID (with NULL structure) that will simply say "OvmfPkg's AcpiPlatformDxe should not wait for PCI enumeration". Then, *both* INF files under OvmfPkg/AcpiPlatformDxe shall receive the following depex:
[Depex]
gEfiAcpiTableProtocolGuid AND
(gEfiPciEnumerationCompleteProtocolGuid OR
gOvmfAcpiPlatformNoPciEnumerationProtocolGuid
)Then each particular platform driver shall unblock AcpiPlatformDxe in its own way:
- OVMF on QEMU will do nothing special, it'll just go with the usual gEfiPciEnumerationCompleteProtocolGuid, installed by PciBusDxe.
- OVMF on Xen will install gOvmfAcpiPlatformNoPciEnumerationProtocolGuid
-- Wei, could you post a patch for this later? I think the protocol should be installed in
XenBusDxeDriverBindingStart(), when it succeeds.It would be probably prudent to coordinate with Ard, wrt. Ard's series that brings Xen to ArmVirtualizationQemu.
- In my PCI-for-ArmVirtualizationQemu series, I'll install gOvmfAcpiPlatformNoPciEnumerationProtocolGuid in case PCI is unavailable on the particular QEMU version.
My main point is, our *real* target is OvmfPkg/AcpiPlatformDxe here, and the conditions whether to delay or not to delay its work until PCI enumeration is complete are platform dependent and *dynamic*. We should let all platform-specific drivers decide for themselves, and we should steer clear of drivers that are central to edk2, like PciBusDxe.
What do you guys think?
Thanks!
LaszloQuoted 190 lines
-Jordan
Quoted 186 lines · Laszlo Ersek
SVN r16411 delayed ACPI table installation until PCI enumeration was complete, because on QEMU the ACPI-related
fw_cfgfiles should only be downloaded after PCI enumeration.However,
InitializeXen()in "OvmfPkg/PlatformPei/Xen.c" sets PcdPciDisableBusEnumeration to TRUE. This causesPciBusDriverBindingStart()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c" to set gFullEnumeration to FALSE, which in turn makesPciEnumerator()in "MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumerator.c" branch toPciEnumeratorLight(). The installation ofEFI_PCI_ENUMERATION_COMPLETE_PROTOCOLat the end ofPciEnumerator()is not reached.Which means that starting with SVN r16411, AcpiPlatformDxe is never dispatched on Xen.
This patch replaces the
EFI_PCI_ENUMERATION_COMPLETE_PROTOCOLdepex with a matching protocol registration callback for the PCI enumeration enabled (ie. QEMU) case. When PCI enumeration is disabled (ie. when running on Xen), AcpiPlatformDxe doesn't wait forEFI_PCI_ENUMERATION_COMPLETE_PROTOCOL.Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by Laszlo Ersek <[email protected]>--- OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf | 4 +- OvmfPkg/AcpiPlatformDxe/AcpiPlatform.c | 84 +++++++++++++++++++++++------ 2 files changed, 72 insertions(+), 16 deletions(-)OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf +3
-1@@ -56,16 +56,18 @@ [Protocols] gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiPciEnumerationCompleteProtocolGuid # PROTOCOL SOMETIMES_CONSUMED [Guids] gEfiXenInfoGuid [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiTableStorageFile + gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration gUefiCpuPkgTokenSpaceGuid.PcdCpuLocalApicBaseAddress gPcAtChipsetPkgTokenSpaceGuid.Pcd8259LegacyModeEdgeLevel gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFdBaseAddress [Depex] - gEfiAcpiTableProtocolGuid AND gEfiPciEnumerationCompleteProtocolGuid + gEfiAcpiTableProtocolGuidOvmfPkg/AcpiPlatformDxe/AcpiPlatform.c +69
-15@@ -12,6 +12,7 @@**/ +#include <Protocol/PciEnumerationComplete.h> #include "AcpiPlatform.h" EFI_STATUS @@ -221,6 +222,47 @@ FindAcpiTablesInFv (return EFI_SUCCESS ; } +STATIC +EFI_STATUS +EFIAPI +InstallTables ( +VOID + ) +{ +EFI_STATUS Status; +EFI_ACPI_TABLE_PROTOCOL *AcpiTable; + + Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, +NULL /* Registration */ , (VOID **)&AcpiTable); +if (EFI_ERROR (Status)) { +return EFI_ABORTED ; + } + +if (XenDetected ()) { + Status =InstallXenTables (AcpiTable); + }else { + Status =InstallAllQemuLinkedTables (AcpiTable); + } + +if (EFI_ERROR (Status)) { + Status =FindAcpiTablesInFv (AcpiTable); + } + +return Status; +} + +STATIC +VOID +EFIAPI +OnPciEnumerated ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ +InstallTables (); + gBS->CloseEvent (Event); +} +/** Entrypoint of Acpi Platform driver. @@ -239,31 +281,43 @@ AcpiPlatformEntryPoint ( IN EFI_SYSTEM_TABLE *SystemTable ) { -EFI_STATUS Status; -EFI_ACPI_TABLE_PROTOCOL *AcpiTable; +EFI_STATUS Status; +VOID *Interface; +EFI_EVENT PciEnumerated; +VOID *Registration;// -// Find the AcpiTable protocol +// If PCI enumeration has been disabled, or it has already completed, install +// the tables at once, and let the entry point's return code reflect the full +// functionality. // - Status = gBS->LocateProtocol ( - &gEfiAcpiTableProtocolGuid, -NULL , - (VOID **)&AcpiTable - ); -if (EFI_ERROR (Status)) { -return EFI_ABORTED ; +if (PcdGetBool (PcdPciDisableBusEnumeration)) { +return InstallTables (); } -if (XenDetected ()) { - Status =InstallXenTables (AcpiTable); - }else { - Status =InstallAllQemuLinkedTables (AcpiTable); + Status = gBS->LocateProtocol (&gEfiPciEnumerationCompleteProtocolGuid, +NULL /* Registration */ , &Interface); +if (!EFI_ERROR (Status)) { +return InstallTables (); } +ASSERT (Status ==EFI_NOT_FOUND ); +// +// Otherwise, delay the installation until PCI enumeration is complete. The +// entry point's return status will only reflect the callback setup. +// + Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL ,TPL_CALLBACK , OnPciEnumerated, +NULL /* Context */ , &PciEnumerated);if (EFI_ERROR (Status)) { - Status =FindAcpiTablesInFv (AcpiTable); +return Status; } + Status = gBS->RegisterProtocolNotify ( + &gEfiPciEnumerationCompleteProtocolGuid, PciEnumerated, + &Registration); +if (EFI_ERROR (Status)) { + gBS->CloseEvent (PciEnumerated); + }return Status; }Signature · 13 lines
1.8.3.1 ------------------------------------------------------------------------------ Dive into the World of Parallel Programming. The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
A message that is not in the archive (sent off-list or not yet received): 20150214200338.31063.16376@jljusten-ivy
Quoted 33 lines · Jordan Justen
Quoted 9 lines · Laszlo Ersek
Quoted 7 lines · Jordan Justen
I think gEfiPciEnumerationCompleteProtocolGuid should be installed by MdeModulePkg/Bus/Pci/PciBusDxe, even when PcdPciDisableBusEnumeration is set.
Ray's main feedback seemed to be that we need to make sure PciBusDxe only installs the protocol once. (I'll also reply to the other related patch thread.)
Quoted 8 lines
First, I now agree that this patch of mine should not go in, hence:
Self-NAK
Second, I tend to disagree that that gEfiPciEnumerationCompleteProtocolGuid should be installed even if full enumeration was eschewed. This might slightly change the de-facto meaning of the protocol (because no resource allocation took place).
De-facto seems the correct term here, since the PI1.2 spec says very little about the protocol.
My interpretation of the protocol is that it is a signal that the EFI knows about the basic PCI topology, and has installed most PciIo instances.
Maybe PcdPciDisableBusEnumeration wasn't the best name. Perhaps PcdPciBusPreEnumerated would have been better.
At any rate, in the case of Xen, the hypervisor has pre-enumerated the bus. PciBusDxe uses this and 'enumerates' PCI devices by simply scanning the pre-enumerated topology.
Quoted 6 lines
So, I still think PciBusDxe should install gEfiPciEnumerationCompleteProtocolGuid, because it still seems like it acurately reflects the phase of the boot process.
Regarding the ACPI tables issue, would a callback for the ReadyToBoot event work?
EFI_EVENT_GROUP_READY_TO_BOOT
This event group is notified by the system when the Boot Manager is about to load and execute a boot option.
(1) As far as I understand, if you boot a UEFI application, then exit it, and boot something else, then the event group will be signalled each time.
We could use a static variable in AcpiPlatformDxe to avoid trying to install again and again, but it wouldn't be nice IMHO.
This is the secondary reason I'm not enthusiastic about EFI_EVENT_GROUP_READY_TO_BOOT. :)
(2) The main reason is different: in both OVMF and ArmVirtualizationQemu we can boot a kernel directly, taken from QEMU. That happens without EFI_EVENT_GROUP_READY_TO_BOOT being signalled.
However, the kernel booted thus should have both ACPI tables and configured PCI devices (if there is a PCI host). In OVMF this is ensured by:
PlatformBdsPolicyBehavior()
PlatformBdsConnectSequence()
BdsLibConnectAll()
TryRunningQemuKernel()
where the BdsLibConnectAll() call listed above will cover the enumeration, and trigger the dependent ACPI table installation as well, before we go to the kernel.
One idea could be to signal EFI_EVENT_GROUP_READY_TO_BOOT ourselves, before booting the kernel; however this event group seems quite tied to the Boot Manager itself (see again its definition above).
I'll post my patch series soon; my idea that is relevant for this discussion is at its beginning (and a later patch also displays how I mean it to be used). We can discuss it there too if you like.
Thanks
Laszlo
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 49 lines · Laszlo Ersek
Quoted 33 lines · Jordan Justen
Quoted 9 lines · Laszlo Ersek
Quoted 7 lines · Jordan Justen
I think gEfiPciEnumerationCompleteProtocolGuid should be installed by MdeModulePkg/Bus/Pci/PciBusDxe, even when PcdPciDisableBusEnumeration is set.
Ray's main feedback seemed to be that we need to make sure PciBusDxe only installs the protocol once. (I'll also reply to the other related patch thread.)
Quoted 8 lines
First, I now agree that this patch of mine should not go in, hence:
Self-NAK
Second, I tend to disagree that that gEfiPciEnumerationCompleteProtocolGuid should be installed even if full enumeration was eschewed. This might slightly change the de-facto meaning of the protocol (because no resource allocation took place).
De-facto seems the correct term here, since the PI1.2 spec says very little about the protocol.
My interpretation of the protocol is that it is a signal that the EFI knows about the basic PCI topology, and has installed most PciIo instances.
Maybe PcdPciDisableBusEnumeration wasn't the best name. Perhaps PcdPciBusPreEnumerated would have been better.
At any rate, in the case of Xen, the hypervisor has pre-enumerated the bus. PciBusDxe uses this and 'enumerates' PCI devices by simply scanning the pre-enumerated topology.
Quoted 6 lines
So, I still think PciBusDxe should install gEfiPciEnumerationCompleteProtocolGuid, because it still seems like it acurately reflects the phase of the boot process.
Regarding the ACPI tables issue, would a callback for the ReadyToBoot event work?
EFI_EVENT_GROUP_READY_TO_BOOTThis event group is notified by the system when the Boot Manager is about to load and execute a boot option.
Quoted 7 lines
(1) As far as I understand, if you boot a UEFI application, then exit it, and boot something else, then the event group will be signalled each time.
We could use a static variable in AcpiPlatformDxe to avoid trying to install again and again, but it wouldn't be nice IMHO.
You can always use a global.
Quoted 15 lines
This is the secondary reason I'm not enthusiastic about
EFI_EVENT_GROUP_READY_TO_BOOT. :)(2) The main reason is different: in both OVMF and ArmVirtualizationQemu we can boot a kernel directly, taken from QEMU. That happens without
EFI_EVENT_GROUP_READY_TO_BOOTbeing signalled.However, the kernel booted thus should have both ACPI tables and configured PCI devices (if there is a PCI host). In OVMF this is ensured by:
PlatformBdsPolicyBehavior()
PlatformBdsConnectSequence()
BdsLibConnectAll()
TryRunningQemuKernel()
Quoted 5 lines
where the
BdsLibConnectAll()call listed above will cover the enumeration, and trigger the dependent ACPI table installation as well, before we go to the kernel.One idea could be to signal
EFI_EVENT_GROUP_READY_TO_BOOTourselves,
That sounds like the right thing to do.
Quoted 3 lines
before booting the kernel; however this event group seems quite tied to the Boot Manager itself (see again its definition above).
The Boot Manager has a few responsibilities in EFI (and few more in PI where it is called the BDS), but in general it is a place where a lot of platform specific policy is enforced. So updating the Boot Manager do do the right thing sees like a good answer.
Thanks,
Andrew Fish
Quoted 7 lines
I'll post my patch series soon; my idea that is relevant for this discussion is at its beginning (and a later patch also displays how I mean it to be used). We can discuss it there too if you like.
Thanks
Laszlo
Quoted 10 lines
------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/ <http://goparallel.sourceforge.net/>
_______________________________________________
edk2-devel mailing list
[email protected] <mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/edk2-devel <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel