Skip to contentSkip to conversation

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

PATCH In review Tianci Yin 3 participants 8 messages Aug 28, 2019 6 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Tianci Yin

author
#0 lore raw

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

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

Fix compute ring test failure in sriov scenario.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +10 -4
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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_buf = NULL;
+	if (!amdgpu_sriov_vf(psp->adev))
+		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+					      AMDGPU_GEM_DOMAIN_VRAM,
+					      &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+	else
+		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+					      AMDGPU_GEM_DOMAIN_VRAM,
+					      &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);
 
 	return ret;
 }
@@ -1216,7 +1222,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, &psp->tmr_buf);
 	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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
index bc0947f..b73d4aa 100644
@@ -171,6 +171,7 @@ struct psp_context
 	/* tmr buffer */
 	struct amdgpu_bo		*tmr_bo;
 	uint64_t			tmr_mc_addr;
+	void				*tmr_buf;
 
 	/* asd firmware and buffer */
 	const struct firmware		*asd_fw;
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): 1566984335-14830-1-git-send-email-tianci.yin-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-				      &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+	psp->tmr_buf = NULL;
+	if (!amdgpu_sriov_vf(psp->adev))
+		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+					      AMDGPU_GEM_DOMAIN_VRAM,
+					      &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+	else
+		ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+					      AMDGPU_GEM_DOMAIN_VRAM,
+					      &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
  	return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
  	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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
  	/* tmr buffer */
  	struct amdgpu_bo		*tmr_bo;
  	uint64_t			tmr_mc_addr;
+	void				*tmr_buf;
 
  	/* asd firmware and buffer */
  	const struct firmware		*asd_fw;

_______________________________________________
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): 45fe6586-a53a-6f02-0e5f-b6224b159e12-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Hi Christian,

I have just realized the stolen_vga_memory problem,
I have ever thought that no one really use the stolen_vga_memory BO in KMD code, so it should be safe.

It seems we have to add a new parameter for amdgpu_bo_create_kernel() to pass the prefer region.

Thanks!

Rico
________________________________
From: Christian K?nig <[email protected]>
Sent: Wednesday, August 28, 2019 17:57
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] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

_______________________________________________
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): DM5PR12MB253547988B61E7D401C6FADC95A30-2J9CzHegvk+FJzKNz6G7XAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#6 lore raw

It seems we have to add a new parameter for amdgpu_bo_create_kernel() to pass the prefer region.

You can also just pass a cpu pointer to the function allocating the stolen_vga_memory.

That's probably less work to change all callers and cleaner in general.

Christian.

Am 28.08.19 um 12:21 schrieb Yin, Tianci (Rico):
Hi Christian,

I have just realized the stolen_vga_memory problem,
I have ever thought that no one really use the stolen_vga_memory BO in KMD code, so it should be safe.

It seems we have to add a new parameter for amdgpu_bo_create_kernel() to pass the prefer region.

Thanks!

Rico
________________________________
From: Christian König <[email protected]><mailto:[email protected]>
Sent: Wednesday, August 28, 2019 17:57
To: Yin, Tianci (Rico) <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>
Cc: Xu, Feifei <[email protected]><mailto:[email protected]>; Ma, Le <[email protected]><mailto:[email protected]>; Xiao, Jack <[email protected]><mailto:[email protected]>; Zhang, Hawking <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

_______________________________________________
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): fa875b9d-4bd6-8f6e-110e-19fa6115b254-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Great! That's good idea!

Thanks!
________________________________
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 28, 2019 18:25
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] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

It seems we have to add a new parameter for amdgpu_bo_create_kernel() to pass the prefer region.

You can also just pass a cpu pointer to the function allocating the stolen_vga_memory.

That's probably less work to change all callers and cleaner in general.

Christian.

Am 28.08.19 um 12:21 schrieb Yin, Tianci (Rico):
Hi Christian,

I have just realized the stolen_vga_memory problem,
I have ever thought that no one really use the stolen_vga_memory BO in KMD code, so it should be safe.

It seems we have to add a new parameter for amdgpu_bo_create_kernel() to pass the prefer region.

