mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: sbi: protect dprintf output with spinlock
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>
This commit is contained in:
@@ -387,8 +387,11 @@ int sbi_dprintf(const char *format, ...)
|
|||||||
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
|
struct sbi_scratch *scratch = sbi_scratch_thishart_ptr();
|
||||||
|
|
||||||
va_start(args, format);
|
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);
|
retval = print(NULL, NULL, format, args);
|
||||||
|
spin_unlock(&console_out_lock);
|
||||||
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
Reference in New Issue
Block a user