All of lore.kernel.org
 help / color / mirror / Atom feed
From: linux@armlinux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] ARM: early_printk: use printascii() rather than printch()
Date: Tue, 31 Oct 2017 18:20:25 +0000	[thread overview]
Message-ID: <20171031182024.GK9463@n2100.armlinux.org.uk> (raw)
In-Reply-To: <nycvar.YSQ.7.76.1710311355000.21665@knanqh.ubzr>

On Tue, Oct 31, 2017 at 02:15:14PM -0400, Nicolas Pitre wrote:
> On Tue, 31 Oct 2017, Russell King - ARM Linux wrote:
> > On Tue, Oct 31, 2017 at 01:48:01PM -0400, Nicolas Pitre wrote:
> > > On Tue, 31 Oct 2017, Russell King - ARM Linux wrote:
> > > 
> > > > On Tue, Oct 31, 2017 at 01:06:35PM -0400, Nicolas Pitre wrote:
> > > > > That's easy to veryfy with this patch:
> > > > 
> > > > Unfortunately not that easy, this patch breaks printch.
> > > 
> > > Right, missed that.
> > > 
> > > New patch below:
> > > 
> > > diff --git a/arch/arm/kernel/debug.S b/arch/arm/kernel/debug.S
> > > index ea9646cc2a..0d1cef4b6e 100644
> > > --- a/arch/arm/kernel/debug.S
> > > +++ b/arch/arm/kernel/debug.S
> > > @@ -79,25 +79,28 @@ hexbuf:		.space 16
> > >  
> > >  ENTRY(printascii)
> > >  		addruart_current r3, r1, r2
> > > -		b	2f
> > > -1:		waituart r2, r3
> > > -		senduart r1, r3
> > > -		busyuart r2, r3
> > > -		teq	r1, #'\n'
> > > -		moveq	r1, #'\r'
> > > -		beq	1b
> > > -2:		teq	r0, #0
> > > +1:		teq	r0, #0
> > >  		ldrneb	r1, [r0], #1
> > >  		teqne	r1, #0
> > > -		bne	1b
> > > -		ret	lr
> > > +		reteq	lr
> > > +		teq     r1, #'\n'
> > > +		bne	2f
> > > +		mov	r1, '\r'
> > > +		waituart r2, r3
> > > +		senduart r1, r3
> > > +		busyuart r2, r3
> > > +		mov	r1, '\n'
> > > +2:		waituart r2, r3
> > > +		senduart r1, r3
> > > +		busyuart r2, r3
> > > +		b	1b
> > >  ENDPROC(printascii)
> > >  
> > >  ENTRY(printch)
> > >  		addruart_current r3, r1, r2
> > >  		mov	r1, r0
> > >  		mov	r0, #0
> > > -		b	1b
> > > +		b	2b
> > >  ENDPROC(printch)
> > 
> > Still, not quite!  printch('\n') with the old code would do this
> > (in terms of executed instructions):
> > 
> >  		mov	r1, r0
> >  		mov	r0, #0
> > 		b	1b
> > 1:		waituart r2, r3
> > 		senduart r1, r3
> > 		busyuart r2, r3
> > 		teq	r1, #'\n'
> > 		moveq	r1, #'\r'
> > 		beq	1b
> > 1:		waituart r2, r3
> > 		senduart r1, r3
> > 		busyuart r2, r3
> > 		teq	r1, #'\n'
> > 		...
> > 2:		teq	r0, #0
> > 		ret	lr
> > 
> > So a printch('\n') produces "\n\r" on the UART.  If we're fixing
> > printascii() to emit "\r\n" instead of "\n\r" for a '\n', then
> > printch() should have the same fix, and should not truncate to
> > just '\n'.
> 
> OK... That's easy to achieve, but is it desirable?

Yes - remember, these are supposed to be usable from assembly,
and we really don't want to have the complexity of:

	mov	r0, #'\r'
	bl	printch
	mov	r0, #'\n'
	bl	printch

each time we want to begin a new line.

