Skip to contentSkip to conversation

drm/amdgpu: decode the ctxid for SMC to host IH

PATCH NAK Evan Quan 3 participants 5 messages May 8, 2020 – May 9, 2020

Subsystems (2)
lore
Share & tools
lore

Evan Quan

author
#0 lore raw

PATCH 1/2 drm/amdgpu: decode the ctxid for SMC to host IH

Driver needs that to tell the different events raised from SMC.

Change-Id I0e44e22527182fbb45a2db4fc3b1cd73fb17ba33
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 1 +
 drivers/gpu/drm/amd/amdgpu/navi10_ih.c  | 1 +
 drivers/gpu/drm/amd/amdgpu/vega10_ih.c  | 1 +
 3 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +1 -0
index 7b1762b1c595..965875b8bf93 100644
@@ -55,6 +55,7 @@ struct amdgpu_iv_entry {
 	unsigned timestamp_src;
 	unsigned pasid;
 	unsigned pasid_src;
+	unsigned ctxid; /* for SMC to Host interrupt */
 	unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW];
 	const uint32_t *iv_entry;
 };
drivers/gpu/drm/amd/amdgpu/navi10_ih.c +1 -0
index f97857ed3c7e..932dc3eabbe2 100644
@@ -470,6 +470,7 @@ static void navi10_ih_decode_iv(struct amdgpu_device *adev,
 	entry->timestamp_src = dw[2] >> 31;
 	entry->pasid = dw[3] & 0xffff;
 	entry->pasid_src = dw[3] >> 31;
+	entry->ctxid = dw[4];
 	entry->src_data[0] = dw[4];
 	entry->src_data[1] = dw[5];
 	entry->src_data[2] = dw[6];
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +1 -0
index 407c6093c2ec..e46d1f9f62ca 100644
@@ -460,6 +460,7 @@ static void vega10_ih_decode_iv(struct amdgpu_device *adev,
 	entry->timestamp_src = dw[2] >> 31;
 	entry->pasid = dw[3] & 0xffff;
 	entry->pasid_src = dw[3] >> 31;
+	entry->ctxid = dw[4];
 	entry->src_data[0] = dw[4];
 	entry->src_data[1] = dw[5];
 	entry->src_data[2] = dw[6];
Signature · 6 lines
2.26.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
author
#1 lore raw

PATCH 2/2 drm/amd/powerplay: report correct AC/DC event based on ctxid

'ctxid' is used to distinguish different events raised from SMC. 0x3 and 0x4 are for AC and DC power mode.

Change-Id I7dbcb053fe9cea7c70e0a33afc2115b3745f6186
---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +13 -2
index ab727f33b8d9..dcd3a54d18a3 100644
@@ -1522,6 +1522,7 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
 {
 	uint32_t client_id = entry->client_id;
 	uint32_t src_id = entry->src_id;
+	uint32_t ctxid = entry->ctxid;
 
 	if (client_id == SOC15_IH_CLIENTID_THM) {
 		switch (src_id) {
@@ -1547,8 +1548,18 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
 
 		}
 	} else if (client_id == SOC15_IH_CLIENTID_MP1) {
-		if (src_id == 0xfe)
-			smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+		if (src_id == 0xfe) {
+			switch (ctxid) {
+			case 0x3:
+				dev_info(adev->dev, "Switched to AC mode!\n");
+				smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+				break;
+			case 0x4:
+				dev_info(adev->dev, "Switched to DC mode!\n");
+				smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+				break;
+			}
+		}
 	}
 
 	return 0;
Signature · 6 lines
2.26.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] drm/amd/powerplay: report correct AC/DC event based on ctxid

Quoted 15 lines · Evan Quan

'ctxid' is used to distinguish different events raised from SMC. 0x3 and 0x4 are for AC and DC power mode.

Change-Id I7dbcb053fe9cea7c70e0a33afc2115b3745f6186
---
 drivers/gpu/drm/amd/powerplay/smu_v11_0.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
index ab727f33b8d9..dcd3a54d18a3 100644

drivers/gpu/drm/amd/powerplay/smu_v11_0.c static int smu_v11_0_irq_process(struct amdgpu_device *adev, · line 1525

Quoted 4 lines
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +1 -0
@@ -1522,6 +1522,7 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
 {
        uint32_t client_id = entry->client_id;
        uint32_t src_id = entry->src_id;
+       uint32_t ctxid = entry->ctxid;

As noted by Christian, just use the entry->src_data[0] directly.

Quoted 7 lines
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +0 -0
        if (client_id == SOC15_IH_CLIENTID_THM) {
                switch (src_id) {
@@ -1547,8 +1548,18 @@ static int smu_v11_0_irq_process(struct amdgpu_device *adev,
 
                }
        } else if (client_id == SOC15_IH_CLIENTID_MP1) {

drivers/gpu/drm/amd/powerplay/smu_v11_0.c static int smu_v11_0_irq_process(struct amdgpu_device *adev, · line 1558

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +8 -2
-               if (src_id == 0xfe)
-                       smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+               if (src_id == 0xfe) {
+                       switch (ctxid) {
+                       case 0x3:
+                               dev_info(adev->dev, "Switched to AC mode!\n");
+                               smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+                               break;
+                       case 0x4:
+                               dev_info(adev->dev, "Switched to DC mode!\n");

Might want to make these dev_debug so we don't spam the logs. With those fixed, patch is:

Quoted 10 lines
drivers/gpu/drm/amd/powerplay/smu_v11_0.c +4 -1
+                               smu_v11_0_ack_ac_dc_interrupt(&adev->smu);
+                               break;
+                       }
+               }
        }
 
        return 0;
--

2.26.2

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

#3 lore raw
In reply to Evan Quan

Am 08.05.20 um 12:02 schrieb Evan Quan:

Quoted 1 line

Driver needs that to tell the different events raised from SMC.

NAK, the ctxid is filled in by the SMC and not by the IH. We only decode fields here which are filled in by the IH.

Just use src_data[0] when you need some SMC specific bits.

Christian.

Quoted 38 lines
Change-Id I0e44e22527182fbb45a2db4fc3b1cd73fb17ba33
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 1 +
  drivers/gpu/drm/amd/amdgpu/navi10_ih.c  | 1 +
  drivers/gpu/drm/amd/amdgpu/vega10_ih.c  | 1 +
  3 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +1 -0
index 7b1762b1c595..965875b8bf93 100644
@@ -55,6 +55,7 @@ struct amdgpu_iv_entry {
  	unsigned timestamp_src;
  	unsigned pasid;
  	unsigned pasid_src;
+	unsigned ctxid; /* for SMC to Host interrupt */
  	unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW];
  	const uint32_t *iv_entry;
  };
drivers/gpu/drm/amd/amdgpu/navi10_ih.c +1 -0
index f97857ed3c7e..932dc3eabbe2 100644
@@ -470,6 +470,7 @@ static void navi10_ih_decode_iv(struct amdgpu_device *adev,
  	entry->timestamp_src = dw[2] >> 31;
  	entry->pasid = dw[3] & 0xffff;
  	entry->pasid_src = dw[3] >> 31;
+	entry->ctxid = dw[4];
  	entry->src_data[0] = dw[4];
  	entry->src_data[1] = dw[5];
  	entry->src_data[2] = dw[6];
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0 -0
index 407c6093c2ec..e46d1f9f62ca 100644

drivers/gpu/drm/amd/amdgpu/vega10_ih.c static void vega10_ih_decode_iv(struct amdgpu_device *adev, · line 466

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +1 -0
@@ -460,6 +460,7 @@ static void vega10_ih_decode_iv(struct amdgpu_device *adev,
  	entry->timestamp_src = dw[2] >> 31;
  	entry->pasid = dw[3] & 0xffff;
  	entry->pasid_src = dw[3] >> 31;
+	entry->ctxid = dw[4];
  	entry->src_data[0] = dw[4];
  	entry->src_data[1] = dw[5];
  	entry->src_data[2] = dw[6];

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

author NAK
#4 lore raw

[AMD Official Use Only - Internal Distribution Only]

OK. Reasonable. Will update the patches.

BR,
Evan
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, May 8, 2020 6:53 PM
To: Quan, Evan <[email protected]>; [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: Re: [PATCH 1/2] drm/amdgpu: decode the ctxid for SMC to host IH

Am 08.05.20 um 12:02 schrieb Evan Quan:

Quoted 1 line

Driver needs that to tell the different events raised from SMC.

NAK, the ctxid is filled in by the SMC and not by the IH. We only decode fields here which are filled in by the IH.

Just use src_data[0] when you need some SMC specific bits.

Christian.

Quoted 41 lines
Change-Id I0e44e22527182fbb45a2db4fc3b1cd73fb17ba33
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h | 1 +
  drivers/gpu/drm/amd/amdgpu/navi10_ih.c  | 1 +
  drivers/gpu/drm/amd/amdgpu/vega10_ih.c  | 1 +
  3 files changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_irq.h +1 -0
index 7b1762b1c595..965875b8bf93 100644
@@ -55,6 +55,7 @@ struct amdgpu_iv_entry {
  unsigned timestamp_src;
  unsigned pasid;
  unsigned pasid_src;
+unsigned ctxid; /* for SMC to Host interrupt */
  unsigned src_data[AMDGPU_IRQ_SRC_DATA_MAX_SIZE_DW];
  const uint32_t *iv_entry;
  };
drivers/gpu/drm/amd/amdgpu/navi10_ih.c +1 -0
index f97857ed3c7e..932dc3eabbe2 100644
@@ -470,6 +470,7 @@ static void navi10_ih_decode_iv(struct amdgpu_device *adev,
  entry->timestamp_src = dw[2] >> 31;
  entry->pasid = dw[3] & 0xffff;
  entry->pasid_src = dw[3] >> 31;
+entry->ctxid = dw[4];
  entry->src_data[0] = dw[4];
  entry->src_data[1] = dw[5];
  entry->src_data[2] = dw[6];
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +0 -0
index 407c6093c2ec..e46d1f9f62ca 100644

drivers/gpu/drm/amd/amdgpu/vega10_ih.c static void vega10_ih_decode_iv(struct amdgpu_device *adev, · line 466

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/vega10_ih.c +1 -0
@@ -460,6 +460,7 @@ static void vega10_ih_decode_iv(struct amdgpu_device *adev,
  entry->timestamp_src = dw[2] >> 31;
  entry->pasid = dw[3] & 0xffff;
  entry->pasid_src = dw[3] >> 31;
+entry->ctxid = dw[4];
  entry->src_data[0] = dw[4];
  entry->src_data[1] = dw[5];
  entry->src_data[2] = dw[6];

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