Page MenuHomeFreeBSD

sifive_uart: Fix input character dropping in ddb and at a mountroot prompt
ClosedPublic

Authored by jrtc27 on Jul 5 2021, 12:04 AM.

Details

Summary

These use the raw console interface and poll. Unfortunately, the SiFive
UART puts the FIFO empty bit inside the FIFO data register, which means
that the act of checking whether a character is available also dequeues
any character from the FIFO, requiring the user to press each key twice.
However, since we configure the watermark to be 0 and, when the UART has
been grabbed for the console, we have interrupts off, we can abuse the
interrupt pending register to act as a substitute for the FIFO empty
bit.

This perhaps suggests that the console interface should move from having
rxready and getc to having getc_nonblock and getc (or make getc take a
bool), as all the places that call rxready do so to avoid blocking on
getc when there is no character available.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

jrtc27 created this revision.
philip added a subscriber: philip.

This changes looks good to me. Though I agree with your observation that we should consider moving away from rxready. I wonder why we never noticed this on the FU540. Did this change?

This revision is now accepted and ready to land.Jul 5 2021, 8:02 AM

This changes looks good to me. Though I agree with your observation that we should consider moving away from rxready. I wonder why we never noticed this on the FU540. Did this change?

It doesn't affect normal serial console use as that uses the uart methods, it's only for the low-level console, i.e. ddb, which includes mountroot, so I assume nobody ever tried to use it with those (or did and never bothered fixing it).

This changes looks good to me. Though I agree with your observation that we should consider moving away from rxready. I wonder why we never noticed this on the FU540. Did this change?

It doesn't affect normal serial console use as that uses the uart methods, it's only for the low-level console, i.e. ddb, which includes mountroot, so I assume nobody ever tried to use it with those (or did and never bothered fixing it).

Ah. That makes sense. I can't remember ever running into this. Thanks for fixing it. :)