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

PCI/VGA: Log bridge control messages when adding devices

Previously vga_arb_device_init() iterated through all VGA devices and
indicated whether legacy VGA routing to each could be controlled by an
upstream bridge.

But we determine that information in vga_arbiter_add_pci_device(), which we
call for every device, so we can log it there without iterating through the
VGA devices again.

Note that we call vga_arbiter_check_bridge_sharing() before adding the
device to vga_list, so we have to handle the very first device separately.

Link: https://lore.kernel.org/r/20220224224753.297579-10-helgaas@kernel.org
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

authored by

Huacai Chen and committed by
Bjorn Helgaas
4e6c9184 dc593fd4

+8 -11
+8 -11
drivers/pci/vgaarb.c
··· 719 719 720 720 vgadev->bridge_has_one_vga = true; 721 721 722 - if (list_empty(&vga_list)) 722 + if (list_empty(&vga_list)) { 723 + vgaarb_info(&vgadev->pdev->dev, "bridge control possible\n"); 723 724 return; 725 + } 724 726 725 727 /* okay iterate the new devices bridge hierarachy */ 726 728 new_bus = vgadev->pdev->bus; ··· 761 759 } 762 760 new_bus = new_bus->parent; 763 761 } 762 + 763 + if (vgadev->bridge_has_one_vga) 764 + vgaarb_info(&vgadev->pdev->dev, "bridge control possible\n"); 765 + else 766 + vgaarb_info(&vgadev->pdev->dev, "no bridge control possible\n"); 764 767 } 765 768 766 769 /* ··· 1564 1557 { 1565 1558 int rc; 1566 1559 struct pci_dev *pdev; 1567 - struct vga_device *vgadev; 1568 1560 1569 1561 rc = misc_register(&vga_arb_device); 1570 1562 if (rc < 0) ··· 1578 1572 pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 1579 1573 PCI_ANY_ID, pdev)) != NULL) 1580 1574 vga_arbiter_add_pci_device(pdev); 1581 - 1582 - list_for_each_entry(vgadev, &vga_list, list) { 1583 - struct device *dev = &vgadev->pdev->dev; 1584 - 1585 - if (vgadev->bridge_has_one_vga) 1586 - vgaarb_info(dev, "bridge control possible\n"); 1587 - else 1588 - vgaarb_info(dev, "no bridge control possible\n"); 1589 - } 1590 1575 1591 1576 pr_info("loaded\n"); 1592 1577 return rc;