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.
Tags
None
Referenced Files
F102803168: D31025.diff
Sun, Nov 17, 9:29 AM
Unknown Object (File)
Fri, Nov 8, 9:17 AM
Unknown Object (File)
Sat, Oct 19, 6:00 PM
Unknown Object (File)
Oct 17 2024, 5:39 PM
Unknown Object (File)
Oct 17 2024, 3:12 AM
Unknown Object (File)
Oct 15 2024, 1:28 AM
Unknown Object (File)
Oct 14 2024, 3:14 AM
Unknown Object (File)
Oct 13 2024, 6:40 AM
Subscribers

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
rG FreeBSD src repository
Lint
Lint Not Applicable
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. :)