serial: qcom_geni_serial: Make kgdb work even if UART isn't console
authorDouglas Anderson <dianders@chromium.org>
Fri, 26 Jun 2020 20:00:32 +0000 (13:00 -0700)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Mon, 13 Jul 2020 23:47:06 +0000 (16:47 -0700)
commite42d6c3ec0c7ade92021252cab49d8e6e14ba496
treed4d4c6338cc6db9c4e2238afa8f14c263ed2361a
parentda48dc8c70c20e5e3e4c8c15a52bb75ebee6fa3c
serial: qcom_geni_serial: Make kgdb work even if UART isn't console

The geni serial driver had the rather sketchy hack in it where it
would adjust the number of bytes per RX FIFO word from 4 down to 1 if
it detected that CONFIG_CONSOLE_POLL was enabled (for kgdb) and this
was a console port (defined by the kernel directing output to this
port via the "console=" command line argument).

The problem with that sketchy hack is that it's possible to run kgdb
over a serial port even if it isn't used for console.

Let's avoid the hack by simply handling the 4-bytes-per-FIFO word case
for kdb.  We'll have to have a (very small) cache but that should be
fine.

A nice side effect of this patch is that an agetty (or similar)
running on this port is less likely to drop characters.  We'll
have roughly 4 times the RX FIFO depth than we used to now.

NOTE: the character cache here isn't shared between the polling API
and the non-polling API.  That means that, technically, the polling
API could eat a few extra bytes.  This doesn't seem to pose a huge
problem in reality because we'll only get several characters per FIFO
word if those characters are all received at nearly the same time and
we don't really expect non-kgdb characters to be sent to the same port
as kgdb at the exact same time we're exiting kgdb.

ALSO NOTE: we still have the sketchy hack for setting the number of
bytes per TX FIFO word in place, but that one is less bad.  kgdb
doesn't have any problem with this because it always just sends 1 byte
at a time and waits for it to finish.  The TX FIFO hack is only really
needed for console output.  In any case, a future patch will remove
that hack, too.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Evan Green <evgreen@chromium.org>
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20200626125844.1.I8546ecb6c5beb054f70c5302d1a7293484212cd1@changeid
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/tty/serial/qcom_geni_serial.c