diff options
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.c | 66 |
1 files changed, 38 insertions, 28 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c index 77a4a01ddc08..1dddd2f4f929 100644 --- a/drivers/gpu/drm/i915/i915_drv.c +++ b/drivers/gpu/drm/i915/i915_drv.c | |||
@@ -870,7 +870,6 @@ static void intel_detect_preproduction_hw(struct drm_i915_private *dev_priv) | |||
870 | /** | 870 | /** |
871 | * i915_driver_init_early - setup state not requiring device access | 871 | * i915_driver_init_early - setup state not requiring device access |
872 | * @dev_priv: device private | 872 | * @dev_priv: device private |
873 | * @ent: the matching pci_device_id | ||
874 | * | 873 | * |
875 | * Initialize everything that is a "SW-only" state, that is state not | 874 | * Initialize everything that is a "SW-only" state, that is state not |
876 | * requiring accessing the device or exposing the driver via kernel internal | 875 | * requiring accessing the device or exposing the driver via kernel internal |
@@ -878,25 +877,13 @@ static void intel_detect_preproduction_hw(struct drm_i915_private *dev_priv) | |||
878 | * system memory allocation, setting up device specific attributes and | 877 | * system memory allocation, setting up device specific attributes and |
879 | * function hooks not requiring accessing the device. | 878 | * function hooks not requiring accessing the device. |
880 | */ | 879 | */ |
881 | static int i915_driver_init_early(struct drm_i915_private *dev_priv, | 880 | static int i915_driver_init_early(struct drm_i915_private *dev_priv) |
882 | const struct pci_device_id *ent) | ||
883 | { | 881 | { |
884 | const struct intel_device_info *match_info = | ||
885 | (struct intel_device_info *)ent->driver_data; | ||
886 | struct intel_device_info *device_info; | ||
887 | int ret = 0; | 882 | int ret = 0; |
888 | 883 | ||
889 | if (i915_inject_load_failure()) | 884 | if (i915_inject_load_failure()) |
890 | return -ENODEV; | 885 | return -ENODEV; |
891 | 886 | ||
892 | /* Setup the write-once "constant" device info */ | ||
893 | device_info = mkwrite_device_info(dev_priv); | ||
894 | memcpy(device_info, match_info, sizeof(*device_info)); | ||
895 | device_info->device_id = dev_priv->drm.pdev->device; | ||
896 | |||
897 | BUILD_BUG_ON(INTEL_MAX_PLATFORMS > | ||
898 | sizeof(device_info->platform_mask) * BITS_PER_BYTE); | ||
899 | BUG_ON(device_info->gen > sizeof(device_info->gen_mask) * BITS_PER_BYTE); | ||
900 | spin_lock_init(&dev_priv->irq_lock); | 887 | spin_lock_init(&dev_priv->irq_lock); |
901 | spin_lock_init(&dev_priv->gpu_error.lock); | 888 | spin_lock_init(&dev_priv->gpu_error.lock); |
902 | mutex_init(&dev_priv->backlight_lock); | 889 | mutex_init(&dev_priv->backlight_lock); |
@@ -1335,6 +1322,39 @@ static void i915_welcome_messages(struct drm_i915_private *dev_priv) | |||
1335 | DRM_INFO("DRM_I915_DEBUG_RUNTIME_PM enabled\n"); | 1322 | DRM_INFO("DRM_I915_DEBUG_RUNTIME_PM enabled\n"); |
1336 | } | 1323 | } |
1337 | 1324 | ||
1325 | static struct drm_i915_private * | ||
1326 | i915_driver_create(struct pci_dev *pdev, const struct pci_device_id *ent) | ||
1327 | { | ||
1328 | const struct intel_device_info *match_info = | ||
1329 | (struct intel_device_info *)ent->driver_data; | ||
1330 | struct intel_device_info *device_info; | ||
1331 | struct drm_i915_private *i915; | ||
1332 | |||
1333 | i915 = kzalloc(sizeof(*i915), GFP_KERNEL); | ||
1334 | if (!i915) | ||
1335 | return NULL; | ||
1336 | |||
1337 | if (drm_dev_init(&i915->drm, &driver, &pdev->dev)) { | ||
1338 | kfree(i915); | ||
1339 | return NULL; | ||
1340 | } | ||
1341 | |||
1342 | i915->drm.pdev = pdev; | ||
1343 | i915->drm.dev_private = i915; | ||
1344 | pci_set_drvdata(pdev, &i915->drm); | ||
1345 | |||
1346 | /* Setup the write-once "constant" device info */ | ||
1347 | device_info = mkwrite_device_info(i915); | ||
1348 | memcpy(device_info, match_info, sizeof(*device_info)); | ||
1349 | device_info->device_id = pdev->device; | ||
1350 | |||
1351 | BUILD_BUG_ON(INTEL_MAX_PLATFORMS > | ||
1352 | sizeof(device_info->platform_mask) * BITS_PER_BYTE); | ||
1353 | BUG_ON(device_info->gen > sizeof(device_info->gen_mask) * BITS_PER_BYTE); | ||
1354 | |||
1355 | return i915; | ||
1356 | } | ||
1357 | |||
1338 | /** | 1358 | /** |
1339 | * i915_driver_load - setup chip and create an initial config | 1359 | * i915_driver_load - setup chip and create an initial config |
1340 | * @pdev: PCI device | 1360 | * @pdev: PCI device |
@@ -1357,24 +1377,15 @@ int i915_driver_load(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1357 | if (!i915_modparams.nuclear_pageflip && match_info->gen < 5) | 1377 | if (!i915_modparams.nuclear_pageflip && match_info->gen < 5) |
1358 | driver.driver_features &= ~DRIVER_ATOMIC; | 1378 | driver.driver_features &= ~DRIVER_ATOMIC; |
1359 | 1379 | ||
1360 | ret = -ENOMEM; | 1380 | dev_priv = i915_driver_create(pdev, ent); |
1361 | dev_priv = kzalloc(sizeof(*dev_priv), GFP_KERNEL); | 1381 | if (!dev_priv) |
1362 | if (dev_priv) | 1382 | return -ENOMEM; |
1363 | ret = drm_dev_init(&dev_priv->drm, &driver, &pdev->dev); | ||
1364 | if (ret) { | ||
1365 | DRM_DEV_ERROR(&pdev->dev, "allocation failed\n"); | ||
1366 | goto out_free; | ||
1367 | } | ||
1368 | |||
1369 | dev_priv->drm.pdev = pdev; | ||
1370 | dev_priv->drm.dev_private = dev_priv; | ||
1371 | 1383 | ||
1372 | ret = pci_enable_device(pdev); | 1384 | ret = pci_enable_device(pdev); |
1373 | if (ret) | 1385 | if (ret) |
1374 | goto out_fini; | 1386 | goto out_fini; |
1375 | 1387 | ||
1376 | pci_set_drvdata(pdev, &dev_priv->drm); | 1388 | ret = i915_driver_init_early(dev_priv); |
1377 | ret = i915_driver_init_early(dev_priv, ent); | ||
1378 | if (ret < 0) | 1389 | if (ret < 0) |
1379 | goto out_pci_disable; | 1390 | goto out_pci_disable; |
1380 | 1391 | ||
@@ -1426,7 +1437,6 @@ out_pci_disable: | |||
1426 | out_fini: | 1437 | out_fini: |
1427 | i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret); | 1438 | i915_load_error(dev_priv, "Device initialization failed (%d)\n", ret); |
1428 | drm_dev_fini(&dev_priv->drm); | 1439 | drm_dev_fini(&dev_priv->drm); |
1429 | out_free: | ||
1430 | kfree(dev_priv); | 1440 | kfree(dev_priv); |
1431 | pci_set_drvdata(pdev, NULL); | 1441 | pci_set_drvdata(pdev, NULL); |
1432 | return ret; | 1442 | return ret; |