Skip to contentSkip to conversation

drm/amdgpu: move PDB bo release into a generic gmc function

PATCH In review Guchun Chen 3 participants 5 messages Mar 17, 2022

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

PATCH 1/1 drm/amdgpu: move PDB bo release into a generic gmc function

To pair with amdgpu_gmc_pdb0_alloc as a more generic handling in amdgpu_gmc.c, no functional change.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 +
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +6 -0
index 7021e8f390bd..36f6b321438f 100644
@@ -136,6 +136,12 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
 	return pd_addr;
 }
 
+/* amdgpu_gmc_pdb0_free - free pdb0 vram */
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev)
+{
+	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+}
+
 /**
  * amdgpu_gmc_set_pte_pde - update the page tables using CPU
  *
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 032b0313f277..6f425e3a9b6e 100644
@@ -299,6 +299,7 @@ static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
 }
 
 int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev);
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev);
 void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
 			       uint64_t *addr, uint64_t *flags);
 int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, void *cpu_pt_addr,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
index 08ceabd6c853..ad600f72a51c 100644
@@ -1721,7 +1721,7 @@ static int gmc_v9_0_sw_fini(void *handle)
 	amdgpu_gem_force_release(adev);
 	amdgpu_vm_manager_fini(adev);
 	amdgpu_gart_table_vram_free(adev);
-	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+	amdgpu_gmc_pdb0_free(adev);
 	amdgpu_bo_fini(adev);
 
 	return 0;
Signature · 1 line
2.17.1
#1 lore raw

Am 17.03.22 um 12:21 schrieb Guchun Chen:

Quoted 15 lines

To pair with amdgpu_gmc_pdb0_alloc as a more generic handling in amdgpu_gmc.c, no functional change.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 +
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
  3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index 7021e8f390bd..36f6b321438f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo) · line 144

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +6 -0
@@ -136,6 +136,12 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
  	return pd_addr;
  }
 
+/* amdgpu_gmc_pdb0_free - free pdb0 vram */
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev)
+{
+	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+}
+

Single line function usually doesn't look that useful to me.

Why is that any improvement?

Regards,
Christian.

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
  /**
   * amdgpu_gmc_set_pte_pde - update the page tables using CPU
   *
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 032b0313f277..6f425e3a9b6e 100644
@@ -299,6 +299,7 @@ static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
  }
 
  int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev);
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev);
  void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
  			       uint64_t *addr, uint64_t *flags);
  int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, void *cpu_pt_addr,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
index 08ceabd6c853..ad600f72a51c 100644
@@ -1721,7 +1721,7 @@ static int gmc_v9_0_sw_fini(void *handle)
  	amdgpu_gem_force_release(adev);
  	amdgpu_vm_manager_fini(adev);
  	amdgpu_gart_table_vram_free(adev);
-	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+	amdgpu_gmc_pdb0_free(adev);
  	amdgpu_bo_fini(adev);
 
  	return 0;
#2 lore raw

Hi Christian,

My intention is to use a paired generic gmc alloc/free function to proceed PDB bo. Current code is gmc v9 code calls amdgpu_gmc_pdb0_alloc to allocate PDB bo buffer, and release the bo directly in gmc_v9_0_sw_fini. I guess PDB bo is not a gmc v9 specific buffer, so it's better to use a release function from amdgpu_gem.c in fini. This may benefit the case that users do the same in GMC newer IP code.

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, March 17, 2022 8:14 PM
To: Chen, Guchun <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move PDB bo release into a generic gmc function

Am 17.03.22 um 12:21 schrieb Guchun Chen:

Quoted 16 lines

To pair with amdgpu_gmc_pdb0_alloc as a more generic handling in amdgpu_gmc.c, no functional change.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 +
  drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
  3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index 7021e8f390bd..36f6b321438f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo) · line 143

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -0
@@ -136,6 +136,12 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
  	return pd_addr;
  }
 
+/* amdgpu_gmc_pdb0_free - free pdb0 vram */ void 
+amdgpu_gmc_pdb0_free(struct amdgpu_device *adev) {
+	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, 
+&adev->gmc.ptr_pdb0); }
+

Single line function usually doesn't look that useful to me.

Why is that any improvement?

Regards,
Christian.

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
  /**
   * amdgpu_gmc_set_pte_pde - update the page tables using CPU
   *
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 032b0313f277..6f425e3a9b6e 100644
@@ -299,6 +299,7 @@ static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
  }
 
  int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev);
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev);
  void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
  			       uint64_t *addr, uint64_t *flags);
  int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, void *cpu_pt_addr,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
index 08ceabd6c853..ad600f72a51c 100644
@@ -1721,7 +1721,7 @@ static int gmc_v9_0_sw_fini(void *handle)
  	amdgpu_gem_force_release(adev);
  	amdgpu_vm_manager_fini(adev);
  	amdgpu_gart_table_vram_free(adev);
-	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+	amdgpu_gmc_pdb0_free(adev);
  	amdgpu_bo_fini(adev);
 
  	return 0;
maintainer
#3 lore raw

Mhm, actually that is indeed purely gmc 9 specific.

This is a workaround for a very specific hardware bug issue which will hopefully never happen again :)

We just implemented it in the common handler to be able to test it with gmc 8 before gmc 9 came out of production.

Do we have a generic amdgpu_gmc_sw_finit()? If yes I would put it there instead, if no we might want to create one.

Regards,
Christian.

Am 17.03.22 um 13:50 schrieb Chen, Guchun:

Quoted 73 lines

Hi Christian,

My intention is to use a paired generic gmc alloc/free function to proceed PDB bo. Current code is gmc v9 code calls amdgpu_gmc_pdb0_alloc to allocate PDB bo buffer, and release the bo directly in gmc_v9_0_sw_fini. I guess PDB bo is not a gmc v9 specific buffer, so it's better to use a release function from amdgpu_gem.c in fini. This may benefit the case that users do the same in GMC newer IP code.

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, March 17, 2022 8:14 PM
To: Chen, Guchun <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move PDB bo release into a generic gmc function

Am 17.03.22 um 12:21 schrieb Guchun Chen:

Quoted 16 lines

To pair with amdgpu_gmc_pdb0_alloc as a more generic handling in amdgpu_gmc.c, no functional change.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 +
   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
   3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index 7021e8f390bd..36f6b321438f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo) · line 143

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -0
@@ -136,6 +136,12 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
   	return pd_addr;
   }
 
+/* amdgpu_gmc_pdb0_free - free pdb0 vram */ void
+amdgpu_gmc_pdb0_free(struct amdgpu_device *adev) {
+	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL,
+&adev->gmc.ptr_pdb0); }
+

