From 90bb4c577d055e7ac6f0488b21885f65617eec82 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Volker=20R=C3=BCmelin?= Date: Mon, 18 Apr 2016 21:51:30 +0200 Subject: [PATCH] OvmfPkg: AcpiPlatformDxe: Don't enable unsupported PCI attributes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Current code in PciEnableDecoding tries to unconditionally enable EFI_PCI_IO_ATTRIBUTE_IO and EFI_PCI_IO_ATTRIBUTE_MEMORY even if they are unsupported attributes. This fails on devices which don't support both attributes. This patch masks out unsupported attributes. Information to reproduce the bug. Host lspci -s 0000:04:00.0 -vnn: 04:00.0 USB controller [0c03]: Renesas Technology Corp. uPD720201 USB 3.0 Host Controller [1912:0014] (rev 03) (prog-if 30 [XHCI]) Flags: fast devsel, IRQ 19 Memory at ef900000 (64-bit, non-prefetchable) [size=8K] Capabilities: [50] Power Management version 3 Capabilities: [70] MSI: Enable- Count=1/8 Maskable- 64bit+ Capabilities: [90] MSI-X: Enable- Count=8 Masked- Capabilities: [a0] Express Endpoint, MSI 00 Capabilities: [100] Advanced Error Reporting Capabilities: [150] Latency Tolerance Reporting Kernel driver in use: pci-stub Kernel modules: xhci_pci libvirt xml:
OVMF debug log with additional DEBUG statement: OnRootBridgesConnected: root bridges have been connected, installing ACPI tables Select Item: 0x19 EnablePciDecoding: GetLocation: D=0000:00:00.0 OrigAttr=0000000000004000 SuppAttr=000000000000E700 EnablePciDecoding: GetLocation: D=0000:00:10.0 OrigAttr=0000000000004000 SuppAttr=000000000000E700 EnablePciDecoding: GetLocation: D=0000:00:11.0 OrigAttr=0000000000004000 SuppAttr=000000000000E600 EnablePciDecoding: EfiPciIoAttributeOperationEnable: Unsupported Select Item: 0x28 Select Item: 0x19 Select Item: 0x2A Select Item: 0x19 Select Item: 0x27 InstallQemuFwCfgTables: installed 6 tables Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Volker Rümelin Reviewed-by: Jordan Justen Reviewed-by: Laszlo Ersek Tested-by: Laszlo Ersek --- OvmfPkg/AcpiPlatformDxe/PciDecoding.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c b/OvmfPkg/AcpiPlatformDxe/PciDecoding.c index 3b9b12ccc8..d63b57e701 100644 --- a/OvmfPkg/AcpiPlatformDxe/PciDecoding.c +++ b/OvmfPkg/AcpiPlatformDxe/PciDecoding.c @@ -89,6 +89,7 @@ EnablePciDecoding ( for (Idx = 0; Idx < NoHandles; ++Idx) { EFI_PCI_IO_PROTOCOL *PciIo; + UINT64 Attributes; // // Look up PciIo on the handle and stash it @@ -109,12 +110,23 @@ EnablePciDecoding ( goto RestoreAttributes; } + // + // Retrieve supported attributes + // + Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0, + &Attributes); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n", + __FUNCTION__, Status)); + goto RestoreAttributes; + } + // // Enable IO and MMIO decoding // + Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY; Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable, - EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY, - NULL); + Attributes, NULL); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n", __FUNCTION__, Status)); -- 2.39.2