Skip to contentSkip to conversation

drm/amd/amdgpu: Enable IH Retry CAM by register read

PATCH In review Dewan Alam 2 participants 4 messages Mar 13, 2024 – Mar 26, 2024

Subsystems (2)
lore
Share & tools
lore

Dewan Alam

author
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Enable IH Retry CAM by register read

IH Retry CAM should be enabled by register reads instead of always being set to true.

---
 drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +11 -4
index b9e785846637..c330f5a88a06 100644
@@ -337,13 +337,20 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
 
 	/* Enable IH Retry CAM */
 	if (amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 0) ||
-	    amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))
+	    amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2)) {
 		WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL_ALDEBARAN,
 			       ENABLE, 1);
-	else
+		adev->irq.retry_cam_enabled = REG_GET_FIELD(
+			RREG32_SOC15(OSSSYS, 0,
+				mmIH_RETRY_INT_CAM_CNTL_ALDEBARAN),
+				IH_RETRY_INT_CAM_CNTL_ALDEBARAN, ENABLE);
+		} else {
 		WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL, ENABLE, 1);
-
-	adev->irq.retry_cam_enabled = true;
+		adev->irq.retry_cam_enabled = REG_GET_FIELD(
+			RREG32_SOC15(OSSSYS, 0,
+				mmIH_RETRY_INT_CAM_CNTL),
+				IH_RETRY_INT_CAM_CNTL, ENABLE);
+		}
 
 	/* enable interrupts */
 	ret = vega20_ih_toggle_interrupts(adev, true);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Dewan Alam

IH Retry CAM should be enabled by register reads instead of always being set to true.

This explanation sounds odd. Your code is still writing the register first. What's the reason for reading back the register? I assume it's not needed for enabling the CAM, but to check whether it was enabled successfully. What are the configurations where it cannot be enabled successfully?

Two more nit-picks inline ...

Quoted 14 lines
---
  drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -0
index b9e785846637..c330f5a88a06 100644
@@ -337,13 +337,20 @@ static int vega20_ih_irq_init(struct amdgpu_device *adev)
 
  	/* Enable IH Retry CAM */
  	if (amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 0) ||

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct amdgpu_device *adev) · line 347

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +6 -2
-	    amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))
+	    amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2)) {
  		WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL_ALDEBARAN,
  			       ENABLE, 1);
-	else
+		adev->irq.retry_cam_enabled = REG_GET_FIELD(
+			RREG32_SOC15(OSSSYS, 0,
+				mmIH_RETRY_INT_CAM_CNTL_ALDEBARAN),
+				IH_RETRY_INT_CAM_CNTL_ALDEBARAN, ENABLE);
+		} else {

Indentation looks wrong here.

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct amdgpu_device *adev) · line 353

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -2
  		WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL, ENABLE, 1);
-
-	adev->irq.retry_cam_enabled = true;
+		adev->irq.retry_cam_enabled = REG_GET_FIELD(
+			RREG32_SOC15(OSSSYS, 0,
+				mmIH_RETRY_INT_CAM_CNTL),
+				IH_RETRY_INT_CAM_CNTL, ENABLE);
+		}

Wrong indentation.

Regards,
  Felix

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -0
  	/* enable interrupts */
  	ret = vega20_ih_toggle_interrupts(adev, true);
#2 lore raw

[AMD Official Use Only - General]

Looping in +@Zhang, Zhaochen

CAM control register can only be written by PF. VF can only read the register. In SRIOV VF, the write won't work.
In SRIOV case, CAM's enablement is controlled by the host. Hence, we think the enablement status should be decided by the register reading.

Thanks,
Dewan

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Wednesday, March 13, 2024 3:46 PM
To: Alam, Dewan <[email protected]>; [email protected]
Cc: Zhang, Hawking <[email protected]>
Subject: Re: [PATCH] drm/amd/amdgpu: Enable IH Retry CAM by register read

Quoted 1 line · Dewan Alam

IH Retry CAM should be enabled by register reads instead of always being set to true.

This explanation sounds odd. Your code is still writing the register first. What's the reason for reading back the register? I assume it's not needed for enabling the CAM, but to check whether it was enabled successfully. What are the configurations where it cannot be enabled successfully?

Two more nit-picks inline ...

Quoted 17 lines
---
  drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -1
index b9e785846637..c330f5a88a06 100644
@@ -337,13 +337,20 @@ static int vega20_ih_irq_init(struct
 amdgpu_device *adev)
 
      /* Enable IH Retry CAM */
      if (amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 0) ||
