diff mbox

agpgart: Reprobe VGA devices when a new GART device is added

Message ID 1267327851.2282.8.camel@localhost (mailing list archive)
State New, archived
Headers show

Commit Message

Ben Hutchings Feb. 28, 2010, 3:30 a.m. UTC
None
diff mbox

Patch

diff --git a/drivers/char/agp/backend.c b/drivers/char/agp/backend.c
index c3ab46d..f9680bf 100644
--- a/drivers/char/agp/backend.c
+++ b/drivers/char/agp/backend.c
@@ -36,6 +36,7 @@ 
 #include <linux/agp_backend.h>
 #include <linux/agpgart.h>
 #include <linux/vmalloc.h>
+#include <linux/workqueue.h>
 #include <asm/io.h>
 #include "agp.h"
 
@@ -281,6 +282,24 @@  void agp_put_bridge(struct agp_bridge_data *bridge)
 EXPORT_SYMBOL(agp_put_bridge);
 

+/*
+ * DRM drivers may fail to probe their devices when the associated AGP
+ * GART does not yet have a driver, so we reprobe unbound VGA devices
+ * when a GART device is added.  This problem applies not only to true
+ * AGP devices which would be children of the affected bridge, but
+ * also to PCI Express devices that may be siblings of the GART
+ * device.  Therefore iterate over all PCI VGA devices.
+ */
+static void agp_probe_video(struct work_struct *work)
+{
+	struct pci_dev *pdev = NULL;
+
+	while ((pdev = pci_get_class(0x030000, pdev)) != NULL) {
+		if (!pdev->dev.driver && device_reprobe(&pdev->dev))
+			pr_err(PFX "failed to reprobe %s\n", pci_name(pdev));
+}
+static DECLARE_WORK(agp_probe_video_work, agp_probe_video);
+
 int agp_add_bridge(struct agp_bridge_data *bridge)
 {
 	int error;
@@ -324,6 +343,7 @@  int agp_add_bridge(struct agp_bridge_data *bridge)
 	}
 
 	list_add(&bridge->list, &agp_bridges);
+	schedule_work(&agp_probe_video_work);
 	return 0;
 
 frontend_err: