Skip to contentSkip to conversation

drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

PATCH In review Tianci Yin 2 participants 4 messages Aug 29, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Tianci Yin

author
#0 lore raw

PATCH 1/2 drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

From: "Tianci.Yin" <[email protected]>

Fix compute ring test failure in sriov scenario.

Change-Id I141d3d094e2cba9bcf2f6c96f4d8c4ef43c421c3
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +6 -2
index 9f7cc5b..d11ce86 100644
@@ -239,6 +239,8 @@ static int psp_tmr_init(struct psp_context *psp)
 {
 	int ret;
 	int tmr_size;
+	void *tmr_buf;
+	void **pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 
 	/*
 	 * According to HW engineer, they prefer the TMR address be "naturally
@@ -263,7 +265,7 @@ static int psp_tmr_init(struct psp_context *psp)
 
 	ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
 				      AMDGPU_GEM_DOMAIN_VRAM,
-				      &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+				      &psp->tmr_bo, &psp->tmr_mc_addr, pptr);
 
 	return ret;
 }
@@ -1206,6 +1208,8 @@ static int psp_hw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	struct psp_context *psp = &adev->psp;
+	void *tmr_buf;
+	void **pptr = amdgpu_sriov_vf(psp->adev) ? &tmr_buf : NULL;
 
 	if (adev->gmc.xgmi.num_physical_nodes > 1 &&
 	    psp->xgmi_context.initialized == 1)
@@ -1216,7 +1220,7 @@ static int psp_hw_fini(void *handle)
 
 	psp_ring_destroy(psp, PSP_RING_TYPE__KM);
 
-	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+	amdgpu_bo_free_kernel(&psp->tmr_bo, &psp->tmr_mc_addr, pptr);
 	amdgpu_bo_free_kernel(&psp->fw_pri_bo,
 			      &psp->fw_pri_mc_addr, &psp->fw_pri_buf);
 	amdgpu_bo_free_kernel(&psp->fence_buf_bo,
Signature · 6 lines
2.7.4

_______________________________________________
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): 1567047930-11912-1-git-send-email-tianci.yin-5C7GfCeVMHo@public.gmane.org

author
#2 lore raw

PATCH 2/2 drm/amdgpu: keep the stolen memory in visible vram region

From: "Tianci.Yin" <[email protected]>

stolen memory should be fixed in visible region.

Change-Id Icbbbd39fd113e93423aad8d2555f4073c08020e5
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++--
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -2
index 801f912..dcd32d0 100644
@@ -1733,6 +1733,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	uint64_t gtt_size;
 	int r;
 	u64 vis_vram_limit;
+	void *stolen_vga_buf;
 
 	mutex_init(&adev->mman.gtt_window_lock);
 
@@ -1787,7 +1788,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
 	r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
 				    AMDGPU_GEM_DOMAIN_VRAM,
 				    &adev->stolen_vga_memory,
-				    NULL, NULL);
+				    NULL, &stolen_vga_buf);
 	if (r)
 		return r;
 	DRM_INFO("amdgpu: %uM of VRAM memory ready\n",
@@ -1851,8 +1852,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  */
 void amdgpu_ttm_late_init(struct amdgpu_device *adev)
 {
+	void *stolen_vga_buf;
 	/* return the VGA stolen memory (if any) back to VRAM */
-	amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+	amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
 }
 
 /**
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +2 -1
index f77138b..ab43ae2 100644
@@ -1248,6 +1248,7 @@ static int gmc_v9_0_sw_init(void *handle)
 static int gmc_v9_0_sw_fini(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	void *stolen_vga_buf;
 
 	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__UMC) &&
 			adev->gmc.umc_ras_if) {
@@ -1280,7 +1281,7 @@ static int gmc_v9_0_sw_fini(void *handle)
 	amdgpu_vm_manager_fini(adev);
 
 	if (gmc_v9_0_keep_stolen_memory(adev))
-		amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+		amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
 
 	amdgpu_gart_table_vram_free(adev);
 	amdgpu_bo_fini(adev);
Signature · 6 lines
2.7.4

_______________________________________________
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): 1567047930-11912-2-git-send-email-tianci.yin-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

Am 29.08.19 um 05:05 schrieb Tianci Yin:

Quoted 33 lines

From: "Tianci.Yin" <[email protected]>

stolen memory should be fixed in visible region.

Change-Id Icbbbd39fd113e93423aad8d2555f4073c08020e5
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 ++-
  2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -1
index 801f912..dcd32d0 100644
@@ -1733,6 +1733,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  	uint64_t gtt_size;
  	int r;
  	u64 vis_vram_limit;
+	void *stolen_vga_buf;
 
  	mutex_init(&adev->mman.gtt_window_lock);
 
@@ -1787,7 +1788,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
  	r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
  				    AMDGPU_GEM_DOMAIN_VRAM,
  				    &adev->stolen_vga_memory,
-				    NULL, NULL);
+				    NULL, &stolen_vga_buf);
  	if (r)
  		return r;
  	DRM_INFO("amdgpu: %uM of VRAM memory ready\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1855

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -1851,8 +1852,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
   */
  void amdgpu_ttm_late_init(struct amdgpu_device *adev)
  {
+	void *stolen_vga_buf;

Coding style says we should add a new line between declaration and code.

Apart from that the series is Reviewed-by: Christian König <[email protected]>.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
  	/* return the VGA stolen memory (if any) back to VRAM */
-	amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+	amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
index f77138b..ab43ae2 100644
@@ -1248,6 +1248,7 @@ static int gmc_v9_0_sw_init(void *handle)
  static int gmc_v9_0_sw_fini(void *handle)
  {
  	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	void *stolen_vga_buf;
 
  	if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__UMC) &&
  			adev->gmc.umc_ras_if) {

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 1287

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -1280,7 +1281,7 @@ static int gmc_v9_0_sw_fini(void *handle)
  	amdgpu_vm_manager_fini(adev);
 
  	if (gmc_v9_0_keep_stolen_memory(adev))
-		amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+		amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
 
  	amdgpu_gart_table_vram_free(adev);
  	amdgpu_bo_fini(adev);

_______________________________________________
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): 5e5b0214-0e50-1a6d-f7f2-54317e5767c4-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw

Re: [PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

Ok, I'll fix that, thanks!
________________________________
From: Christian König <[email protected]>
Sent: Thursday, August 29, 2019 15:13
To: Yin, Tianci (Rico) <[email protected]>; [email protected] <[email protected]>
Cc: Xu, Feifei <[email protected]>; Ma, Le <[email protected]>; Xiao, Jack <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH 2/2] drm/amdgpu: keep the stolen memory in visible vram region

Am 29.08.19 um 05:05 schrieb Tianci Yin:

Quoted 33 lines

From: "Tianci.Yin" <[email protected]>

stolen memory should be fixed in visible region.

Change-Id Icbbbd39fd113e93423aad8d2555f4073c08020e5
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++++--
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 3 ++-
  2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +2 -1
index 801f912..dcd32d0 100644
@@ -1733,6 +1733,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
       uint64_t gtt_size;
       int r;
       u64 vis_vram_limit;
+     void *stolen_vga_buf;
 
       mutex_init(&adev->mman.gtt_window_lock);
 
@@ -1787,7 +1788,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
       r = amdgpu_bo_create_kernel(adev, adev->gmc.stolen_size, PAGE_SIZE,
                                   AMDGPU_GEM_DOMAIN_VRAM,
                                   &adev->stolen_vga_memory,
-                                 NULL, NULL);
+                                 NULL, &stolen_vga_buf);
       if (r)
               return r;
       DRM_INFO("amdgpu: %uM of VRAM memory ready\n",

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c int amdgpu_ttm_init(struct amdgpu_device *adev) · line 1855

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -0
@@ -1851,8 +1852,9 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
   */
  void amdgpu_ttm_late_init(struct amdgpu_device *adev)
  {
+     void *stolen_vga_buf;

Coding style says we should add a new line between declaration and code.

Apart from that the series is Reviewed-by: Christian König <[email protected]>.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
       /* return the VGA stolen memory (if any) back to VRAM */
-     amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+     amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
  }
 
  /**
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -0
index f77138b..ab43ae2 100644
@@ -1248,6 +1248,7 @@ static int gmc_v9_0_sw_init(void *handle)
  static int gmc_v9_0_sw_fini(void *handle)
  {
       struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+     void *stolen_vga_buf;
 
       if (amdgpu_ras_is_supported(adev, AMDGPU_RAS_BLOCK__UMC) &&
                       adev->gmc.umc_ras_if) {

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c static int gmc_v9_0_sw_fini(void *handle) · line 1287

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -1280,7 +1281,7 @@ static int gmc_v9_0_sw_fini(void *handle)
       amdgpu_vm_manager_fini(adev);
 
       if (gmc_v9_0_keep_stolen_memory(adev))
-             amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, NULL);
+             amdgpu_bo_free_kernel(&adev->stolen_vga_memory, NULL, &stolen_vga_buf);
 
       amdgpu_gart_table_vram_free(adev);
       amdgpu_bo_fini(adev);

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