[PATCH v3 3/3] drm/amdgpu: Add ip dump support in devcoredump

Sunil Khatri sunil.khatri at amd.com
Fri Apr 12 16:54:12 UTC 2024


Add support of dumping the IP registers for
debugging purposes in devcoredump.

Signed-off-by: Sunil Khatri <sunil.khatri at amd.com>
---
 .../gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c  | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
index 1129e5e5fb42..c6eea58d137d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -261,6 +261,19 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count,
 	drm_printf(&p, "Faulty page starting at address: 0x%016llx\n", fault_info->addr);
 	drm_printf(&p, "Protection fault status register: 0x%x\n\n", fault_info->status);
 
+	/* Add IP dump for each ip */
+	if (coredump->adev->ip_dump != NULL) {
+		struct reg_pair *pair;
+
+		pair = (struct reg_pair *)coredump->adev->ip_dump;
+		drm_printf(&p, "IP register dump\n");
+		drm_printf(&p, "Offset \t Value\n");
+		for (int i = 0; i < coredump->adev->num_regs; i++)
+			drm_printf(&p, "0x%04x \t 0x%08x\n", pair[i].offset,
+				   pair[i].value);
+		drm_printf(&p, "\n");
+	}
+
 	/* Add ring buffer information */
 	drm_printf(&p, "Ring buffer information\n");
 	for (int i = 0; i < coredump->adev->num_rings; i++) {
@@ -299,6 +312,11 @@ amdgpu_devcoredump_read(char *buffer, loff_t offset, size_t count,
 
 static void amdgpu_devcoredump_free(void *data)
 {
+	struct amdgpu_coredump_info *temp = data;
+
+	kfree(temp->adev->ip_dump);
+	temp->adev->ip_dump = NULL;
+	temp->adev->num_regs = 0;
 	kfree(data);
 }
 
@@ -337,6 +355,11 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool vram_lost,
 
 	coredump->adev = adev;
 
+	/* Trigger ip dump here to capture the value of registers */
+	for (int i = 0; i < adev->num_ip_blocks; i++)
+		if (adev->ip_blocks[i].version->funcs->dump_ip_state)
+			adev->ip_blocks[i].version->funcs->dump_ip_state((void *)adev);
+
 	ktime_get_ts64(&coredump->reset_time);
 
 	dev_coredumpm(dev->dev, THIS_MODULE, coredump, 0, GFP_NOWAIT,
-- 
2.34.1



More information about the amd-gfx mailing list