Avoid getting messages from multiple harts (using dprintf and printf)
concurrently with a spinlock serializaing calls to sbi_dprintf(),
sbi_printf() and sbi_puts()
Signed-off-by: Dong Du <Dd_nirvana@sjtu.edu.cn>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
va_start(args, format);
- if (scratch->options & SBI_SCRATCH_DEBUG_PRINTS)
+ if (scratch->options & SBI_SCRATCH_DEBUG_PRINTS) {
+ spin_lock(&console_out_lock);
retval = print(NULL, NULL, format, args);
+ spin_unlock(&console_out_lock);
+ }
va_end(args);
return retval;