public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 3/4] tegra: Implement pre-console putc() for fdt warning
Date: Sat, 10 Mar 2012 21:08:30 +0100	[thread overview]
Message-ID: <20120310200830.C8F9E202DB1@gemini.denx.de> (raw)
In-Reply-To: <CAPnjgZ1=KK9UNy2fyk9WJ-gcyYE5JgwqO_cT8igXjD-OFP_h6w@mail.gmail.com>

Dear Simon Glass,

In message <CAPnjgZ1=KK9UNy2fyk9WJ-gcyYE5JgwqO_cT8igXjD-OFP_h6w@mail.gmail.com> you wrote:
> 
> >> +void board_pre_console_putc(int ch)
> >> +{
> > ...
> >> +     for (uart_addr = uart_reg_addr; *uart_addr; uart_addr++) {
> >> +             NS16550_t regs = (NS16550_t)*uart_addr;
> >> +
> >> +             NS16550_init(regs, divisor);
> >> +             NS16550_putc(regs, ch);
> >> +             if (ch == '\n')
> >> +                     NS16550_putc(regs, '\r');
> >> +             NS16550_drain(regs);
> >
> > Why is this needed for every output character?
> >
> > Actually, why is it needed at all?
>
> Of course in this case the init could be done for each UART at the
> start of the function rather than in the loop, by looping through the
> UARTs twice.

Both the init() and the drain() should never be used in a character
output loop.

> After requests on the list for general purpose pre-console output
> function (the purpose of which I didn't necessary see) I changed this
> to a putc() mechanism. This means that we need to set up the UARTs
> each time it is called. We can't really add a flag to global data
> since this might be called before that is even set up. There might be
> a better way, but I'm not sure what it is.
>
> For SPL I would like to be able use this same mechanism to call
> panic() when something goes wrong, and use the same mechanism to get a
> message to the user. Again, this avoids a bricked unit with no failure
> indication.

I understand your intention, but I disagree with the design, and with
the implementation.

I think outputting data to all "potential" console ports is a really
bad thing, as you cannot know how your users are using the hardware.
They may have attached hardware to the UARTs, and the data you send to
the port causes a mis-function of the device.  I guess you don't add
to your documentation a warning like: select one port as console, and
leave allother ports unused, because we may send random date to all
ports any time?

If you do not know which UART port to use, then the only consequence
can be not to use any UART prt at all.  Use a LED with blink codes or
whatever your hardwar ehas, but do not mess with random ports.

I also cannot understand why you think you must init() and drain() the
UART for each character printed - ok, the latter is probably a
consequence of re-initializing the port for each character.
Eventually this will be not needed once you get rid of the re-init.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Consistency requires you to be as ignorant today as you were a  year
ago."                                              - Bernard Berenson

  reply	other threads:[~2012-03-10 20:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 20:32 [U-Boot] [PATCH v2 1/4] ns16550: Add function to drain serial output Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 2/4] Enable printf() console if pre-console putc() is available Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 3/4] tegra: Implement pre-console putc() for fdt warning Simon Glass
2012-03-10  8:16   ` Wolfgang Denk
2012-03-10 19:22     ` Simon Glass
2012-03-10 20:08       ` Wolfgang Denk [this message]
2012-03-10 21:25         ` Simon Glass
2012-03-10 22:49           ` Wolfgang Denk
2012-03-11  0:48             ` Simon Glass
2012-03-09 20:32 ` [U-Boot] [PATCH v2 4/4] tegra: Enable pre-console putc() for Tegra boards Simon Glass
2012-03-09 20:59 ` [U-Boot] [PATCH v2 1/4] ns16550: Add function to drain serial output Tom Warren
2012-03-10  8:20   ` Wolfgang Denk
2012-03-09 21:00 ` Stephen Warren
2012-03-09 21:08   ` Simon Glass
2012-03-09 21:23     ` Tom Warren
2012-03-09 21:29       ` Simon Glass
2012-03-09 21:40         ` Stephen Warren
2012-03-10  8:19 ` Wolfgang Denk
2012-03-10 19:27   ` Simon Glass
2012-03-10 20:24     ` Wolfgang Denk
2012-03-11  0:52       ` Simon Glass
2012-03-11  2:06 ` Mike Frysinger

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=20120310200830.C8F9E202DB1@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox