Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 Fix PCIe LER when GRUB2 accesses non-enabled MMIO data from VGA
A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.
The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.
--- grub-2.02/grub-core/video/efi_uga.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
grub-core/video/efi_uga.c renamed from grub-core/video/efi_uga.c.orig +11 -1
@@ -95,9 +95,19 @@ find_card (grub_pci_device_t dev, grub_p {struct find_framebuf_ctx *ctx = data;grub_pci_address_t addr; +grub_uint32_t class; addr =grub_pci_make_address (dev,GRUB_PCI_REG_CLASS ); -if (grub_pci_read (addr) >>24 ==0x3 ) + class =grub_pci_read (addr); +if (((class >>16 ) &0xffff ) !=GRUB_PCI_CLASS_SUBCLASS_VGA ) +return 0 ; + +/* Enable MEM address spaces */ + { +grub_pci_address_t rcaddr =grub_pci_make_address (dev,GRUB_PCI_REG_COMMAND ); +grub_pci_write_word (rcaddr,grub_pci_read_word (rcaddr) |GRUB_PCI_COMMAND_MEM_ENABLED ); + } + {int i;
Quoted 20 lines · Mike Travis
A GPU inserted into a PCIe I/O slot disappears during system startup. The problem centers around GRUB and a specific VGA init function in
efi_uga.c. This causes an LER (link error recorvery) because the MMIO memory has not been enabled before attempting access.The fix is to add the same coding used in other VGA drivers, specifically to add a check to insure that it is indeed a VGA controller. And then enable the MMIO address space with the specific bits.
Signed-off-by Mike Travis <[email protected]>Reviewed-by Michael Chang <[email protected]>--- grub-2.02/grub-core/video/efi_uga.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)Index:
grub-2.02/grub-core/video/efi_uga.c
===================================================================
grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 98
Quoted 4 lines
grub-core/video/efi_uga.c renamed from grub-core/video/efi_uga.c.orig +1
-0@@ -95,9 +95,19 @@ find_card (grub_pci_device_t dev, grub_p {struct find_framebuf_ctx *ctx = data;grub_pci_address_t addr; +grub_uint32_t class;
s/class/subclass/
grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 101
Quoted 3 lines
grub-core/video/efi_uga.c renamed from grub-core/video/efi_uga.c.orig +1
-1addr =grub_pci_make_address (dev,GRUB_PCI_REG_CLASS ); -if (grub_pci_read (addr) >>24 ==0x3 ) + class =grub_pci_read (addr);
subclass = (grub_pci_read (addr) >> 16) & 0xffff;
grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 102
Quoted 1 line
grub-core/video/efi_uga.c renamed from grub-core/video/efi_uga.c.orig +1
-0+if (((class >>16 ) &0xffff ) !=GRUB_PCI_CLASS_SUBCLASS_VGA )
if (subclass != GRUB_PCI_CLASS_SUBCLASS_VGA)
grub-core/video/efi_uga.c find_card (grub_pci_device_t dev, grub_p · line 109
Quoted 7 lines
grub-core/video/efi_uga.c renamed from grub-core/video/efi_uga.c.orig +7
-0+return 0 ; + +/* Enable MEM address spaces */ + { +grub_pci_address_t rcaddr =grub_pci_make_address (dev,GRUB_PCI_REG_COMMAND ); +grub_pci_write_word (rcaddr,grub_pci_read_word (rcaddr) |GRUB_PCI_COMMAND_MEM_ENABLED ); + }
Please drop these curly brackets.
Daniel