mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] MIPS: asm/debug_ll_ns16550.h: add nop in delay slot
@ 2020-09-08  6:25 Du Huanpeng
  2020-09-08 11:39 ` Antony Pavlov
  0 siblings, 1 reply; 2+ messages in thread
From: Du Huanpeng @ 2020-09-08  6:25 UTC (permalink / raw)
  To: barebox; +Cc: Du Huanpeng

In the debug_ll_outc_a0 macro, a0 is written to the uart data
register many times in a delay slot when the uart is not ready
to send data. insert a nop to avoid this.

Signed-off-by: Du Huanpeng <u74147@gmail.com>
---
 arch/mips/include/asm/debug_ll_ns16550.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/mips/include/asm/debug_ll_ns16550.h b/arch/mips/include/asm/debug_ll_ns16550.h
index df58c4c..cf666d1 100644
--- a/arch/mips/include/asm/debug_ll_ns16550.h
+++ b/arch/mips/include/asm/debug_ll_ns16550.h
@@ -88,6 +88,7 @@ static inline void PUTC_LL(char ch)
 201:	lbu	t1, UART_LSR(t0)	/* get line status */
 	andi	t1, t1, UART_LSR_THRE	/* check for transmitter empty */
 	beqz	t1, 201b			/* try again */
+	nop
 
 	sb	a0, UART_THR(t0)	/* write the character */
 
-- 
2.7.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] MIPS: asm/debug_ll_ns16550.h: add nop in delay slot
  2020-09-08  6:25 [PATCH] MIPS: asm/debug_ll_ns16550.h: add nop in delay slot Du Huanpeng
@ 2020-09-08 11:39 ` Antony Pavlov
  0 siblings, 0 replies; 2+ messages in thread
From: Antony Pavlov @ 2020-09-08 11:39 UTC (permalink / raw)
  To: Du Huanpeng; +Cc: barebox

On Tue,  8 Sep 2020 14:25:05 +0800
Du Huanpeng <u74147@gmail.com> wrote:

Hi!

Adding nop is not necessary.

Please see full text of debug_ll_outc_a0:

.macro  debug_ll_outc_a0
#ifdef CONFIG_DEBUG_LL
        .set    push
        .set    reorder  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

        la      t0, DEBUG_LL_UART_ADDR

201:    lbu     t1, UART_LSR(t0)        /* get line status */
        andi    t1, t1, UART_LSR_THRE   /* check for transmitter empty */
        beqz    t1, 201b                        /* try again */

        sb      a0, UART_THR(t0)        /* write the character */

        .set    pop
#endif /* CONFIG_DEBUG_LL */
.endm


There is '.set reorder' so assembler has insert nop after beqz automatically.

I have compiled barebox for qemu-malta with DEBUG_LL enabled.

barebox$ mips-linux-gnu-objdump -D arch/mips/boards/qemu-malta/lowlevel.pbl.o  | grep -A 10 "_nmon_outc_a0>:$"

00000314 <_nmon_outc_a0>:
 314:	3c08b800 	lui	t0,0xb800
 318:	350803f8 	ori	t0,t0,0x3f8
 31c:	91090005 	lbu	t1,5(t0)
 320:	31290020 	andi	t1,t1,0x20
 324:	1120fffd 	beqz	t1,31c <_nmon_outc_a0+0x8>
 328:	00000000 	nop                            <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 32c:	a1040000 	sb	a0,0(t0)
 330:	03e00008 	jr	ra
 334:	00000000 	nop


> In the debug_ll_outc_a0 macro, a0 is written to the uart data
> register many times in a delay slot when the uart is not ready
> to send data. insert a nop to avoid this.
> 
> Signed-off-by: Du Huanpeng <u74147@gmail.com>
> ---
>  arch/mips/include/asm/debug_ll_ns16550.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/mips/include/asm/debug_ll_ns16550.h b/arch/mips/include/asm/debug_ll_ns16550.h
> index df58c4c..cf666d1 100644
> --- a/arch/mips/include/asm/debug_ll_ns16550.h
> +++ b/arch/mips/include/asm/debug_ll_ns16550.h
> @@ -88,6 +88,7 @@ static inline void PUTC_LL(char ch)
>  201:	lbu	t1, UART_LSR(t0)	/* get line status */
>  	andi	t1, t1, UART_LSR_THRE	/* check for transmitter empty */
>  	beqz	t1, 201b			/* try again */
> +	nop
>  
>  	sb	a0, UART_THR(t0)	/* write the character */
>  
> -- 
> 2.7.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox


-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-08 11:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08  6:25 [PATCH] MIPS: asm/debug_ll_ns16550.h: add nop in delay slot Du Huanpeng
2020-09-08 11:39 ` Antony Pavlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox