Skip to contentSkip to conversation

drm/amdgpu/gmc7: fix wait_for_idle callers

PATCH In review Alex Deucher 4 participants 4 messages Nov 19, 2024 – Nov 20, 2024

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu/gmc7: fix wait_for_idle callers

The wait_for_idle signature was changed, but the callers were not.

Fixes 82ae6619a450 ("drm/amdgpu: update the handle ptr in wait_for_idle")
Cc Sunil Khatri <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +14 -4
index 8f6f2f067641..347bccd92696 100644
@@ -87,9 +87,14 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev)
 
 static void gmc_v7_0_mc_stop(struct amdgpu_device *adev)
 {
+	struct amdgpu_ip_block *ip_block;
 	u32 blackout;
 
-	gmc_v7_0_wait_for_idle((void *)adev);
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
+	gmc_v7_0_wait_for_idle(ip_block);
 
 	blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
 	if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
@@ -251,9 +256,14 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
  */
 static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
 {
+	struct amdgpu_ip_block *ip_block;
 	u32 tmp;
 	int i, j;
 
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
 	/* Initialize HDP */
 	for (i = 0, j = 0; i < 32; i++, j += 0x6) {
 		WREG32((0xb05 + j), 0x00000000);
@@ -264,7 +274,7 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
 	}
 	WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0);
 
-	if (gmc_v7_0_wait_for_idle((void *)adev))
+	if (gmc_v7_0_wait_for_idle(ip_block))
 		dev_warn(adev->dev, "Wait for MC idle timedout !\n");
 
 	if (adev->mode_info.num_crtc) {
@@ -288,7 +298,7 @@ static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
 	WREG32(mmMC_VM_AGP_BASE, 0);
 	WREG32(mmMC_VM_AGP_TOP, adev->gmc.agp_end >> 22);
 	WREG32(mmMC_VM_AGP_BOT, adev->gmc.agp_start >> 22);
-	if (gmc_v7_0_wait_for_idle((void *)adev))
+	if (gmc_v7_0_wait_for_idle(ip_block))
 		dev_warn(adev->dev, "Wait for MC idle timedout !\n");
 
 	WREG32(mmBIF_FB_EN, BIF_FB_EN__FB_READ_EN_MASK | BIF_FB_EN__FB_WRITE_EN_MASK);
@@ -1183,7 +1193,7 @@ static int gmc_v7_0_soft_reset(struct amdgpu_ip_block *ip_block)
 
 	if (srbm_soft_reset) {
 		gmc_v7_0_mc_stop(adev);
-		if (gmc_v7_0_wait_for_idle((void *)adev))
+		if (gmc_v7_0_wait_for_idle(ip_block))
 			dev_warn(adev->dev, "Wait for GMC idle timed out !\n");
 
 		tmp = RREG32(mmSRBM_SOFT_RESET);
Signature · 1 line
2.47.0
#1 lore raw
Quoted 36 lines · Alex Deucher

The wait_for_idle signature was changed, but the callers were not.

Fixes 82ae6619a450 ("drm/amdgpu: update the handle ptr in wait_for_idle")
Cc Sunil Khatri <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 8f6f2f067641..347bccd92696 100644
@@ -87,9 +87,14 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev)
 
 static void gmc_v7_0_mc_stop(struct amdgpu_device *adev)
 {
+	struct amdgpu_ip_block *ip_block;
 	u32 blackout;
 
-	gmc_v7_0_wait_for_idle((void *)adev);
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
+	gmc_v7_0_wait_for_idle(ip_block);
 
 	blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
 	if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
@@ -251,9 +256,14 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
  */
 static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
 {
+	struct amdgpu_ip_block *ip_block;

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, · line 269

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -0
 	u32 tmp;
 	int i, j;
 
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
 	/* Initialize HDP */
 	for (i = 0, j = 0; i < 32; i++, j += 0x6) {
 		WREG32((0xb05 + j), 0x00000000);

Seems simpler to make gmc_v7_0_mc_stop & gmc_v7_0_mc_program take ip_block instead of adev as well (and fix up the comment before gmc_v7_0_mc_program).

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
Reviewed-by
#2 lore raw
Quoted 51 lines · Michel Dänzer
Quoted 36 lines · Alex Deucher

The wait_for_idle signature was changed, but the callers were not.

Fixes 82ae6619a450 ("drm/amdgpu: update the handle ptr in wait_for_idle")
Cc Sunil Khatri <[email protected]>
---
  drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 18 ++++++++++++++----
  1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 8f6f2f067641..347bccd92696 100644
@@ -87,9 +87,14 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev)
 
  static void gmc_v7_0_mc_stop(struct amdgpu_device *adev)
  {
+	struct amdgpu_ip_block *ip_block;
  	u32 blackout;
 
-	gmc_v7_0_wait_for_idle((void *)adev);
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
+	gmc_v7_0_wait_for_idle(ip_block);
 
  	blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
  	if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
@@ -251,9 +256,14 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
   */
  static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
  {
+	struct amdgpu_ip_block *ip_block;

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, · line 269

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -0
  	u32 tmp;
  	int i, j;
 
+	ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+	if (!ip_block)
+		return;
+
  	/* Initialize HDP */
  	for (i = 0, j = 0; i < 32; i++, j += 0x6) {
  		WREG32((0xb05 + j), 0x00000000);

Seems simpler to make gmc_v7_0_mc_stop & gmc_v7_0_mc_program take ip_block instead of adev as well (and fix up the comment before gmc_v7_0_mc_program). We have changed the signature of the functions which are part of the amdgpu_ip_functions and not for all. The existing change look good to me the way it is.

#3 lore raw
In reply to Michel Dänzer
Quoted 41 lines · Michel Dänzer
Quoted 39 lines · Alex Deucher

The wait_for_idle signature was changed, but the callers were not.

Fixes 82ae6619a450 ("drm/amdgpu: update the handle ptr in wait_for_idle")
Cc Sunil Khatri <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +7 -1
index 8f6f2f067641..347bccd92696 100644
@@ -87,9 +87,14 @@ static void gmc_v7_0_init_golden_registers(struct amdgpu_device *adev)
 
 static void gmc_v7_0_mc_stop(struct amdgpu_device *adev)
 {
+     struct amdgpu_ip_block *ip_block;
      u32 blackout;
 
-     gmc_v7_0_wait_for_idle((void *)adev);
+     ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+     if (!ip_block)
+             return;
+
+     gmc_v7_0_wait_for_idle(ip_block);
 
      blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
      if (REG_GET_FIELD(blackout, MC_SHARED_BLACKOUT_CNTL, BLACKOUT_MODE) != 1) {
@@ -251,9 +256,14 @@ static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev,
  */
 static void gmc_v7_0_mc_program(struct amdgpu_device *adev)
 {
+     struct amdgpu_ip_block *ip_block;
      u32 tmp;
      int i, j;
 
Quoted 9 lines

drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c static void gmc_v7_0_vram_gtt_location(struct amdgpu_device *adev, · line 269

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c +4 -0
+     ip_block = amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GMC);
+     if (!ip_block)
+             return;
+
      /* Initialize HDP */
      for (i = 0, j = 0; i < 32; i++, j += 0x6) {
              WREG32((0xb05 + j), 0x00000000);

Seems simpler to make gmc_v7_0_mc_stop & gmc_v7_0_mc_program take ip_block instead of adev as well (and fix up the comment before gmc_v7_0_mc_program).

I thought about that, but this keeps it consistent with the other gmc files and I'd like to keep the ip_block to the IP level functions.

Alex

Quoted 5 lines

--
Earthling Michel Dänzer \ GNOME / Xwayland / Mesa developer
https://redhat.com \ Libre software enthusiast