According to spec, for the MaxTimingOffset and MaxVoltageOffset parameters 'A 0 value may be reported if the vendor chooses not to report the offset'. Use max possible Offset value in such situations and report to the user. Reviewed-by: Sergei Miroshnichenko <s.miroshnichenko@xxxxxxxxx> Signed-off-by: Nikita Proshkin <n.proshkin@xxxxxxxxx> --- lmr/lmr.h | 3 +++ lmr/margin.c | 9 +++++++-- lmr/margin_log.c | 7 +++++++ lmr/margin_results.c | 13 +++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lmr/lmr.h b/lmr/lmr.h index c9dcd69..7375c33 100644 --- a/lmr/lmr.h +++ b/lmr/lmr.h @@ -107,6 +107,9 @@ struct margin_results { double tim_coef; double volt_coef; + bool tim_off_reported; + bool volt_off_reported; + u8 lanes_n; struct margin_res_lane *lanes; }; diff --git a/lmr/margin.c b/lmr/margin.c index cc142fa..0b14747 100644 --- a/lmr/margin.c +++ b/lmr/margin.c @@ -328,8 +328,13 @@ margin_test_receiver(struct margin_dev *dev, u8 recvn, struct margin_args *args, margin_apply_hw_quirks(&recv); margin_log_hw_quirks(&recv); - results->tim_coef = (double)params.timing_offset / (double)params.timing_steps; - results->volt_coef = (double)params.volt_offset / (double)params.volt_steps * 10.0; + results->tim_off_reported = params.timing_offset != 0; + results->volt_off_reported = params.volt_offset != 0; + double tim_offset = results->tim_off_reported ? (double)params.timing_offset : 50.0; + double volt_offset = results->volt_off_reported ? (double)params.volt_offset : 50.0; + + results->tim_coef = tim_offset / (double)params.timing_steps; + results->volt_coef = volt_offset / (double)params.volt_steps * 10.0; results->lane_reversal = recv.lane_reversal; results->link_speed = dev->link_speed; diff --git a/lmr/margin_log.c b/lmr/margin_log.c index a93e07b..b3c4bd5 100644 --- a/lmr/margin_log.c +++ b/lmr/margin_log.c @@ -86,6 +86,13 @@ margin_log_receiver(struct margin_recv *recv) margin_log("\nWarning: device uses Lane Reversal.\n"); margin_log("However, utility uses logical lane numbers in arguments and for logging.\n"); } + + if (recv->params->timing_offset == 0) + margin_log("\nWarning: Vendor chose not to report the Max Timing Offset.\n" + "Utility will use its max possible value - 50 (50%% UI).\n"); + if (recv->params->volt_support && recv->params->volt_offset == 0) + margin_log("\nWarning: Vendor chose not to report the Max Voltage Offset.\n" + "Utility will use its max possible value - 50 (500 mV).\n"); } void diff --git a/lmr/margin_results.c b/lmr/margin_results.c index aca3ab7..6d6ed29 100644 --- a/lmr/margin_results.c +++ b/lmr/margin_results.c @@ -105,6 +105,19 @@ margin_results_print_brief(struct margin_results *results, u8 recvs_n) if (res->lane_reversal) printf("Rx(%X) - Lane Reversal\n", 10 + res->recvn - 1); + if (!res->tim_off_reported) + printf("Rx(%X) - Attention: Vendor chose not to report the Max Timing Offset.\n" + "Utility used its max possible value (50%% UI) for calculations of %% UI and ps.\n" + "Keep in mind that for timing results of this receiver only steps values are " + "reliable.\n\n", + 10 + res->recvn - 1); + if (params.volt_support && !res->volt_off_reported) + printf("Rx(%X) - Attention: Vendor chose not to report the Max Voltage Offset.\n" + "Utility used its max possible value (500 mV) for calculations of mV.\n" + "Keep in mind that for voltage results of this receiver only steps values are " + "reliable.\n\n", + 10 + res->recvn - 1); + if (check_recv_weird(res, MARGIN_TIM_MIN, MARGIN_VOLT_MIN)) lane_rating = WEIRD; else -- 2.34.1