From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57463) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVsIZ-00071e-Qh for qemu-devel@nongnu.org; Sun, 21 Sep 2014 21:20:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XVsIT-0002Ny-Mh for qemu-devel@nongnu.org; Sun, 21 Sep 2014 21:20:15 -0400 Received: from mga09.intel.com ([134.134.136.24]:18582) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVsIT-0002Fq-I1 for qemu-devel@nongnu.org; Sun, 21 Sep 2014 21:20:09 -0400 Message-ID: <541F793B.6030208@intel.com> Date: Mon, 22 Sep 2014 09:19:55 +0800 From: "Chen, Tiejun" MIME-Version: 1.0 References: <1411116849-18157-1-git-send-email-pbonzini@redhat.com> <1411116849-18157-2-git-send-email-pbonzini@redhat.com> <541BF4B9.9060708@intel.com> <541C2829.5020704@redhat.com> In-Reply-To: <541C2829.5020704@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: armbru@redhat.com, pavel.dovgaluk@ispras.ru, batuzovk@ispras.ru On 2014/9/19 20:57, Paolo Bonzini wrote: > Il 19/09/2014 11:17, Chen, Tiejun ha scritto: >> On 2014/9/19 16:54, Paolo Bonzini wrote: >>> When a serial port is started, its initial state is all zero. Make >>> it consistent with reset state instead. >>> >>> Signed-off-by: Paolo Bonzini >>> --- >>> hw/char/serial.c | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/hw/char/serial.c b/hw/char/serial.c >>> index 764e184..4523ccb 100644 >>> --- a/hw/char/serial.c >>> +++ b/hw/char/serial.c >>> @@ -668,6 +668,7 @@ void serial_realize_core(SerialState *s, Error >>> **errp) >>> serial_event, s); >> >> It should just follow qemu_register_reset(serial_reset, s). >> >>> fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH); >>> fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH); >>> + serial_reset(s); >> >> Or at least we should push this before this pair of fifo8_create() since > > No, it should be _after_ the fifo8_create() pair. With the current > implementation it doesn't matter, but first you create something and Yes, I took a look at this pair, void fifo8_create(Fifo8 *fifo, uint32_t capacity) { fifo->data = g_new(uint8_t, capacity); fifo->capacity = capacity; fifo->head = 0; fifo->num = 0; } and void fifo8_reset(Fifo8 *fifo) { fifo->num = 0; fifo->head = 0; } > then you initialize it, not the other way round. > Thanks for your explanation in this case. Thanks Tiejun > Paolo > >> static void serial_reset(void *opaque) >> { >> ... >> fifo8_reset(&s->recv_fifo); >> fifo8_reset(&s->xmit_fifo); >> >> >> Thanks >> Tiejun >> >>> } >>> >>> void serial_exit_core(SerialState *s) >>> >> >> > >