--- zzzz-none-000/linux-4.4.271/drivers/firmware/psci.c 2021-06-03 06:22:09.000000000 +0000 +++ hawkeye-5590-750/linux-4.4.271/drivers/firmware/psci.c 2023-04-19 10:22:28.000000000 +0000 @@ -13,6 +13,7 @@ #define pr_fmt(fmt) "psci: " fmt +#include #include #include #include @@ -249,6 +250,31 @@ static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd) { + /* + * From kernel, psci_sys_reset function is called during reboot for + * both warm and cold reset. + * + * QSEE differentiates between warm and cold reset by checking the + * TZ_WONCE register, which is set by SBL based on CDT settings. + * + * During cold reset, QSEE communicates with RPM via glink and requests + * RPM to reset and during warm reset, QSEE directly toggles PSHOLD + * register. + * + * During warm reset case, the "Restarting system" print after reboot + * command is given is not flushed from the serial driver to console + * before which the board gets rebooted. + * + * The pr_emerg("Restarting system\n") is called after the reboot + * notifier callbacks are finished, therefore even if we add a + * reboot notifier in serial driver and flush the tx buffer, it still + * wouldn't help. + * + * We have added this 100 ms delay before invoking psci call for the + * serial driver to flush the tx buf contents to console before + * rebooting. + */ + mdelay(100); invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); } @@ -503,7 +529,7 @@ np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np); - if (!np) + if (!np || !of_device_is_available(np)) return -ENODEV; init_fn = (psci_initcall_t)matched_np->data;