> IMHO the semantics of a single character should be just that: a single 
> character.  And if some user relied on printch('\n') inserting the \r 
> automatically then this would have run into the same display issue we're 
> attempting to fix here. That might be why early_write() did the extra \r 
> itself.

You're thinking about these functions as C functions that you'd call
from C code.  That's not their primary purpose or intention, they're
for debugging assembly.  They just happen to be re-used for the
early printk crap because people find these a convenient implementation.

> Thing is: that only printch user user is now gone. So I'd fix the 
> semantic issue by simply removing printch altogether.

No.  You could make the same argument for the printhex*() functions
too, but removing them means next time we need to stuff in some
debug that prints hex numbers before the MMU is up, we need to
reinvent those wheels yet again.

The point of this assembly is to provide a set of debugging functions
that can be used from assembly.  They were never really meant for C
code to use.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

  reply	other threads:[~2017-10-31 18:20 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02  2:06 [PATCH 0/3] a few debug_ll fixes and improvements Nicolas Pitre
2017-10-02  2:06 ` [PATCH 1/3] ARM: debug.S: move hexbuf to a writable section Nicolas Pitre
2017-10-02  2:06 ` [PATCH 2/3] ARM: semihosting: use proper instruction on v7m processors Nicolas Pitre
2017-10-02  2:06 ` [PATCH 3/3] ARM: early_printk: use printascii() rather than printch() Nicolas Pitre
2017-10-02  5:20   ` Uwe Kleine-König
2017-10-02 14:09     ` Nicolas Pitre
2017-10-31 11:28   ` Chris Brandt
2017-10-31 16:22     ` Nicolas Pitre
2017-10-31 16:38       ` Robin Murphy
2017-10-31 17:06         ` Nicolas Pitre
2017-10-31 17:16           ` Russell King - ARM Linux
2017-10-31 17:48             ` Nicolas Pitre
2017-10-31 17:53               ` Russell King - ARM Linux
2017-10-31 18:15                 ` Nicolas Pitre
2017-10-31 18:20                   ` Russell King - ARM Linux [this message]
2017-10-31 18:35                     ` Nicolas Pitre
2017-10-31 19:12                       ` Chris Brandt
2017-10-31 19:28                         ` Nicolas Pitre
2017-10-31 21:50                           ` Russell King - ARM Linux
2017-10-31 23:35                             ` Nicolas Pitre
2017-10-31 23:50                               ` Russell King - ARM Linux
2017-11-02  0:09                         ` Russell King - ARM Linux
2017-11-02  3:59                           ` Nicolas Pitre
2017-11-02  4:16                             ` Nicolas Pitre
2017-11-02 11:09                               ` Russell King - ARM Linux
2017-11-02 15:12                                 ` Nicolas Pitre
2017-11-02 11:06                             ` Chris Brandt
2017-11-02 11:20                               ` Russell King - ARM Linux
2017-11-02 11:28                                 ` Chris Brandt
2017-11-02 13:04                                   ` Russell King - ARM Linux
2017-11-02 15:04                                   ` Nicolas Pitre
2017-11-02 15:18                                     ` Robin Murphy
2017-11-02 15:22                                       ` Russell King - ARM Linux
2017-11-02 15:25                                       ` Chris Brandt
2017-11-02 15:23                                     ` Chris Brandt
2017-11-02 15:35                                       ` Nicolas Pitre
2017-11-02 16:06                                         ` Nicolas Pitre
2017-11-02 16:38                                           ` Chris Brandt
2017-11-02 17:10                                             ` Russell King - ARM Linux
2017-11-02 17:20                                               ` Nicolas Pitre
2017-11-02 17:28                                               ` Chris Brandt
2017-11-02 18:29                                               ` Robin Murphy
2017-11-02 21:46                                                 ` syntax unified, was " Nicolas Pitre
2017-11-02 15:48                                       ` Russell King - ARM Linux
2017-11-02 16:30                                         ` Chris Brandt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171031182024.GK9463@n2100.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.