Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2022 Advanced Micro Devices, Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: AMD
0023  *
0024  */
0025 #include "dc_link.h"
0026 #include "link_dp_trace.h"
0027 
0028 void dp_trace_init(struct dc_link *link)
0029 {
0030     memset(&link->dp_trace, 0, sizeof(link->dp_trace));
0031     link->dp_trace.is_initialized = true;
0032 }
0033 
0034 void dp_trace_reset(struct dc_link *link)
0035 {
0036     memset(&link->dp_trace, 0, sizeof(link->dp_trace));
0037 }
0038 
0039 bool dc_dp_trace_is_initialized(struct dc_link *link)
0040 {
0041     return link->dp_trace.is_initialized;
0042 }
0043 
0044 void dp_trace_detect_lt_init(struct dc_link *link)
0045 {
0046     memset(&link->dp_trace.detect_lt_trace, 0, sizeof(link->dp_trace.detect_lt_trace));
0047 }
0048 
0049 void dp_trace_commit_lt_init(struct dc_link *link)
0050 {
0051     memset(&link->dp_trace.commit_lt_trace, 0, sizeof(link->dp_trace.commit_lt_trace));
0052 }
0053 
0054 void dp_trace_link_loss_increment(struct dc_link *link)
0055 {
0056     link->dp_trace.link_loss_count++;
0057 }
0058 
0059 void dp_trace_lt_fail_count_update(struct dc_link *link,
0060         unsigned int fail_count,
0061         bool in_detection)
0062 {
0063     if (in_detection)
0064         link->dp_trace.detect_lt_trace.counts.fail = fail_count;
0065     else
0066         link->dp_trace.commit_lt_trace.counts.fail = fail_count;
0067 }
0068 
0069 void dp_trace_lt_total_count_increment(struct dc_link *link,
0070         bool in_detection)
0071 {
0072     if (in_detection)
0073         link->dp_trace.detect_lt_trace.counts.total++;
0074     else
0075         link->dp_trace.commit_lt_trace.counts.total++;
0076 }
0077 
0078 void dc_dp_trace_set_is_logged_flag(struct dc_link *link,
0079         bool in_detection,
0080         bool is_logged)
0081 {
0082     if (in_detection)
0083         link->dp_trace.detect_lt_trace.is_logged = is_logged;
0084     else
0085         link->dp_trace.commit_lt_trace.is_logged = is_logged;
0086 }
0087 
0088 bool dc_dp_trace_is_logged(struct dc_link *link,
0089         bool in_detection)
0090 {
0091     if (in_detection)
0092         return link->dp_trace.detect_lt_trace.is_logged;
0093     else
0094         return link->dp_trace.commit_lt_trace.is_logged;
0095 }
0096 
0097 void dp_trace_lt_result_update(struct dc_link *link,
0098         enum link_training_result result,
0099         bool in_detection)
0100 {
0101     if (in_detection)
0102         link->dp_trace.detect_lt_trace.result = result;
0103     else
0104         link->dp_trace.commit_lt_trace.result = result;
0105 }
0106 
0107 void dp_trace_set_lt_start_timestamp(struct dc_link *link,
0108         bool in_detection)
0109 {
0110     if (in_detection)
0111         link->dp_trace.detect_lt_trace.timestamps.start = dm_get_timestamp(link->dc->ctx);
0112     else
0113         link->dp_trace.commit_lt_trace.timestamps.start = dm_get_timestamp(link->dc->ctx);
0114 }
0115 
0116 void dp_trace_set_lt_end_timestamp(struct dc_link *link,
0117         bool in_detection)
0118 {
0119     if (in_detection)
0120         link->dp_trace.detect_lt_trace.timestamps.end = dm_get_timestamp(link->dc->ctx);
0121     else
0122         link->dp_trace.commit_lt_trace.timestamps.end = dm_get_timestamp(link->dc->ctx);
0123 }
0124 
0125 unsigned long long dc_dp_trace_get_lt_end_timestamp(struct dc_link *link,
0126         bool in_detection)
0127 {
0128     if (in_detection)
0129         return link->dp_trace.detect_lt_trace.timestamps.end;
0130     else
0131         return link->dp_trace.commit_lt_trace.timestamps.end;
0132 }
0133 
0134 struct dp_trace_lt_counts *dc_dp_trace_get_lt_counts(struct dc_link *link,
0135         bool in_detection)
0136 {
0137     if (in_detection)
0138         return &link->dp_trace.detect_lt_trace.counts;
0139     else
0140         return &link->dp_trace.commit_lt_trace.counts;
0141 }
0142 
0143 unsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link)
0144 {
0145     return link->dp_trace.link_loss_count;
0146 }
0147 
0148 void dp_trace_set_edp_power_timestamp(struct dc_link *link,
0149         bool power_up)
0150 {
0151     if (!power_up)
0152         /*save driver power off time stamp*/
0153         link->dp_trace.edp_trace_power_timestamps.poweroff = dm_get_timestamp(link->dc->ctx);
0154     else
0155         link->dp_trace.edp_trace_power_timestamps.poweron = dm_get_timestamp(link->dc->ctx);
0156 }
0157 
0158 uint64_t dp_trace_get_edp_poweron_timestamp(struct dc_link *link)
0159 {
0160     return link->dp_trace.edp_trace_power_timestamps.poweron;
0161 }
0162 
0163 uint64_t dp_trace_get_edp_poweroff_timestamp(struct dc_link *link)
0164 {
0165     return link->dp_trace.edp_trace_power_timestamps.poweroff;
0166 }