Hi, On Mon, Sep 2, 2024 at 8:26 AM Johan Hovold <johan+linaro@xxxxxxxxxx> wrote: > > The polled UART operations are used by the kernel debugger (KDB, KGDB), > which can interrupt the kernel at any point in time. The current > Qualcomm GENI implementation does not really work when there is on-going > serial output as it inadvertently "hijacks" the current tx command, > which can result in both the initial debugger output being corrupted as > well as the corruption of any on-going serial output (up to 4k > characters) when execution resumes: > > 0190: abcdefghijklmnopqrstuvwxyz0123456789 0190: abcdefghijklmnopqrstuvwxyz0123456789 > 0191: abcdefghijklmnop[ 50.825552] sysrq: DEBUG > qrstuvwxyz0123456789 0191: abcdefghijklmnopqrstuvwxyz0123456789 > Entering kdb (current=0xffff53510b4cd280, pid 640) on processor 2 due to Keyboard Entry > [2]kdb> go > omlji3h3h2g2g1f1f0e0ezdzdycycxbxbwawav :t72r2rp > o9n976k5j5j4i4i3h3h2g2g1f1f0e0ezdzdycycxbxbwawavu:t7t8s8s8r2r2q0q0p > o9n9n8ml6k6k5j5j4i4i3h3h2g2g1f1f0e0ezdzdycycxbxbwawav v u:u:t9t0s4s4rq0p > o9n9n8m8m7l7l6k6k5j5j40q0p p o > o9n9n8m8m7l7l6k6k5j5j4i4i3h3h2g2g1f1f0e0ezdzdycycxbxbwawav :t8t9s4s4r4r4q0q0p > > Fix this by making sure that the polled output implementation waits for > the tx fifo to drain before cancelling any on-going longer transfers. As > the polled code cannot take any locks, leave the state variables as they > are and instead make sure that the interrupt handler always starts a new > tx command when there is data in the write buffer. > > Since the debugger can interrupt the interrupt handler when it is > writing data to the tx fifo, it is currently not possible to fully > prevent losing up to 64 bytes of tty output on resume. > > Fixes: c4f528795d1a ("tty: serial: msm_geni_serial: Add serial driver support for GENI based QUP") > Cc: stable@xxxxxxxxxxxxxxx # 4.17 > Signed-off-by: Johan Hovold <johan+linaro@xxxxxxxxxx> > --- > drivers/tty/serial/qcom_geni_serial.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) Reviewed-by: Douglas Anderson <dianders@xxxxxxxxxxxx>