drm/amdgpu: Basic emulation support
authorShaoyun Liu <Shaoyun.Liu@amd.com>
Thu, 1 Feb 2018 22:37:50 +0000 (17:37 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 19 Feb 2018 19:19:47 +0000 (14:19 -0500)
Add amdgpu_emu_mode module parameter to control the emulation mode
Avoid vbios operation on emulation since there is no vbios post duirng emulation,
use the common hw_init to simulate the post

Signed-off-by: Shaoyun Liu <Shaoyun.Liu@amd.com>
Acked-By: Alex Deucher <alexander.deucher@amd.com>
Acked-By: Christian Konig <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

index 276c4ad1cb6e15826818596a4e060e92960cf14d..8ad0d48a1fe39d98682483e20dda1d8a54774be0 100644 (file)
@@ -128,6 +128,7 @@ extern int amdgpu_job_hang_limit;
 extern int amdgpu_lbpw;
 extern int amdgpu_compute_multipipe;
 extern int amdgpu_gpu_recovery;
+extern int amdgpu_emu_mode;
 
 #ifdef CONFIG_DRM_AMDGPU_SI
 extern int amdgpu_si_support;
index 628ed92fe9a2a1bebdb570c40f76049d23cdc5b8..3c0299bad59cb8ae2bedc559526111c25270db57 100644 (file)
@@ -1310,6 +1310,20 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
                        return r;
                }
                adev->ip_blocks[i].status.sw = true;
+
+               if (amdgpu_emu_mode == 1) {
+                       /* Need to do common hw init first on emulation  */
+                       if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_COMMON) {
+                               r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev);
+                               if (r) {
+                                       DRM_ERROR("hw_init of IP block <%s> failed %d\n",
+                                               adev->ip_blocks[i].version->funcs->name, r);
+                                       return r;
+                               }
+                               adev->ip_blocks[i].status.hw = true;
+                       }
+               }
+
                /* need to do gmc hw init early so we can allocate gpu mem */
                if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC) {
                        r = amdgpu_device_vram_scratch_init(adev);
@@ -1343,8 +1357,7 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
        for (i = 0; i < adev->num_ip_blocks; i++) {
                if (!adev->ip_blocks[i].status.sw)
                        continue;
-               /* gmc hw init is done early */
-               if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_GMC)
+               if (adev->ip_blocks[i].status.hw)
                        continue;
                r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev);
                if (r) {
@@ -1884,6 +1897,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        if (runtime)
                vga_switcheroo_init_domain_pm_ops(adev->dev, &adev->vga_pm_domain);
 
+       if (amdgpu_emu_mode == 1)
+               goto fence_driver_init;
+
        /* Read BIOS */
        if (!amdgpu_get_bios(adev)) {
                r = -EINVAL;
@@ -1936,6 +1952,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
                        amdgpu_atombios_i2c_init(adev);
        }
 
+fence_driver_init:
        /* Fence driver */
        r = amdgpu_fence_driver_init(adev);
        if (r) {
@@ -2078,7 +2095,10 @@ void amdgpu_device_fini(struct amdgpu_device *adev)
        /* free i2c buses */
        if (!amdgpu_device_has_dc_support(adev))
                amdgpu_i2c_fini(adev);
-       amdgpu_atombios_fini(adev);
+
+       if (amdgpu_emu_mode != 1)
+               amdgpu_atombios_fini(adev);
+
        kfree(adev->bios);
        adev->bios = NULL;
        if (!pci_is_thunderbolt_attached(adev->pdev))
index 367f331b4a544631474a39b9f55804a15cd26f55..6c8ae59d4d9499920e7414e3141dd2ef621ddfc8 100644 (file)
@@ -131,6 +131,7 @@ int amdgpu_job_hang_limit = 0;
 int amdgpu_lbpw = -1;
 int amdgpu_compute_multipipe = -1;
 int amdgpu_gpu_recovery = -1; /* auto */
+int amdgpu_emu_mode = 0;
 
 MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
 module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
@@ -286,6 +287,9 @@ module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444);
 MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto");
 module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444);
 
+MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 = disable");
+module_param_named(emu_mode, amdgpu_emu_mode, int, 0444);
+
 #ifdef CONFIG_DRM_AMDGPU_SI
 
 #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE)