| .. | .. |
|---|
| 22 | 22 | */ |
|---|
| 23 | 23 | |
|---|
| 24 | 24 | #include "i915_drv.h" |
|---|
| 25 | +#include "i915_vgpu.h" |
|---|
| 25 | 26 | #include "intel_gvt.h" |
|---|
| 27 | +#include "gvt/gvt.h" |
|---|
| 26 | 28 | |
|---|
| 27 | 29 | /** |
|---|
| 28 | 30 | * DOC: Intel GVT-g host support |
|---|
| .. | .. |
|---|
| 49 | 51 | return true; |
|---|
| 50 | 52 | if (IS_BROXTON(dev_priv)) |
|---|
| 51 | 53 | return true; |
|---|
| 54 | + if (IS_COFFEELAKE(dev_priv)) |
|---|
| 55 | + return true; |
|---|
| 56 | + if (IS_COMETLAKE(dev_priv)) |
|---|
| 57 | + return true; |
|---|
| 58 | + |
|---|
| 52 | 59 | return false; |
|---|
| 53 | 60 | } |
|---|
| 54 | 61 | |
|---|
| .. | .. |
|---|
| 60 | 67 | */ |
|---|
| 61 | 68 | void intel_gvt_sanitize_options(struct drm_i915_private *dev_priv) |
|---|
| 62 | 69 | { |
|---|
| 63 | | - if (!i915_modparams.enable_gvt) |
|---|
| 70 | + if (!dev_priv->params.enable_gvt) |
|---|
| 64 | 71 | return; |
|---|
| 65 | 72 | |
|---|
| 66 | 73 | if (intel_vgpu_active(dev_priv)) { |
|---|
| 67 | | - DRM_INFO("GVT-g is disabled for guest\n"); |
|---|
| 74 | + drm_info(&dev_priv->drm, "GVT-g is disabled for guest\n"); |
|---|
| 68 | 75 | goto bail; |
|---|
| 69 | 76 | } |
|---|
| 70 | 77 | |
|---|
| 71 | 78 | if (!is_supported_device(dev_priv)) { |
|---|
| 72 | | - DRM_INFO("Unsupported device. GVT-g is disabled\n"); |
|---|
| 79 | + drm_info(&dev_priv->drm, |
|---|
| 80 | + "Unsupported device. GVT-g is disabled\n"); |
|---|
| 73 | 81 | goto bail; |
|---|
| 74 | 82 | } |
|---|
| 75 | 83 | |
|---|
| 76 | 84 | return; |
|---|
| 77 | 85 | bail: |
|---|
| 78 | | - i915_modparams.enable_gvt = 0; |
|---|
| 86 | + dev_priv->params.enable_gvt = 0; |
|---|
| 79 | 87 | } |
|---|
| 80 | 88 | |
|---|
| 81 | 89 | /** |
|---|
| .. | .. |
|---|
| 92 | 100 | { |
|---|
| 93 | 101 | int ret; |
|---|
| 94 | 102 | |
|---|
| 95 | | - if (i915_inject_load_failure()) |
|---|
| 103 | + if (i915_inject_probe_failure(dev_priv)) |
|---|
| 96 | 104 | return -ENODEV; |
|---|
| 97 | 105 | |
|---|
| 98 | | - if (!i915_modparams.enable_gvt) { |
|---|
| 99 | | - DRM_DEBUG_DRIVER("GVT-g is disabled by kernel params\n"); |
|---|
| 106 | + if (!dev_priv->params.enable_gvt) { |
|---|
| 107 | + drm_dbg(&dev_priv->drm, |
|---|
| 108 | + "GVT-g is disabled by kernel params\n"); |
|---|
| 100 | 109 | return 0; |
|---|
| 101 | 110 | } |
|---|
| 102 | 111 | |
|---|
| 103 | | - if (USES_GUC_SUBMISSION(dev_priv)) { |
|---|
| 104 | | - DRM_ERROR("i915 GVT-g loading failed due to Graphics virtualization is not yet supported with GuC submission\n"); |
|---|
| 112 | + if (intel_uc_wants_guc_submission(&dev_priv->gt.uc)) { |
|---|
| 113 | + drm_err(&dev_priv->drm, |
|---|
| 114 | + "i915 GVT-g loading failed due to Graphics virtualization is not yet supported with GuC submission\n"); |
|---|
| 105 | 115 | return -EIO; |
|---|
| 106 | | - } |
|---|
| 107 | | - |
|---|
| 108 | | - /* |
|---|
| 109 | | - * We're not in host or fail to find a MPT module, disable GVT-g |
|---|
| 110 | | - */ |
|---|
| 111 | | - ret = intel_gvt_init_host(); |
|---|
| 112 | | - if (ret) { |
|---|
| 113 | | - DRM_DEBUG_DRIVER("Not in host or MPT modules not found\n"); |
|---|
| 114 | | - goto bail; |
|---|
| 115 | 116 | } |
|---|
| 116 | 117 | |
|---|
| 117 | 118 | ret = intel_gvt_init_device(dev_priv); |
|---|
| 118 | 119 | if (ret) { |
|---|
| 119 | | - DRM_DEBUG_DRIVER("Fail to init GVT device\n"); |
|---|
| 120 | + drm_dbg(&dev_priv->drm, "Fail to init GVT device\n"); |
|---|
| 120 | 121 | goto bail; |
|---|
| 121 | 122 | } |
|---|
| 122 | 123 | |
|---|
| 123 | 124 | return 0; |
|---|
| 124 | 125 | |
|---|
| 125 | 126 | bail: |
|---|
| 126 | | - i915_modparams.enable_gvt = 0; |
|---|
| 127 | + dev_priv->params.enable_gvt = 0; |
|---|
| 127 | 128 | return 0; |
|---|
| 128 | 129 | } |
|---|
| 129 | 130 | |
|---|
| 131 | +static inline bool intel_gvt_active(struct drm_i915_private *dev_priv) |
|---|
| 132 | +{ |
|---|
| 133 | + return dev_priv->gvt; |
|---|
| 134 | +} |
|---|
| 135 | + |
|---|
| 130 | 136 | /** |
|---|
| 131 | | - * intel_gvt_cleanup - cleanup GVT components when i915 driver is unloading |
|---|
| 137 | + * intel_gvt_driver_remove - cleanup GVT components when i915 driver is |
|---|
| 138 | + * unbinding |
|---|
| 132 | 139 | * @dev_priv: drm i915 private * |
|---|
| 133 | 140 | * |
|---|
| 134 | 141 | * This function is called at the i915 driver unloading stage, to shutdown |
|---|
| 135 | 142 | * GVT components and release the related resources. |
|---|
| 136 | 143 | */ |
|---|
| 137 | | -void intel_gvt_cleanup(struct drm_i915_private *dev_priv) |
|---|
| 144 | +void intel_gvt_driver_remove(struct drm_i915_private *dev_priv) |
|---|
| 138 | 145 | { |
|---|
| 139 | 146 | if (!intel_gvt_active(dev_priv)) |
|---|
| 140 | 147 | return; |
|---|
| 141 | 148 | |
|---|
| 142 | 149 | intel_gvt_clean_device(dev_priv); |
|---|
| 143 | 150 | } |
|---|
| 151 | + |
|---|
| 152 | +/** |
|---|
| 153 | + * intel_gvt_resume - GVT resume routine wapper |
|---|
| 154 | + * |
|---|
| 155 | + * @dev_priv: drm i915 private * |
|---|
| 156 | + * |
|---|
| 157 | + * This function is called at the i915 driver resume stage to restore required |
|---|
| 158 | + * HW status for GVT so that vGPU can continue running after resumed. |
|---|
| 159 | + */ |
|---|
| 160 | +void intel_gvt_resume(struct drm_i915_private *dev_priv) |
|---|
| 161 | +{ |
|---|
| 162 | + if (intel_gvt_active(dev_priv)) |
|---|
| 163 | + intel_gvt_pm_resume(dev_priv->gvt); |
|---|
| 164 | +} |
|---|