From a9901a7748ad08664ebc323ee9c475176aca48e7 Mon Sep 17 00:00:00 2001 From: Paul Chang Date: Mon, 28 Oct 2024 15:53:25 +0800 Subject: MdeModulePkg: SataControllerSupported checks DevicePath Protocol REF:https://bugzilla.tianocore.org/show_bug.cgi?id=4858 Ph52a PCIE to SATA card inserted on Intel MTL/ARL causes system hanged. Root cause of this issue is because Ph52a's driver only uses DevicePath protocol alone and EDK2 driver only uses PciIo protocol alone. Both drivers start and try to manage SATA controller. Signed-off-by: Paul Chang --- .../Bus/Pci/SataControllerDxe/SataController.c | 32 ++++++++++++++++++++-- .../Bus/Pci/SataControllerDxe/SataController.h | 1 + .../Pci/SataControllerDxe/SataControllerDxe.inf | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) (limited to 'MdeModulePkg/Bus/Pci') diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c index ea0116071c..e38304cffd 100644 --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c @@ -287,9 +287,35 @@ SataControllerSupported ( IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath ) { - EFI_STATUS Status; - EFI_PCI_IO_PROTOCOL *PciIo; - PCI_TYPE00 PciData; + EFI_STATUS Status; + EFI_PCI_IO_PROTOCOL *PciIo; + PCI_TYPE00 PciData; + EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; + + // + // Attempt to open DevicePath Protocol + // + Status = gBS->OpenProtocol ( + Controller, + &gEfiDevicePathProtocolGuid, + (VOID *)&ParentDevicePath, + This->DriverBindingHandle, + Controller, + EFI_OPEN_PROTOCOL_BY_DRIVER + ); + if (EFI_ERROR (Status)) { + return Status; + } + + /// + /// Close the protocol because we don't use it here + /// + gBS->CloseProtocol ( + Controller, + &gEfiDevicePathProtocolGuid, + This->DriverBindingHandle, + Controller + ); // // Attempt to open PCI I/O Protocol diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.h b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.h index 4d545fb1f9..91d10e1555 100644 --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.h +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf index 488920a68c..e446058e34 100644 --- a/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf +++ b/MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf @@ -45,6 +45,7 @@ [Protocols] gEfiPciIoProtocolGuid ## TO_START gEfiIdeControllerInitProtocolGuid ## BY_START + gEfiDevicePathProtocolGuid [UserExtensions.TianoCore."ExtraFiles"] SataControllerDxeExtra.uni -- cgit v1.2.3