Hi. In many places, the "cold" global variable is used to check whether timer can be used or not. cpu_reboot(9) says:
----------------------------- DESCRIPTION The cpu_reboot() function handles final system shutdown, and either halts or reboots the system. The exact action to be taken is determined by the flags passed in howto and by whether or not the system has finished autoconfiguration. If the system has finished autoconfiguration, cpu_reboot() does the following: 1. Sets the boothowto system variable (see boothowto(9)) from the howto argument. 2. If this is the first invocation of cpu_reboot() and the RB_NOSYNC flag is not set in howto, syncs and unmounts the system disks by calling vfs_shutdown(9) and sets the time of day clock by calling resettodr(9). 3. Disables interrupts. 4. If rebooting after a crash (i.e., if RB_DUMP is set in howto, but RB_HALT is not), saves a system crash dump. 5. Runs any shutdown hooks by calling pmf_system_shutdown(9). 6. Prints a message indicating that the system is about to be halted or rebooted. 7. If RB_HALT is set in howto, halts the system. Otherwise, reboots the system. ----------- After disabling interrupt (by splhigh()), devices are detached. Some drivers uses "cold" to check the availability of timer. One of example is: ------- /* Delay for a certain number of ms */ void usb_delay_ms_locked(struct usbd_bus *bus, u_int ms, kmutex_t *lock) { /* Wait at least two clock ticks so we know the time has passed. */ if (bus->ub_usepolling || cold) delay((ms+1) * 1000); else kpause("usbdly", false, (ms*hz+999)/1000 + 1, lock); } ------- Does it work on shutdown? I've also noticed that some code also checks shutting_down: ------- static inline int iic_op_flags(int flags) { return flags | ((cold || shutting_down) ? I2C_F_POLL : 0); } ------- The shutting_down variable is new and many drivers don't use it yet. Should we replace if (cold) to if (cold || shutting_down) Or any other solutions? (e.g setting cold = 1 after splhigh()). Thanks. -- ----------------------------------------------- SAITOH Masanobu (msai...@execsw.org msai...@netbsd.org)