Single line function usually doesn't look that useful to me.

Why is that any improvement?

Regards,
Christian.

Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
   /**
    * amdgpu_gmc_set_pte_pde - update the page tables using CPU
    *
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 032b0313f277..6f425e3a9b6e 100644
@@ -299,6 +299,7 @@ static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
   }
 
   int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev);
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev);
   void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
   			       uint64_t *addr, uint64_t *flags);
   int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, void *cpu_pt_addr,
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
index 08ceabd6c853..ad600f72a51c 100644
@@ -1721,7 +1721,7 @@ static int gmc_v9_0_sw_fini(void *handle)
   	amdgpu_gem_force_release(adev);
   	amdgpu_vm_manager_fini(adev);
   	amdgpu_gart_table_vram_free(adev);
-	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+	amdgpu_gmc_pdb0_free(adev);
   	amdgpu_bo_fini(adev);
 
   	return 0;
#4 lore raw

Thanks for the info, Christian, and I will abandon this patch. We don’t have a generic amdgpu_gmc_sw_fini.

Regards,
Guchun

-----Original Message-----
From: Koenig, Christian <[email protected]>
Sent: Thursday, March 17, 2022 8:55 PM
To: Chen, Guchun <[email protected]>; Christian König <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move PDB bo release into a generic gmc function

Mhm, actually that is indeed purely gmc 9 specific.

This is a workaround for a very specific hardware bug issue which will hopefully never happen again :)

We just implemented it in the common handler to be able to test it with gmc 8 before gmc 9 came out of production.

Do we have a generic amdgpu_gmc_sw_finit()? If yes I would put it there instead, if no we might want to create one.

Regards,
Christian.

Am 17.03.22 um 13:50 schrieb Chen, Guchun:

Quoted 79 lines

Hi Christian,

My intention is to use a paired generic gmc alloc/free function to proceed PDB bo. Current code is gmc v9 code calls amdgpu_gmc_pdb0_alloc to allocate PDB bo buffer, and release the bo directly in gmc_v9_0_sw_fini. I guess PDB bo is not a gmc v9 specific buffer, so it's better to use a release function from amdgpu_gem.c in fini. This may benefit the case that users do the same in GMC newer IP code.

Regards,
Guchun

-----Original Message-----
From: Christian König <[email protected]>
Sent: Thursday, March 17, 2022 8:14 PM
To: Chen, Guchun <[email protected]>; [email protected]; Zhang, Hawking <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; Deucher, Alexander <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: move PDB bo release into a generic gmc function

Am 17.03.22 um 12:21 schrieb Guchun Chen:

Quoted 16 lines

To pair with amdgpu_gmc_pdb0_alloc as a more generic handling in amdgpu_gmc.c, no functional change.

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 6 ++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h | 1 +
   drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c   | 2 +-
   3 files changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
index 7021e8f390bd..36f6b321438f 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo) · line 143

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +5 -0
@@ -136,6 +136,12 @@ uint64_t amdgpu_gmc_pd_addr(struct amdgpu_bo *bo)
   	return pd_addr;
   }
 
+/* amdgpu_gmc_pdb0_free - free pdb0 vram */ void 
+amdgpu_gmc_pdb0_free(struct amdgpu_device *adev) {
+	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, 
+&adev->gmc.ptr_pdb0); }
+

Single line function usually doesn't look that useful to me.

Why is that any improvement?

Regards,
Christian.

Quoted 30 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +0 -0
   /**
    * amdgpu_gmc_set_pte_pde - update the page tables using CPU
    *
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.h +1 -0
index 032b0313f277..6f425e3a9b6e 100644
@@ -299,6 +299,7 @@ static inline uint64_t amdgpu_gmc_sign_extend(uint64_t addr)
   }
 
   int amdgpu_gmc_pdb0_alloc(struct amdgpu_device *adev);
+void amdgpu_gmc_pdb0_free(struct amdgpu_device *adev);
   void amdgpu_gmc_get_pde_for_bo(struct amdgpu_bo *bo, int level,
   			       uint64_t *addr, uint64_t *flags);
   int amdgpu_gmc_set_pte_pde(struct amdgpu_device *adev, void 

*cpu_pt_addr, diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
index 08ceabd6c853..ad600f72a51c 100644

drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c +1 -1
@@ -1721,7 +1721,7 @@ static int gmc_v9_0_sw_fini(void *handle)
   	amdgpu_gem_force_release(adev);
   	amdgpu_vm_manager_fini(adev);
   	amdgpu_gart_table_vram_free(adev);
-	amdgpu_bo_free_kernel(&adev->gmc.pdb0_bo, NULL, &adev->gmc.ptr_pdb0);
+	amdgpu_gmc_pdb0_free(adev);
   	amdgpu_bo_fini(adev);
 
   	return 0;