diff --git a/apps/baremetal/acs.h b/apps/baremetal/acs.h index 3e492885..ad61303c 100644 --- a/apps/baremetal/acs.h +++ b/apps/baremetal/acs.h @@ -118,7 +118,6 @@ extern uint32_t g_acs_tests_fail; extern uint64_t g_stack_pointer; extern uint64_t g_exception_ret_addr; extern uint64_t g_ret_addr; -extern uint32_t g_wakeup_timeout; extern bool g_pcie_skip_dp_nic_ms; extern uint32_t g_build_sbsa; extern uint32_t g_build_pcbsa; diff --git a/apps/baremetal/acs_globals.c b/apps/baremetal/acs_globals.c index 8f319931..2085b87b 100644 --- a/apps/baremetal/acs_globals.c +++ b/apps/baremetal/acs_globals.c @@ -29,7 +29,6 @@ uint32_t g_enable_module; uint32_t g_acs_tests_total; uint32_t g_acs_tests_pass; uint32_t g_acs_tests_fail; -uint32_t g_wakeup_timeout; uint32_t g_build_sbsa = 0; uint32_t g_build_pcbsa = 0; uint32_t g_its_init = 0; diff --git a/apps/baremetal/bsa_main.c b/apps/baremetal/bsa_main.c index 9fa34b37..2ab607b5 100644 --- a/apps/baremetal/bsa_main.c +++ b/apps/baremetal/bsa_main.c @@ -86,10 +86,8 @@ uint32_t apply_user_config_and_defaults(void) g_skip_modules = g_skip_modules_arr; } - /* Set default values for g_print_mmio and g_wakeup_timeout */ + /* Set default values for g_print_mmio */ g_print_mmio = 0; - g_wakeup_timeout = 1; - /* If selected rule count is zero, default to BSA */ if (g_rule_count == 0) { /* Standalone BSA Baremetal app, set g_arch_selection to BSA */ diff --git a/apps/baremetal/pc_bsa_main.c b/apps/baremetal/pc_bsa_main.c index 90c32767..b0139c32 100644 --- a/apps/baremetal/pc_bsa_main.c +++ b/apps/baremetal/pc_bsa_main.c @@ -99,9 +99,8 @@ apply_user_config_and_defaults(void) g_skip_modules = g_skip_modules_arr; } - /* Set default values for g_print_mmio and g_wakeup_timeout */ + /* Set default values for g_print_mmio */ g_print_mmio = 0; - g_wakeup_timeout = 1; /* If selected rule count is zero, default to PCBSA */ if (g_rule_count == 0) { diff --git a/apps/baremetal/sbsa_main.c b/apps/baremetal/sbsa_main.c index d564cf44..cfa7eada 100644 --- a/apps/baremetal/sbsa_main.c +++ b/apps/baremetal/sbsa_main.c @@ -104,9 +104,8 @@ uint32_t apply_user_config_and_defaults(void) g_skip_modules = g_skip_modules_arr; } - /* Set default values for g_print_mmio, g_wakeup_timeout */ + /* Set default values for g_print_mmio */ g_print_mmio = 0; - g_wakeup_timeout = 1; /* If selected rule count is zero, default to SBSA */ if (g_rule_count == 0) { diff --git a/apps/uefi/acs.h b/apps/uefi/acs.h index 8d320069..83155218 100644 --- a/apps/uefi/acs.h +++ b/apps/uefi/acs.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2016-2025, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2016-2026, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * Licensed under the Apache License, Version 2.0 (the "License"); @@ -152,7 +152,8 @@ extern UINT32 g_num_skip; extern UINT64 g_stack_pointer; extern UINT64 g_exception_ret_addr; extern UINT64 g_ret_addr; -extern UINT32 g_wakeup_timeout; +extern UINT32 g_timeout_pass; +extern UINT32 g_timeout_fail; extern UINT32 g_build_sbsa; extern UINT32 g_build_pcbsa; extern UINT32 g_print_mmio; diff --git a/apps/uefi/acs_globals.c b/apps/uefi/acs_globals.c index e726348f..6bcd3c4f 100644 --- a/apps/uefi/acs_globals.c +++ b/apps/uefi/acs_globals.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2025-2026, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +32,8 @@ UINT32 g_num_skip; UINT64 g_stack_pointer; UINT64 g_exception_ret_addr; UINT64 g_ret_addr; -UINT32 g_wakeup_timeout; +UINT32 g_timeout_pass; +UINT32 g_timeout_fail; /* Following g_build_* is retained to have compatibility with tests which use it, and used pass on -a selection hint to tests */ diff --git a/apps/uefi/acs_helpers.c b/apps/uefi/acs_helpers.c index 8b8c51dd..e48423ce 100644 --- a/apps/uefi/acs_helpers.c +++ b/apps/uefi/acs_helpers.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2025-2026, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * Licensed under the Apache License, Version 2.0 (the "License"); @@ -548,12 +548,46 @@ command_init (void) /* Parse -timeout */ CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-timeout"); if (CmdLineArg == NULL) { - g_wakeup_timeout = 1; + g_timeout_pass = WAKEUP_WD_PASS_TIMEOUT_DEFAULT; + g_timeout_fail = g_timeout_pass * WAKEUP_WD_FAILSAFE_TIMEOUT_MULTIPLIER; } else { - g_wakeup_timeout = StrDecimalToUintn(CmdLineArg); - Print(L"Wakeup timeout multiple %d.\n", g_wakeup_timeout); - if (g_wakeup_timeout > 5) - g_wakeup_timeout = 5; + /* Accept a single value; ignore any trailing delimiters */ + CHAR16 buf[64]; + UINTN len = StrLen(CmdLineArg); + UINTN i; + + if (len >= (sizeof(buf) / sizeof(buf[0]))) + len = (sizeof(buf) / sizeof(buf[0])) - 1; + + for (i = 0; i < len; i++) { + buf[i] = CmdLineArg[i]; + } + buf[i] = L'\0'; + + if (i == 0) { + Print(L"Invalid -timeout: provide a timeout value\n"); + return SHELL_INVALID_PARAMETER; + } + + /* trim leading/trailing spaces */ + while (buf[0] == L' ' || buf[0] == L'\t') { + for (i = 0; buf[i] != L'\0'; i++) buf[i] = buf[i + 1]; + } + i = StrLen(buf); + while (i > 0 && (buf[i - 1] == L' ' || buf[i - 1] == L'\t')) { + buf[i - 1] = L'\0'; + i--; + } + + g_timeout_pass = (UINT32)StrDecimalToUintn(buf); + g_timeout_fail = g_timeout_pass * WAKEUP_WD_FAILSAFE_TIMEOUT_MULTIPLIER; + if (!(g_timeout_pass >= WAKEUP_WD_PASS_TIMEOUT_THRESHOLD && + g_timeout_pass <= WAKEUP_WD_PASS_TIMEOUT_MAX_THRESHOLD)) { + Print(L"Invalid -timeout: pass timeout range should be within 500ms and 2sec\n"); + return SHELL_INVALID_PARAMETER; + } + + Print(L"Timeouts (us): PASS=%d, FAIL=%d\n", g_timeout_pass, g_timeout_fail); } /* Parse verbosity level */ diff --git a/apps/uefi/bsa_main.c b/apps/uefi/bsa_main.c index 89fc4416..4458fe53 100644 --- a/apps/uefi/bsa_main.c +++ b/apps/uefi/bsa_main.c @@ -102,8 +102,8 @@ HelpMsg (VOID) " Skip the specified modules (comma-separated names).\n" " Example: -skipmodule PE,GIC,PCIE\n" "-timeout \n" - " Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value, Defaults to 1 \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-v Verbosity of the prints\n" " 1 prints all, 5 prints only the errors\n"); } diff --git a/apps/uefi/mem_test_main.c b/apps/uefi/mem_test_main.c index 7297218a..86cee25b 100644 --- a/apps/uefi/mem_test_main.c +++ b/apps/uefi/mem_test_main.c @@ -50,7 +50,8 @@ UINT32 g_acs_tests_fail; UINT64 g_stack_pointer; UINT64 g_exception_ret_addr; UINT64 g_ret_addr; -UINT32 g_wakeup_timeout; +UINT32 g_timeout_pass; +UINT32 g_timeout_fail; UINT32 g_build_sbsa = 0; UINT32 g_build_pcbsa = 0; UINT32 g_print_mmio; @@ -100,8 +101,9 @@ HelpMsg ( "-no_crypto_ext Pass this flag if cryptography extension not supported due to export restrictions\n" "-p2p Pass this flag to indicate that PCIe Hierarchy Supports Peer-to-Peer\n" "-cache Pass this flag to indicate that if the test system supports PCIe address translation cache\n" - "-timeout Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value\n" + "-timeout \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-os Enable the execution of operating system tests\n" "-hyp Enable the execution of hypervisor tests\n" "-ps Enable the execution of platform security tests\n" @@ -204,16 +206,50 @@ command_init () } } - // Options with Values + /* Parse -timeout */ CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-timeout"); if (CmdLineArg == NULL) { - g_wakeup_timeout = 1; + g_timeout_pass = WAKEUP_WD_PASS_TIMEOUT_DEFAULT; + g_timeout_fail = g_timeout_pass * WAKEUP_WD_FAILSAFE_TIMEOUT_MULTIPLIER; } else { - g_wakeup_timeout = StrDecimalToUintn(CmdLineArg); - Print(L"Wakeup timeout multiple %d.\n", g_wakeup_timeout); - if (g_wakeup_timeout > 5) - g_wakeup_timeout = 5; - } + /* Accept a single value; ignore any trailing delimiters */ + CHAR16 buf[64]; + UINTN len = StrLen(CmdLineArg); + UINTN i; + + if (len >= (sizeof(buf) / sizeof(buf[0]))) + len = (sizeof(buf) / sizeof(buf[0])) - 1; + + for (i = 0; i < len; i++) { + buf[i] = CmdLineArg[i]; + } + buf[i] = L'\0'; + + if (i == 0) { + Print(L"Invalid -timeout: provide a timeout value\n"); + return SHELL_INVALID_PARAMETER; + } + + /* trim leading/trailing spaces */ + while (buf[0] == L' ' || buf[0] == L'\t') { + for (i = 0; buf[i] != L'\0'; i++) buf[i] = buf[i + 1]; + } + i = StrLen(buf); + while (i > 0 && (buf[i - 1] == L' ' || buf[i - 1] == L'\t')) { + buf[i - 1] = L'\0'; + i--; + } + + g_timeout_pass = (UINT32)StrDecimalToUintn(buf); + g_timeout_fail = g_timeout_pass * WAKEUP_WD_FAILSAFE_TIMEOUT_MULTIPLIER; + if (!(g_timeout_pass >= WAKEUP_WD_PASS_TIMEOUT_THRESHOLD && + g_timeout_pass <= WAKEUP_WD_PASS_TIMEOUT_MAX_THRESHOLD)) { + Print(L"Invalid -timeout: pass timeout range should be within 500ms and 2sec\n"); + return SHELL_INVALID_PARAMETER; + } + + Print(L"Timeouts (us): PASS=%d, FAIL=%d\n", g_timeout_pass, g_timeout_fail); + } // Options with Values CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-v"); diff --git a/apps/uefi/pc_bsa_main.c b/apps/uefi/pc_bsa_main.c index 27f4315e..44cd4718 100644 --- a/apps/uefi/pc_bsa_main.c +++ b/apps/uefi/pc_bsa_main.c @@ -81,8 +81,8 @@ HelpMsg (VOID) " Skip the specified modules (comma-separated names).\n" " Example: -skipmodule PE,GIC,PCIE\n" "-timeout \n" - " Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value, Defaults to 1 \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-v Verbosity of the prints\n" " 1 prints all, 5 prints only the errors\n"); } diff --git a/apps/uefi/sbsa_main.c b/apps/uefi/sbsa_main.c index ec8084a5..1695605c 100644 --- a/apps/uefi/sbsa_main.c +++ b/apps/uefi/sbsa_main.c @@ -95,8 +95,8 @@ HelpMsg (VOID) "-slc Provide system last level cache type\n" " 1 - PPTT PE-side cache, 2 - HMAT mem-side cache\n" "-timeout \n" - " Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value, Defaults to 1 \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-v Verbosity of the prints\n" " 1 prints all, 5 prints only the errors\n"); } diff --git a/apps/uefi/sbsa_nist_main.c b/apps/uefi/sbsa_nist_main.c index 40f91722..a8a6ec10 100644 --- a/apps/uefi/sbsa_nist_main.c +++ b/apps/uefi/sbsa_nist_main.c @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2025, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2025-2026, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * Licensed under the Apache License, Version 2.0 (the "License"); @@ -315,8 +315,9 @@ HelpMsg ( "-no_crypto_ext Pass this flag if cryptography extension not supported due to export restrictions\n" "-p2p Pass this flag to indicate that PCIe Hierarchy Supports Peer-to-Peer\n" "-cache Pass this flag to indicate that if the test system supports PCIe address translation cache\n" - "-timeout Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value\n" + "-timeout \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-slc Provide system last level cache type\n" " 1 - PPTT PE-side cache, 2 - HMAT mem-side cache\n" " defaults to 0, if not set depicting SLC type unknown\n" diff --git a/apps/uefi/vbsa_main.c b/apps/uefi/vbsa_main.c index 409233e2..0f8fd10a 100644 --- a/apps/uefi/vbsa_main.c +++ b/apps/uefi/vbsa_main.c @@ -89,8 +89,8 @@ HelpMsg (VOID) "-skip-dp-nic-ms \n" " Skip PCIe tests for DisplayPort, Network, Mass Storage devices and Unclassified devices\n" "-timeout \n" - " Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value, Defaults to 1 \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-v Verbosity of the prints\n" " 1 prints all, 5 prints only the errors\n"); } diff --git a/apps/uefi/xbsa_main.c b/apps/uefi/xbsa_main.c index 8ea87472..9125c73e 100644 --- a/apps/uefi/xbsa_main.c +++ b/apps/uefi/xbsa_main.c @@ -122,8 +122,8 @@ HelpMsg (VOID) " Skip the specified modules (comma-separated names).\n" " Example: -skipmodule PE,GIC,PCIE\n" "-timeout \n" - " Set timeout multiple for wakeup tests\n" - " 1 - min value 5 - max value, Defaults to 1 \n" + " Set pass timeout (in microseconds) for wakeup tests (500 us - 2 sec)\n" + " Example: -timeout 2000 \n" "-v Verbosity of the prints\n" " 1 prints all, 5 prints only the errors\n" ); diff --git a/pal/baremetal/target/RDN2/include/platform_override_fvp.h b/pal/baremetal/target/RDN2/include/platform_override_fvp.h index 040ff14c..6bb9f6c4 100644 --- a/pal/baremetal/target/RDN2/include/platform_override_fvp.h +++ b/pal/baremetal/target/RDN2/include/platform_override_fvp.h @@ -261,7 +261,15 @@ #define PLATFORM_OVERRIDE_MAX_SID 24 -#define PLATFORM_OVERRIDE_TIMEOUT 0 +/* TIMEOUT should be in Microsecond 5us to 2 sec */ +#define PLATFORM_OVERRIDE_TIMEOUT 1000 /* time out for DUT */ + +/* FAIL safe timeout (> PLATFORM_OVERRIDE_TIMEOUT) */ +#define PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT (PLATFORM_OVERRIDE_TIMEOUT * 2) + +/*Max timeout set for systimer*/ +#define PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX 0xFFFFFFFF + /* Define the Timeout values to be used */ #define PLATFORM_BM_OVERRIDE_TIMEOUT_LARGE 0x10000 #define PLATFORM_BM_OVERRIDE_TIMEOUT_MEDIUM 0x1000 diff --git a/pal/baremetal/target/RDN2/src/platform_cfg_fvp.c b/pal/baremetal/target/RDN2/src/platform_cfg_fvp.c index 52ccb87c..316c0abe 100644 --- a/pal/baremetal/target/RDN2/src/platform_cfg_fvp.c +++ b/pal/baremetal/target/RDN2/src/platform_cfg_fvp.c @@ -83,6 +83,9 @@ uint32_t g_level_filter_mode = LVL_FILTER_MAX; /* Default set to LVL_FILTER_MAX */ uint32_t g_sys_last_lvl_cache = PLATFORM_OVERRRIDE_SLC; +uint32_t g_timeout_pass = PLATFORM_OVERRIDE_TIMEOUT; +uint32_t g_timeout_fail = PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT; + PE_SMBIOS_PROCESSOR_INFO_TABLE platform_smbios_cfg = { .slot_count = PLATFORM_OVERRIDE_SMBIOS_SLOT_COUNT, diff --git a/pal/baremetal/target/RDV3/include/platform_override_fvp.h b/pal/baremetal/target/RDV3/include/platform_override_fvp.h index 0323e09f..f9c12632 100644 --- a/pal/baremetal/target/RDV3/include/platform_override_fvp.h +++ b/pal/baremetal/target/RDV3/include/platform_override_fvp.h @@ -295,7 +295,14 @@ // This value is arbitrary and may have to be adjusted #define PLATFORM_BM_OVERRIDE_MAX_IRQ_CNT 0xFFFF /* Max IRQs any device may raise */ -#define PLATFORM_OVERRIDE_TIMEOUT 0 /* Override default wakeup timeout */ +/* TIMEOUT should be in Microsecond 5us to 2 sec */ +#define PLATFORM_OVERRIDE_TIMEOUT 1000 /* time out for DUT */ + +/* FAIL safe timeout (> PLATFORM_OVERRIDE_TIMEOUT) */ +#define PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT (PLATFORM_OVERRIDE_TIMEOUT * 2) + +/*Max timeout set for systimer*/ +#define PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX 0xFFFFFFFF /* Generic timeout helpers for bare-metal tests */ #define PLATFORM_BM_OVERRIDE_TIMEOUT_LARGE 0x10000 diff --git a/pal/baremetal/target/RDV3/src/platform_cfg_fvp.c b/pal/baremetal/target/RDV3/src/platform_cfg_fvp.c index 46c3aafe..47bbf75a 100644 --- a/pal/baremetal/target/RDV3/src/platform_cfg_fvp.c +++ b/pal/baremetal/target/RDV3/src/platform_cfg_fvp.c @@ -83,6 +83,9 @@ uint32_t g_level_filter_mode = LVL_FILTER_MAX; /* Default set to LVL_FILTER_MAX */ uint32_t g_sys_last_lvl_cache = PLATFORM_OVERRRIDE_SLC; +uint32_t g_timeout_pass = PLATFORM_OVERRIDE_TIMEOUT; +uint32_t g_timeout_fail = PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT; + PE_SMBIOS_PROCESSOR_INFO_TABLE platform_smbios_cfg = { .slot_count = PLATFORM_OVERRIDE_SMBIOS_SLOT_COUNT, diff --git a/pal/baremetal/target/RDV3CFG1/include/platform_override_fvp.h b/pal/baremetal/target/RDV3CFG1/include/platform_override_fvp.h index 033150a1..b3da7613 100644 --- a/pal/baremetal/target/RDV3CFG1/include/platform_override_fvp.h +++ b/pal/baremetal/target/RDV3CFG1/include/platform_override_fvp.h @@ -244,7 +244,14 @@ // This value is arbitrary and may have to be adjusted #define PLATFORM_BM_OVERRIDE_MAX_IRQ_CNT 0xFFFF /* Max IRQs any device may raise */ -#define PLATFORM_OVERRIDE_TIMEOUT 0 /* Override default wakeup timeout */ +/* TIMEOUT should be in Microsecond 5us to 2 sec */ +#define PLATFORM_OVERRIDE_TIMEOUT 1000 /* time out for DUT */ + +/* FAIL safe timeout (> PLATFORM_OVERRIDE_TIMEOUT) */ +#define PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT (PLATFORM_OVERRIDE_TIMEOUT * 2) + +/*Max timeout set for systimer*/ +#define PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX 0xFFFFFFFF /* Generic timeout helpers for bare-metal tests */ #define PLATFORM_BM_OVERRIDE_TIMEOUT_LARGE 0x10000 diff --git a/pal/baremetal/target/RDV3CFG1/src/platform_cfg_fvp.c b/pal/baremetal/target/RDV3CFG1/src/platform_cfg_fvp.c index 6081ea3e..457b71a5 100644 --- a/pal/baremetal/target/RDV3CFG1/src/platform_cfg_fvp.c +++ b/pal/baremetal/target/RDV3CFG1/src/platform_cfg_fvp.c @@ -83,6 +83,9 @@ uint32_t g_level_filter_mode = LVL_FILTER_MAX; /* Default set to LVL_FILTER_MAX */ uint32_t g_sys_last_lvl_cache = PLATFORM_OVERRRIDE_SLC; +uint32_t g_timeout_pass = PLATFORM_OVERRIDE_TIMEOUT; +uint32_t g_timeout_fail = PLATFORM_OVERRIDE_FAILSAFE_TIMEOUT; + PE_SMBIOS_PROCESSOR_INFO_TABLE platform_smbios_cfg = { .slot_count = PLATFORM_OVERRIDE_SMBIOS_SLOT_COUNT, diff --git a/pal/include/platform_override.h b/pal/include/platform_override.h index a6cb1225..31c74b55 100644 --- a/pal/include/platform_override.h +++ b/pal/include/platform_override.h @@ -1,5 +1,5 @@ /** @file - * Copyright (c) 2022-2025, Arm Limited or its affiliates. All rights reserved. + * Copyright (c) 2022-2026, Arm Limited or its affiliates. All rights reserved. * SPDX-License-Identifier : Apache-2.0 * Licensed under the Apache License, Version 2.0 (the "License"); @@ -72,5 +72,8 @@ /* Size used to Map the SMMU Register Space, if not mapped */ #define PLATFORM_OVERRIDE_SMMU_MAP_SIZE 0x20000 //2*64 KB +/*Max timeout set for systimer*/ +#define PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX 0xFFFFFFFF + extern UINT32 g_pcie_p2p; extern UINT32 g_pcie_cache_present; diff --git a/test_pool/power_wakeup/u001.c b/test_pool/power_wakeup/u001.c index 5c962a4f..5dc2d423 100644 --- a/test_pool/power_wakeup/u001.c +++ b/test_pool/power_wakeup/u001.c @@ -24,8 +24,8 @@ #define TEST_RULE "B_WAK_03, B_WAK_07" #define TEST_DESC "Wake from EL1 PHY Timer Int " -extern uint32_t g_wakeup_timeout; static uint32_t g_el1phy_int_received; +extern uint32_t g_timeout_pass; static void @@ -49,8 +49,7 @@ payload1() uint32_t intid; uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid()); uint32_t delay_loop = MAX_SPIN_LOOPS; - uint32_t timer_expire_val = - (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_pass)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); if (val_gic_install_isr(intid, isr1)) { diff --git a/test_pool/power_wakeup/u002.c b/test_pool/power_wakeup/u002.c index 9281e61e..fe75d522 100644 --- a/test_pool/power_wakeup/u002.c +++ b/test_pool/power_wakeup/u002.c @@ -24,9 +24,10 @@ #define TEST_RULE "B_WAK_03, B_WAK_07" #define TEST_DESC "Wake from EL1 VIR Timer Int " -extern uint32_t g_wakeup_timeout; static uint32_t g_el1vir_int_received; static uint32_t g_failsafe_int_rcvd; +extern uint32_t g_timeout_pass; +extern uint32_t g_timeout_fail; static void @@ -48,8 +49,7 @@ void wakeup_set_failsafe() { uint32_t intid; - uint32_t timer_expire_val = - (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * (g_wakeup_timeout + 1)); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_fail)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); val_gic_install_isr(intid, isr_failsafe); val_timer_set_phy_el1(timer_expire_val); @@ -85,7 +85,7 @@ payload2() uint32_t intid; uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid()); uint32_t delay_loop = MAX_SPIN_LOOPS; - uint32_t timer_expire_val = (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_pass)); intid = val_timer_get_info(TIMER_INFO_VIR_EL1_INTID, 0); if (val_gic_install_isr(intid, isr2)) { diff --git a/test_pool/power_wakeup/u003.c b/test_pool/power_wakeup/u003.c index f3f2fa6f..fe7d95cc 100644 --- a/test_pool/power_wakeup/u003.c +++ b/test_pool/power_wakeup/u003.c @@ -24,9 +24,10 @@ #define TEST_RULE "B_WAK_03, B_WAK_07" #define TEST_DESC "Wake from EL2 PHY Timer Int " -extern uint32_t g_wakeup_timeout; static uint32_t g_el2phy_int_rcvd; static uint32_t g_failsafe_int_rcvd; +extern uint32_t g_timeout_pass; +extern uint32_t g_timeout_fail; static void @@ -64,8 +65,7 @@ void wakeup_set_failsafe() { uint32_t intid; - uint32_t timer_expire_val = - (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * (g_wakeup_timeout + 1)); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_fail)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); val_gic_install_isr(intid, isr_failsafe); @@ -86,7 +86,7 @@ payload3() uint32_t intid; uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid()); uint32_t delay_loop = MAX_SPIN_LOOPS; - uint32_t timer_expire_val = (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_pass)); intid = val_timer_get_info(TIMER_INFO_PHY_EL2_INTID, 0); if (val_gic_install_isr(intid, isr3)) { diff --git a/test_pool/power_wakeup/u004.c b/test_pool/power_wakeup/u004.c index eeb2f314..f145cf1c 100644 --- a/test_pool/power_wakeup/u004.c +++ b/test_pool/power_wakeup/u004.c @@ -26,8 +26,9 @@ static uint64_t wd_num; static uint32_t g_wd_int_received; -extern uint32_t g_wakeup_timeout; static uint32_t g_failsafe_int_received; +extern uint32_t g_timeout_pass; +extern uint32_t g_timeout_fail; static void @@ -63,7 +64,7 @@ void wakeup_set_failsafe() { uint32_t intid; - uint64_t timer_expire_val = (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout); + uint64_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_fail)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); val_gic_install_isr(intid, isr_failsafe); @@ -86,7 +87,7 @@ payload4() uint32_t intid; uint32_t delay_loop = MAX_SPIN_LOOPS; uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid()); - uint32_t timer_expire_val = 1 * g_wakeup_timeout; + uint64_t timer_expire_val = val_get_timeout_to_ticks(g_timeout_pass); wd_num = val_wd_get_info(0, WD_INFO_COUNT); diff --git a/test_pool/power_wakeup/u005.c b/test_pool/power_wakeup/u005.c index 66daffb5..2897a65f 100644 --- a/test_pool/power_wakeup/u005.c +++ b/test_pool/power_wakeup/u005.c @@ -25,9 +25,10 @@ #define TEST_DESC "Wake from System Timer Int " static uint64_t timer_num; -extern uint32_t g_wakeup_timeout; static uint32_t g_failsafe_int_rcvd; static uint32_t g_timer_int_rcvd; +extern uint32_t g_timeout_pass; +extern uint32_t g_timeout_fail; static void @@ -65,8 +66,7 @@ void wakeup_set_failsafe() { uint32_t intid; - uint32_t timer_expire_val = - (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * (g_wakeup_timeout + 1)); + uint64_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_fail)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); val_gic_install_isr(intid, isr_failsafe); @@ -90,7 +90,7 @@ payload5() uint32_t intid; uint32_t delay_loop = MAX_SPIN_LOOPS; uint64_t cnt_base_n; - uint32_t timer_expire_val = (uint32_t)((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout); + uint64_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_pass)); timer_num = val_timer_get_info(TIMER_INFO_NUM_PLATFORM_TIMERS, 0); if (!timer_num) { diff --git a/test_pool/watchdog/w002.c b/test_pool/watchdog/w002.c index adbe7f07..2981700f 100644 --- a/test_pool/watchdog/w002.c +++ b/test_pool/watchdog/w002.c @@ -34,8 +34,8 @@ static uint32_t int_id; static uint64_t wd_num; static volatile uint32_t g_failsafe_int_received; static volatile uint32_t g_wd_int_received; - -extern uint32_t g_wakeup_timeout; +extern uint32_t g_timeout_pass; +extern uint32_t g_timeout_fail; static void @@ -69,8 +69,7 @@ void wakeup_set_failsafe() { uint32_t intid; - uint32_t timer_expire_val = - (uint32_t)(((uint64_t)val_get_safe_timeout_ticks() * 3 * g_wakeup_timeout) / 2); + uint32_t timer_expire_val = CEIL_TO_MAX_SYS_TIMEOUT(val_get_timeout_to_ticks(g_timeout_fail)); intid = val_timer_get_info(TIMER_INFO_PHY_EL1_INTID, 0); val_gic_install_isr(intid, isr_failsafe); @@ -90,8 +89,8 @@ payload() { uint32_t status, ns_wdg = 0; - uint32_t timeout; - uint64_t timer_expire_ticks = 1 * g_wakeup_timeout; + uint64_t timeout; + uint64_t timer_expire_ticks = val_get_timeout_to_ticks(g_timeout_pass); uint32_t index = val_pe_get_index_mpid(val_pe_get_mpid()); wd_num = val_wd_get_info(0, WD_INFO_COUNT); @@ -147,7 +146,7 @@ payload() } wakeup_set_failsafe(); - timeout = (uint32_t)(((uint64_t)val_get_safe_timeout_ticks() * g_wakeup_timeout) / 2); + timeout = val_get_timeout_to_ticks(g_timeout_fail); while (timeout && (g_wd_int_received == 0) && (g_failsafe_int_received == 0)) { val_data_cache_ops_by_va((addr_t)&g_wd_int_received, INVALIDATE); val_data_cache_ops_by_va((addr_t)&g_failsafe_int_received, INVALIDATE); diff --git a/val/include/acs_timer.h b/val/include/acs_timer.h index a52379c4..f2c8dd82 100644 --- a/val/include/acs_timer.h +++ b/val/include/acs_timer.h @@ -39,6 +39,7 @@ #define CNTP_CTL 0x2C #define COUNTER_ID 0xFD0 +#define MICRO_SECONDS 1000000 #define MAX_WAKEUP_TIMEOUT 5 uint32_t t001_entry(uint32_t num_pe); diff --git a/val/include/pal_interface.h b/val/include/pal_interface.h index 6e93daa3..27317a00 100644 --- a/val/include/pal_interface.h +++ b/val/include/pal_interface.h @@ -54,17 +54,17 @@ #define TCR_TG0 VAL_TG0_64K #endif - #define MAX_SID PLATFORM_OVERRIDE_MAX_SID - #define MMU_PGT_IAS PLATFORM_OVERRIDE_MMU_PGT_IAS - #define MMU_PGT_OAS PLATFORM_OVERRIDE_MMU_PGT_OAS - #define MAX_IRQ_CNT PLATFORM_BM_OVERRIDE_MAX_IRQ_CNT - #define PCIE_MAX_BUS PLATFORM_BM_OVERRIDE_PCIE_MAX_BUS - #define PCIE_MAX_DEV PLATFORM_BM_OVERRIDE_PCIE_MAX_DEV - #define PCIE_MAX_FUNC PLATFORM_BM_OVERRIDE_PCIE_MAX_FUNC - #define TIMEOUT_LARGE PLATFORM_BM_OVERRIDE_TIMEOUT_LARGE - #define TIMEOUT_MEDIUM PLATFORM_BM_OVERRIDE_TIMEOUT_MEDIUM - #define TIMEOUT_SMALL PLATFORM_BM_OVERRIDE_TIMEOUT_SMALL - + #define MAX_SID PLATFORM_OVERRIDE_MAX_SID + #define MMU_PGT_IAS PLATFORM_OVERRIDE_MMU_PGT_IAS + #define MMU_PGT_OAS PLATFORM_OVERRIDE_MMU_PGT_OAS + #define MAX_IRQ_CNT PLATFORM_BM_OVERRIDE_MAX_IRQ_CNT + #define PCIE_MAX_BUS PLATFORM_BM_OVERRIDE_PCIE_MAX_BUS + #define PCIE_MAX_DEV PLATFORM_BM_OVERRIDE_PCIE_MAX_DEV + #define PCIE_MAX_FUNC PLATFORM_BM_OVERRIDE_PCIE_MAX_FUNC + #define TIMEOUT_LARGE PLATFORM_BM_OVERRIDE_TIMEOUT_LARGE + #define TIMEOUT_MEDIUM PLATFORM_BM_OVERRIDE_TIMEOUT_MEDIUM + #define TIMEOUT_SMALL PLATFORM_BM_OVERRIDE_TIMEOUT_SMALL + #define WAKEUP_WD_SYS_TIMEOUT_MAX PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX #endif // TARGET_BAREMETAL #ifdef TARGET_LINUX @@ -85,6 +85,8 @@ #define MAX_SID 32 #define MMU_PGT_IAS 48 #define MMU_PGT_OAS 48 + + #define WAKEUP_WD_SYS_TIMEOUT_MAX 0XFFFFFFFF #endif //TARGET_LINUX #ifdef TARGET_UEFI @@ -111,14 +113,16 @@ #define MMU_PGT_IAS 48 #define MMU_PGT_OAS 48 - #define SMMU_MAP_SIZE PLATFORM_OVERRIDE_SMMU_MAP_SIZE /* Size of memory to map from SMMU base */ - #define TIMEOUT_LARGE PLATFORM_OVERRIDE_TIMEOUT_LARGE - #define TIMEOUT_MEDIUM PLATFORM_OVERRIDE_TIMEOUT_MEDIUM - #define TIMEOUT_SMALL PLATFORM_OVERRIDE_TIMEOUT_SMALL - #define PCIE_MAX_BUS PLATFORM_OVERRIDE_PCIE_MAX_BUS - #define PCIE_MAX_DEV PLATFORM_OVERRIDE_PCIE_MAX_DEV - #define PCIE_MAX_FUNC PLATFORM_OVERRIDE_PCIE_MAX_FUNC - #define MAX_IRQ_CNT PLATFORM_OVERRIDE_MAX_IRQ_CNT + /* Size of memory to map from SMMU base */ + #define SMMU_MAP_SIZE PLATFORM_OVERRIDE_SMMU_MAP_SIZE + #define TIMEOUT_LARGE PLATFORM_OVERRIDE_TIMEOUT_LARGE + #define TIMEOUT_MEDIUM PLATFORM_OVERRIDE_TIMEOUT_MEDIUM + #define TIMEOUT_SMALL PLATFORM_OVERRIDE_TIMEOUT_SMALL + #define PCIE_MAX_BUS PLATFORM_OVERRIDE_PCIE_MAX_BUS + #define PCIE_MAX_DEV PLATFORM_OVERRIDE_PCIE_MAX_DEV + #define PCIE_MAX_FUNC PLATFORM_OVERRIDE_PCIE_MAX_FUNC + #define MAX_IRQ_CNT PLATFORM_OVERRIDE_MAX_IRQ_CNT + #define WAKEUP_WD_SYS_TIMEOUT_MAX PLATFORM_OVERRIDE_SYS_TIMEOUT_MAX #endif // TARGET_UEFI /* The following are common across all platform unless guarded explicitly */ diff --git a/val/include/val_interface.h b/val/include/val_interface.h index 48df3d58..aa16b953 100644 --- a/val/include/val_interface.h +++ b/val/include/val_interface.h @@ -42,6 +42,15 @@ #define VAL_EXTRACT_BITS(data, start, end) ((data >> start) & ((1ul << (end-start+1))-1)) +#define WAKEUP_WD_PASS_TIMEOUT_THRESHOLD 500 /*minimum timeout that can be + set for wakeup and wd tests*/ +#define WAKEUP_WD_PASS_TIMEOUT_MAX_THRESHOLD 2000000 /*minimum timeout that can be + set for wakeup and wd tests*/ +#define WAKEUP_WD_FAILSAFE_TIMEOUT_MULTIPLIER 2 /*fail safe timeout multipler + multiplied to timeout of ISR + under test*/ +#define WAKEUP_WD_PASS_TIMEOUT_DEFAULT 1000 /*minimum timeout set + by default (1ms)*/ /* Test status counters visible across ACS */ typedef struct { uint32_t total_rules_run; /* Total rules/tests that reported a status */ @@ -232,6 +241,7 @@ void val_timer_disable_system_timer(addr_t cnt_base_n); uint32_t val_timer_skip_if_cntbase_access_not_allowed(uint64_t index); uint64_t val_get_phy_el1_timer_count(void); uint32_t val_get_safe_timeout_ticks(void); +uint64_t val_get_timeout_to_ticks(uint32_t timeout_us); /* Watchdog VAL APIs */ typedef enum { @@ -247,7 +257,7 @@ void val_wd_create_info_table(uint64_t *wd_info_table); void val_wd_free_info_table(void); uint64_t val_wd_get_info(uint32_t index, WD_INFO_TYPE_e info_type); uint32_t val_bsa_wd_execute_tests(uint32_t num_pe, uint32_t *g_sw_view); -uint32_t val_wd_set_ws0(uint32_t index, uint32_t timeout); +uint32_t val_wd_set_ws0(uint32_t index, uint64_t timeout); uint64_t val_get_counter_frequency(void); @@ -471,6 +481,11 @@ void val_setup_mair_register(void); #define MEM_NORMAL_NC_IN_OUT(attr) (attr == 0x44) #define MEM_DEVICE(attr) ((attr & 0xf0) == 0) #define MEM_SH_INNER(sh) (sh == 0x3) +#define CEIL_TO_MAX_SYS_TIMEOUT(v) \ +({ \ + uint64_t __x = (uint64_t)(v); \ + ((__x >> 32) != 0) ? WAKEUP_WD_SYS_TIMEOUT_MAX : (uint32_t)__x; \ +}) void val_memory_create_info_table(uint64_t *memory_info_table); void val_memory_free_info_table(void); diff --git a/val/src/acs_timer.c b/val/src/acs_timer.c index 487f2d83..7fe0ec95 100644 --- a/val/src/acs_timer.c +++ b/val/src/acs_timer.c @@ -458,3 +458,20 @@ val_get_safe_timeout_ticks(void) return (uint32_t)ticks; } + +/** + @brief convert timeout in terms of us to ticks. + + @param timeout_us input timeout in terms of us + + @return uint64_t timeout in terms of ticks. +**/ +uint64_t +val_get_timeout_to_ticks(uint32_t timeout_us) +{ + + uint64_t freq = val_get_counter_frequency(); + uint64_t ticks = (timeout_us * freq)/MICRO_SECONDS; + + return ticks; +} diff --git a/val/src/acs_wd.c b/val/src/acs_wd.c index 008526e3..9cb3007e 100644 --- a/val/src/acs_wd.c +++ b/val/src/acs_wd.c @@ -136,10 +136,8 @@ val_wd_disable(uint32_t index) @return Success/Failure **/ uint32_t -val_wd_set_ws0(uint32_t index, uint32_t timeout) +val_wd_set_ws0(uint32_t index, uint64_t timeout) { - uint64_t counter_freq; - uint64_t freq; uint32_t wor_l; uint32_t wor_h = 0; uint64_t ctrl_base; @@ -155,35 +153,8 @@ val_wd_set_ws0(uint32_t index, uint32_t timeout) /* W_IIDR.Architecture Revision [19:16] = 0x1 for Watchdog Rev 1 */ data = VAL_EXTRACT_BITS(val_mmio_read(ctrl_base + WD_IIDR_OFFSET), 16, 19); - /* - * The common system_counter_to_watchdog_counter frequency ratio can be - * anywhere from 1x to 256x, meaning the watchdog counter typically runs - * slower than the system counter. If we used the system counter frequency - * directly, the system-counter-based failsafe interrupt could fire before - * the watchdog interrupt, which would break the watchdog tests. - * - * To avoid this, we divide the watchdog counter frequency by 1024 so that - * the watchdog interrupt always occurs before the system-counter-based - * failsafe interrupt.Ensure the resulting frequency is never zero. - */ - freq = val_get_counter_frequency(); - counter_freq = freq / 1024; - - if (counter_freq == 0) - counter_freq = 1; - - /* Check if the timeout value exceeds */ - if (data == 0) - { - if ((counter_freq * timeout) >> 32) - { - val_print(ACS_PRINT_ERR, "\nCounter frequency value exceeded", 0); - return 1; - } - } - - wor_l = (uint32_t)(counter_freq * timeout); - wor_h = (uint32_t)((counter_freq * timeout) >> 32); + wor_l = (uint32_t)(timeout); + wor_h = (uint32_t)((timeout) >> 32); val_mmio_write((g_wd_info_table->wd_info[index].wd_ctrl_base + 8), wor_l);