]> mj.ucw.cz Git - pciutils.git/commitdiff
pcilmr: Add handling of situations when device reports its MaxOffset values equal...
authorNikita Proshkin <n.proshkin@yadro.com>
Wed, 27 Dec 2023 09:45:03 +0000 (14:45 +0500)
committerMartin Mares <mj@ucw.cz>
Sat, 17 Feb 2024 22:44:53 +0000 (23:44 +0100)
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@yadro.com>
Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
lmr/lmr.h
lmr/margin.c
lmr/margin_log.c
lmr/margin_results.c

index c9dcd69899a624884bbfb75a7a84fea43cc9fb1c..7375c33f6358a7b676c4c00daee000309aa0fc78 100644 (file)
--- 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;
 };
index cc142fa17bfbf1eb9c1a7c79114fa9f71442aed9..0b14747edf0314a2ca6d31dee2d9b00aa9131a91 100644 (file)
@@ -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;
index a93e07b5df468b0d131576cfc0b0fcd087758eee..b3c4bd562d0ec54bc50300d0a32f4cdb27ecf964 100644 (file)
@@ -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
index aca3ab739c2b0259755c9733d6e94194c7c01465..6d6ed29cd193f8693a88df5a1138e363a0dda086 100644 (file)
@@ -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