Blame SOURCES/0288-efi-uga-Fix-PCIe-LER-when-GRUB2-accesses-non-enabled.patch

f731ee
From a897321d9c318c18c92c6431115fd9be71fedba1 Mon Sep 17 00:00:00 2001
f731ee
From: "mike.travis@hpe.com" <mike.travis@hpe.com>
f731ee
Date: Wed, 28 Mar 2018 11:42:18 -0500
f731ee
Subject: [PATCH 288/288] efi/uga: Fix PCIe LER when GRUB2 accesses non-enabled
f731ee
 MMIO data from VGA
f731ee
f731ee
A GPU inserted into a PCIe I/O slot disappears during system startup.
f731ee
The problem centers around GRUB and a specific VGA init function in
f731ee
efi_uga.c. This causes an LER (Link Error Recorvery) because the MMIO
f731ee
memory has not been enabled before attempting access.
f731ee
f731ee
The fix is to add the same coding used in other VGA drivers, specifically
f731ee
to add a check to insure that it is indeed a VGA controller. And then
f731ee
enable the MMIO address space with the specific bits.
f731ee
f731ee
Signed-off-by: Mike Travis <mike.travis@hpe.com>
f731ee
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
f731ee
---
f731ee
 grub-core/video/efi_uga.c | 13 +++++++++++--
f731ee
 1 file changed, 11 insertions(+), 2 deletions(-)
f731ee
f731ee
diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c
f731ee
index 1d4091c5631..97a607c01a5 100644
f731ee
--- a/grub-core/video/efi_uga.c
f731ee
+++ b/grub-core/video/efi_uga.c
f731ee
@@ -94,10 +94,19 @@ static int
f731ee
 find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
f731ee
 {
f731ee
   struct find_framebuf_ctx *ctx = data;
f731ee
-  grub_pci_address_t addr;
f731ee
+  grub_pci_address_t addr, rcaddr;
f731ee
+  grub_uint32_t subclass;
f731ee
 
f731ee
   addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
f731ee
-  if (grub_pci_read (addr) >> 24 == 0x3)
f731ee
+  subclass = (grub_pci_read (addr) >> 16) & 0xffff;
f731ee
+
f731ee
+  if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA)
f731ee
+    return 0;
f731ee
+
f731ee
+  /* Enable MEM address spaces */
f731ee
+  rcaddr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
f731ee
+  grub_pci_write_word (rcaddr, grub_pci_read_word (rcaddr) | GRUB_PCI_COMMAND_MEM_ENABLED);
f731ee
+
f731ee
     {
f731ee
       int i;
f731ee
 
f731ee
-- 
f731ee
2.17.1
f731ee