-         amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct · line 349

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +7 -1
+         amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))
+{
              WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL_ALDEBARAN,
                             ENABLE, 1);
-     else
+             adev->irq.retry_cam_enabled = REG_GET_FIELD(
+                     RREG32_SOC15(OSSSYS, 0,
+                             mmIH_RETRY_INT_CAM_CNTL_ALDEBARAN),
+                             IH_RETRY_INT_CAM_CNTL_ALDEBARAN, ENABLE);
+             } else {

Indentation looks wrong here.

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct amdgpu_device *adev) · line 353

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -2
              WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL, ENABLE, 1);
-
-     adev->irq.retry_cam_enabled = true;
+             adev->irq.retry_cam_enabled = REG_GET_FIELD(
+                     RREG32_SOC15(OSSSYS, 0,
+                             mmIH_RETRY_INT_CAM_CNTL),
+                             IH_RETRY_INT_CAM_CNTL, ENABLE);
+             }

Wrong indentation.

Regards,
Felix

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -0
      /* enable interrupts */
      ret = vega20_ih_toggle_interrupts(adev, true);
#3 lore raw
Quoted 6 lines · Dewan

[AMD Official Use Only - General]

Looping in +@Zhang, Zhaochen

CAM control register can only be written by PF. VF can only read the register. In SRIOV VF, the write won't work.
In SRIOV case, CAM's enablement is controlled by the host. Hence, we think the enablement status should be decided by the register reading.

Thank you for clarifying that. With that in mind, I would suggest changes to the commit headline and description to avoid confusion:

drm/amdgpu: Confirm IH retry CAM enablement by reading the register

Under SRIOV, the IH CAM cannot be enabled by the guest. The host controls this register. In the guest driver, read the register to confirm whether the CAM was enabled.

Regards,
  Felix

Quoted 61 lines

Thanks,
Dewan

-----Original Message-----
From: Kuehling, Felix<[email protected]>
Sent: Wednesday, March 13, 2024 3:46 PM
To: Alam, Dewan<[email protected]>;[email protected]
Cc: Zhang, Hawking<[email protected]>
Subject: Re: [PATCH] drm/amd/amdgpu: Enable IH Retry CAM by register read

Quoted 1 line · Dewan Alam

IH Retry CAM should be enabled by register reads instead of always being set to true.

This explanation sounds odd. Your code is still writing the register first. What's the reason for reading back the register? I assume it's not needed for enabling the CAM, but to check whether it was enabled successfully. What are the configurations where it cannot be enabled successfully?

Two more nit-picks inline ...

Quoted 16 lines
---
   drivers/gpu/drm/amd/amdgpu/vega20_ih.c | 15 +++++++++++----
   1 file changed, 11 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -1
index b9e785846637..c330f5a88a06 100644
@@ -337,13 +337,20 @@ static int vega20_ih_irq_init(struct
 amdgpu_device *adev)
 
       /* Enable IH Retry CAM */
       if (amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 0) ||
-         amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct · line 349

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +7 -1
+         amdgpu_ip_version(adev, OSSSYS_HWIP, 0) == IP_VERSION(4, 4, 2))
+{
               WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL_ALDEBARAN,
                              ENABLE, 1);
-     else
+             adev->irq.retry_cam_enabled = REG_GET_FIELD(
+                     RREG32_SOC15(OSSSYS, 0,
+                             mmIH_RETRY_INT_CAM_CNTL_ALDEBARAN),
+                             IH_RETRY_INT_CAM_CNTL_ALDEBARAN, ENABLE);
+             } else {

Indentation looks wrong here.

drivers/gpu/drm/amd/amdgpu/vega20_ih.c static int vega20_ih_irq_init(struct amdgpu_device *adev) · line 353

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +5 -2
               WREG32_FIELD15(OSSSYS, 0, IH_RETRY_INT_CAM_CNTL, ENABLE, 1);
-
-     adev->irq.retry_cam_enabled = true;
+             adev->irq.retry_cam_enabled = REG_GET_FIELD(
+                     RREG32_SOC15(OSSSYS, 0,
+                             mmIH_RETRY_INT_CAM_CNTL),
+                             IH_RETRY_INT_CAM_CNTL, ENABLE);
+             }

Wrong indentation.

Regards,
Felix

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/vega20_ih.c +0 -0
       /* enable interrupts */
       ret = vega20_ih_toggle_interrupts(adev, true);