Skip to contentSkip to conversation

drm/amdgpu: Basic emulation support

PATCH In review Shaoyun Liu 4 participants 6 messages Feb 1, 2018 – Feb 5, 2018 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Basic emulation support

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

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26 +++++++++++++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
 3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
 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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -3
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,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);
@@ -1372,8 +1386,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) {
@@ -1914,6 +1927,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;
@@ -1966,6 +1982,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) {
@@ -2108,7 +2125,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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -0
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
 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);
@@ -285,6 +286,9 @@
 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)
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1517526990-17331-1-git-send-email-Shaoyun.Liu-5C7GfCeVMHo@public.gmane.org

Acked-by
#2 lore raw
Quoted 6 lines · Shaoyun Liu

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

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58
Quoted 108 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26 +++++++++++++++++++++++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
 3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
 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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -3
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,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);
@@ -1372,8 +1386,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) {
@@ -1914,6 +1927,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;
@@ -1966,6 +1982,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) {
@@ -2108,7 +2125,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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
 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);
@@ -285,6 +286,9 @@
 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)
--

1.9.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_Otc=AZ04YGLc29qF2cLU-Q5Vz8LMToa3Y+iMLyrqkqkA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw

Am 05.02.2018 um 17:45 schrieb Alex Deucher:

Quoted 8 lines · Shaoyun Liu
Quoted 6 lines

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

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58
Quoted 109 lines
Quoted 109 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26 +++++++++++++++++++++++---
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
  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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +23 -3
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,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);
@@ -1372,8 +1386,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) {
@@ -1914,6 +1927,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;
@@ -1966,6 +1982,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) {
@@ -2108,7 +2125,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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +4 -1
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
  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);
@@ -285,6 +286,9 @@
  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)
--

1.9.1

Quoted 8 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 90ed8e6e-7915-efec-a927-2d01d7ea5733-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw
Quoted 15 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Monday, February 05, 2018 11:49 AM
To: Alex Deucher; Liu, Shaoyun
Cc: amd-gfx list
Subject: Re: [PATCH] drm/amdgpu: Basic emulation support

Am 05.02.2018 um 17:45 schrieb Alex Deucher:

Quoted 1 line

On Thu, Feb 1, 2018 at 6:16 PM, Shaoyun Liu <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line

Add amdgpu_emu_mode module parameter to control the emulation

mode

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

Avoid vbios operation on emulation since there is no vbios post duirng emulation, use the common hw_init to simulate the post

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58

Maybe add a comment to the following change indicating that we might have done early HW init either due to emulation or early init of GMC during normal operation ?

Otherwise change is Reviewed-by: John Bridgman <[email protected]>

Quoted 138 lines
Quoted 5 lines
Quoted 5 lines

---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26

+++++++++++++++++++++++---

Quoted 14 lines
Quoted 14 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
  extern int amdgpu_lbpw;
  extern int amdgpu_compute_multipipe;
  extern int amdgpu_gpu_recovery;
+extern int amdgpu_emu_mode;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  #ifdef CONFIG_DRM_AMDGPU_SI
  extern int amdgpu_si_support;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,20 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct amdgpu_device *adev)

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
                         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) {

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1346

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+                               r = adev->ip_blocks[i].version->funcs->hw_init((void

*)adev);

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct amdgpu_device *adev)

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
+                               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) {

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                         r = amdgpu_device_vram_scratch_init(adev);
@@ -1372,8 +1386,7 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct amdgpu_device *adev)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -2
         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)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+               if (adev->ip_blocks[i].status.hw)
                         continue;
                 r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev);
                 if (r) {
@@ -1914,6 +1927,9 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
         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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1966,6 +1982,7 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
                         amdgpu_atombios_i2c_init(adev);
         }
 
+fence_driver_init:
         /* Fence driver */
         r = amdgpu_fence_driver_init(adev);
         if (r) {
@@ -2108,7 +2125,10 @@ void amdgpu_device_fini(struct amdgpu_device

*adev)

Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
         /* 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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
  int amdgpu_lbpw = -1;
  int amdgpu_compute_multipipe = -1;
  int amdgpu_gpu_recovery = -1; /* auto */
+int amdgpu_emu_mode = 0;
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c line 135

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
  MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in

megabytes");

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
  module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); @@
-285,6 +286,9 @@
  MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism,

