Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vgaarb: Use ACPI HID name to find integrated GPU

Commit 3d42f1ddc47a ("vgaarb: Keep adding VGA device in queue") assumes
the first device is an integrated GPU. However, on AMD platforms an
integrated GPU can have higher PCI device number than a discrete GPU.

Integrated GPU on ACPI platform generally has _DOD and _DOS method, so
use that as predicate to find integrated GPU. If the new strategy
doesn't work, fallback to use the first device as boot VGA.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210519135723.525997-1-kai.heng.feng@canonical.com

authored by

Kai-Heng Feng and committed by
Alex Deucher
808a4ae5 3203e497

+26 -5
+26 -5
drivers/gpu/vga/vgaarb.c
··· 50 50 #include <linux/screen_info.h> 51 51 #include <linux/vt.h> 52 52 #include <linux/console.h> 53 + #include <linux/acpi.h> 53 54 54 55 #include <linux/uaccess.h> 55 56 ··· 1451 1450 MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops 1452 1451 }; 1453 1452 1453 + #if defined(CONFIG_ACPI) 1454 + static bool vga_arb_integrated_gpu(struct device *dev) 1455 + { 1456 + struct acpi_device *adev = ACPI_COMPANION(dev); 1457 + 1458 + return adev && !strcmp(acpi_device_hid(adev), ACPI_VIDEO_HID); 1459 + } 1460 + #else 1461 + static bool vga_arb_integrated_gpu(struct device *dev) 1462 + { 1463 + return false; 1464 + } 1465 + #endif 1466 + 1454 1467 static void __init vga_arb_select_default_device(void) 1455 1468 { 1456 - struct pci_dev *pdev; 1469 + struct pci_dev *pdev, *found = NULL; 1457 1470 struct vga_device *vgadev; 1458 1471 1459 1472 #if defined(CONFIG_X86) || defined(CONFIG_IA64) ··· 1520 1505 #endif 1521 1506 1522 1507 if (!vga_default_device()) { 1523 - list_for_each_entry(vgadev, &vga_list, list) { 1508 + list_for_each_entry_reverse(vgadev, &vga_list, list) { 1524 1509 struct device *dev = &vgadev->pdev->dev; 1525 1510 u16 cmd; 1526 1511 1527 1512 pdev = vgadev->pdev; 1528 1513 pci_read_config_word(pdev, PCI_COMMAND, &cmd); 1529 1514 if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) { 1530 - vgaarb_info(dev, "setting as boot device (VGA legacy resources not available)\n"); 1531 - vga_set_default_device(pdev); 1532 - break; 1515 + found = pdev; 1516 + if (vga_arb_integrated_gpu(dev)) 1517 + break; 1533 1518 } 1534 1519 } 1520 + } 1521 + 1522 + if (found) { 1523 + vgaarb_info(&found->dev, "setting as boot device (VGA legacy resources not available)\n"); 1524 + vga_set_default_device(found); 1525 + return; 1535 1526 } 1536 1527 1537 1528 if (!vga_default_device()) {