drm/amd/display: Add DMUB firmware state debugfs
authorNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Tue, 11 Feb 2020 14:48:18 +0000 (09:48 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 25 Feb 2020 16:05:57 +0000 (11:05 -0500)
[Why]
Firmware state helps to debug sequence issues and hangs for DMCUB
commands and we don't have an easy mechanism to dump it from the driver.

[How]
Add a debugfs entry to dump the current firmware state.
Example usage:

cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_fw_state

Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Hersen Wu <hersenxs.wu@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c

index ead5c05eec92faeebfd30ed4a64975a6df34d489..8ec3b4335c69405c0d0f5b57d49f1b6b8676c872 100644 (file)
@@ -732,6 +732,29 @@ static int dmub_tracebuffer_show(struct seq_file *m, void *data)
        return 0;
 }
 
+/**
+ * Returns the DMCUB firmware state contents.
+ * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_fw_state
+ */
+static int dmub_fw_state_show(struct seq_file *m, void *data)
+{
+       struct amdgpu_device *adev = m->private;
+       struct dmub_srv_fb_info *fb_info = adev->dm.dmub_fb_info;
+       uint8_t *state_base;
+       uint32_t state_size;
+
+       if (!fb_info)
+               return 0;
+
+       state_base = (uint8_t *)fb_info->fb[DMUB_WINDOW_6_FW_STATE].cpu_addr;
+       if (!state_base)
+               return 0;
+
+       state_size = fb_info->fb[DMUB_WINDOW_6_FW_STATE].size;
+
+       return seq_write(m, state_base, state_size);
+}
+
 /*
  * Returns the current and maximum output bpc for the connector.
  * Example usage: cat /sys/kernel/debug/dri/0/DP-1/output_bpc
@@ -937,6 +960,7 @@ static ssize_t dp_dpcd_data_read(struct file *f, char __user *buf,
        return read_size - r;
 }
 
+DEFINE_SHOW_ATTRIBUTE(dmub_fw_state);
 DEFINE_SHOW_ATTRIBUTE(dmub_tracebuffer);
 DEFINE_SHOW_ATTRIBUTE(output_bpc);
 DEFINE_SHOW_ATTRIBUTE(vrr_range);
@@ -1249,5 +1273,8 @@ int dtn_debugfs_init(struct amdgpu_device *adev)
        debugfs_create_file_unsafe("amdgpu_dm_dmub_tracebuffer", 0644, root,
                                   adev, &dmub_tracebuffer_fops);
 
+       debugfs_create_file_unsafe("amdgpu_dm_dmub_fw_state", 0644, root,
+                                  adev, &dmub_fw_state_fops);
+
        return 0;
 }