Page MenuHomeFreeBSD

ns8250: don't drop IER_TXRDY on bus_grab/ungrab
ClosedPublic

Authored by mhorne on Mar 8 2021, 5:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Dec 20, 1:26 AM
Unknown Object (File)
Nov 19 2024, 10:03 PM
Unknown Object (File)
Nov 14 2024, 3:18 AM
Unknown Object (File)
Nov 12 2024, 8:26 PM
Unknown Object (File)
Oct 22 2024, 9:11 AM
Unknown Object (File)
Oct 2 2024, 1:33 PM
Unknown Object (File)
Sep 30 2024, 9:44 PM
Unknown Object (File)
Sep 26 2024, 7:21 AM
Subscribers

Details

Summary

It has been observed that some systems are often unable to resume from
ddb after entering with debug.kdb.enter=1. Checking the status further
shows the terminal is blocked waiting in tty_drain(), but it never makes
progress in clearing the output queue, because sc->sc_txbusy is high.

I noticed that when entering polling mode for the debugger, IER_TXRDY is
set in the failure case. Since this bit is never tracked by the softc,
it will not be restored by ns8250_bus_ungrab(). This creates a race in
which a TX interrupt can be lost, creating the hang described above.
Ensuring that this bit is restored is enough to prevent this, and resume
from ddb as expected.

After some study, the best solution seems to be to track this bit in the
sc->ier field, for the same lifetime that TX interrupts are enabled.

PR: 223917, 240122
Partial diagnosis: markj, in 240122

Test Plan

Without this patch, continuing from ddb will almost always hang on my rockpro64.

With, it appears to never happen.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 37697
Build 34586: arc lint + arc unit

Event Timeline

mhorne requested review of this revision.Mar 8 2021, 5:59 PM
mhorne created this revision.
sys/dev/uart/uart_dev_ns8250.c
1039–1041

With the bit or'd in on the prior line, is this still needed? What does broken_txfifo control?

sys/dev/uart/uart_dev_ns8250.c
1039–1041

broken_txfifo seems to be for devices where the TX-ready interrupt won't fire. When set, it drains the tx fifo and schedules the SER_INT_TXIDLE softih immediately.

So it seems that IER_ETXRDY should not be needed at all for this case, but I think I left it above because I was unsure of this.

Looks like this tunable was needed for old versions of QEMU and possibly the Allwinner A10 uart (1c60b24baa50 and ac4adddf040f).

Remove superfluous IER_ETXRDY.

This revision is now accepted and ready to land.Mar 9 2021, 9:02 PM
manu added a subscriber: manu.

Awesome, thanks for looking into this !

bz added a subscriber: bz.

Accepting on the basis that it fixes PR 240122 (just tested)