Skip to content

Commit be6e193

Browse files
khfengalexdeucher
authored andcommitted
vgaarb: Use ACPI HID name to find integrated GPU
Commit 3dd1179 ("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
1 parent 83f7774 commit be6e193

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

drivers/gpu/vga/vgaarb.c

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include <linux/screen_info.h>
5151
#include <linux/vt.h>
5252
#include <linux/console.h>
53+
#include <linux/acpi.h>
5354

5455
#include <linux/uaccess.h>
5556

@@ -1450,9 +1451,23 @@ static struct miscdevice vga_arb_device = {
14501451
MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops
14511452
};
14521453

1454+
#if defined(CONFIG_ACPI)
1455+
static bool vga_arb_integrated_gpu(struct device *dev)
1456+
{
1457+
struct acpi_device *adev = ACPI_COMPANION(dev);
1458+
1459+
return adev && !strcmp(acpi_device_hid(adev), ACPI_VIDEO_HID);
1460+
}
1461+
#else
1462+
static bool vga_arb_integrated_gpu(struct device *dev)
1463+
{
1464+
return false;
1465+
}
1466+
#endif
1467+
14531468
static void __init vga_arb_select_default_device(void)
14541469
{
1455-
struct pci_dev *pdev;
1470+
struct pci_dev *pdev, *found = NULL;
14561471
struct vga_device *vgadev;
14571472

14581473
#if defined(CONFIG_X86) || defined(CONFIG_IA64)
@@ -1505,20 +1520,26 @@ static void __init vga_arb_select_default_device(void)
15051520
#endif
15061521

15071522
if (!vga_default_device()) {
1508-
list_for_each_entry(vgadev, &vga_list, list) {
1523+
list_for_each_entry_reverse(vgadev, &vga_list, list) {
15091524
struct device *dev = &vgadev->pdev->dev;
15101525
u16 cmd;
15111526

15121527
pdev = vgadev->pdev;
15131528
pci_read_config_word(pdev, PCI_COMMAND, &cmd);
15141529
if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
1515-
vgaarb_info(dev, "setting as boot device (VGA legacy resources not available)\n");
1516-
vga_set_default_device(pdev);
1517-
break;
1530+
found = pdev;
1531+
if (vga_arb_integrated_gpu(dev))
1532+
break;
15181533
}
15191534
}
15201535
}
15211536

1537+
if (found) {
1538+
vgaarb_info(&found->dev, "setting as boot device (VGA legacy resources not available)\n");
1539+
vga_set_default_device(found);
1540+
return;
1541+
}
1542+
15221543
if (!vga_default_device()) {
15231544
vgadev = list_first_entry_or_null(&vga_list,
15241545
struct vga_device, list);

0 commit comments

Comments
 (0)