Hello everyone,
I have since found the problem.
The problem is not related to setting the parod termios flag or the ninth bit.
It is related to the imx_flush_buffer function in drivers/tty/serial/imx.c that has been changed from the 3.10.17 to the 4.9.11 kernel. The following has been added:
/*
* According to the Reference Manual description of the UART SRST bit:
* "Reset the transmit and receive state machines,
* all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
* and UTS[6-3]". As we don't need to restore the old values from
* USR1, USR2, URXD, UTXD, only save/restore the other four registers
*/
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
uts = readl(sport->port.membase + IMX21_UTS);
temp = readl(sport->port.membase + UCR2);
temp &= ~UCR2_SRST;
writel(temp, sport->port.membase + UCR2);
while (!(readl(sport->port.membase + UCR2) & UCR2_SRST) && (--i > 0))
udelay(1);
/* Restore the registers */
writel(ubir, sport->port.membase + UBIR);
writel(ubmr, sport->port.membase + UBMR);
writel(uts, sport->port.membase + IMX21_UTS);
It would seem that it performs a software reset in the flush, and that this does not adequately wait for the DMA to finish its work.
So instead of flushing the buffer, it actually prevents some data to be written.
In the cusomer's code a flush is issued right after a write.
bytes_written = write(fd, buf+totalSent, len);
tcflush(fd, TCIOFLUSH);
This flush causes the behavior mentioned in my previous post.
This has been introduced in commit 934084a9d2d95d0ce98ae8d1ec3bfe81c95c678c, and is still present in the current version:
linux-fslc/imx.c at 4.1-2.0.x-imx · Freescale/linux-fslc · GitHub
I have tried to add some code that would wait for the DMA to complete any work.
However, it seems that i am not allowed to call a premptive function to wait for the work_queue to be empty.
Furthermore, looping for the sport->dma_is_txing to change does not fix the issue.
I also tried to restore some more of the registers mention in the comments, but this has not fixed the issue.
My current solution is to undo commit 934084a9d2d95d0ce98ae8d1ec3bfe81c95c678c.
Best regards,
Rick Veens