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

drm/amd/display: Add function and debugfs to dump DCC_EN bit

[why]
Currently to view the DCC_EN bit the entire DTN log
must be dumped. A compact method to view the DCC_EN
bit is desirable.

[how]
Introduce new debugfs interface that only dumps the
DCC_EN bit.

Example usage:
cat /sys/kernel/debug/dri/0/amdgpu_dm_dcc_en

Signed-off-by: Victor Lu <victorchengchi.lu@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Qingqing Zhuo <qingqing.zhuo@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Victor Lu and committed by
Alex Deucher
712343cd ad0d8ebc

+96 -5
+66
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
··· 3043 3043 DEFINE_DEBUGFS_ATTRIBUTE(visual_confirm_fops, visual_confirm_get, 3044 3044 visual_confirm_set, "%llu\n"); 3045 3045 3046 + /* 3047 + * Dumps the DCC_EN bit for each pipe. 3048 + * Example usage: cat /sys/kernel/debug/dri/0/amdgpu_dm_dcc_en 3049 + */ 3050 + static ssize_t dcc_en_bits_read( 3051 + struct file *f, 3052 + char __user *buf, 3053 + size_t size, 3054 + loff_t *pos) 3055 + { 3056 + struct amdgpu_device *adev = file_inode(f)->i_private; 3057 + struct dc *dc = adev->dm.dc; 3058 + char *rd_buf = NULL; 3059 + const uint32_t rd_buf_size = 32; 3060 + uint32_t result = 0; 3061 + int offset = 0; 3062 + int num_pipes = dc->res_pool->pipe_count; 3063 + int *dcc_en_bits; 3064 + int i, r; 3065 + 3066 + dcc_en_bits = kcalloc(num_pipes, sizeof(int), GFP_KERNEL); 3067 + if (!dcc_en_bits) 3068 + return -ENOMEM; 3069 + 3070 + if (!dc->hwss.get_dcc_en_bits) { 3071 + kfree(dcc_en_bits); 3072 + return 0; 3073 + } 3074 + 3075 + dc->hwss.get_dcc_en_bits(dc, dcc_en_bits); 3076 + 3077 + rd_buf = kcalloc(rd_buf_size, sizeof(char), GFP_KERNEL); 3078 + if (!rd_buf) 3079 + return -ENOMEM; 3080 + 3081 + for (i = 0; i < num_pipes; i++) 3082 + offset += snprintf(rd_buf + offset, rd_buf_size - offset, 3083 + "%d ", dcc_en_bits[i]); 3084 + rd_buf[strlen(rd_buf)] = '\n'; 3085 + 3086 + kfree(dcc_en_bits); 3087 + 3088 + while (size) { 3089 + if (*pos >= rd_buf_size) 3090 + break; 3091 + r = put_user(*(rd_buf + result), buf); 3092 + if (r) 3093 + return r; /* r = -EFAULT */ 3094 + buf += 1; 3095 + size -= 1; 3096 + *pos += 1; 3097 + result += 1; 3098 + } 3099 + 3100 + kfree(rd_buf); 3101 + return result; 3102 + } 3103 + 3046 3104 void dtn_debugfs_init(struct amdgpu_device *adev) 3047 3105 { 3048 3106 static const struct file_operations dtn_log_fops = { 3049 3107 .owner = THIS_MODULE, 3050 3108 .read = dtn_log_read, 3051 3109 .write = dtn_log_write, 3110 + .llseek = default_llseek 3111 + }; 3112 + static const struct file_operations dcc_en_bits_fops = { 3113 + .owner = THIS_MODULE, 3114 + .read = dcc_en_bits_read, 3052 3115 .llseek = default_llseek 3053 3116 }; 3054 3117 ··· 3141 3078 3142 3079 debugfs_create_file_unsafe("amdgpu_dm_dmcub_trace_event_en", 0644, root, 3143 3080 adev, &dmcub_trace_event_state_fops); 3081 + 3082 + debugfs_create_file_unsafe("amdgpu_dm_dcc_en", 0644, root, adev, 3083 + &dcc_en_bits_fops); 3144 3084 }
+16
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 3979 3979 dc->clk_mgr->funcs->get_clock(dc->clk_mgr, context, clock_type, clock_cfg); 3980 3980 3981 3981 } 3982 + 3983 + void dcn10_get_dcc_en_bits(struct dc *dc, int *dcc_en_bits) 3984 + { 3985 + struct resource_pool *pool = dc->res_pool; 3986 + int i; 3987 + 3988 + for (i = 0; i < pool->pipe_count; i++) { 3989 + struct hubp *hubp = pool->hubps[i]; 3990 + struct dcn_hubp_state *s = &(TO_DCN10_HUBP(hubp)->state); 3991 + 3992 + hubp->funcs->hubp_read_state(hubp); 3993 + 3994 + if (!s->blank_en) 3995 + dcc_en_bits[i] = s->dcc_en ? 1 : 0; 3996 + } 3997 + }
+3 -1
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.h
··· 1 1 /* 2 - * Copyright 2016 Advanced Micro Devices, Inc. 2 + * Copyright 2016-2020 Advanced Micro Devices, Inc. 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 208 208 struct dc_state *context); 209 209 void dcn10_set_hdr_multiplier(struct pipe_ctx *pipe_ctx); 210 210 void dcn10_verify_allow_pstate_change_high(struct dc *dc); 211 + 212 + void dcn10_get_dcc_en_bits(struct dc *dc, int *dcc_en_bits); 211 213 212 214 #endif /* __DC_HWSS_DCN10_H__ */
+2 -1
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_init.c
··· 1 1 /* 2 - * Copyright 2016 Advanced Micro Devices, Inc. 2 + * Copyright 2016-2020 Advanced Micro Devices, Inc. 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 79 79 .set_backlight_level = dce110_set_backlight_level, 80 80 .set_abm_immediate_disable = dce110_set_abm_immediate_disable, 81 81 .set_pipe = dce110_set_pipe, 82 + .get_dcc_en_bits = dcn10_get_dcc_en_bits, 82 83 }; 83 84 84 85 static const struct hwseq_private_funcs dcn10_private_funcs = {
+1
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_init.c
··· 95 95 .optimize_timing_for_fsft = dcn20_optimize_timing_for_fsft, 96 96 #endif 97 97 .set_disp_pattern_generator = dcn20_set_disp_pattern_generator, 98 + .get_dcc_en_bits = dcn10_get_dcc_en_bits, 98 99 }; 99 100 100 101 static const struct hwseq_private_funcs dcn20_private_funcs = {
+2 -1
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_init.c
··· 1 1 /* 2 - * Copyright 2016 Advanced Micro Devices, Inc. 2 + * Copyright 2016-2020 Advanced Micro Devices, Inc. 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 99 99 #endif 100 100 .is_abm_supported = dcn21_is_abm_supported, 101 101 .set_disp_pattern_generator = dcn20_set_disp_pattern_generator, 102 + .get_dcc_en_bits = dcn10_get_dcc_en_bits, 102 103 }; 103 104 104 105 static const struct hwseq_private_funcs dcn21_private_funcs = {
+2 -1
drivers/gpu/drm/amd/display/dc/dcn30/dcn30_init.c
··· 1 1 /* 2 - * Copyright 2020 Advanced Micro Devices, Inc. 2 + * Copyright 2016-2020 Advanced Micro Devices, Inc. 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 98 98 .hardware_release = dcn30_hardware_release, 99 99 .set_pipe = dcn21_set_pipe, 100 100 .set_disp_pattern_generator = dcn30_set_disp_pattern_generator, 101 + .get_dcc_en_bits = dcn10_get_dcc_en_bits, 101 102 }; 102 103 103 104 static const struct hwseq_private_funcs dcn30_private_funcs = {
+2 -1
drivers/gpu/drm/amd/display/dc/dcn301/dcn301_init.c
··· 1 1 /* 2 - * Copyright 2020 Advanced Micro Devices, Inc. 2 + * Copyright 2016-2020 Advanced Micro Devices, Inc. 3 3 * 4 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 5 * copy of this software and associated documentation files (the "Software"), ··· 98 98 .set_abm_immediate_disable = dcn21_set_abm_immediate_disable, 99 99 .set_pipe = dcn21_set_pipe, 100 100 .set_disp_pattern_generator = dcn30_set_disp_pattern_generator, 101 + .get_dcc_en_bits = dcn10_get_dcc_en_bits, 101 102 }; 102 103 103 104 static const struct hwseq_private_funcs dcn301_private_funcs = {
+2
drivers/gpu/drm/amd/display/dc/inc/hw_sequencer.h
··· 217 217 218 218 void (*set_pipe)(struct pipe_ctx *pipe_ctx); 219 219 220 + void (*get_dcc_en_bits)(struct dc *dc, int *dcc_en_bits); 221 + 220 222 /* Idle Optimization Related */ 221 223 bool (*apply_idle_power_optimizations)(struct dc *dc, bool enable); 222 224