(1 = enable, 0 = disable, -1 = auto");

Quoted 1 line
Quoted 1 line

module_param_named(gpu_recovery, amdgpu_gpu_recovery, int,

0444);

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
+MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 =
+disable"); module_param_named(emu_mode, amdgpu_emu_mode, int,

0444);

Quoted 4 lines
Quoted 4 lines

+
#ifdef CONFIG_DRM_AMDGPU_SI

  #if defined(CONFIG_DRM_RADEON) ||

defined(CONFIG_DRM_RADEON_MODULE)

Quoted 11 lines
Quoted 7 lines

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): BN6PR12MB1348F0F0E0E60CF27F039E1EE8FE0-/b2+HYfkarQX0pEhCR5T8QdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#8 lore raw
Quoted 20 lines · John
Quoted 20 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Monday, February 05, 2018 11:49 AM
To: Alex Deucher; Liu, Shaoyun
Cc: amd-gfx list
Subject: Re: [PATCH] drm/amdgpu: Basic emulation support

Am 05.02.2018 um 17:45 schrieb Alex Deucher:

Quoted 1 line

On Thu, Feb 1, 2018 at 6:16 PM, Shaoyun Liu <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line

Add amdgpu_emu_mode module parameter to control the emulation

mode

Quoted 5 lines
Quoted 5 lines

Avoid vbios operation on emulation since there is no vbios post duirng emulation, use the common hw_init to simulate the post

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Maybe add a comment to the following change indicating that we might have done early HW init either due to emulation or early init of GMC during normal operation ?

Otherwise change is Reviewed-by: John Bridgman <[email protected]>

Actually, thinking about this a bit more, is there any reason to not always just do the common soc hw init first? It doesn't seem like it would hurt anything.

Alex

Quoted 139 lines
Quoted 139 lines
Quoted 6 lines
Quoted 6 lines


---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26

+++++++++++++++++++++++---

Quoted 14 lines
Quoted 14 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
  extern int amdgpu_lbpw;
  extern int amdgpu_compute_multipipe;
  extern int amdgpu_gpu_recovery;
+extern int amdgpu_emu_mode;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  #ifdef CONFIG_DRM_AMDGPU_SI
  extern int amdgpu_si_support;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,20 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1345

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
                         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) {

Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1346

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+                               r = adev->ip_blocks[i].version->funcs->hw_init((void

*)adev);

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1357

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
+                               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) {

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                         r = amdgpu_device_vram_scratch_init(adev);
@@ -1372,8 +1386,7 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1376

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -2
         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)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+               if (adev->ip_blocks[i].status.hw)
                         continue;
                 r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev);
                 if (r) {
@@ -1914,6 +1927,9 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
         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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1966,6 +1982,7 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
                         amdgpu_atombios_i2c_init(adev);
         }
 
+fence_driver_init:
         /* Fence driver */
         r = amdgpu_fence_driver_init(adev);
         if (r) {
@@ -2108,7 +2125,10 @@ void amdgpu_device_fini(struct amdgpu_device

*adev)

Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
         /* 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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
  int amdgpu_lbpw = -1;
  int amdgpu_compute_multipipe = -1;
  int amdgpu_gpu_recovery = -1; /* auto */
+int amdgpu_emu_mode = 0;
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c line 135

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
  MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in

megabytes");

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
  module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); @@
-285,6 +286,9 @@
  MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism,

(1 = enable, 0 = disable, -1 = auto");

Quoted 1 line
Quoted 1 line

module_param_named(gpu_recovery, amdgpu_gpu_recovery, int,

0444);

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
+MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 =
+disable"); module_param_named(emu_mode, amdgpu_emu_mode, int,

0444);

Quoted 4 lines
Quoted 4 lines

+
#ifdef CONFIG_DRM_AMDGPU_SI

  #if defined(CONFIG_DRM_RADEON) ||

defined(CONFIG_DRM_RADEON_MODULE)

Quoted 11 lines
Quoted 7 lines

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CADnq5_OW7gLPYzyY3nhRB+C_a4EyBwAxBJYOszgawLUakSs1qQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw

-----Original Message-----
From: Alex Deucher [mailto:[email protected]]
Sent: Monday, February 05, 2018 12:53 PM
To: Bridgman, John
Cc: Koenig, Christian; Liu, Shaoyun; amd-gfx list
Subject: Re: [PATCH] drm/amdgpu: Basic emulation support

Quoted 20 lines · John
Quoted 20 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Christian König
Sent: Monday, February 05, 2018 11:49 AM
To: Alex Deucher; Liu, Shaoyun
Cc: amd-gfx list
Subject: Re: [PATCH] drm/amdgpu: Basic emulation support

