Bug 128036

Summary: [sio] [patch] serial console mostly ignores typein to restart after shutdown
Product: Base System Reporter: Arthur Hartwig <arthur.hartwig>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Arthur Hartwig 2008-10-13 02:00:01 UTC
System with serial console.

If the system is shutdown by "shutdown -h ..." the following prompt is displayed on the console:

"The operating system has halted.
Please press any key to reboot."

Often a single keypress is not recognised; multiple keypresses are often required for the system to reboot.

Fix: 

In sys/dev/sio.c, function siocnclose() change

    outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS);
    outb(iobase + com_ier, sp->ier);
to
    outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS);
    if (rebooting == 0) {
        /*
         * Only restore the interrupt enables if not rebooting. If 
	 * rebooting leave interrupts disabled, else a key press might be 
	 * swallowed by the interrupt handler and not seen by the shutdown code.
	 */
        outb(iobase + com_ier, sp->ier);
    }

The problem is that the shutdown code looking for a keypress on the console (loop in sys/kern/kern_shutdown.c function shutdown_halt) runs with console interrupts enabled. If the keypress generates a console interrupt then the keypress is swallowed by the console interrupt handler and not seen by the code polling for a keypress.
How-To-Repeat: On system with serial console, issue 

# shutdown -h now 

command
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2012-11-14 23:34:55 UTC
Responsible Changed
From-To: freebsd-bugs->eadler

I'll take it.
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2012-11-16 04:07:52 UTC
Responsible Changed
From-To: eadler->freebsd-bugs

according to bde@ this patch is incorrect. In particular the bug actually lies in a higher level driver and needs to be fixed there. I can't track this down at the moment.
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:45 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 4 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:36:53 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>