diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_dma.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 91ef4c150193..9909505d070a 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -898,6 +898,18 @@ static int i915_set_status_page(struct drm_device *dev, void *data, | |||
898 | return 0; | 898 | return 0; |
899 | } | 899 | } |
900 | 900 | ||
901 | static int i915_get_bridge_dev(struct drm_device *dev) | ||
902 | { | ||
903 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
904 | |||
905 | dev_priv->bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); | ||
906 | if (!dev_priv->bridge_dev) { | ||
907 | DRM_ERROR("bridge device not found\n"); | ||
908 | return -1; | ||
909 | } | ||
910 | return 0; | ||
911 | } | ||
912 | |||
901 | /** | 913 | /** |
902 | * i915_probe_agp - get AGP bootup configuration | 914 | * i915_probe_agp - get AGP bootup configuration |
903 | * @pdev: PCI device | 915 | * @pdev: PCI device |
@@ -911,20 +923,13 @@ static int i915_set_status_page(struct drm_device *dev, void *data, | |||
911 | static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size, | 923 | static int i915_probe_agp(struct drm_device *dev, uint32_t *aperture_size, |
912 | uint32_t *preallocated_size) | 924 | uint32_t *preallocated_size) |
913 | { | 925 | { |
914 | struct pci_dev *bridge_dev; | 926 | struct drm_i915_private *dev_priv = dev->dev_private; |
915 | u16 tmp = 0; | 927 | u16 tmp = 0; |
916 | unsigned long overhead; | 928 | unsigned long overhead; |
917 | unsigned long stolen; | 929 | unsigned long stolen; |
918 | 930 | ||
919 | bridge_dev = pci_get_bus_and_slot(0, PCI_DEVFN(0,0)); | ||
920 | if (!bridge_dev) { | ||
921 | DRM_ERROR("bridge device not found\n"); | ||
922 | return -1; | ||
923 | } | ||
924 | |||
925 | /* Get the fb aperture size and "stolen" memory amount. */ | 931 | /* Get the fb aperture size and "stolen" memory amount. */ |
926 | pci_read_config_word(bridge_dev, INTEL_GMCH_CTRL, &tmp); | 932 | pci_read_config_word(dev_priv->bridge_dev, INTEL_GMCH_CTRL, &tmp); |
927 | pci_dev_put(bridge_dev); | ||
928 | 933 | ||
929 | *aperture_size = 1024 * 1024; | 934 | *aperture_size = 1024 * 1024; |
930 | *preallocated_size = 1024 * 1024; | 935 | *preallocated_size = 1024 * 1024; |
@@ -1176,11 +1181,16 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) | |||
1176 | base = drm_get_resource_start(dev, mmio_bar); | 1181 | base = drm_get_resource_start(dev, mmio_bar); |
1177 | size = drm_get_resource_len(dev, mmio_bar); | 1182 | size = drm_get_resource_len(dev, mmio_bar); |
1178 | 1183 | ||
1184 | if (i915_get_bridge_dev(dev)) { | ||
1185 | ret = -EIO; | ||
1186 | goto free_priv; | ||
1187 | } | ||
1188 | |||
1179 | dev_priv->regs = ioremap(base, size); | 1189 | dev_priv->regs = ioremap(base, size); |
1180 | if (!dev_priv->regs) { | 1190 | if (!dev_priv->regs) { |
1181 | DRM_ERROR("failed to map registers\n"); | 1191 | DRM_ERROR("failed to map registers\n"); |
1182 | ret = -EIO; | 1192 | ret = -EIO; |
1183 | goto free_priv; | 1193 | goto put_bridge; |
1184 | } | 1194 | } |
1185 | 1195 | ||
1186 | dev_priv->mm.gtt_mapping = | 1196 | dev_priv->mm.gtt_mapping = |
@@ -1292,6 +1302,8 @@ out_iomapfree: | |||
1292 | io_mapping_free(dev_priv->mm.gtt_mapping); | 1302 | io_mapping_free(dev_priv->mm.gtt_mapping); |
1293 | out_rmmap: | 1303 | out_rmmap: |
1294 | iounmap(dev_priv->regs); | 1304 | iounmap(dev_priv->regs); |
1305 | put_bridge: | ||
1306 | pci_dev_put(dev_priv->bridge_dev); | ||
1295 | free_priv: | 1307 | free_priv: |
1296 | kfree(dev_priv); | 1308 | kfree(dev_priv); |
1297 | return ret; | 1309 | return ret; |
@@ -1335,6 +1347,7 @@ int i915_driver_unload(struct drm_device *dev) | |||
1335 | i915_gem_lastclose(dev); | 1347 | i915_gem_lastclose(dev); |
1336 | } | 1348 | } |
1337 | 1349 | ||
1350 | pci_dev_put(dev_priv->bridge_dev); | ||
1338 | kfree(dev->dev_private); | 1351 | kfree(dev->dev_private); |
1339 | 1352 | ||
1340 | return 0; | 1353 | return 0; |