Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/display: add a debugfs interface for the DMUB trace mask

For features that are implemented primarily in DMUB (e.g. PSR), it is
useful to be able to trace them at a DMUB level from the kernel,
especially when debugging issues. So, introduce a debugfs interface that
is able to read and set the DMUB trace mask dynamically at runtime and
document how to use it.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Mario Limonciello <mario.limonciello@amd.com>
Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Hamza Mahfooz and committed by
Alex Deucher
c41028a2 fcfc6cee

+209 -2
+41
Documentation/gpu/amdgpu/display/dc-debug.rst
··· 75 75 76 76 When reporting a bug related to DC, consider attaching this log before and 77 77 after you reproduce the bug. 78 + 79 + DMUB Firmware Debug 80 + =================== 81 + 82 + Sometimes, dmesg logs aren't enough. This is especially true if a feature is 83 + implemented primarily in DMUB firmware. In such cases, all we see in dmesg when 84 + an issue arises is some generic timeout error. So, to get more relevant 85 + information, we can trace DMUB commands by enabling the relevant bits in 86 + `amdgpu_dm_dmub_trace_mask`. 87 + 88 + Currently, we support the tracing of the following groups: 89 + 90 + Trace Groups 91 + ------------ 92 + 93 + .. csv-table:: 94 + :header-rows: 1 95 + :widths: 1, 1 96 + :file: ./trace-groups-table.csv 97 + 98 + **Note: Not all ASICs support all of the listed trace groups** 99 + 100 + So, to enable just PSR tracing you can use the following command:: 101 + 102 + # echo 0x8020 > /sys/kernel/debug/dri/0/amdgpu_dm_dmub_trace_mask 103 + 104 + Then, you need to enable logging trace events to the buffer, which you can do 105 + using the following:: 106 + 107 + # echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en 108 + 109 + Lastly, after you are able to reproduce the issue you are trying to debug, 110 + you can disable tracing and read the trace log by using the following:: 111 + 112 + # echo 0 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en 113 + # cat /sys/kernel/debug/dri/0/amdgpu_dm_dmub_tracebuffer 114 + 115 + So, when reporting bugs related to features such as PSR and ABM, consider 116 + enabling the relevant bits in the mask before reproducing the issue and 117 + attach the log that you obtain from the trace buffer in any bug reports that you 118 + create.
+29
Documentation/gpu/amdgpu/display/trace-groups-table.csv
··· 1 + Name, Mask Value 2 + INFO, 0x1 3 + IRQ SVC, 0x2 4 + VBIOS, 0x4 5 + REGISTER, 0x8 6 + PHY DBG, 0x10 7 + PSR, 0x20 8 + AUX, 0x40 9 + SMU, 0x80 10 + MALL, 0x100 11 + ABM, 0x200 12 + ALPM, 0x400 13 + TIMER, 0x800 14 + HW LOCK MGR, 0x1000 15 + INBOX1, 0x2000 16 + PHY SEQ, 0x4000 17 + PSR STATE, 0x8000 18 + ZSTATE, 0x10000 19 + TRANSMITTER CTL, 0x20000 20 + PANEL CNTL, 0x40000 21 + FAMS, 0x80000 22 + DPIA, 0x100000 23 + SUBVP, 0x200000 24 + INBOX0, 0x400000 25 + SDP, 0x4000000 26 + REPLAY, 0x8000000 27 + REPLAY RESIDENCY, 0x20000000 28 + CURSOR INFO, 0x80000000 29 + IPS, 0x100000000
+101
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
··· 2971 2971 return 0; 2972 2972 } 2973 2973 2974 + static int dmub_trace_mask_set(void *data, u64 val) 2975 + { 2976 + struct amdgpu_device *adev = data; 2977 + struct dmub_srv *srv = adev->dm.dc->ctx->dmub_srv->dmub; 2978 + enum dmub_gpint_command cmd; 2979 + enum dmub_status status; 2980 + u64 mask = 0xffff; 2981 + u8 shift = 0; 2982 + u32 res; 2983 + int i; 2984 + 2985 + if (!srv->fw_version) 2986 + return -EINVAL; 2987 + 2988 + for (i = 0; i < 4; i++) { 2989 + res = (val & mask) >> shift; 2990 + 2991 + switch (i) { 2992 + case 0: 2993 + cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD0; 2994 + break; 2995 + case 1: 2996 + cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD1; 2997 + break; 2998 + case 2: 2999 + cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD2; 3000 + break; 3001 + case 3: 3002 + cmd = DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD3; 3003 + break; 3004 + } 3005 + 3006 + status = dmub_srv_send_gpint_command(srv, cmd, res, 30); 3007 + 3008 + if (status == DMUB_STATUS_TIMEOUT) 3009 + return -ETIMEDOUT; 3010 + else if (status == DMUB_STATUS_INVALID) 3011 + return -EINVAL; 3012 + else if (status != DMUB_STATUS_OK) 3013 + return -EIO; 3014 + 3015 + usleep_range(100, 1000); 3016 + 3017 + mask <<= 16; 3018 + shift += 16; 3019 + } 3020 + 3021 + return 0; 3022 + } 3023 + 3024 + static int dmub_trace_mask_show(void *data, u64 *val) 3025 + { 3026 + enum dmub_gpint_command cmd = DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD0; 3027 + struct amdgpu_device *adev = data; 3028 + struct dmub_srv *srv = adev->dm.dc->ctx->dmub_srv->dmub; 3029 + enum dmub_status status; 3030 + u8 shift = 0; 3031 + u64 raw = 0; 3032 + u64 res = 0; 3033 + int i = 0; 3034 + 3035 + if (!srv->fw_version) 3036 + return -EINVAL; 3037 + 3038 + while (i < 4) { 3039 + status = dmub_srv_send_gpint_command(srv, cmd, 0, 30); 3040 + 3041 + if (status == DMUB_STATUS_OK) { 3042 + status = dmub_srv_get_gpint_response(srv, (u32 *) &raw); 3043 + 3044 + if (status == DMUB_STATUS_INVALID) 3045 + return -EINVAL; 3046 + else if (status != DMUB_STATUS_OK) 3047 + return -EIO; 3048 + } else if (status == DMUB_STATUS_TIMEOUT) { 3049 + return -ETIMEDOUT; 3050 + } else if (status == DMUB_STATUS_INVALID) { 3051 + return -EINVAL; 3052 + } else { 3053 + return -EIO; 3054 + } 3055 + 3056 + usleep_range(100, 1000); 3057 + 3058 + cmd++; 3059 + res |= (raw << shift); 3060 + shift += 16; 3061 + i++; 3062 + } 3063 + 3064 + *val = res; 3065 + 3066 + return 0; 3067 + } 3068 + 3069 + DEFINE_DEBUGFS_ATTRIBUTE(dmub_trace_mask_fops, dmub_trace_mask_show, 3070 + dmub_trace_mask_set, "0x%llx\n"); 3071 + 2974 3072 /* 2975 3073 * Set dmcub trace event IRQ enable or disable. 2976 3074 * Usage to enable dmcub trace event IRQ: echo 1 > /sys/kernel/debug/dri/0/amdgpu_dm_dmcub_trace_event_en ··· 3981 3883 3982 3884 debugfs_create_file_unsafe("amdgpu_dm_force_timing_sync", 0644, root, 3983 3885 adev, &force_timing_sync_ops); 3886 + 3887 + debugfs_create_file_unsafe("amdgpu_dm_dmub_trace_mask", 0644, root, 3888 + adev, &dmub_trace_mask_fops); 3984 3889 3985 3890 debugfs_create_file_unsafe("amdgpu_dm_dmcub_trace_event_en", 0644, root, 3986 3891 adev, &dmcub_trace_event_state_fops);
+38 -2
drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
··· 818 818 * RETURN: Lower 32-bit mask. 819 819 */ 820 820 DMUB_GPINT__UPDATE_TRACE_BUFFER_MASK = 101, 821 + 821 822 /** 822 - * DESC: Updates the trace buffer lower 32-bit mask. 823 + * DESC: Updates the trace buffer mask bit0~bit15. 823 824 * ARGS: The new mask 824 825 * RETURN: Lower 32-bit mask. 825 826 */ 826 827 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD0 = 102, 828 + 827 829 /** 828 - * DESC: Updates the trace buffer mask bi0~bit15. 830 + * DESC: Updates the trace buffer mask bit16~bit31. 829 831 * ARGS: The new mask 830 832 * RETURN: Lower 32-bit mask. 831 833 */ 832 834 DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD1 = 103, 835 + 836 + /** 837 + * DESC: Updates the trace buffer mask bit32~bit47. 838 + * ARGS: The new mask 839 + * RETURN: Lower 32-bit mask. 840 + */ 841 + DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD2 = 114, 842 + 843 + /** 844 + * DESC: Updates the trace buffer mask bit48~bit63. 845 + * ARGS: The new mask 846 + * RETURN: Lower 32-bit mask. 847 + */ 848 + DMUB_GPINT__SET_TRACE_BUFFER_MASK_WORD3 = 115, 849 + 850 + /** 851 + * DESC: Read the trace buffer mask bi0~bit15. 852 + */ 853 + DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD0 = 116, 854 + 855 + /** 856 + * DESC: Read the trace buffer mask bit16~bit31. 857 + */ 858 + DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD1 = 117, 859 + 860 + /** 861 + * DESC: Read the trace buffer mask bi32~bit47. 862 + */ 863 + DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD2 = 118, 864 + 865 + /** 866 + * DESC: Updates the trace buffer mask bit32~bit63. 867 + */ 868 + DMUB_GPINT__GET_TRACE_BUFFER_MASK_WORD3 = 119, 833 869 }; 834 870 835 871 /**