Skip to contentSkip to conversation

drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

PATCH Superseded Andrey Grodzovsky 4 participants 12 messages Mar 14, 2018 – Mar 16, 2018 7 messages not in the archive

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

PATCH 1/2 drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -2
index 48e0115..11673c3 100644
@@ -171,7 +171,7 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: resulting BO (new BO is created if bo_ptr is NULL)
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
@@ -240,7 +240,7 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: resulting BO (new BO is created if bo_ptr is NULL)
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
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): 1521050869-29589-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amd/powerplay: Fix KASAN user after free on driver unload.

Reusing local handle to initialize BO without resetting it to NULL is wrong since it causes amdgpu_bo_create_reserved to skip new BO creation and just reuse the given pointer for pinning.

---
 drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c     |  7 ++-----
 drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | 16 +++++-----------
 2 files changed, 7 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c +2 -5
index e2ee23a..65c6ca7 100644
@@ -327,7 +327,6 @@ static int rv_start_smu(struct pp_hwmgr *hwmgr)
 
 static int rv_smu_init(struct pp_hwmgr *hwmgr)
 {
-	struct amdgpu_bo *handle = NULL;
 	struct rv_smumgr *priv;
 	uint64_t mc_addr;
 	void *kaddr = NULL;
@@ -345,7 +344,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 			sizeof(Watermarks_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[WMTABLE].handle,
 			&mc_addr,
 			&kaddr);
 
@@ -357,14 +356,13 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
 	priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[WMTABLE].table = kaddr;
-	priv->smu_tables.entry[WMTABLE].handle = handle;
 
 	/* allocate space for watermarks table */
 	r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
 			sizeof(DpmClocks_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[CLOCKTABLE].handle,
 			&mc_addr,
 			&kaddr);
 
@@ -380,7 +378,6 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[CLOCKTABLE].table_id = TABLE_DPMCLOCKS;
 	priv->smu_tables.entry[CLOCKTABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[CLOCKTABLE].table = kaddr;
-	priv->smu_tables.entry[CLOCKTABLE].handle = handle;
 
 	return 0;
 }
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +5 -11
index 15e1afa..c8b326e 100644
@@ -377,7 +377,6 @@ static int vega10_verify_smc_interface(struct pp_hwmgr *hwmgr)
 
 static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 {
-	struct amdgpu_bo *handle = NULL;
 	struct vega10_smumgr *priv;
 	uint64_t mc_addr;
 	void *kaddr = NULL;
@@ -403,7 +402,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 			sizeof(PPTable_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[PPTABLE].handle,
 			&mc_addr,
 			&kaddr);
 
@@ -415,14 +414,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[PPTABLE].table_id = TABLE_PPTABLE;
 	priv->smu_tables.entry[PPTABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[PPTABLE].table = kaddr;
-	priv->smu_tables.entry[PPTABLE].handle = handle;
 
 	/* allocate space for watermarks table */
 	ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
 			sizeof(Watermarks_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[WMTABLE].handle,
 			&mc_addr,
 			&kaddr);
 
@@ -434,14 +432,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
 	priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[WMTABLE].table = kaddr;
-	priv->smu_tables.entry[WMTABLE].handle = handle;
 
 	/* allocate space for AVFS table */
 	ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
 			sizeof(AvfsTable_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[AVFSTABLE].handle,
 			&mc_addr,
 			&kaddr);
 
@@ -453,7 +450,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[AVFSTABLE].table_id = TABLE_AVFS;
 	priv->smu_tables.entry[AVFSTABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[AVFSTABLE].table = kaddr;
-	priv->smu_tables.entry[AVFSTABLE].handle = handle;
 
 	tools_size = 0x19000;
 	if (tools_size) {
@@ -461,7 +457,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 				tools_size,
 				PAGE_SIZE,
 				AMDGPU_GEM_DOMAIN_VRAM,
-				&handle,
+				&priv->smu_tables.entry[TOOLSTABLE].handle,
 				&mc_addr,
 				&kaddr);
 		if (ret)
@@ -471,7 +467,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 		priv->smu_tables.entry[TOOLSTABLE].table_id = TABLE_PMSTATUSLOG;
 		priv->smu_tables.entry[TOOLSTABLE].mc_addr = mc_addr;
 		priv->smu_tables.entry[TOOLSTABLE].table = kaddr;
-		priv->smu_tables.entry[TOOLSTABLE].handle = handle;
 	}
 
 	/* allocate space for AVFS Fuse table */
@@ -479,7 +474,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 			sizeof(AvfsFuseOverride_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[AVFSFUSETABLE].handle,
 			&mc_addr,
 			&kaddr);
 	if (ret)
@@ -490,7 +485,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[AVFSFUSETABLE].table_id = TABLE_AVFS_FUSE_OVERRIDE;
 	priv->smu_tables.entry[AVFSFUSETABLE].mc_addr = mc_addr;
 	priv->smu_tables.entry[AVFSFUSETABLE].table = kaddr;
-	priv->smu_tables.entry[AVFSFUSETABLE].handle = handle;
 
 	return 0;
 
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): 1521050869-29589-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] drm/amd/powerplay: Fix KASAN user after free on driver unload.

Am 14.03.2018 um 19:07 schrieb Andrey Grodzovsky:

Quoted 117 lines

Reusing local handle to initialize BO without resetting it to NULL is wrong since it causes amdgpu_bo_create_reserved to skip new BO creation and just reuse the given pointer for pinning.

---
  drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c     |  7 ++-----
  drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | 16 +++++-----------
  2 files changed, 7 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c +2 -5
index e2ee23a..65c6ca7 100644
@@ -327,7 +327,6 @@ static int rv_start_smu(struct pp_hwmgr *hwmgr)
 
  static int rv_smu_init(struct pp_hwmgr *hwmgr)
  {
-	struct amdgpu_bo *handle = NULL;
  	struct rv_smumgr *priv;
  	uint64_t mc_addr;
  	void *kaddr = NULL;
@@ -345,7 +344,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
  			sizeof(Watermarks_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[WMTABLE].handle,
  			&mc_addr,
  			&kaddr);
 
@@ -357,14 +356,13 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
  	priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[WMTABLE].table = kaddr;
-	priv->smu_tables.entry[WMTABLE].handle = handle;
 
  	/* allocate space for watermarks table */
  	r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
  			sizeof(DpmClocks_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[CLOCKTABLE].handle,
  			&mc_addr,
  			&kaddr);
 
@@ -380,7 +378,6 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[CLOCKTABLE].table_id = TABLE_DPMCLOCKS;
  	priv->smu_tables.entry[CLOCKTABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[CLOCKTABLE].table = kaddr;
-	priv->smu_tables.entry[CLOCKTABLE].handle = handle;
 
  	return 0;
  }
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +3 -7
index 15e1afa..c8b326e 100644
@@ -377,7 +377,6 @@ static int vega10_verify_smc_interface(struct pp_hwmgr *hwmgr)
 
  static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  {
-	struct amdgpu_bo *handle = NULL;
  	struct vega10_smumgr *priv;
  	uint64_t mc_addr;
  	void *kaddr = NULL;
@@ -403,7 +402,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  			sizeof(PPTable_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[PPTABLE].handle,
  			&mc_addr,
  			&kaddr);
 
@@ -415,14 +414,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[PPTABLE].table_id = TABLE_PPTABLE;
  	priv->smu_tables.entry[PPTABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[PPTABLE].table = kaddr;
-	priv->smu_tables.entry[PPTABLE].handle = handle;
 
  	/* allocate space for watermarks table */
  	ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
  			sizeof(Watermarks_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[WMTABLE].handle,
  			&mc_addr,
  			&kaddr);
 
@@ -434,14 +432,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
  	priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[WMTABLE].table = kaddr;
-	priv->smu_tables.entry[WMTABLE].handle = handle;
 
  	/* allocate space for AVFS table */
  	ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
  			sizeof(AvfsTable_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[AVFSTABLE].handle,
  			&mc_addr,
  			&kaddr);
 
@@ -453,7 +450,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[AVFSTABLE].table_id = TABLE_AVFS;
  	priv->smu_tables.entry[AVFSTABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[AVFSTABLE].table = kaddr;
-	priv->smu_tables.entry[AVFSTABLE].handle = handle;
 
  	tools_size = 0x19000;
  	if (tools_size) {

drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c static int vega10_smu_init(struct pp_hwmgr *hwmgr) · line 462

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +1 -1
@@ -461,7 +457,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  				tools_size,
  				PAGE_SIZE,
  				AMDGPU_GEM_DOMAIN_VRAM,
-				&handle,
+				&priv->smu_tables.entry[TOOLSTABLE].handle,
  				&mc_addr,
  				&kaddr);

I think it would be better to specify mc_addr and kaddr directly as well.

Christian.

Quoted 19 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +1 -2
  		if (ret)
@@ -471,7 +467,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  		priv->smu_tables.entry[TOOLSTABLE].table_id = TABLE_PMSTATUSLOG;
  		priv->smu_tables.entry[TOOLSTABLE].mc_addr = mc_addr;
  		priv->smu_tables.entry[TOOLSTABLE].table = kaddr;
-		priv->smu_tables.entry[TOOLSTABLE].handle = handle;
  	}
 
  	/* allocate space for AVFS Fuse table */
@@ -479,7 +474,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  			sizeof(AvfsFuseOverride_t),
  			PAGE_SIZE,
  			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
+			&priv->smu_tables.entry[AVFSFUSETABLE].handle,
  			&mc_addr,
  			&kaddr);
  	if (ret)

drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c static int vega10_smu_init(struct pp_hwmgr *hwmgr) · line 490

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +0 -1
@@ -490,7 +485,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  	priv->smu_tables.entry[AVFSFUSETABLE].table_id = TABLE_AVFS_FUSE_OVERRIDE;
  	priv->smu_tables.entry[AVFSFUSETABLE].mc_addr = mc_addr;
  	priv->smu_tables.entry[AVFSFUSETABLE].table = kaddr;
-	priv->smu_tables.entry[AVFSFUSETABLE].handle = handle;
 
  	return 0;
 

_______________________________________________
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): 992da07d-1f19-3a1d-c065-10824871f756-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw

Re: [PATCH 2/2] drm/amd/powerplay: Fix KASAN user after free on driver unload.

Apply this patch with Christian's suggestions.

Thanks.

Best Regards

Rex

________________________________
From: Christian König <[email protected]>
Sent: Thursday, March 15, 2018 2:21 AM
To: Grodzovsky, Andrey; [email protected]
Cc: Zhu, Rex; Koenig, Christian
Subject: Re: [PATCH 2/2] drm/amd/powerplay: Fix KASAN user after free on driver unload.

Am 14.03.2018 um 19:07 schrieb Andrey Grodzovsky:

Quoted 117 lines

Reusing local handle to initialize BO without resetting it to NULL is wrong since it causes amdgpu_bo_create_reserved to skip new BO creation and just reuse the given pointer for pinning.

---
  drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c     |  7 ++-----
  drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c | 16 +++++-----------
  2 files changed, 7 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c +2 -5
index e2ee23a..65c6ca7 100644
@@ -327,7 +327,6 @@ static int rv_start_smu(struct pp_hwmgr *hwmgr)
 
  static int rv_smu_init(struct pp_hwmgr *hwmgr)
  {
-     struct amdgpu_bo *handle = NULL;
       struct rv_smumgr *priv;
       uint64_t mc_addr;
       void *kaddr = NULL;
@@ -345,7 +344,7 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
                       sizeof(Watermarks_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[WMTABLE].handle,
                       &mc_addr,
                       &kaddr);
 
@@ -357,14 +356,13 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
       priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[WMTABLE].table = kaddr;
-     priv->smu_tables.entry[WMTABLE].handle = handle;
 
       /* allocate space for watermarks table */
       r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
                       sizeof(DpmClocks_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[CLOCKTABLE].handle,
                       &mc_addr,
                       &kaddr);
 
@@ -380,7 +378,6 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[CLOCKTABLE].table_id = TABLE_DPMCLOCKS;
       priv->smu_tables.entry[CLOCKTABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[CLOCKTABLE].table = kaddr;
-     priv->smu_tables.entry[CLOCKTABLE].handle = handle;
 
       return 0;
  }
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +3 -7
index 15e1afa..c8b326e 100644
@@ -377,7 +377,6 @@ static int vega10_verify_smc_interface(struct pp_hwmgr *hwmgr)
 
  static int vega10_smu_init(struct pp_hwmgr *hwmgr)
  {
-     struct amdgpu_bo *handle = NULL;
       struct vega10_smumgr *priv;
       uint64_t mc_addr;
       void *kaddr = NULL;
@@ -403,7 +402,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
                       sizeof(PPTable_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[PPTABLE].handle,
                       &mc_addr,
                       &kaddr);
 
@@ -415,14 +414,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[PPTABLE].table_id = TABLE_PPTABLE;
       priv->smu_tables.entry[PPTABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[PPTABLE].table = kaddr;
-     priv->smu_tables.entry[PPTABLE].handle = handle;
 
       /* allocate space for watermarks table */
       ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
                       sizeof(Watermarks_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[WMTABLE].handle,
                       &mc_addr,
                       &kaddr);
 
@@ -434,14 +432,13 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
       priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[WMTABLE].table = kaddr;
-     priv->smu_tables.entry[WMTABLE].handle = handle;
 
       /* allocate space for AVFS table */
       ret = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
                       sizeof(AvfsTable_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[AVFSTABLE].handle,
                       &mc_addr,
                       &kaddr);
 
@@ -453,7 +450,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[AVFSTABLE].table_id = TABLE_AVFS;
       priv->smu_tables.entry[AVFSTABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[AVFSTABLE].table = kaddr;
-     priv->smu_tables.entry[AVFSTABLE].handle = handle;
 
       tools_size = 0x19000;
       if (tools_size) {

drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c static int vega10_smu_init(struct pp_hwmgr *hwmgr) · line 462

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +1 -1
@@ -461,7 +457,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
                               tools_size,
                               PAGE_SIZE,
                               AMDGPU_GEM_DOMAIN_VRAM,
-                             &handle,
+                             &priv->smu_tables.entry[TOOLSTABLE].handle,
                               &mc_addr,
                               &kaddr);

I think it would be better to specify mc_addr and kaddr directly as well.

Christian.

Quoted 19 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +1 -2
               if (ret)
@@ -471,7 +467,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
               priv->smu_tables.entry[TOOLSTABLE].table_id = TABLE_PMSTATUSLOG;
               priv->smu_tables.entry[TOOLSTABLE].mc_addr = mc_addr;
               priv->smu_tables.entry[TOOLSTABLE].table = kaddr;
-             priv->smu_tables.entry[TOOLSTABLE].handle = handle;
       }
 
       /* allocate space for AVFS Fuse table */
@@ -479,7 +474,7 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
                       sizeof(AvfsFuseOverride_t),
                       PAGE_SIZE,
                       AMDGPU_GEM_DOMAIN_VRAM,
-                     &handle,
+                     &priv->smu_tables.entry[AVFSFUSETABLE].handle,
                       &mc_addr,
                       &kaddr);
       if (ret)

drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c static int vega10_smu_init(struct pp_hwmgr *hwmgr) · line 490

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +0 -1
@@ -490,7 +485,6 @@ static int vega10_smu_init(struct pp_hwmgr *hwmgr)
       priv->smu_tables.entry[AVFSFUSETABLE].table_id = TABLE_AVFS_FUSE_OVERRIDE;
       priv->smu_tables.entry[AVFSFUSETABLE].mc_addr = mc_addr;
       priv->smu_tables.entry[AVFSFUSETABLE].table = kaddr;
-     priv->smu_tables.entry[AVFSFUSETABLE].handle = handle;
 
       return 0;
 

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

#7 lore raw

PATCH v2 1/2 drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

In reply to a message not in the archive

and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -2
index 48e0115..ac1fa33 100644
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use, and returns it still
  * reserved.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
@@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_kernel(struct amdgpu_device *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): 1521130511-10816-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#9 lore raw

PATCH v2 2/2 drm/amd/powerplay: Fix KASAN user after after free on driver unload.

Reusing local handle to initialize BO without resetting it to NULL is wrong since it causes amdgpu_bo_create_reserved to skip new BO creation and just reuse the given pointer for pinning.

v2:
Get rid of mc_addr and kaddr.

---
 drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c   | 21 +++-------
 .../gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c   | 48 +++++++---------------
 2 files changed, 21 insertions(+), 48 deletions(-)
drivers/gpu/drm/amd/powerplay/smumgr/rv_smumgr.c +6 -15
index e2ee23a..01fcfb9 100644
@@ -327,10 +327,7 @@ static int rv_start_smu(struct pp_hwmgr *hwmgr)
 
 static int rv_smu_init(struct pp_hwmgr *hwmgr)
 {
-	struct amdgpu_bo *handle = NULL;
 	struct rv_smumgr *priv;
-	uint64_t mc_addr;
-	void *kaddr = NULL;
 	int r;
 
 	priv = kzalloc(sizeof(struct rv_smumgr), GFP_KERNEL);
@@ -345,9 +342,9 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 			sizeof(Watermarks_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
-			&mc_addr,
-			&kaddr);
+			&priv->smu_tables.entry[WMTABLE].handle,
+			&priv->smu_tables.entry[WMTABLE].mc_addr,
+			&priv->smu_tables.entry[WMTABLE].table);
 
 	if (r)
 		return -EINVAL;
@@ -355,18 +352,15 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[WMTABLE].version = 0x01;
 	priv->smu_tables.entry[WMTABLE].size = sizeof(Watermarks_t);
 	priv->smu_tables.entry[WMTABLE].table_id = TABLE_WATERMARKS;
-	priv->smu_tables.entry[WMTABLE].mc_addr = mc_addr;
-	priv->smu_tables.entry[WMTABLE].table = kaddr;
-	priv->smu_tables.entry[WMTABLE].handle = handle;
 
 	/* allocate space for watermarks table */
 	r = amdgpu_bo_create_kernel((struct amdgpu_device *)hwmgr->adev,
 			sizeof(DpmClocks_t),
 			PAGE_SIZE,
 			AMDGPU_GEM_DOMAIN_VRAM,
-			&handle,
-			&mc_addr,
-			&kaddr);
+			&priv->smu_tables.entry[CLOCKTABLE].handle,
+			&priv->smu_tables.entry[CLOCKTABLE].mc_addr,
+			&priv->smu_tables.entry[CLOCKTABLE].table);
 
 	if (r) {
 		amdgpu_bo_free_kernel(&priv->smu_tables.entry[WMTABLE].handle,
@@ -378,9 +372,6 @@ static int rv_smu_init(struct pp_hwmgr *hwmgr)
 	priv->smu_tables.entry[CLOCKTABLE].version = 0x01;
 	priv->smu_tables.entry[CLOCKTABLE].size = sizeof(DpmClocks_t);
 	priv->smu_tables.entry[CLOCKTABLE].table_id = TABLE_DPMCLOCKS;
-	priv->smu_tables.entry[CLOCKTABLE].mc_addr = mc_addr;
-	priv->smu_tables.entry[CLOCKTABLE].table = kaddr;
-	priv->smu_tables.entry[CLOCKTABLE].handle = handle;
 
 	return 0;
 }
drivers/gpu/drm/amd/powerplay/smumgr/vega10_smumgr.c +15 -33

114 lines not on this page · raw message

Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by
#10 lore raw
In reply to a message not in the archive

For the series:

I think Rex already applied the second one.

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Andrey Grodzovsky <[email protected]>
Sent: Thursday, March 15, 2018 12:15 PM
To: [email protected]; [email protected]; Zhu, Rex
Cc: Grodzovsky, Andrey
Subject: [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -2
index 48e0115..ac1fa33 100644
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use, and returns it still
  * reserved.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
@@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_kernel(struct amdgpu_device *adev,

--
2.7.4

_______________________________________________
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): BN6PR12MB1652922737FD3A6CBA7EA323F7D00-/b2+HYfkarQqUD6E6FAiowdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#12 lore raw

That explains the merge conflict that surprised me :)

Thanks,

Andrey

Quoted 59 lines · Alexander

For the series:

I think Rex already applied the second one.

------------------------------------------------------------------------
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Andrey Grodzovsky <[email protected]> *Sent:* Thursday, March 15, 2018 12:15 PM
*To:* [email protected]; [email protected]; Zhu, Rex *Cc:* Grodzovsky, Andrey
*Subject:* [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel
and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--

 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -1
index 48e0115..ac1fa33 100644
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct 
 amdgpu_bo *abo, u32 domain)
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *
   * Allocates and pins a BO for kernel internal use, and returns it still
   * reserved.
   *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
   * Returns 0 on success, negative error code otherwise.
   */

 int amdgpu_bo_create_reserved(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -1
@@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct 
 amdgpu_device *adev,
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *
   * Allocates and pins a BO for kernel internal use.
   *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
   * Returns 0 on success, negative error code otherwise.
   */
Quoted 8 lines

 int amdgpu_bo_create_kernel(struct amdgpu_device *adev,

Signature · 6 lines
2.7.4

_______________________________________________
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): 32eb92c9-2e79-cb1a-7757-825183be8365-5C7GfCeVMHo@public.gmane.org

#14 lore raw

Yeah, not really the usually flow.

Either way Reviewed-by: Christian König <[email protected]> for both.

Christian.

Am 15.03.2018 um 17:19 schrieb Andrey Grodzovsky:

Quoted 73 lines

That explains the merge conflict that surprised me :)

Thanks,

Andrey

Quoted 63 lines · Alexander

For the series:

I think Rex already applied the second one.

------------------------------------------------------------------------
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Andrey Grodzovsky <[email protected]> *Sent:* Thursday, March 15, 2018 12:15 PM
*To:* [email protected]; [email protected]; Zhu, Rex *Cc:* Grodzovsky, Andrey
*Subject:* [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel
and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--

 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -1
index 48e0115..ac1fa33 100644
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct 
 amdgpu_bo *abo, u32 domain)
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *
   * Allocates and pins a BO for kernel internal use, and returns it still
   * reserved.
   *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
   * Returns 0 on success, negative error code otherwise.
   */

 int amdgpu_bo_create_reserved(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +3 -1
@@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct 
 amdgpu_device *adev,
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *
   * Allocates and pins a BO for kernel internal use.
   *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
   * Returns 0 on success, negative error code otherwise.
   */

 int amdgpu_bo_create_kernel(struct amdgpu_device *adev,

Signature · 1 line
2.7.4
Quoted 5 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

Reviewed-by Alex Deucher
#15 lore raw
In reply to a message not in the archive

Hi Andrey,

Sorry for the confusion.
I just need to push a bunch of patches that conflict with your patch. So apply your patch first.

Best Regards
Rex

From: amd-gfx [mailto:[email protected]] On Behalf Of Andrey Grodzovsky
Sent: Friday, March 16, 2018 12:20 AM
To: Deucher, Alexander; [email protected]; [email protected]; Zhu, Rex
Subject: Re: [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

That explains the merge conflict that surprised me :)

Thanks,

Andrey

On 03/15/2018 12:18 PM, Deucher, Alexander wrote:

For the series:

I think Rex already applied the second one.

________________________________
From: amd-gfx <[email protected]><mailto:[email protected]> on behalf of Andrey Grodzovsky <[email protected]><mailto:[email protected]>
Sent: Thursday, March 15, 2018 12:15 PM
To: [email protected]<mailto:[email protected]>; [email protected]<mailto:[email protected]>; Zhu, Rex
Cc: Grodzovsky, Andrey
Subject: [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

and amdgpu_bo_create_reserved.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +6 -2
index 48e0115..ac1fa33 100644
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use, and returns it still
  * reserved.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
@@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise.
  */
 int amdgpu_bo_create_kernel(struct amdgpu_device *adev,

--
2.7.4

_______________________________________________
amd-gfx mailing list [email protected]<mailto:[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): CY4PR12MB1687399608EE02426B0AEF31FBD70-rpdhrqHFk06Y0SjTqZDccQdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#17 lore raw

NP, makes sense what you did.

Andrey

Quoted 100 lines · Rex

Hi Andrey,

Sorry for the confusion.

I just need to push a bunch of patches that conflict with  your patch.

So apply your patch first.

Best Regards

Rex

*From:*amd-gfx [mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org] *On Behalf Of *Andrey Grodzovsky
*Sent:* Friday, March 16, 2018 12:20 AM
*To:* Deucher, Alexander; [email protected]; [email protected]; Zhu, Rex *Subject:* Re: [PATCH v2 1/2] drm/amdgpu: Improve documentation of bo_ptr in amdgpu_bo_create_kernel

That explains the merge conflict that surprised me :)

Thanks,

Andrey

On 03/15/2018 12:18 PM, Deucher, Alexander wrote:

For the series:

<mailto:[email protected]>

I think Rex already applied the second one.

------------------------------------------------------------------------

*From:*amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> <mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Andrey Grodzovsky <[email protected]> <mailto:[email protected]>
*Sent:* Thursday, March 15, 2018 12:15 PM
*To:* [email protected] <mailto:[email protected]>; [email protected] <mailto:[email protected]>; Zhu, Rex *Cc:* Grodzovsky, Andrey
*Subject:* [PATCH v2 1/2] drm/amdgpu: Improve documentation of
bo_ptr in amdgpu_bo_create_kernel

and amdgpu_bo_create_reserved.

<mailto:[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index 48e0115..ac1fa33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -171,13 +171,15 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use, and returns it still
  * reserved.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise. */
 int amdgpu_bo_create_reserved(struct amdgpu_device *adev, @@ -240,12 +242,14 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
  * @size: size for the new BO
  * @align: alignment for the new BO
  * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr:  used to initialize BOs in structures
  * @gpu_addr: GPU addr of the pinned BO
  * @cpu_addr: optional CPU address mapping
  *
  * Allocates and pins a BO for kernel internal use.
  *
+ * Note: For bo_ptr new BO is only created if bo_ptr points to NULL.
+ *
  * Returns 0 on success, negative error code otherwise. */
 int amdgpu_bo_create_kernel(struct amdgpu_device *adev, --
2.7.4

Quoted 5 lines

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

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

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

Am 14.03.2018 um 19:07 schrieb Andrey Grodzovsky:

Quoted 12 lines

and amdgpu_bo_create_reserved.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +0 -0
index 48e0115..11673c3 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain) · line 174

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
@@ -171,7 +171,7 @@ void amdgpu_ttm_placement_from_domain(struct amdgpu_bo *abo, u32 domain)
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: resulting BO (new BO is created if bo_ptr is NULL)

Maybe add "only" here, e.g. new BO is only created if bo_ptr points to NULL.

And add something like "used to initialize BOs in structures".

Either way the patch is Reviewed-by: Christian König <[email protected]>.

Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_object.c int amdgpu_bo_create_reserved(struct amdgpu_device *adev, · line 246

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +1 -1
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *
@@ -240,7 +240,7 @@ int amdgpu_bo_create_reserved(struct amdgpu_device *adev,
   * @size: size for the new BO
   * @align: alignment for the new BO
   * @domain: where to place it
- * @bo_ptr: resulting BO
+ * @bo_ptr: resulting BO (new BO is created if bo_ptr is NULL)
   * @gpu_addr: GPU addr of the pinned BO
   * @cpu_addr: optional CPU address mapping
   *

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