nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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