Skip to content

Commit 6fd0248

Browse files
bwhacksairlied
authored andcommitted
amd64-agp: Probe unknown AGP devices the right way
The current initialisation code probes 'unsupported' AGP devices simply by calling its own probe function. It does not lock these devices or even check whether another driver is already bound to them. We must use the device core to manage this. So if the specific device id table didn't match anything and agp_try_unsupported=1, switch the device id table and call driver_attach() again. Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent d831692 commit 6fd0248

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

drivers/char/agp/amd64-agp.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,10 @@ static int __devinit agp_amd64_probe(struct pci_dev *pdev,
500500
u8 cap_ptr;
501501
int err;
502502

503+
/* The Highlander principle */
504+
if (agp_bridges_found)
505+
return -ENODEV;
506+
503507
cap_ptr = pci_find_capability(pdev, PCI_CAP_ID_AGP);
504508
if (!cap_ptr)
505509
return -ENODEV;
@@ -563,6 +567,8 @@ static void __devexit agp_amd64_remove(struct pci_dev *pdev)
563567
amd64_aperture_sizes[bridge->aperture_size_idx].size);
564568
agp_remove_bridge(bridge);
565569
agp_put_bridge(bridge);
570+
571+
agp_bridges_found--;
566572
}
567573

568574
#ifdef CONFIG_PM
@@ -710,6 +716,11 @@ static struct pci_device_id agp_amd64_pci_table[] = {
710716

711717
MODULE_DEVICE_TABLE(pci, agp_amd64_pci_table);
712718

719+
static DEFINE_PCI_DEVICE_TABLE(agp_amd64_pci_promisc_table) = {
720+
{ PCI_DEVICE_CLASS(0, 0) },
721+
{ }
722+
};
723+
713724
static struct pci_driver agp_amd64_pci_driver = {
714725
.name = "agpgart-amd64",
715726
.id_table = agp_amd64_pci_table,
@@ -735,7 +746,6 @@ int __init agp_amd64_init(void)
735746
return err;
736747

737748
if (agp_bridges_found == 0) {
738-
struct pci_dev *dev;
739749
if (!agp_try_unsupported && !agp_try_unsupported_boot) {
740750
printk(KERN_INFO PFX "No supported AGP bridge found.\n");
741751
#ifdef MODULE
@@ -751,17 +761,10 @@ int __init agp_amd64_init(void)
751761
return -ENODEV;
752762

753763
/* Look for any AGP bridge */
754-
dev = NULL;
755-
err = -ENODEV;
756-
for_each_pci_dev(dev) {
757-
if (!pci_find_capability(dev, PCI_CAP_ID_AGP))
758-
continue;
759-
/* Only one bridge supported right now */
760-
if (agp_amd64_probe(dev, NULL) == 0) {
761-
err = 0;
762-
break;
763-
}
764-
}
764+
agp_amd64_pci_driver.id_table = agp_amd64_pci_promisc_table;
765+
err = driver_attach(&agp_amd64_pci_driver.driver);
766+
if (err == 0 && agp_bridges_found == 0)
767+
err = -ENODEV;
765768
}
766769
return err;
767770
}

0 commit comments

Comments
 (0)