Anastasia Klimchuk submitted this change.

View Change

Approvals: Anastasia Klimchuk: Looks good to me, approved build bot (Jenkins): Verified Nikolai Artemiev: Looks good to me, approved Hsuan-ting Chen: Looks good to me, approved
cli_classic: Defer flashrom_init calibration until after options parsing

flashrom_init() may run through an expensive delay calibration phase,
depending on the system timer behavior (e.g., if high resolution timers
are disabled). This is wholly unnecessary if we're only going to dump
usage output or similar.

Defer the calibration until we've finished our CLI overhead.

BUG=b:325539928
TEST=`flashrom --help` with `sysctl kernel.timer_highres` == 0

Change-Id: I57949ab511df04c6922008fa8cb12467154e2c5e
Signed-off-by: Brian Norris <briannorris@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/80772
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Hsuan-ting Chen <roccochen@google.com>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
---
M cli_classic.c
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/cli_classic.c b/cli_classic.c
index 60f3fd5..ffded5f 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -917,10 +917,6 @@
print_version();
print_banner();

- /* FIXME: Delay calibration should happen in programmer code. */
- if (flashrom_init(1))
- exit(1);
-
setbuf(stdout, NULL);

parse_options(argc, argv, optstring, long_options, &options);
@@ -1005,6 +1001,10 @@
}
}

+ /* FIXME: Delay calibration should happen in programmer code. */
+ if (flashrom_init(1))
+ exit(1);
+
if (programmer_init(options.prog, options.pparam)) {
msg_perr("Error: Programmer initialization failed.\n");
ret = 1;

To view, visit change 80772. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: I57949ab511df04c6922008fa8cb12467154e2c5e
Gerrit-Change-Number: 80772
Gerrit-PatchSet: 3
Gerrit-Owner: Brian Norris <briannorris@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Hsuan-ting Chen <roccochen@google.com>
Gerrit-Reviewer: Nikolai Artemiev <nartemiev@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged