summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2018-11-08 14:10:18 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2018-12-13 16:07:05 +0100
commit750b7cca6af02a35e52eaf012b32f1f11dc18ceb (patch)
tree857aab92ded199a089919bb4fb6e519483dcf11d
parent411a6b26f73dfb85143603cdad09588b8e159b04 (diff)
Do not print CPU MPID in mp_printf()
mp_printf() should just be an MP-safe version of printf(), i.e. one that takes the console lock before printing. It should not be responsible for printing the CPU MPID as well, this decision should be left to the caller. Also make Cactus and Ivy use mp_printf(). Before that, they could not call this function because they couldn't access the MPIDR_EL1 as S-EL0 images. Change-Id: I4eafee01ffc279296395b94dd4a07cfbb8e858e2 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
-rw-r--r--include/common/debug.h23
-rw-r--r--lib/utils/mp_printf.c47
-rw-r--r--spm/cactus/cactus.mk2
-rw-r--r--spm/ivy/ivy.mk2
4 files changed, 10 insertions, 64 deletions
diff --git a/include/common/debug.h b/include/common/debug.h
index bfbff09..216c53d 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -9,34 +9,15 @@
#include <stdio.h>
-/* TODO: Deal with per-image printf functions in a cleaner way. */
-
-#if defined(IMAGE_CACTUS) || defined(IMAGE_IVY)
-/*
- * The register MPIDR_EL1 can't be read from EL0, which means that mp_printf()
- * can't be used.
- */
-#define mp_printf printf
-#else
/*
* Print a formatted string on the UART.
*
* Does the same thing as the standard libc's printf() function but in a MP-safe
* manner, i.e. it can be called from several CPUs simultaneously without
* getting interleaved messages.
- *
- * The messages printed using mp_printf() won't be saved in the test results
- * (use tftf_testcase_output() instead for that). mp_printf() is meant to be
- * used for debug traces only. Unlike messages stored in the tests output which
- * appear only at the end of the test session in the test report, messages
- * printed using mp_printf() will be displayed straight away.
- *
- * Messaged will be prefixed by the CPU MPID issuing the call, like that:
- * [cpu 0x0002] Sending SGI #1 to cpu 0
*/
__attribute__((format(printf, 1, 2)))
void mp_printf(const char *fmt, ...);
-#endif
/*
* The log output macros print output to the console. These macros produce
@@ -44,8 +25,8 @@ void mp_printf(const char *fmt, ...);
* make command line) is greater or equal than the level required for that
* type of log output.
* The format expected is similar to printf(). For example:
- * INFO("Info %s.\n", "message") -> [cpu 0xxx] INFO: Info message.
- * WARN("Warning %s.\n", "message") -> [cpu 0xxx] WARNING: Warning message.
+ * INFO("Info %s.\n", "message") -> INFO: Info message.
+ * WARN("Warning %s.\n", "message") -> WARNING: Warning message.
*/
#define LOG_LEVEL_NONE 0
#define LOG_LEVEL_ERROR 10
diff --git a/lib/utils/mp_printf.c b/lib/utils/mp_printf.c
index 27a93ac..777c736 100644
--- a/lib/utils/mp_printf.c
+++ b/lib/utils/mp_printf.c
@@ -4,8 +4,6 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <platform.h>
#include <spinlock.h>
#include <stdarg.h>
#include <stdio.h>
@@ -13,51 +11,14 @@
/* Lock to avoid concurrent accesses to the serial console */
static spinlock_t printf_lock;
-/*
- * Print the MPID header, e.g.: [cpu 0x0100]
- *
- * If SHELL_COLOR == 1, this also prints shell's color escape sequences to ease
- * identifying which CPU displays the message. There are 8 standard colors so
- * if the platform has more than 8 CPUs, some colors will be reused.
- */
-#if SHELL_COLOR
-#define PRINT_MPID_HDR(_mpid) \
- do { \
- unsigned int linear_id = platform_get_core_pos(_mpid); \
- printf("\033[1;%u;40m", 30 + (linear_id & 0x7)); \
- printf("[cpu 0x%.4x] ", _mpid); \
- printf("\033[0m"); \
- } while (0)
-#else
-#define PRINT_MPID_HDR(_mpid) \
- printf("[cpu 0x%.4x] ", _mpid)
-#endif /* SHELL_COLOR */
-
void mp_printf(const char *fmt, ...)
{
- /*
- * As part of testing Firmware Update feature on Cortex-A57 CPU, an
- * issue was discovered while printing in NS_BL1U stage. The issue
- * appears when the second call to `NOTICE()` is made in the
- * `ns_bl1u_main()`. As a result of this issue the CPU hangs and the
- * debugger is also not able to connect anymore.
- *
- * After further debugging and experiments it was found that if
- * `read_mpidr_el1()` is avoided or volatile qualifier is used for
- * reading the mpidr, this issue gets resolved.
- *
- * NOTE: The actual/real reason why this happens is still not known.
- * Moreover this problem is not encountered on Cortex-A53 CPU.
- */
- volatile unsigned int mpid = read_mpidr_el1() & 0xFFFF;
-
- va_list ap;
- va_start(ap, fmt);
+ va_list args;
+ va_start(args, fmt);
spin_lock(&printf_lock);
- PRINT_MPID_HDR(mpid);
- vprintf(fmt, ap);
+ vprintf(fmt, args);
spin_unlock(&printf_lock);
- va_end(ap);
+ va_end(args);
}
diff --git a/spm/cactus/cactus.mk b/spm/cactus/cactus.mk
index 1ebc692..03d809d 100644
--- a/spm/cactus/cactus.mk
+++ b/spm/cactus/cactus.mk
@@ -58,6 +58,8 @@ CACTUS_SOURCES += \
CACTUS_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \
lib/${ARCH}/cache_helpers.S \
lib/${ARCH}/misc_helpers.S \
+ lib/locks/${ARCH}/spinlock.S \
+ lib/utils/mp_printf.c \
${STDLIB_SOURCES} \
${SPRT_LIB_SOURCES}
diff --git a/spm/ivy/ivy.mk b/spm/ivy/ivy.mk
index 89fd92d..c7726f4 100644
--- a/spm/ivy/ivy.mk
+++ b/spm/ivy/ivy.mk
@@ -55,6 +55,8 @@ IVY_SOURCES += \
IVY_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \
lib/${ARCH}/cache_helpers.S \
lib/${ARCH}/misc_helpers.S \
+ lib/locks/${ARCH}/spinlock.S \
+ lib/utils/mp_printf.c \
${STDLIB_SOURCES} \
${SPRT_LIB_SOURCES}