struct monitor* monitor_new(void) { struct monitor* mon = calloc(1, sizeof(struct monitor)); // Half a second is a decent default mon->update_interval = 500; mon->active = 1; // Fetch the basic info that should hold true throughout execution init_device_info(mon); return mon; }
/** * intel_gvt_init_device - initialize a GVT device * @dev_priv: drm i915 private data * * This function is called at the initialization stage, to initialize * necessary GVT components. * * Returns: * Zero on success, negative error code if failed. * */ int intel_gvt_init_device(struct drm_i915_private *dev_priv) { struct intel_gvt *gvt; struct intel_vgpu *vgpu; int ret; /* * Cannot initialize GVT device without intel_gvt_host gets * initialized first. */ if (WARN_ON(!intel_gvt_host.initialized)) return -EINVAL; if (WARN_ON(dev_priv->gvt)) return -EEXIST; gvt = kzalloc(sizeof(struct intel_gvt), GFP_KERNEL); if (!gvt) return -ENOMEM; gvt_dbg_core("init gvt device\n"); idr_init(&gvt->vgpu_idr); spin_lock_init(&gvt->scheduler.mmio_context_lock); mutex_init(&gvt->lock); gvt->dev_priv = dev_priv; init_device_info(gvt); ret = intel_gvt_setup_mmio_info(gvt); if (ret) goto out_clean_idr; ret = intel_gvt_load_firmware(gvt); if (ret) goto out_clean_mmio_info; ret = intel_gvt_init_irq(gvt); if (ret) goto out_free_firmware; ret = intel_gvt_init_gtt(gvt); if (ret) goto out_clean_irq; ret = intel_gvt_init_opregion(gvt); if (ret) goto out_clean_gtt; ret = intel_gvt_init_workload_scheduler(gvt); if (ret) goto out_clean_opregion; ret = intel_gvt_init_sched_policy(gvt); if (ret) goto out_clean_workload_scheduler; ret = intel_gvt_init_cmd_parser(gvt); if (ret) goto out_clean_sched_policy; ret = init_service_thread(gvt); if (ret) goto out_clean_cmd_parser; ret = intel_gvt_init_vgpu_types(gvt); if (ret) goto out_clean_thread; ret = intel_gvt_hypervisor_host_init(&dev_priv->drm.pdev->dev, gvt, &intel_gvt_ops); if (ret) { gvt_err("failed to register gvt-g host device: %d\n", ret); goto out_clean_types; } vgpu = intel_gvt_create_idle_vgpu(gvt); if (IS_ERR(vgpu)) { ret = PTR_ERR(vgpu); gvt_err("failed to create idle vgpu\n"); goto out_clean_types; } gvt->idle_vgpu = vgpu; gvt_dbg_core("gvt device initialization is done\n"); dev_priv->gvt = gvt; return 0; out_clean_types: intel_gvt_clean_vgpu_types(gvt); out_clean_thread: clean_service_thread(gvt); out_clean_cmd_parser: intel_gvt_clean_cmd_parser(gvt); out_clean_sched_policy: intel_gvt_clean_sched_policy(gvt); out_clean_workload_scheduler: intel_gvt_clean_workload_scheduler(gvt); out_clean_opregion: intel_gvt_clean_opregion(gvt); out_clean_gtt: intel_gvt_clean_gtt(gvt); out_clean_irq: intel_gvt_clean_irq(gvt); out_free_firmware: intel_gvt_free_firmware(gvt); out_clean_mmio_info: intel_gvt_clean_mmio_info(gvt); out_clean_idr: idr_destroy(&gvt->vgpu_idr); kfree(gvt); return ret; }