From: Paolo Bonzini <pbonzini@redhat.com>
To: Andrew Jones <drjones@redhat.com>, kvm@vger.kernel.org
Cc: alex.bennee@linaro.org, cov@codeaurora.org
Subject: Re: [kvm-unit-tests PATCH 18/18] arm/arm64: uart0_init: check /chosen/stdout-path
Date: Tue, 10 Nov 2015 17:37:18 +0100 [thread overview]
Message-ID: <56421D3E.2000301@redhat.com> (raw)
In-Reply-To: <1446769483-21586-19-git-send-email-drjones@redhat.com>
On 06/11/2015 01:24, Andrew Jones wrote:
> Arguably all of uart0_init() is unnecessary, as we're pretty sure
> that the address we initialize uart0_base to is correct. We go
> through the motions of finding the uart anyway though, because it's
> easy. It's also easy to check chosen/stdout-path first, so let's do
> that too. But, just to make all this stuff is a little less unnecessary,
> let's add a warning when we do actually find an address that doesn't
> match our initializer.
>
> Signed-off-by: Andrew Jones <drjones@redhat.com>
> ---
> lib/arm/io.c | 36 +++++++++++++++++++++++++++---------
> 1 file changed, 27 insertions(+), 9 deletions(-)
>
> diff --git a/lib/arm/io.c b/lib/arm/io.c
> index 8b1501886736a..a08d394e4aa1c 100644
> --- a/lib/arm/io.c
> +++ b/lib/arm/io.c
> @@ -19,12 +19,14 @@ extern void halt(int code);
> /*
> * Use this guess for the pl011 base in order to make an attempt at
> * having earlier printf support. We'll overwrite it with the real
> - * base address that we read from the device tree later.
> + * base address that we read from the device tree later. This is
> + * the address we expect QEMU's mach-virt machine type to put in
> + * its generated device tree.
> */
> -#define QEMU_MACH_VIRT_PL011_BASE 0x09000000UL
> +#define UART_EARLY_BASE 0x09000000UL
>
> static struct spinlock uart_lock;
> -static volatile u8 *uart0_base = (u8 *)QEMU_MACH_VIRT_PL011_BASE;
> +static volatile u8 *uart0_base = (u8 *)UART_EARLY_BASE;
>
> static void uart0_init(void)
> {
> @@ -32,16 +34,32 @@ static void uart0_init(void)
> struct dt_pbus_reg base;
> int ret;
>
> - ret = dt_pbus_get_base_compatible(compatible, &base);
> - assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
> + ret = dt_get_default_console_node();
> + assert(ret >= 0 || ret == -FDT_ERR_NOTFOUND);
>
> - if (ret) {
> - printf("%s: %s not found in the device tree, aborting...\n",
> - __func__, compatible);
> - abort();
> + if (ret == -FDT_ERR_NOTFOUND) {
> +
> + ret = dt_pbus_get_base_compatible(compatible, &base);
> + assert(ret == 0 || ret == -FDT_ERR_NOTFOUND);
> +
> + if (ret) {
> + printf("%s: %s not found in the device tree, "
> + "aborting...\n",
> + __func__, compatible);
> + abort();
> + }
> +
> + } else {
> + assert(dt_pbus_translate_node(ret, 0, &base) == 0);
> }
>
> uart0_base = ioremap(base.addr, base.size);
> +
> + if (uart0_base != (u8 *)UART_EARLY_BASE) {
> + printf("WARNING: early print support may not work. "
> + "Found uart at %p, but early base is %p.\n",
> + uart0_base, (u8 *)UART_EARLY_BASE);
> + }
> }
>
> void io_init(void)
>
Applied, thanks.
Paolo
next prev parent reply other threads:[~2015-11-10 16:37 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-06 0:24 [kvm-unit-tests PATCH 00/18] bunch of mostly trivial patches Andrew Jones
2015-11-06 0:24 ` [kvm-unit-tests PATCH 01/18] makefiles: use bash Andrew Jones
2015-11-10 16:22 ` Paolo Bonzini
2015-11-10 16:37 ` Andrew Jones
2015-11-10 16:48 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 02/18] trivial: lib: fail hard on failed mallocs Andrew Jones
2015-11-06 14:05 ` Thomas Huth
2015-11-07 1:02 ` Andrew Jones
2015-11-09 20:53 ` [kvm-unit-tests PATCH v2 02/19] " Andrew Jones
2015-11-09 20:55 ` Thomas Huth
2015-11-10 16:23 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 03/18] trivial: alloc: don't use 'top' outside spinlock Andrew Jones
2015-11-10 16:24 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 04/18] trivial: lib: missing extern in string.h Andrew Jones
2015-11-10 16:24 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 05/18] README: add pointer to new wiki page Andrew Jones
2015-11-10 16:25 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 06/18] README: add some CONTRIBUTING notes Andrew Jones
2015-11-10 16:25 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 07/18] configure: emit HOST=$host to config.mak Andrew Jones
2015-11-10 16:26 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 08/18] run_tests: pass test name to run script Andrew Jones
2015-11-10 16:34 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 09/18] arm/run: use ACCEL to choose between kvm and tcg Andrew Jones
2015-11-10 16:30 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 10/18] run_tests: probe for max-smp Andrew Jones
2015-11-10 16:31 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 11/18] lib/printf: support the %u unsigned fmt field Andrew Jones
2015-11-10 16:33 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 12/18] lib/arm: add flush_tlb_page mmu function Andrew Jones
2015-11-10 16:33 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 13/18] arm: Fail on unknown subtest Andrew Jones
2015-11-10 16:34 ` Paolo Bonzini
2015-11-06 0:24 ` [kvm-unit-tests PATCH 14/18] arm/arm64: allow building a single test Andrew Jones
2015-11-06 0:24 ` [kvm-unit-tests PATCH 15/18] arm/arm64: generate map files Andrew Jones
2015-11-06 0:24 ` [kvm-unit-tests PATCH 16/18] lib: link in linux kernel headers (uapi) Andrew Jones
2015-11-06 0:24 ` [kvm-unit-tests PATCH 17/18] Revert "arm/arm64: import include/uapi/linux/psci.h" Andrew Jones
2015-11-06 0:24 ` [kvm-unit-tests PATCH 18/18] arm/arm64: uart0_init: check /chosen/stdout-path Andrew Jones
2015-11-10 16:37 ` Paolo Bonzini [this message]
2015-11-09 20:57 ` [kvm-unit-tests PATCH 19/18] don't embed code inside asserts Andrew Jones
2015-11-10 16:37 ` Paolo Bonzini
2015-11-10 16:38 ` [kvm-unit-tests PATCH 00/18] bunch of mostly trivial patches Paolo Bonzini
2015-11-10 16:54 ` Andrew Jones
2015-11-20 18:01 ` Andrew Jones
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=56421D3E.2000301@redhat.com \
--to=pbonzini@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=cov@codeaurora.org \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.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.