Thanks!

Rico
________________________________
From: Christian König <[email protected]><mailto:[email protected]>
Sent: Wednesday, August 28, 2019 17:57
To: Yin, Tianci (Rico) <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]> <[email protected]><mailto:[email protected]>
Cc: Xu, Feifei <[email protected]><mailto:[email protected]>; Ma, Le <[email protected]><mailto:[email protected]>; Xiao, Jack <[email protected]><mailto:[email protected]>; Zhang, Hawking <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

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

#9 lore raw
In reply to a message not in the archive

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

Local variable can't be used in cleaner.

________________________________
From: Christian K?nig <[email protected]>
Sent: Wednesday, August 28, 2019 17:57
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] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

_______________________________________________
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): DM5PR12MB2535E067922B65112BEECCFA95A30-2J9CzHegvk+FJzKNz6G7XAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#11 lore raw

That's irrelevant in this case. CPU mapping's are destroyed automatically when the BO is freed.

Giving the CPU pointer to the free function is only for extra checking that we can't access it anymore.

Christian.

Am 28.08.2019 13:05 schrieb "Yin, Tianci (Rico)" <[email protected]>:
Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

Local variable can't be used in cleaner.

________________________________
From: Christian König <[email protected]>
Sent: Wednesday, August 28, 2019 17:57
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] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

_______________________________________________
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): 85324125-c6dd-4f93-807f-04ff0ee7c815-2ueSQiBKiTY7tOexoI0I+QC/[email protected]

#13 lore raw

I checked the code, cpu pointer indeed only used for checking.

Thanks for your suggestions!

________________________________
From: Koenig, Christian <[email protected]>
Sent: Wednesday, August 28, 2019 19:08
To: Yin, Tianci (Rico) <[email protected]>
Cc: [email protected] <[email protected]>; Xu, Feifei <[email protected]>; Ma, Le <[email protected]>; Xiao, Jack <[email protected]>; Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

That's irrelevant in this case. CPU mapping's are destroyed automatically when the BO is freed.

Giving the CPU pointer to the free function is only for extra checking that we can't access it anymore.

Christian.

Am 28.08.2019 13:05 schrieb "Yin, Tianci (Rico)" <[email protected]>:
Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

Local variable can't be used in cleaner.

________________________________
From: Christian König <[email protected]>
Sent: Wednesday, August 28, 2019 17:57
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] drm/amdgpu/psp: keep TMR in visible vram region for SRIOV

Am 28.08.19 um 11:25 schrieb Tianci Yin:

Quoted 20 lines

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

Fix compute ring test failure in sriov scenario.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 14 ++++++++++----
  drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  1 +
  2 files changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +0 -2
index 9f7cc5b..92c68c9 100644
@@ -261,9 +261,15 @@ 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,

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c static int psp_tmr_init(struct psp_context *psp) · line 272

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +9 -1
-                                   &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     psp->tmr_buf = NULL;
+     if (!amdgpu_sriov_vf(psp->adev))
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, NULL);
+     else
+             ret = amdgpu_bo_create_kernel(psp->adev, tmr_size, PSP_TMR_SIZE,
+                                           AMDGPU_GEM_DOMAIN_VRAM,
+                                           &psp->tmr_bo, &psp->tmr_mc_addr, &psp->tmr_buf);

Might be better to use a local variable for the CPU pointer instead of duplicating the calling parameters.

BTW: How did you solved the stolen_vga_memory problem I pointed out in the original patch set?

Christian.

Quoted 17 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +1 -1
       return ret;
  }
@@ -1216,7 +1222,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, &psp->tmr_buf);
       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,
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +0 -0
index bc0947f..b73d4aa 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h struct psp_context · line 177

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +1 -0
@@ -171,6 +171,7 @@ struct psp_context
       /* tmr buffer */
       struct amdgpu_bo                *tmr_bo;
       uint64_t                        tmr_mc_addr;
+     void                            *tmr_buf;
 
       /* asd firmware and buffer */
       const struct firmware           *asd_fw;

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