Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel dmesg UART output is garbled using the ttyS0/mini-UART/8250 on 5.17 #4849

Closed
pelwell opened this issue Jan 26, 2022 · 6 comments
Closed

Comments

@pelwell
Copy link
Contributor

pelwell commented Jan 26, 2022

Describe the bug

Messages from the kernel over the mini-UART (ttyS0) while booting 5.17 are garbled:

MESS:00:00:03.912325:0: uart: Set PL011 baud rate to 103448.300000 Hz
MESS:00:00:03.918842:0: uart: Baud rate change done...
[    0.00is7vlo-n-u.n00dift)Ma:Mud rate[    0.00oip
                                [    0.00P7sfe4)c[    0.00Piiip n[    0.00P ni Vasn
                                                                                   [    0.00FMma dv[    0.00aa [    0.00elt l[    0.00emcCra0iM[    0.00Fv iecpido[    0.00oe[    0.00  x000f[    0.00
                                                        [    0.00ootc
                                                                     [    0.00ao
                                                                                 [    0.00 00000f[    0.00nee 000f
                                                                                                                  [    0.00em1/72
                                                                                                                                  [    0.00uo,ti a3[    0.00emnrl0t_.cld5_vm10__3 m=0mb0sS0eoU7 y p t p.so

It appears that only a subset of the characters are getting through. The fact that the first 8 or 9 characters on a line are getting through intact suggests there is confusion over the FIFO size (which is a uniquely paltry 8).

ttyAMA0 (a PL011) is unaffected.

Observed on a 4B and 3B, but probably affects all Pis.

An investigation is underway.

Steps to reproduce the behaviour

Install a 5.17 kernel, put enable_uart=1 in config.txt (and not dtoverlay=disable-bt), and hook up a serial cable.

Device (s)

Raspberry Pi 3 Mod. B, Raspberry Pi 4 Mod. B

System

pi@raspberrypi:~$ uname -a
Linux raspberrypi 5.17.0-rc1-v7l+ #904 SMP Wed Jan 26 12:59:04 GMT 2022 armv7l GNU/Linux

Logs

See above.

Additional context

No response

@pelwell
Copy link
Contributor Author

pelwell commented Jan 26, 2022

Reverting 5021d70 (a patch that enables use of the FIFO) fixes it.

@popcornmix
Copy link
Collaborator

Does setting fifosize to 8 also work?

@pelwell
Copy link
Contributor Author

pelwell commented Jan 26, 2022

No - fifosize is already set to 8...

@pelwell
Copy link
Contributor Author

pelwell commented Jan 26, 2022

Ah - this comment must be significant:

		/* The BCM2835 MINI UART THRE bit is really a not-full bit. */
		if ((up->capabilities & UART_CAP_MINI) &&
		    !(serial_in(up, UART_LSR) & UART_LSR_THRE))
			break;

The easy (and possibly best) fix is to disable FIFO use if UART_CAP_MINI is set.

pelwell added a commit that referenced this issue Jan 26, 2022
The mini-UART on BCM283x is doubly crippled - it has 8-byte FIFOs and
the THRE bit indicates that the TX FIFO is not-full rather than empty.

The optimisation to enable the use of the FIFO assumes that it is safe
to write fifosize bytes whenever THRE is set, but the BCM283x quirk
(indicated by the presence of UART_CAP_MINI) makes it necessary to
check the FIFO state after each byte.

See: #4849

Fixes: 5021d70 ("tty: serial: Use fifo in 8250 console driver")
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
@pelwell
Copy link
Contributor Author

pelwell commented Jan 26, 2022

Fixed by ba71fc8, which will be pushed upstream.

@pelwell
Copy link
Contributor Author

pelwell commented Jan 26, 2022

Greg KH says he's dropped the offending patch, so at some point this fix will fail to apply.

@pelwell pelwell closed this as completed Jan 26, 2022
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this issue Mar 25, 2022
From Phil's original patch:

"""
The mini-UART on BCM283x is doubly crippled - it has 8-byte FIFOs and
the THRE bit indicates that the TX FIFO is not-full rather than empty.

The optimisation to enable the use of the FIFO assumes that it is safe
to write fifosize bytes whenever THRE is set, but the BCM283x quirk
(indicated by the presence of UART_CAP_MINI) makes it necessary to
check the FIFO state after each byte.

See: raspberrypi/linux#4849
"""

Thanks to Phil Elwell for reporting the issue and providing the original
patch.

Reported-by: Phil Elwell <phil@raspberrypi.com>
Co-author: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Wander Lairson Costa <wander@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants