From 3c5eb532ada8d2efc5e59117b73020fbb6a93aae Mon Sep 17 00:00:00 2001 From: Brian Norris Date: Tue, 27 Feb 2024 13:06:52 -0800 Subject: [PATCH] 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/80772 Tested-by: build bot (Jenkins) Reviewed-by: Hsuan-ting Chen Reviewed-by: Nikolai Artemiev Reviewed-by: Anastasia Klimchuk --- cli_classic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli_classic.c b/cli_classic.c index 60f3fd508..ffded5f21 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -917,10 +917,6 @@ int main(int argc, char *argv[]) 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 @@ int main(int argc, char *argv[]) } } + /* 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;