agp/intel: split out gmch/gtt probe, part 1
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 13 Apr 2010 22:29:55 +0000 (00:29 +0200)
committerEric Anholt <eric@anholt.net>
Mon, 19 Apr 2010 00:37:46 +0000 (17:37 -0700)
This is essentially the last piece of code that's tying intel-gtt.c
to intel-agp.c. Extract the probe code into it's own function so that
it can be moved to intel-gtt.c.

This requires some slight changes in the ordering of device probe function.
This patch just implements that for better bisectability in case this
introduces bugs.

The biggest change is that the gmch/gtt code doesn't execute a pci
resource fixup anymore. I've dug around in historical git trees, and
this change is to support the agp port on an old HP server with the
i440 intel chipset. So only needed for the agp driver.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Eric Anholt <eric@anholt.net>
drivers/char/agp/intel-agp.c

index b5cb192dc6b61a0d3cdb20939870b62e6c8ec024..cc494abe195ec605a453ef4aaf6772ed8a6fe5ca 100644 (file)
@@ -812,6 +812,41 @@ static const struct intel_driver_description {
        { 0, 0, NULL, NULL, NULL }
 };
 
+static int __devinit intel_gmch_probe(struct pci_dev *pdev,
+                                     struct agp_bridge_data *bridge)
+{
+       int i;
+       bridge->driver = NULL;
+
+       for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
+               if ((intel_agp_chipsets[i].gmch_chip_id != 0) &&
+                       find_gmch(intel_agp_chipsets[i].gmch_chip_id)) {
+                       bridge->driver =
+                               intel_agp_chipsets[i].gmch_driver;
+                       break;
+               }
+       }
+
+       if (!bridge->driver)
+               return 0;
+
+       bridge->dev_private_data = &intel_private;
+       bridge->dev = pdev;
+
+       dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name);
+
+       if (bridge->driver->mask_memory == intel_i965_mask_memory) {
+               if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36)))
+                       dev_err(&intel_private.pcidev->dev,
+                               "set gfx device dma mask 36bit failed!\n");
+               else
+                       pci_set_consistent_dma_mask(intel_private.pcidev,
+                                                   DMA_BIT_MASK(36));
+       }
+
+       return 1;
+}
+
 static int __devinit agp_intel_probe(struct pci_dev *pdev,
                                     const struct pci_device_id *ent)
 {
@@ -826,20 +861,18 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
        if (!bridge)
                return -ENOMEM;
 
+       bridge->capndx = cap_ptr;
+
+       if (intel_gmch_probe(pdev, bridge))
+               goto found_gmch;
+
        for (i = 0; intel_agp_chipsets[i].name != NULL; i++) {
                /* In case that multiple models of gfx chip may
                   stand on same host bridge type, this can be
                   sure we detect the right IGD. */
                if (pdev->device == intel_agp_chipsets[i].chip_id) {
-                       if ((intel_agp_chipsets[i].gmch_chip_id != 0) &&
-                               find_gmch(intel_agp_chipsets[i].gmch_chip_id)) {
-                               bridge->driver =
-                                       intel_agp_chipsets[i].gmch_driver;
-                               break;
-                       } else {
-                               bridge->driver = intel_agp_chipsets[i].driver;
-                               break;
-                       }
+                       bridge->driver = intel_agp_chipsets[i].driver;
+                       break;
                }
        }
 
@@ -851,18 +884,8 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
                return -ENODEV;
        }
 
-       if (bridge->driver == NULL) {
-               /* bridge has no AGP and no IGD detected */
-               if (cap_ptr)
-                       dev_warn(&pdev->dev, "can't find bridge device (chip_id: %04x)\n",
-                                intel_agp_chipsets[i].gmch_chip_id);
-               agp_put_bridge(bridge);
-               return -ENODEV;
-       }
-
        bridge->dev = pdev;
-       bridge->capndx = cap_ptr;
-       bridge->dev_private_data = &intel_private;
+       bridge->dev_private_data = NULL;
 
        dev_info(&pdev->dev, "Intel %s Chipset\n", intel_agp_chipsets[i].name);
 
@@ -898,15 +921,7 @@ static int __devinit agp_intel_probe(struct pci_dev *pdev,
                                &bridge->mode);
        }
 
-       if (bridge->driver->mask_memory == intel_i965_mask_memory) {
-               if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(36)))
-                       dev_err(&intel_private.pcidev->dev,
-                               "set gfx device dma mask 36bit failed!\n");
-               else
-                       pci_set_consistent_dma_mask(intel_private.pcidev,
-                                                   DMA_BIT_MASK(36));
-       }
-
+found_gmch:
        pci_set_drvdata(pdev, bridge);
        err = agp_add_bridge(bridge);
        if (!err)