]> Git Repo - J-linux.git/blobdiff - drivers/gpu/drm/i915/selftests/mock_gem_device.c
Merge tag 'drm-intel-gt-next-2023-08-04' of git://anongit.freedesktop.org/drm/drm...
[J-linux.git] / drivers / gpu / drm / i915 / selftests / mock_gem_device.c
index 4fad81f9f0eeb2c3c281c4a6e24dd7bc1764c440..da0b269606c51db5fddbcd1751696d8c7435f541 100644 (file)
@@ -69,6 +69,7 @@ static void mock_device_release(struct drm_device *dev)
        i915_gem_drain_workqueue(i915);
 
        mock_fini_ggtt(to_gt(i915)->ggtt);
+       destroy_workqueue(i915->unordered_wq);
        destroy_workqueue(i915->wq);
 
        intel_region_ttm_device_fini(i915);
@@ -117,15 +118,31 @@ static void mock_gt_probe(struct drm_i915_private *i915)
        i915->gt[0]->name = "Mock GT";
 }
 
+static const struct intel_device_info mock_info = {
+       .__runtime.graphics.ip.ver = -1,
+       .__runtime.page_sizes = (I915_GTT_PAGE_SIZE_4K |
+                                I915_GTT_PAGE_SIZE_64K |
+                                I915_GTT_PAGE_SIZE_2M),
+       .memory_regions = REGION_SMEM,
+       .platform_engine_mask = BIT(0),
+
+       /* simply use legacy cache level for mock device */
+       .max_pat_index = 3,
+       .cachelevel_to_pat = {
+               [I915_CACHE_NONE]   = 0,
+               [I915_CACHE_LLC]    = 1,
+               [I915_CACHE_L3_LLC] = 2,
+               [I915_CACHE_WT]     = 3,
+       },
+};
+
 struct drm_i915_private *mock_gem_device(void)
 {
 #if IS_ENABLED(CONFIG_IOMMU_API) && defined(CONFIG_INTEL_IOMMU)
        static struct dev_iommu fake_iommu = { .priv = (void *)-1 };
 #endif
        struct drm_i915_private *i915;
-       struct intel_device_info *i915_info;
        struct pci_dev *pdev;
-       unsigned int i;
        int ret;
 
        pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);
@@ -158,15 +175,18 @@ struct drm_i915_private *mock_gem_device(void)
 
        pci_set_drvdata(pdev, i915);
 
+       /* Device parameters start as a copy of module parameters. */
+       i915_params_copy(&i915->params, &i915_modparams);
+
+       /* Set up device info and initial runtime info. */
+       intel_device_info_driver_create(i915, pdev->device, &mock_info);
+
        dev_pm_domain_set(&pdev->dev, &pm_domain);
        pm_runtime_enable(&pdev->dev);
        pm_runtime_dont_use_autosuspend(&pdev->dev);
        if (pm_runtime_enabled(&pdev->dev))
                WARN_ON(pm_runtime_get_sync(&pdev->dev));
 
-
-       i915_params_copy(&i915->params, &i915_modparams);
-
        intel_runtime_pm_init_early(&i915->runtime_pm);
        /* wakeref tracking has significant overhead */
        i915->runtime_pm.no_wakeref_tracking = true;
@@ -174,21 +194,6 @@ struct drm_i915_private *mock_gem_device(void)
        /* Using the global GTT may ask questions about KMS users, so prepare */
        drm_mode_config_init(&i915->drm);
 
-       RUNTIME_INFO(i915)->graphics.ip.ver = -1;
-
-       RUNTIME_INFO(i915)->page_sizes =
-               I915_GTT_PAGE_SIZE_4K |
-               I915_GTT_PAGE_SIZE_64K |
-               I915_GTT_PAGE_SIZE_2M;
-
-       RUNTIME_INFO(i915)->memory_regions = REGION_SMEM;
-
-       /* simply use legacy cache level for mock device */
-       i915_info = (struct intel_device_info *)INTEL_INFO(i915);
-       i915_info->max_pat_index = 3;
-       for (i = 0; i < I915_MAX_CACHE_LEVEL; i++)
-               i915_info->cachelevel_to_pat[i] = i;
-
        intel_memory_regions_hw_probe(i915);
 
        spin_lock_init(&i915->gpu_error.lock);
@@ -208,6 +213,10 @@ struct drm_i915_private *mock_gem_device(void)
        if (!i915->wq)
                goto err_drv;
 
+       i915->unordered_wq = alloc_workqueue("mock-unordered", 0, 0);
+       if (!i915->unordered_wq)
+               goto err_wq;
+
        mock_init_contexts(i915);
 
        /* allocate the ggtt */
@@ -218,7 +227,6 @@ struct drm_i915_private *mock_gem_device(void)
        mock_init_ggtt(to_gt(i915));
        to_gt(i915)->vm = i915_vm_get(&to_gt(i915)->ggtt->vm);
 
-       RUNTIME_INFO(i915)->platform_engine_mask = BIT(0);
        to_gt(i915)->info.engine_mask = BIT(0);
 
        to_gt(i915)->engine[RCS0] = mock_engine(i915, "mock", RCS0);
@@ -239,6 +247,8 @@ struct drm_i915_private *mock_gem_device(void)
 err_context:
        intel_gt_driver_remove(to_gt(i915));
 err_unlock:
+       destroy_workqueue(i915->unordered_wq);
+err_wq:
        destroy_workqueue(i915->wq);
 err_drv:
        intel_region_ttm_device_fini(i915);
This page took 0.038248 seconds and 4 git commands to generate.