hw/openrisc/openrisc_sim: keep serial@90000000 as default
PATCH v2 1/1 hw/openrisc/openrisc_sim: keep serial@90000000 as default
From: Ahmad Fatoum <[email protected]>
We used to only have a single UART on the platform and it was located at address 0x90000000. When the number of UARTs was increased to 4, the first UART remained at it's location, but instead of being the first one to be registered, it became the last.
This caused QEMU to pick 0x90000300 as the default UART, which broke software that hardcoded the address of 0x90000000 and expected it's output to be visible when the user configured only a single console.
This caused regressions[1] in the barebox test suite when updating to a newer QEMU. As there seems to be no good reason to register the UARTs in inverse order, let's register them by ascending address, so existing software can remain oblivious to the additional UART ports.
Changing the order of uart registration alone breaks Linux which was choosing the UART at 0x90000300 as the default for ttyS0. To fix Linux we fix two things in the device tree:
1. Define stdout-path only one time for the first registerd UART instead of incorrectly defining for each UART.
2. Change the UART alias name from 'uart0' to 'serial0' as almost all Linux tty drivers look for an alias starting with "serial".
[1]: https://lore.barebox.org/barebox/[email protected]/T/#m5da26e8a799033301489a938b5d5667b81cef6ad
---
Since v1:
- Stafford is sending the patch for Ahmad now.
- Added 'Fixes'
- Only define stdout-path one time.
- Change alias name from 'uartN' to 'serialN'
hw/openrisc/openrisc_sim.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
hw/openrisc/openrisc_sim.c +8 -5
@@ -250,7 +250,7 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,void *fdt = state->fdt;char *nodename;qemu_irq serial_irq; -char alias[sizeof ("uart0" )]; +char alias[sizeof ("serial0" )];int i;if (num_cpus >1 ) {
@@ -265,7 +265,7 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base, serial_irq =get_cpu_irq (cpus,0 , irq_pin); }serial_mm_init (get_system_memory (), base,0 , serial_irq,115200 , -serial_hd (OR1KSIM_UART_COUNT - uart_idx -1 ), +serial_hd (uart_idx),DEVICE_NATIVE_ENDIAN );/* Add device tree node for serial. */
@@ -277,10 +277,13 @@ static void openrisc_sim_serial_init(Or1ksimState *state, hwaddr base,qemu_fdt_setprop_cell (fdt, nodename,"clock-frequency" ,OR1KSIM_CLK_MHZ );qemu_fdt_setprop (fdt, nodename,"big-endian" ,NULL ,0 ); -/* The /chosen node is created during fdt creation. */ -qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" , nodename); -snprintf (alias,sizeof (alias),"uart%d" , uart_idx); +if (uart_idx ==0 ) { +/* The /chosen node is created during fdt creation. */ +qemu_fdt_setprop_string (fdt,"/chosen" ,"stdout-path" , nodename); + } +snprintf (alias,sizeof (alias),"serial%d" , uart_idx);qemu_fdt_setprop_string (fdt,"/aliases" , alias, nodename); +g_free (nodename); }
Signature · 1 line
2.44.0