Skip to content

Commit

Permalink
Rk3588PciHostBridgeLib: Try to avoid a potential bus hang up
Browse files Browse the repository at this point in the history
Some devices that appear to have working CFG0 filtering (my VIA VL805)
do not actually like config cycles at B/D/F 01:01.0 and may screw up
further accesses (e.g. read 0xFFFFFFFF at valid locations) + eventually
hang up the bus after a few more attempts.

Checking for mirroring in this case is asking for trouble, but it seems
that trying 01:01.0 first and then 01:00.0 avoids the problem in UEFI.

OSes that rely on single device ECAM mode in ACPI are still going to
hang up the system, since they scan the entire affected bus.

Signed-off-by: Mario Bălănică <[email protected]>
  • Loading branch information
mariobalanica committed Feb 12, 2024
1 parent 4b915e6 commit ba8fbee
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,24 @@ PciValidateCfg0 (
EFI_STATUS Status;

//
// If the downstream device doesn't appear mirrored, config accesses
// must not be shifted by 0x8000 anymore.
// Check if the downstream device appears mirrored (due to 64 KB iATU granularity)
// and needs to have config acesses shifted for single device ECAM mode in ACPI.
//
if (MmioRead32 (Cfg0Base) != 0xffffffff
&& MmioRead32 (Cfg0Base + 0x8000) == 0xffffffff) {
// Warning:
// Bus hang ups have been observed when doing CFG0 cycles to 01:01.0 (+0x8000)
// for some devices that have working filtering and aren't mirrored (e.g. VIA VL805).
//
// Checking 01:01.0 before 01:00.0 and then never again seems fine, at least for UEFI.
// In single-device ECAM mode, an OS is going to scan the entire affected bus again, so
// there's still a risk of locking up the system, but we can't do anything about it.
//
if (MmioRead32 (Cfg0Base + 0x8000) == 0xffffffff
&& MmioRead32 (Cfg0Base) != 0xffffffff) {
Status = PcdSet32S (PcdPcieEcamCompliantSegmentsMask,
PcdGet32 (PcdPcieEcamCompliantSegmentsMask) | (1 << Segment));
ASSERT_EFI_ERROR (Status);

DEBUG((DEBUG_INFO, "PCIe: Working CFG0 TLP filtering for connected device!\n"));
DEBUG ((DEBUG_INFO, "PCIe: Working CFG0 TLP filtering for connected device!\n"));
}
}

Expand Down

0 comments on commit ba8fbee

Please sign in to comment.