Got it. 

Peter Maydell <peter.maydell@linaro.org> 于2021年9月8日周三 下午5:47写道:
On Wed, 8 Sept 2021 at 03:50, Duo jia <jiaduo19920301@gmail.com> wrote:
> Also I want to know how to make a delay in qemu.
> For example, when I send a UART data, there is a certain time interval from setting the register to when the data is sent. Most of this time does not affect the simulation effect, but some guest firmware will execute errors when there is no such delay. This is a comparison. Few, but it does exist.
>
> My question is, if I really want to add such a delay, how to do it. For example, in USART, can I set a callback for sending completion, or add some delays that will not cause qemu to freeze.

You can do this kind of thing with an additional timer.
Look at hw/char/cadenc_uart.c and its handling of char_tx_time
for an example. In that case it is (despite the name)
modelling slow data receive, not slow data transmit, but
the basic idea is the same.

As you say, though, very little guest code really cares about
UART character timings (and the guest code that does is probably
buggy strictly speaking). So if I were you I would put "model
delays in UART timings" very low on your priority list...

-- PMM