Skip to content

Commit 300bac9

Browse files
Sui Jingfengbjorn-helgaas
authored andcommitted
PCI/VGA: Select VGA devices earlier
Select VGA devices in vga_arb_device_init() and pci_notify() instead of in vga_arbiter_add_pci_device(). This is a trivial optimization for adding devices. It's a bigger optimization for the removal case because pci_notify() won't call vga_arbiter_del_pci_device() for non-VGA devices, so it won't have to search the vga_list for them. https://lore.kernel.org/r/[email protected] Signed-off-by: Sui Jingfeng <[email protected]> [bhelgaas: commit log, split from functional change] Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 655e6fe commit 300bac9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/pci/vgaarb.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,10 +764,6 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev)
764764
struct pci_dev *bridge;
765765
u16 cmd;
766766

767-
/* Only deal with VGA class devices */
768-
if (!pci_is_vga(pdev))
769-
return false;
770-
771767
/* Allocate structure */
772768
vgadev = kzalloc(sizeof(struct vga_device), GFP_KERNEL);
773769
if (vgadev == NULL) {
@@ -1503,6 +1499,10 @@ static int pci_notify(struct notifier_block *nb, unsigned long action,
15031499

15041500
vgaarb_dbg(dev, "%s\n", __func__);
15051501

1502+
/* Only deal with VGA class devices */
1503+
if (!pci_is_vga(pdev))
1504+
return 0;
1505+
15061506
/*
15071507
* For now, we're only interested in devices added and removed.
15081508
* I didn't test this thing here, so someone needs to double check
@@ -1550,8 +1550,10 @@ static int __init vga_arb_device_init(void)
15501550
pdev = NULL;
15511551
while ((pdev =
15521552
pci_get_subsys(PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
1553-
PCI_ANY_ID, pdev)) != NULL)
1554-
vga_arbiter_add_pci_device(pdev);
1553+
PCI_ANY_ID, pdev)) != NULL) {
1554+
if (pci_is_vga(pdev))
1555+
vga_arbiter_add_pci_device(pdev);
1556+
}
15551557

15561558
pr_info("loaded\n");
15571559
return rc;

0 commit comments

Comments
 (0)