sys/dev/drm/i915/i915_drv.c
/**
 * i915_driver_init_early - setup state not requiring device access
 * @dev_priv: device private
 *
 * Initialize everything that is a "SW-only" state, that is state not
 * requiring accessing the device or exposing the driver via kernel internal
 * or userspace interfaces. Example steps belonging here: lock initialization,
 * system memory allocation, setting up device specific attributes and
 * function hooks not requiring accessing the device.
 */
setup state not requiring device access
@dev_priv: device private

Initialize everything that is a "SW-only" state, that is state not
requiring accessing the device or exposing the driver via kernel internal
or userspace interfaces. Example steps belonging here: lock initialization,
system memory allocation, setting up device specific attributes and
function hooks not requiring accessing the device.
setup state not requiring device access @dev_priv : device private Initialize everything that is a " SW - only " state that is state not requiring accessing the device or exposing the driver via kernel internal or userspace interfaces . Example steps belonging here : lock initialization system memory allocation setting up device specific attributes and function hooks not requiring accessing the device .
static int i915_driver_init_early(struct drm_i915_private *dev_priv,
				  const struct pci_device_id *ent)
{
	const struct intel_device_info *match_info =
		(struct intel_device_info *)ent->driver_data;
	struct intel_device_info *device_info;
	int ret = 0;
	if (i915_inject_load_failure())
		return -ENODEV;
	device_info = (struct intel_device_info *)&dev_priv->info;
	memcpy(device_info, match_info, sizeof(*device_info));
	device_info->device_id = dev_priv->drm.pdev->device;
	BUG_ON(device_info->gen > sizeof(device_info->gen_mask) * BITS_PER_BYTE);
	device_info->gen_mask = BIT(device_info->gen - 1);
	lockinit(&dev_priv->irq_lock, "userirq", 0, LK_CANRECURSE);
	lockinit(&dev_priv->gpu_error.lock, "915err", 0, LK_CANRECURSE);
	lockinit(&dev_priv->backlight_lock, "i915bl", 0, LK_CANRECURSE);
	lockinit(&dev_priv->uncore.lock, "915gt", 0, LK_CANRECURSE);
	spin_init(&dev_priv->mm.object_stat_lock, "i915osl");
	spin_init(&dev_priv->mmio_flip_lock, "i915mfl");
	lockinit(&dev_priv->sb_lock, "i915sbl", 0, LK_CANRECURSE);
	lockinit(&dev_priv->modeset_restore_lock, "i915mrl", 0, LK_CANRECURSE);
	lockinit(&dev_priv->av_mutex, "i915am", 0, LK_CANRECURSE);
	lockinit(&dev_priv->wm.wm_mutex, "i915wm", 0, LK_CANRECURSE);
	lockinit(&dev_priv->pps_mutex, "i915pm", 0, LK_CANRECURSE);
	ret = i915_workqueues_init(dev_priv);
	if (ret < 0)
		return ret;
	ret = intel_gvt_init(dev_priv);
	if (ret < 0)
		goto err_workqueues;
	intel_detect_pch(&dev_priv->drm);
	intel_pm_setup(&dev_priv->drm);
	intel_init_dpio(dev_priv);
	intel_power_domains_init(dev_priv);
	intel_irq_init(dev_priv);
	intel_init_display_hooks(dev_priv);
	intel_init_clock_gating_hooks(dev_priv);
	intel_init_audio_hooks(dev_priv);
	i915_gem_load_init(&dev_priv->drm);
	intel_display_crc_init(&dev_priv->drm);
	i915_dump_device_info(dev_priv);
	if (IS_HSW_EARLY_SDV(dev_priv))
		DRM_INFO("This is an early pre-production Haswell machine. "
			 "It may not be fully functional.\n");
	return 0;
err_workqueues:
	i915_workqueues_cleanup(dev_priv);
	return ret;
}
static int i915_driver_init_early ( struct drm_i915_private * dev_priv , const struct pci_device_id * ent ) { const struct intel_device_info * match_info = ( struct intel_device_info * ) ent -> driver_data ; struct intel_device_info * device_info ; int ret = 0 ; if ( i915_inject_load_failure ( ) ) return - ENODEV ; device_info = ( struct intel_device_info * ) & dev_priv -> info ; memcpy ( device_info , match_info , sizeof ( * device_info ) ) ; device_info -> device_id = dev_priv -> drm . pdev -> device ; BUG_ON ( device_info -> gen > sizeof ( device_info -> gen_mask ) * BITS_PER_BYTE ) ; device_info -> gen_mask = BIT ( device_info -> gen - 1 ) ; lockinit ( & dev_priv -> irq_lock , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> gpu_error . lock , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> backlight_lock , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> uncore . lock , " " , 0 , LK_CANRECURSE ) ; spin_init ( & dev_priv -> mm . object_stat_lock , " " ) ; spin_init ( & dev_priv -> mmio_flip_lock , " " ) ; lockinit ( & dev_priv -> sb_lock , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> modeset_restore_lock , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> av_mutex , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> wm . wm_mutex , " " , 0 , LK_CANRECURSE ) ; lockinit ( & dev_priv -> pps_mutex , " " , 0 , LK_CANRECURSE ) ; ret = i915_workqueues_init ( dev_priv ) ; if ( ret < 0 ) return ret ; ret = intel_gvt_init ( dev_priv ) ; if ( ret < 0 ) goto err_workqueues ; intel_detect_pch ( & dev_priv -> drm ) ; intel_pm_setup ( & dev_priv -> drm ) ; intel_init_dpio ( dev_priv ) ; intel_power_domains_init ( dev_priv ) ; intel_irq_init ( dev_priv ) ; intel_init_display_hooks ( dev_priv ) ; intel_init_clock_gating_hooks ( dev_priv ) ; intel_init_audio_hooks ( dev_priv ) ; i915_gem_load_init ( & dev_priv -> drm ) ; intel_display_crc_init ( & dev_priv -> drm ) ; i915_dump_device_info ( dev_priv ) ; if ( IS_HSW_EARLY_SDV ( dev_priv ) ) DRM_INFO ( " " " \n " ) ; return 0 ; err_workqueues : i915_workqueues_cleanup ( dev_priv ) ; return ret ; }
i915_driver_init_early - setup state not requiring device access
 @dev_priv: device private
i915_driver_init_early - setup state not requiring device access @dev_priv : device private
/* Setup the write-once "constant" device info */ /* This must be called before any calls to HAS_PCH_* */ /* Not all pre-production machines fall into this category, only the
	 * very first ones. Almost everything should work, except for maybe
	 * suspend/resume. And we don't implement workarounds that affect only
	 * pre-production machines. */