Am 05.02.2018 um 17:45 schrieb Alex Deucher:

Quoted 1 line

On Thu, Feb 1, 2018 at 6:16 PM, Shaoyun Liu <[email protected]>

Quoted 1 line · wrote:
Quoted 1 line

Add amdgpu_emu_mode module parameter to control the emulation

mode

Quoted 5 lines
Quoted 5 lines

Avoid vbios operation on emulation since there is no vbios post duirng emulation, use the common hw_init to simulate the post

Change-Id Iba32fa16e735490e7401e471219797b83c6c2a58
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Maybe add a comment to the following change indicating that we might have done early HW init either due to emulation or early init of GMC during normal operation ?

Otherwise change is Reviewed-by: John Bridgman <[email protected]>

Actually, thinking about this a bit more, is there any reason to not always just do the common soc hw init first? It doesn't seem like it would hurt anything.

Alex

Ye , seems the common hw init used to program the golden setting and some PCIE registers , it should works even in none-emulation mode .

Shaoyun.liu

Quoted 140 lines
Quoted 140 lines
Quoted 6 lines
Quoted 6 lines


---
  drivers/gpu/drm/amd/amdgpu/amdgpu.h        |  1 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 26

+++++++++++++++++++++++---

Quoted 14 lines
Quoted 14 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c    |  4 ++++
  3 files changed, 28 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +1 -0
index ab10295..4c9c320 100644
@@ -129,6 +129,7 @@
  extern int amdgpu_lbpw;
  extern int amdgpu_compute_multipipe;
  extern int amdgpu_gpu_recovery;
+extern int amdgpu_emu_mode;
 
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu.h +0 -0
  #ifdef CONFIG_DRM_AMDGPU_SI
  extern int amdgpu_si_support;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
index 6adb6e8..fe7a941 100644
@@ -1339,6 +1339,20 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1345

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -0
                         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) {

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1347

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
+                               r = 
+ adev->ip_blocks[i].version->funcs->hw_init((void

*)adev);

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1358

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +9 -0
+                               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) {

Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
                         r = amdgpu_device_vram_scratch_init(adev);
@@ -1372,8 +1386,7 @@ static int amdgpu_device_ip_init(struct

amdgpu_device *adev)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c static int amdgpu_device_ip_init(struct · line 1376

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -2
         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)

Quoted 5 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
+               if (adev->ip_blocks[i].status.hw)
                         continue;
                 r = adev->ip_blocks[i].version->funcs->hw_init((void *)adev);
                 if (r) {
@@ -1914,6 +1927,9 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 11 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c int amdgpu_device_init(struct amdgpu_device

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +3 -0
         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;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +0 -0
@@ -1966,6 +1982,7 @@ int amdgpu_device_init(struct amdgpu_device

*adev,

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c void amdgpu_device_fini(struct amdgpu_device

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +1 -0
                         amdgpu_atombios_i2c_init(adev);
         }
 
+fence_driver_init:
         /* Fence driver */
         r = amdgpu_fence_driver_init(adev);
         if (r) {
@@ -2108,7 +2125,10 @@ void amdgpu_device_fini(struct amdgpu_device

*adev)

Quoted 22 lines
Quoted 22 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +4 -1
         /* 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))
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +1 -0
index 5a5ed47..fdd24d5 100644
@@ -130,6 +130,7 @@
  int amdgpu_lbpw = -1;
  int amdgpu_compute_multipipe = -1;
  int amdgpu_gpu_recovery = -1; /* auto */
+int amdgpu_emu_mode = 0;
 
Quoted 1 line

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c line 135

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -0
  MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in

megabytes");

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +0 -1
  module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); @@
-285,6 +286,9 @@
  MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism,

(1 = enable, 0 = disable, -1 = auto");

Quoted 1 line
Quoted 1 line

module_param_named(gpu_recovery, amdgpu_gpu_recovery, int,

0444);

Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +2 -0
+MODULE_PARM_DESC(emu_mode, "Emulation mode, (1 = enable, 0 = 
+disable"); module_param_named(emu_mode, amdgpu_emu_mode, int,

0444);

Quoted 4 lines
Quoted 4 lines

+
#ifdef CONFIG_DRM_AMDGPU_SI

  #if defined(CONFIG_DRM_RADEON) ||

defined(CONFIG_DRM_RADEON_MODULE)

Quoted 11 lines
Quoted 7 lines

--
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx