arm/xen: vpl011: Fix SBSA UART interrupt assertion
authorBhupinder Thakur <bhupinder.thakur@linaro.org>
Tue, 24 Oct 2017 17:09:22 +0000 (18:09 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 27 Oct 2017 17:11:05 +0000 (10:11 -0700)
commitbb2c1a1cc98a22e2d4c14b18421aa7be6c2adf0d
tree1791b8ac71cc4b29031b8d8d3268f18789e97fc9
parent393a541f7d151242f186ad2fb9b6c20db1db6cb9
arm/xen: vpl011: Fix SBSA UART interrupt assertion

With the current SBSA UART emulation, streaming larger amounts of data
(as caused by "find /", for instance) can lead to character losses.
This is due to the OUT ring buffer getting full, because we change the
TX interrupt bit only when the FIFO is actually full, and not already
when it's half-way filled, as the Linux driver expects.
The SBSA spec does not explicitly state this, but we assume that an
SBSA compliant UART uses the PL011 default "interrupt FIFO level select
register" value of "1/2 way". The Linux driver certainly makes this
assumption, so it expect to be able to write a number of characters
after the TX interrupt line has been asserted.
On a similar issue we have the same wrong behaviour on the receive side.
However changing the RX interrupt to trigger on reaching half of the FIFO
level will lead to lag, because the guest would not be notified of incoming
characters until the FIFO is half way filled. This leads to inacceptible
lags when typing on a terminal.
Real hardware solves this issue by using the "receive timeout
interrupt" (RTI), which is triggered when character reception stops for
32 baud cycles. As we cannot and do not want to emulate any timing here,
we slightly abuse the timeout interrupt to notify the guest of new
characters: when a new character comes in, the RTI is asserted, when
the FIFO is cleared, the interrupt gets cleared.

So this patch changes the emulated interrupt trigger behaviour to come
as close to real hardware as possible: the RX and TX interrupt trigger
when the FIFO gets half full / half empty, and the RTI interrupt signals
new incoming characters.

[Andre: reword commit message, introduce receive timeout interrupt, add
        comments]

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Reviewed-by: Andre Przywara <andre.przywara@linaro.org>
Signed-off-by: Andre Przywara <andre.przywara@linaro.org>
Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Release-acked-by: Julien Grall <julien.grall@linaro.org>
xen/arch/arm/vpl011.c
xen/include/asm-arm/vpl011.h