diff mbox series

[pciutils,4/6] pcilmr: Add option to configure margining dwell time

Message ID 20240522160634.29831-5-n.proshkin@yadro.com (mailing list archive)
State Handled Elsewhere
Delegated to: Bjorn Helgaas
Headers show
Series pcilmr: Improve grading of the margining results | expand

Commit Message

Nikita Proshkin May 22, 2024, 4:06 p.m. UTC
Signed-off-by: Nikita Proshkin <n.proshkin@yadro.com>
---
 lmr/lmr.h         | 4 ++--
 lmr/margin.c      | 5 +++--
 lmr/margin_args.c | 6 +++++-
 lmr/margin_log.c  | 7 ++++---
 4 files changed, 14 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/lmr/lmr.h b/lmr/lmr.h
index da40bfe..f070309 100644
--- a/lmr/lmr.h
+++ b/lmr/lmr.h
@@ -15,8 +15,6 @@ 
 
 #include "pciutils.h"
 
-#define MARGIN_STEP_MS 1000
-
 enum margin_hw { MARGIN_HW_DEFAULT, MARGIN_ICE_LAKE_RC };
 
 // in ps
@@ -119,6 +117,7 @@  struct margin_com_args {
   u64 steps_utility; // For ETA logging
   bool save_csv;
   char *dir_for_csv;
+  u8 dwell_time;
 };
 
 struct margin_recv_args {
@@ -157,6 +156,7 @@  struct margin_recv {
 
   u8 parallel_lanes;
   u8 error_limit;
+  u8 dwell_time;
 };
 
 struct margin_lanes_data {
diff --git a/lmr/margin.c b/lmr/margin.c
index e2ea300..6ce4fe6 100644
--- a/lmr/margin.c
+++ b/lmr/margin.c
@@ -260,7 +260,7 @@  margin_test_lanes(struct margin_lanes_data arg)
               pci_write_word(arg.recv->dev->dev, ctrl_addr, step_cmd);
             }
         }
-      msleep(MARGIN_STEP_MS);
+      msleep(arg.recv->dwell_time * 1000);
 
       for (int i = 0; i < arg.lanes_n; i++)
         {
@@ -312,7 +312,8 @@  margin_test_receiver(struct margin_dev *dev, u8 recvn, struct margin_link_args *
                               .lane_reversal = false,
                               .params = &params,
                               .parallel_lanes = args->parallel_lanes ? args->parallel_lanes : 1,
-                              .error_limit = args->common->error_limit };
+                              .error_limit = args->common->error_limit,
+                              .dwell_time = args->common->dwell_time };
 
   results->recvn = recvn;
   results->lanes_n = lanes_n;
diff --git a/lmr/margin_args.c b/lmr/margin_args.c
index 484c58f..8a6345f 100644
--- a/lmr/margin_args.c
+++ b/lmr/margin_args.c
@@ -229,9 +229,10 @@  margin_parse_util_args(struct pci_access *pacc, int argc, char **argv, enum marg
   com_args->steps_utility = 0;
   com_args->dir_for_csv = NULL;
   com_args->save_csv = false;
+  com_args->dwell_time = 1;
 
   int c;
-  while ((c = getopt(argc, argv, "+e:co:")) != -1)
+  while ((c = getopt(argc, argv, "+e:co:d:")) != -1)
     {
       switch (c)
         {
@@ -245,6 +246,9 @@  margin_parse_util_args(struct pci_access *pacc, int argc, char **argv, enum marg
             com_args->dir_for_csv = optarg;
             com_args->save_csv = true;
             break;
+          case 'd':
+            com_args->dwell_time = atoi(optarg);
+            break;
           default:
             die("Invalid arguments\n\n%s", usage);
         }
diff --git a/lmr/margin_log.c b/lmr/margin_log.c
index 6fa4f09..88e3594 100644
--- a/lmr/margin_log.c
+++ b/lmr/margin_log.c
@@ -88,7 +88,8 @@  void
 margin_log_receiver(struct margin_recv *recv)
 {
   margin_log("\nError Count Limit = %d\n", recv->error_limit);
-  margin_log("Parallel Lanes: %d\n\n", recv->parallel_lanes);
+  margin_log("Parallel Lanes: %d\n", recv->parallel_lanes);
+  margin_log("Margining dwell time: %d s\n\n", recv->dwell_time);
 
   margin_log_params(recv->params);
 
@@ -143,8 +144,8 @@  margin_log_margining(struct margin_lanes_data arg)
         }
       margin_log("]");
 
-      u64 lane_eta_s = (arg.steps_lane_total - arg.steps_lane_done) * MARGIN_STEP_MS / 1000;
-      u64 total_eta_s = *arg.steps_utility * MARGIN_STEP_MS / 1000 + lane_eta_s;
+      u64 lane_eta_s = (arg.steps_lane_total - arg.steps_lane_done) * arg.recv->dwell_time;
+      u64 total_eta_s = *arg.steps_utility * arg.recv->dwell_time + lane_eta_s;
       margin_log(" - ETA: %3ds Steps: %3d Total ETA: %3dm %2ds", lane_eta_s, arg.steps_lane_done,
                  total_eta_s / 60, total_eta_s % 60);