qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] serial: cleanups for physical serial port passthrough
@ 2014-09-19  8:54 Paolo Bonzini
  2014-09-19  8:54 ` [Qemu-devel] [PATCH 1/2] serial: reset state at startup Paolo Bonzini
  2014-09-19  8:54 ` [Qemu-devel] [PATCH 2/2] serial: check if backed by a physical serial port at realize time Paolo Bonzini
  0 siblings, 2 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-09-19  8:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

Patch 1 ensures that the serial port state is the same at VM startup
and after reset.

Patch 2 ensures that the poll_msl field is computed at reset time
(rather than arbitrarily later), so that it becomes -1 for serial ports
backed by PTYs, sockets, etc.

Please review!

Paolo

Paolo Bonzini (2):
  serial: reset state at startup
  serial: check if backed by a physical serial port at realize time

 hw/char/serial.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/2] serial: reset state at startup
  2014-09-19  8:54 [Qemu-devel] [PATCH 0/2] serial: cleanups for physical serial port passthrough Paolo Bonzini
@ 2014-09-19  8:54 ` Paolo Bonzini
  2014-09-19  9:17   ` Chen, Tiejun
  2014-09-19  8:54 ` [Qemu-devel] [PATCH 2/2] serial: check if backed by a physical serial port at realize time Paolo Bonzini
  1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2014-09-19  8:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

When a serial port is started, its initial state is all zero.  Make
it consistent with reset state instead.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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);
     fifo8_create(&s->recv_fifo, UART_FIFO_LENGTH);
     fifo8_create(&s->xmit_fifo, UART_FIFO_LENGTH);
+    serial_reset(s);
 }
 
 void serial_exit_core(SerialState *s)
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2] serial: check if backed by a physical serial port at realize time
  2014-09-19  8:54 [Qemu-devel] [PATCH 0/2] serial: cleanups for physical serial port passthrough Paolo Bonzini
  2014-09-19  8:54 ` [Qemu-devel] [PATCH 1/2] serial: reset state at startup Paolo Bonzini
@ 2014-09-19  8:54 ` Paolo Bonzini
  1 sibling, 0 replies; 6+ messages in thread
From: Paolo Bonzini @ 2014-09-19  8:54 UTC (permalink / raw)
  To: qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

Right now, s->poll_msl may linger at "0" value for an arbitrarily long
time, until serial_update_msl is called for the first time.  This is
unnecessary, and will lead to the s->poll_msl field being unnecessarily
migrated.

We can call serial_update_msl immediately at realize time (via
serial_reset) and be done with it.  The memory-mapped UART was already
doing that, but not the ISA and PCI variants.

Regarding the delta bits, be consistent with what serial_reset does when
the serial port is not backed by a physical serial port, and always clear
them at reset time.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/char/serial.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index 4523ccb..e1dd0c9 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -650,6 +650,9 @@ static void serial_reset(void *opaque)
     s->thr_ipending = 0;
     s->last_break_enable = 0;
     qemu_irq_lower(s->irq);
+
+    serial_update_msl(s);
+    s->msr &= ~UART_MSR_ANY_DELTA;
 }
 
 void serial_realize_core(SerialState *s, Error **errp)
@@ -780,7 +783,5 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
     memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s,
                           "serial", 8 << it_shift);
     memory_region_add_subregion(address_space, base, &s->io);
-
-    serial_update_msl(s);
     return s;
 }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup
  2014-09-19  8:54 ` [Qemu-devel] [PATCH 1/2] serial: reset state at startup Paolo Bonzini
@ 2014-09-19  9:17   ` Chen, Tiejun
  2014-09-19 12:57     ` Paolo Bonzini
  0 siblings, 1 reply; 6+ messages in thread
From: Chen, Tiejun @ 2014-09-19  9:17 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

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 <pbonzini@redhat.com>
> ---
>   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

static void serial_reset(void *opaque)
{
     ...
     fifo8_reset(&s->recv_fifo);
     fifo8_reset(&s->xmit_fifo);


Thanks
Tiejun

>   }
>
>   void serial_exit_core(SerialState *s)
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup
  2014-09-19  9:17   ` Chen, Tiejun
@ 2014-09-19 12:57     ` Paolo Bonzini
  2014-09-22  1:19       ` Chen, Tiejun
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2014-09-19 12:57 UTC (permalink / raw)
  To: Chen, Tiejun, qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

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 <pbonzini@redhat.com>
>> ---
>>   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
then you initialize it, not the other way round.

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)
>>
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH 1/2] serial: reset state at startup
  2014-09-19 12:57     ` Paolo Bonzini
@ 2014-09-22  1:19       ` Chen, Tiejun
  0 siblings, 0 replies; 6+ messages in thread
From: Chen, Tiejun @ 2014-09-22  1:19 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: armbru, pavel.dovgaluk, batuzovk

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 <pbonzini@redhat.com>
>>> ---
>>>    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)
>>>
>>
>>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-09-22  1:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-19  8:54 [Qemu-devel] [PATCH 0/2] serial: cleanups for physical serial port passthrough Paolo Bonzini
2014-09-19  8:54 ` [Qemu-devel] [PATCH 1/2] serial: reset state at startup Paolo Bonzini
2014-09-19  9:17   ` Chen, Tiejun
2014-09-19 12:57     ` Paolo Bonzini
2014-09-22  1:19       ` Chen, Tiejun
2014-09-19  8:54 ` [Qemu-devel] [PATCH 2/2] serial: check if backed by a physical serial port at realize time Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).