Page MenuHomeFreeBSD

virtio_console: Make the transmit path usable without the tty lock
Needs ReviewPublic

Authored by kfv on Fri, Oct 9, 4:56 PM.
Tags
None
Referenced Files
F175742114: D60538.id189475.diff
Mon, Oct 12, 11:14 PM
F175727408: D60538.id189267.diff
Mon, Oct 12, 8:18 PM
F175714744: D60538.id.diff
Mon, Oct 12, 5:42 PM
F175702444: D60538.id189342.diff
Mon, Oct 12, 3:33 PM
F175690183: D60538.diff
Mon, Oct 12, 1:33 PM
F175628638: D60538.id189475.diff
Mon, Oct 12, 3:55 AM
Unknown Object (File)
Sun, Oct 11, 11:57 PM
Unknown Object (File)
Sun, Oct 11, 11:36 PM
Subscribers
None

Details

Summary

vtcon_port_out() spun in virtqueue_poll() under the tty
mutex until the host completed the buffer, which a reset
device never does; detaching while a process was writing
to a port thus deadlocked, with the writer spinning and
detach waiting for its mutex. Stop transmitting, control
messages included, before the device is reset at detach
or shutdown.

Also, serialise each port's virtqueues with a spin mutex
and keep the transmit buffer in the per-port softc where
it outlives both the call and the port, so a system
console can transmit where the tty mutex cannot be taken.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 78013
Build 74896: arc lint + arc unit

Event Timeline

kfv requested review of this revision.Fri, Oct 9, 4:56 PM
kfv created this revision.

Also, serialise each port's virtqueues with a spin mutex
and keep the transmit buffer in the per-port softc where
it outlives both the call and the port, so a system
console can transmit where the tty mutex cannot be taken.

Why exactly does it need to be a spin mutex? Are you planning to define CONSOLE_DRIVER methods?

No, not really. It's for the console patch following in the series. That registers via cnadd()​ once the device is up (and the device doesn't exist at cninit()​ yet, so CONSOLE_DRIVER​ won't do), and its cn_putc()​/cn_getc()​ run under cnputs_mtx​ and in ddb/panic, so they cannot take the tty mutex. The deadlock fix alone doesn't strictly need the spin mutex, though; I just didn't want to rework the tx path twice. Happy to move it into the console patch if you’d rather keep this one minimal.

Drop redundant reference to prior behaviour

Reclaim transmit buffers and stop TX before disabling interrupts