diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2017-10-12 23:47:29 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2017-10-18 04:04:56 -0400 |
commit | 505a1b571711a977b7d069dec3c14381521e9683 (patch) | |
tree | 8b74843c99dda03db00dec7b4f59ccfe1da49f64 /drivers/gpu/vga | |
parent | a37c0f48950b56f6ef2ee637ba597855504e3056 (diff) |
vgaarb: Factor out EFI and fallback default device selection
The default VGA device is normally set in vga_arbiter_add_pci_device() when
we call it for the first enabled device that can be accessed with the
legacy VGA resources ([mem 0xa0000-0xbffff], etc.)
That default device can be overridden by an EFI device that owns the boot
framebuffer. As a fallback, we can also select a VGA device that can't be
accessed via legacy VGA resources, or a VGA device that isn't even enabled.
Factor out this EFI and fallback selection from vga_arb_device_init() into
a separate vga_arb_select_default_device() function. This doesn't change
any behavior, but it untangles the "bridge control possible" checking and
messages from the default device selection.
Tested-by: Zhou Wang <wangzhou1@hisilicon.com> # D05 Hisi Hip07, Hip08
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171013034729.14630.30419.stgit@bhelgaas-glaptop.roam.corp.google.com
Diffstat (limited to 'drivers/gpu/vga')
-rw-r--r-- | drivers/gpu/vga/vgaarb.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index 8035e38d5110..d35d6d271f3f 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c | |||
@@ -1402,29 +1402,14 @@ static struct miscdevice vga_arb_device = { | |||
1402 | MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops | 1402 | MISC_DYNAMIC_MINOR, "vga_arbiter", &vga_arb_device_fops |
1403 | }; | 1403 | }; |
1404 | 1404 | ||
1405 | static int __init vga_arb_device_init(void) | 1405 | static void __init vga_arb_select_default_device(void) |
1406 | { | 1406 | { |
1407 | int rc; | ||
1408 | struct pci_dev *pdev; | 1407 | struct pci_dev *pdev; |
1409 | struct vga_device *vgadev; | 1408 | struct vga_device *vgadev; |
1410 | 1409 | ||
1411 | rc = misc_register(&vga_arb_device); | 1410 | #if defined(CONFIG_X86) || defined(CONFIG_IA64) |
1412 | if (rc < 0) | ||
1413 | pr_err("error %d registering device\n", rc); | ||
1414 | |||
1415 | bus_register_notifier(&pci_bus_type, &pci_notifier); | ||
1416 | |||
1417 | /* We add all pci devices satisfying vga class in the arbiter by | ||
1418 | * default */ | ||
1419 | pdev = NULL; | ||
1420 | while ((pdev = | ||
1421 | pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | ||
1422 | PCI_ANY_ID, pdev)) != NULL) | ||
1423 | vga_arbiter_add_pci_device(pdev); | ||
1424 | |||
1425 | list_for_each_entry(vgadev, &vga_list, list) { | 1411 | list_for_each_entry(vgadev, &vga_list, list) { |
1426 | struct device *dev = &vgadev->pdev->dev; | 1412 | struct device *dev = &vgadev->pdev->dev; |
1427 | #if defined(CONFIG_X86) || defined(CONFIG_IA64) | ||
1428 | /* | 1413 | /* |
1429 | * Override vga_arbiter_add_pci_device()'s I/O based detection | 1414 | * Override vga_arbiter_add_pci_device()'s I/O based detection |
1430 | * as it may take the wrong device (e.g. on Apple system under | 1415 | * as it may take the wrong device (e.g. on Apple system under |
@@ -1461,12 +1446,8 @@ static int __init vga_arb_device_init(void) | |||
1461 | vgaarb_info(dev, "overriding boot device\n"); | 1446 | vgaarb_info(dev, "overriding boot device\n"); |
1462 | vga_set_default_device(vgadev->pdev); | 1447 | vga_set_default_device(vgadev->pdev); |
1463 | } | 1448 | } |
1464 | #endif | ||
1465 | if (vgadev->bridge_has_one_vga) | ||
1466 | vgaarb_info(dev, "bridge control possible\n"); | ||
1467 | else | ||
1468 | vgaarb_info(dev, "no bridge control possible\n"); | ||
1469 | } | 1449 | } |
1450 | #endif | ||
1470 | 1451 | ||
1471 | if (!vga_default_device()) { | 1452 | if (!vga_default_device()) { |
1472 | list_for_each_entry(vgadev, &vga_list, list) { | 1453 | list_for_each_entry(vgadev, &vga_list, list) { |
@@ -1492,6 +1473,38 @@ static int __init vga_arb_device_init(void) | |||
1492 | vga_set_default_device(vgadev->pdev); | 1473 | vga_set_default_device(vgadev->pdev); |
1493 | } | 1474 | } |
1494 | } | 1475 | } |
1476 | } | ||
1477 | |||
1478 | static int __init vga_arb_device_init(void) | ||
1479 | { | ||
1480 | int rc; | ||
1481 | struct pci_dev *pdev; | ||
1482 | struct vga_device *vgadev; | ||
1483 | |||
1484 | rc = misc_register(&vga_arb_device); | ||
1485 | if (rc < 0) | ||
1486 | pr_err("error %d registering device\n", rc); | ||
1487 | |||
1488 | bus_register_notifier(&pci_bus_type, &pci_notifier); | ||
1489 | |||
1490 | /* We add all PCI devices satisfying VGA class in the arbiter by | ||
1491 | * default */ | ||
1492 | pdev = NULL; | ||
1493 | while ((pdev = | ||
1494 | pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, | ||
1495 | PCI_ANY_ID, pdev)) != NULL) | ||
1496 | vga_arbiter_add_pci_device(pdev); | ||
1497 | |||
1498 | list_for_each_entry(vgadev, &vga_list, list) { | ||
1499 | struct device *dev = &vgadev->pdev->dev; | ||
1500 | |||
1501 | if (vgadev->bridge_has_one_vga) | ||
1502 | vgaarb_info(dev, "bridge control possible\n"); | ||
1503 | else | ||
1504 | vgaarb_info(dev, "no bridge control possible\n"); | ||
1505 | } | ||
1506 | |||
1507 | vga_arb_select_default_device(); | ||
1495 | 1508 | ||
1496 | pr_info("loaded\n"); | 1509 | pr_info("loaded\n"); |
1497 | return rc; | 1510 | return rc; |