Skip to content

Commit 2c50a57

Browse files
Linus WalleijRussell King
authored andcommitted
ARM: 9004/1: debug: Split waituart to CTS and TXRDY
This patch was triggered by a remark from Russell that introducing a call to the waituart (needed to fix debug prints on the Qualcomm platforms) was dangerous because in some cases this will involve waiting for a modem CTS (clear to send) signal, and debug messages would maybe not work on platforms with no modem connected to the UART port: they will just hang waiting for the modem to assert CTS and this might never happen. Looking through all UART debug drivers implementing the waituart macro I discovered that all users except two actually use this macro to check if the UART is ready for TX, let's call this TXRDY. Only two debug UART drivers actually check for CTS: - arch/arm/include/debug/8250.S - arch/arm/include/debug/tegra.S The former is very significant since the 8250 is possibly the most common UART on the planet. We have the following problem: the semantics of waituart are ambiguous making it dangerous to introduce the macro to debug code fixing debug prints for Qualcomm. To start to pry this problem apart, this patch does the following: - Convert all debug UART drivers to define two macros: - waituartcts with the clear semantic to wait for CTS to be asserted - waituarttxrdy with the clear semantic to wait for the TX capability of the UART to be ready - When doing this take care to assign the right function to each drivers macro, so they now do exactly the above. - Update the three sites in the kernel invoking the waituart macro to call waituartcts/waituarttxrdy in sequence, so that the functional impact on the kernel should be zero. After this we can start to change the code sites using this code to do the right thing. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
1 parent 6428ea2 commit 2c50a57

27 files changed

Lines changed: 114 additions & 30 deletions

‎arch/arm/boot/compressed/debug.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
ENTRY(putc)
1010
addruart r1, r2, r3
11-
waituart r3, r1
11+
waituartcts r3, r1
12+
waituarttxrdy r3, r1
1213
senduart r0, r1
1314
busyuart r3, r1
1415
mov pc, lr

‎arch/arm/include/debug/8250.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@
4545
bne 1002b
4646
.endm
4747

48-
.macro waituart,rd,rx
48+
.macro waituarttxrdy,rd,rx
49+
.endm
50+
51+
.macro waituartcts,rd,rx
4952
#ifdef CONFIG_DEBUG_UART_8250_FLOW_CONTROL
5053
1001: load \rd, [\rx, #UART_MSR << UART_SHIFT]
5154
tst \rd, #UART_MSR_CTS

‎arch/arm/include/debug/asm9260.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
ldr \rv, = CONFIG_DEBUG_UART_VIRT
1212
.endm
1313

14-
.macro waituart,rd,rx
14+
.macro waituarttxrdy,rd,rx
15+
.endm
16+
17+
.macro waituartcts,rd,rx
1518
.endm
1619

1720
.macro senduart,rd,rx

‎arch/arm/include/debug/at91.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
strb \rd, [\rx, #(AT91_DBGU_THR)] @ Write to Transmitter Holding Register
2020
.endm
2121

22-
.macro waituart,rd,rx
22+
.macro waituarttxrdy,rd,rx
2323
1001: ldr \rd, [\rx, #(AT91_DBGU_SR)] @ Read Status Register
2424
tst \rd, #AT91_DBGU_TXRDY @ DBGU_TXRDY = 1 when ready to transmit
2525
beq 1001b
2626
.endm
2727

28+
.macro waituartcts,rd,rx
29+
.endm
30+
2831
.macro busyuart,rd,rx
2932
1001: ldr \rd, [\rx, #(AT91_DBGU_SR)] @ Read Status Register
3033
tst \rd, #AT91_DBGU_TXEMPTY @ DBGU_TXEMPTY = 1 when transmission complete

‎arch/arm/include/debug/bcm63xx.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
strb \rd, [\rx, #UART_FIFO_REG]
1818
.endm
1919

20-
.macro waituart, rd, rx
20+
.macro waituarttxrdy, rd, rx
2121
1001: ldr \rd, [\rx, #UART_IR_REG]
2222
tst \rd, #(1 << UART_IR_TXEMPTY)
2323
beq 1001b
2424
.endm
2525

26+
.macro waituartcts, rd, rx
27+
.endm
28+
2629
.macro busyuart, rd, rx
2730
1002: ldr \rd, [\rx, #UART_IR_REG]
2831
tst \rd, #(1 << UART_IR_TXTRESH)

‎arch/arm/include/debug/brcmstb.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ ARM_BE8( rev \rd, \rd )
142142
bne 1002b
143143
.endm
144144

145-
.macro waituart,rd,rx
145+
.macro waituarttxrdy,rd,rx
146+
.endm
147+
148+
.macro waituartcts,rd,rx
146149
.endm
147150

148151
/*

‎arch/arm/include/debug/clps711x.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
ldr \rp, =CLPS711X_UART_PADDR
2121
.endm
2222

23-
.macro waituart,rd,rx
23+
.macro waituartcts,rd,rx
24+
.endm
25+
26+
.macro waituarttxrdy,rd,rx
2427
.endm
2528

2629
.macro senduart,rd,rx

‎arch/arm/include/debug/dc21285.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@
3434
bne 1001b
3535
.endm
3636

37-
.macro waituart,rd,rx
37+
.macro waituartcts,rd,rx
38+
.endm
39+
40+
.macro waituarttxrdy,rd,rx
3841
.endm

‎arch/arm/include/debug/digicolor.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
strb \rd, [\rx, #UA0_EMI_REC]
2222
.endm
2323

24-
.macro waituart,rd,rx
24+
.macro waituartcts,rd,rx
25+
.endm
26+
27+
.macro waituarttxrdy,rd,rx
2528
.endm
2629

2730
.macro busyuart,rd,rx

‎arch/arm/include/debug/efm32.S‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
strb \rd, [\rx, #UARTn_TXDATA]
3030
.endm
3131

32-
.macro waituart,rd,rx
32+
.macro waituartcts,rd,rx
33+
.endm
34+
35+
.macro waituarttxrdy,rd,rx
3336
1001: ldr \rd, [\rx, #UARTn_STATUS]
3437
tst \rd, #UARTn_STATUS_TXBL
3538
beq 1001b

0 commit comments

Comments
 (0)