Skip to content

Commit

Permalink
[DNM] MdeModulePkg: PciBusDxe: Drop RemoveRejectedPciDevices()
Browse files Browse the repository at this point in the history
There is an assumption in `IsPciDeviceRejected()` (at least for I/O)
that a BAR with all read-write bits set is invalid. However, this is not
the case: when a resource is size-aligned down from the top, this may
also be the case.

This code causes the rejection of the iGPU (and therefore, display) in
some cases with the UefiPayloadPkg, when the coreboot
ESOURCE_ALLOCATION_TOP_DOWN config is enabled. It remains to be seen
whether this code addresses some other issue.

Signed-off-by: Benjamin Doron <[email protected]>
  • Loading branch information
benjamindoron authored and miczyg1 committed Jun 14, 2024
1 parent 9756808 commit 6a6d410
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 205 deletions.
116 changes: 0 additions & 116 deletions MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -2525,11 +2525,6 @@ PciEnumeratorLight (

if (!EFI_ERROR (Status)) {

//
// Remove those PCI devices which are rejected when full enumeration
//
RemoveRejectedPciDevices (RootBridgeDev->Handle, RootBridgeDev);

if (!PcdGetBool (PcdPciDisableBusEnumeration)) {
//
// Process option rom light
Expand Down Expand Up @@ -2652,117 +2647,6 @@ StartManagingRootBridge (

}

/**
This routine can be used to check whether a PCI device should be rejected when light enumeration.
@param PciIoDevice Pci device instance.
@retval TRUE This device should be rejected.
@retval FALSE This device shouldn't be rejected.
**/
BOOLEAN
IsPciDeviceRejected (
IN PCI_IO_DEVICE *PciIoDevice
)
{
EFI_STATUS Status;
UINT32 TestValue;
UINT32 OldValue;
UINT32 Mask;
UINT8 BarOffset;

//
// PPB should be skip!
//
if (IS_PCI_BRIDGE (&PciIoDevice->Pci)) {
return FALSE;
}

if (IS_CARDBUS_BRIDGE (&PciIoDevice->Pci)) {
//
// Only test base registers for P2C
//
for (BarOffset = 0x1C; BarOffset <= 0x38; BarOffset += 2 * sizeof (UINT32)) {

Mask = (BarOffset < 0x2C) ? 0xFFFFF000 : 0xFFFFFFFC;
Status = BarExisted (PciIoDevice, BarOffset, &TestValue, &OldValue);
if (EFI_ERROR (Status)) {
continue;
}

TestValue = TestValue & Mask;
if ((TestValue != 0) && (TestValue == (OldValue & Mask))) {
//
// The bar isn't programed, so it should be rejected
//
return TRUE;
}
}

return FALSE;
}

for (BarOffset = 0x14; BarOffset <= 0x24; BarOffset += sizeof (UINT32)) {
//
// Test PCI devices
//
Status = BarExisted (PciIoDevice, BarOffset, &TestValue, &OldValue);
if (EFI_ERROR (Status)) {
continue;
}

if ((TestValue & 0x01) != 0) {

//
// IO Bar
//
Mask = 0xFFFFFFFC;
TestValue = TestValue & Mask;
if ((TestValue != 0) && (TestValue == (OldValue & Mask))) {
return TRUE;
}

} else {

//
// Mem Bar
//
Mask = 0xFFFFFFF0;
TestValue = TestValue & Mask;

if ((TestValue & 0x07) == 0x04) {

//
// Mem64 or PMem64
//
BarOffset += sizeof (UINT32);
if ((TestValue != 0) && (TestValue == (OldValue & Mask))) {

//
// Test its high 32-Bit BAR
//
Status = BarExisted (PciIoDevice, BarOffset, &TestValue, &OldValue);
if (TestValue == OldValue) {
return TRUE;
}
}

} else {

//
// Mem32 or PMem32
//
if ((TestValue != 0) && (TestValue == (OldValue & Mask))) {
return TRUE;
}
}
}
}

return FALSE;
}

/**
Reset all bus number from specific bridge.
Expand Down
14 changes: 0 additions & 14 deletions MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,20 +427,6 @@ StartManagingRootBridge (
IN PCI_IO_DEVICE *RootBridgeDev
);

/**
This routine can be used to check whether a PCI device should be rejected when light enumeration.
@param PciIoDevice Pci device instance.
@retval TRUE This device should be rejected.
@retval FALSE This device shouldn't be rejected.
**/
BOOLEAN
IsPciDeviceRejected (
IN PCI_IO_DEVICE *PciIoDevice
);

/**
Reset all bus number from specific bridge.
Expand Down
61 changes: 0 additions & 61 deletions MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,67 +138,6 @@ GetBackPcCardBar (
}
}

/**
Remove rejected pci device from specific root bridge
handle.
@param RootBridgeHandle Specific parent root bridge handle.
@param Bridge Bridge device instance.
**/
VOID
RemoveRejectedPciDevices (
IN EFI_HANDLE RootBridgeHandle,
IN PCI_IO_DEVICE *Bridge
)
{
PCI_IO_DEVICE *Temp;
LIST_ENTRY *CurrentLink;
LIST_ENTRY *LastLink;

if (!FeaturePcdGet (PcdPciBusHotplugDeviceSupport)) {
return;
}

CurrentLink = Bridge->ChildList.ForwardLink;

while (CurrentLink != NULL && CurrentLink != &Bridge->ChildList) {

Temp = PCI_IO_DEVICE_FROM_LINK (CurrentLink);

if (IS_PCI_BRIDGE (&Temp->Pci)) {
//
// Remove rejected devices recusively
//
RemoveRejectedPciDevices (RootBridgeHandle, Temp);
} else {
//
// Skip rejection for all PPBs, while detect rejection for others
//
if (IsPciDeviceRejected (Temp)) {

//
// For P2C, remove all devices on it
//
if (!IsListEmpty (&Temp->ChildList)) {
RemoveAllPciDeviceOnBridge (RootBridgeHandle, Temp);
}

//
// Finally remove itself
//
LastLink = CurrentLink->BackLink;
RemoveEntryList (CurrentLink);
FreePciDevice (Temp);

CurrentLink = LastLink;
}
}

CurrentLink = CurrentLink->ForwardLink;
}
}

/**
Dump the resourc map of the bridge device.
Expand Down
14 changes: 0 additions & 14 deletions MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,6 @@ GetBackPcCardBar (
IN PCI_IO_DEVICE *PciIoDevice
);

/**
Remove rejected pci device from specific root bridge
handle.
@param RootBridgeHandle Specific parent root bridge handle.
@param Bridge Bridge device instance.
**/
VOID
RemoveRejectedPciDevices (
IN EFI_HANDLE RootBridgeHandle,
IN PCI_IO_DEVICE *Bridge
);

/**
Submits the I/O and memory resource requirements for the specified PCI Host Bridge.
Expand Down

0 comments on commit 6a6d410

Please sign in to comment.