Re: Regression: serial: imx: overrun errors on debug UART

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

Stefan Wahren <stefan.wahren@xxxxxxxx> writes:

> Hi Uwe,
>
> Am 25.03.23 um 16:11 schrieb Uwe Kleine-König:
>> Hello,
>> On Sat, Mar 25, 2023 at 12:31:01PM +0100, Stefan Wahren wrote:
>>> Am 24.03.23 um 16:00 schrieb Stefan Wahren:
>>>> Am 24.03.23 um 13:57 schrieb Fabio Estevam:
>>>>> On Fri, Mar 24, 2023 at 8:48 AM Ilpo Järvinen
>>>>> <ilpo.jarvinen@xxxxxxxxxxxxxxx> wrote:
>>>>>
>>>>>> This has come up earlier, see e.g.:
>>>>>>
>>>>>> https://lore.kernel.org/linux-serial/20221003110850.GA28338@xxxxxxxxxxxxxxxxxxxxxxxxxxxx/
>>>>>>
>>>>>> My somewhat uninformed suggestion: if the overrun problems
>>>>>> mostly show up
>>>>>> with console ports, maybe the trigger level could depend on the port
>>>>>> being a console or not?
>>>>> Does the change below help? Taking Ilpo's suggestion into account:
>>>> this breaks the boot / debug console completely, but i got the idea.
>>>>>
>>>
>>> based on your patch, i successfully tested this:
>>>
>>> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
>>> index f07c4f9ff13c..1aacaa637ede 100644
>>> --- a/drivers/tty/serial/imx.c
>>> +++ b/drivers/tty/serial/imx.c
>>> @@ -1277,6 +1277,7 @@ static void imx_uart_clear_rx_errors(struct imx_port
>>> *sport)
>>>   }
>>>
>>>   #define TXTL_DEFAULT 2 /* reset default */
>>> +#define RXTL_DEFAULT_CONSOLE 1 /* reset default */
>>>   #define RXTL_DEFAULT 8 /* 8 characters or aging timer */
>>>   #define TXTL_DMA 8 /* DMA burst setting */
>>>   #define RXTL_DMA 9 /* DMA burst setting */
>>> @@ -1286,6 +1287,9 @@ static void imx_uart_setup_ufcr(struct imx_port
>>> *sport,
>>>   {
>>>   	unsigned int val;
>>>
>>> +	if (uart_console(&sport->port))
>>> +		rxwl = RXTL_DEFAULT_CONSOLE; // fallback
>>> +
>>>   	/* set receiver / transmitter trigger level */
>>>   	val = imx_uart_readl(sport, UFCR) & (UFCR_RFDIV | UFCR_DCEDTE);
>>>   	val |= txwl << UFCR_TXTL_SHF | rxwl;
>> So the current theory that the issue occurs because of a combination of:
>>   - With a higher watermark value the irq triggers later and so there is
>>     less time the until the ISR must run before an overflow happens; and
>>   - serial console activity disables irqs for a (relative) long time
>> right?
>> So on an UP system the problem should occur also on a non-console port?
>
> This is less likely, because UART applications usually need some kind
> of flow control (either from hardware or protocol side). For a
> non-console application the receiver usually wait until the end and
> then starts to transmit.

Only CTS/RTS hardware handshake could help, as otherwise printk() output
is typically entirely async with respect to transmissions on another
port, and software protocol(s) then are irrelevant, unless they enforce
extremely short chunks of data (less than FIFO size).

> Sure you can flood the UART with characters and it's only a question
> of time until the RX FIFO is full and data get lost.

In correctly working RT system this doesn't typically happen, as CPUs
are way faster than typical UART speeds, and are able to handle the
loads easily, provided UART has decent FIFO. It's disabling IRQs for
prolonged times that makes shit happen.

[...]

>
> According to these lines in imx.c DMA is never used for console:
>
>   /* Can we enable the DMA support? */
>   if (!uart_console(port) && imx_uart_dma_init(sport) == 0)
>     dma_is_inited = 1;
>
> At the end the patch above only restores the old console behavior, but
> keep Tomasz Moń's optimization for non-console (which was indented
> for).

So this will likely only be of help for this particular case, and will
leave the problem there on other DMA-disabled ports. To "fix" this, the
old threshold is to be returned on all DMA-disabled ports, and then the
Tomasz original patch would be entirely reverted, it seems.

Disclaimer: all the above is said on the assumption that it's printk
that is core cause of the problem in this case, that has not yet been
shown in testing, as far as I know.

Best regards,
-- Sergey



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux