summaryrefslogtreecommitdiffstats
path: root/hw/char/serial.c
Commit message (Collapse)AuthorAgeFilesLines
* migration: Use normal VMStateDescriptions for SubsectionsJuan Quintela2015-06-121-25/+16
| | | | | | | | | | | | | | | | We create optional sections with this patch. But we already have optional subsections. Instead of having two mechanism that do the same, we can just generalize it. For subsections we just change: - Add a needed function to VMStateDescription - Remove VMStateSubsection (after removal of the needed function it is just a VMStateDescription) - Adjust the whole tree, moving the needed function to the corresponding VMStateDescription Signed-off-by: Juan Quintela <quintela@redhat.com>
* error: Use error_report_err() where appropriateMarkus Armbruster2015-02-181-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Coccinelle semantic patch: @@ expression E; @@ - error_report("%s", error_get_pretty(E)); - error_free(E); + error_report_err(E); @@ expression E, S; @@ - error_report("%s", error_get_pretty(E)); + error_report_err(E); ( exit(S); | abort(); ) Trivial manual touch-ups in block/sheepdog.c. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
* serial: Fix warnings caused by missing 'static' attributeStefan Weil2015-02-101-7/+7
| | | | | | | | | | | | | | | | | | | | | | Warnings from the Sparse static analysis tool: hw/char/serial.c:630:26: warning: symbol 'vmstate_serial_thr_ipending' was not declared. Should it be static? hw/char/serial.c:646:26: warning: symbol 'vmstate_serial_tsr' was not declared. Should it be static? hw/char/serial.c:665:26: warning: symbol 'vmstate_serial_recv_fifo' was not declared. Should it be static? hw/char/serial.c:681:26: warning: symbol 'vmstate_serial_xmit_fifo' was not declared. Should it be static? hw/char/serial.c:697:26: warning: symbol 'vmstate_serial_fifo_timeout_timer' was not declared. Should it be static? hw/char/serial.c:713:26: warning: symbol 'vmstate_serial_timeout_ipending' was not declared. Should it be static? hw/char/serial.c:729:26: warning: symbol 'vmstate_serial_poll' was not declared. Should it be static? Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* vmstate: accept QEMUTimer in VMSTATE_TIMER*, add VMSTATE_TIMER_PTR*Paolo Bonzini2015-01-261-2/+2
| | | | | | | Old users of VMSTATE_TIMER* are mechanically changed to VMSTATE_TIMER_PTR variants. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: refine serial_thr_ipending_neededPaolo Bonzini2015-01-031-2/+11
| | | | | | | | | | | | | | If the THR interrupt is disabled, there is no need to migrate thr_ipending because LSR.THRE will be sampled again when the interrupt is enabled. (This is the behavior that is not documented in the datasheet, but relied on by Windows!) Note that in this case IIR will never be 0x2 so, if thr_ipending were to be one, QEMU would produce the subsection. Reported-by: Igor Mammedov <imammedo@redhat.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: only resample THR interrupt on rising edge of IER.THRIPaolo Bonzini2014-12-151-9/+16
| | | | | | | | | | | | | There is disagreement on whether LSR.THRE should be resampled when IER.THRI goes from 1 to 1. Bochs only does it if IER.THRI goes from 0 to 1; PCE does it even if IER.THRI is unchanged. But the Windows driver seems to always go from 1 to 0 and back to 1, so do things in agreement with Bochs, because the handling of thr_ipending was reported in 2010 (https://lists.gnu.org/archive/html/qemu-devel/2010-03/msg01914.html) as breaking DR-DOS Plus. Reported-by: Roy Tam <roytam@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: update LSR on enabling/disabling FIFOsPaolo Bonzini2014-12-151-0/+3
| | | | | | | | | | | | | | When the transmit FIFO is emptied or enabled, the transmitter hold register is empty. When it is disabled, it is also emptied and in addition the previous contents of the transmitter hold register are discarded. In either case, the THRE bit in LSR must be set and THRI raised. When the receive FIFO is emptied or enabled, the data ready and break bits must be cleared in LSR. Likewise when the receive FIFO is disabled. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: clean up THRE/TEMT handlingPaolo Bonzini2014-12-151-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - assert TEMT is cleared before sending a character; we'll get one from TSR if tsr_retry > 0, from the FIFO or THR otherwise - assert THRE cleared and FIFO not empty (if enabled) before fetching a character to send. This effectively reverts dffacd46, but the check makes no sense and commit f702e62 (serial: change retry logic to avoid concurrency, 2014-07-11) must have made it unnecessary. The commit message for f702e62 talks about multiple calls to qemu_chr_fe_add_watch triggering s->tsr_retry >= MAX_XMIT_RETRY, but other failures were possible. For example, if you have multiple calls, the subsequent ones will see s->tsr_retry == 0 and will find THRE and/or TEMT on entry. - for clarity, raise THRI immediately after the code sets THRE - check THRE to see if another character has to be sent. This makes the assertions more obvious and also means TEMT has to be set as soon as the loop ends. It makes the loop send both TSR and THR if flow-control happens in non-FIFO mode. Previously, THR would be lost. - clear TEMT together with THRE even in the non-FIFO case The last two items are bugfixes, but they were just found by inspection and do not squash known bugs. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: reset thri_pending on IER writes with THRI=0Paolo Bonzini2014-12-151-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is responsible for failure of migration from 2.2 to 2.1, because thr_ipending is always one in practice. serial.c is setting thr_ipending unconditionally. However, thr_ipending is not used at all if THRI=0, and it will be overwritten again the next time THRE or THRI changes. For that reason, we can set thr_ipending to zero every time THRI is reset. There is disagreement on whether LSR.THRE should be resampled when IER.THRI goes from 1 to 1. This patch does not touch the code, leaving that for QEMU 2.3+. This has no semantic change and is enough to fix migration in the common case where the interrupt is not pending or is reported in IIR. It does not change the migration format, so 2.2.0 -> 2.1 will remain broken but we can fix 2.2.1 -> 2.1 without breaking 2.2.1 <-> 2.2.0. The case that remains broken (the one in which the subsection is strictly necessary) is when THRE=1, the THRI interrupt has *not* been acknowledged yet, and a higher-priority interrupt comes. In this case, you need the subsection to tell the source that the lower-priority THRI interrupt is pending. The subsection's breakage of migration, in this case, prevents continuing the VM on the destination with an invalid state. Cc: qemu-stable@nongnu.org Reported-by: Igor Mammedov <imammedo@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: check if backed by a physical serial port at realize timePaolo Bonzini2014-09-191-2/+3
| | | | | | | | | | | | | | | | | 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>
* serial: reset state at startupPaolo Bonzini2014-09-191-0/+1
| | | | | | | 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>
* serial: fixing vmstate for save/restorePavel Dovgalyuk2014-09-111-30/+195
| | | | | | | | | | Some fields were added to VMState by this patch to preserve correct loading of the serial port controller state. Updating FCR value while loading was also modified to disable generating an interrupt by loadvm. Signed-off-by: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: change retry logic to avoid concurrencyKirill Batuzov2014-07-141-26/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Whenever serial_xmit fails to transmit a byte it adds a watch that would call it again when the "line" becomes ready. This results in a retry chain: serial_xmit -> add_watch -> serial_xmit Each chain is able to transmit one character, and for every character passed to serial by the guest driver a new chain is spawned. The problem lays with the fact that a new chain is spawned even when there is one already waiting on the watch. So there can be several retry chains waiting concurrently on one "line". Every chain tries to transmit current character, so character order is not messed up. But also every chain increases retry counter (tsr_retry). If there are enough concurrent chains this counter will hit MAX_XMIT_RETRY value and the character will be dropped. To reproduce this bug you need to feed serial output to some program consuming it slowly enough. A python script from bug #1335444 description is an example of such program. This commit changes retry logic in the following way to avoid concurrency: instead of spawning a new chain for each character being transmitted spawn only one and make it transmit characters until FIFO is empty. The change consists of two parts: - add a do {} while () loop in serial_xmit (diff is a bit erratic for this part, diff -w will show actual change), - do not call serial_xmit from serial_ioport_write if there is one waiting on the watch already. This should fix another issue causing bug #1335444. Signed-off-by: Kirill Batuzov <batuzovk@ispras.ru> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* serial: poll the serial console with G_IO_HUPRoger Pau Monne2014-06-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On FreeBSD polling a master pty while the other end is not connected with G_IO_OUT only results in an endless wait. This is different from the Linux behaviour, that returns immediately. In order to demonstrate this, I have the following example code: http://xenbits.xen.org/people/royger/test_poll.c When executed on Linux: $ ./test_poll In callback On FreeBSD instead, the callback never gets called: $ ./test_poll So, in order to workaround this, poll the source with G_IO_HUP (which makes the code behave the same way on both Linux and FreeBSD). Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Cc: Michael Tokarev <mjt@tls.msk.ru> Cc: "Andreas Färber" <afaerber@suse.de> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: xen-devel@lists.xenproject.org [Add hw/char/cadence_uart.c too. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* savevm: Remove all the unneeded version_minimum_id_old (x86)Juan Quintela2014-06-161-1/+1
| | | | | | | | | | | | | | | | | | | | | After previous Peter patch, they are redundant. This way we don't assign them except when needed. Once there, there were lots of case where the ".fields" indentation was wrong: .fields = (VMStateField []) { and .fields = (VMStateField []) { Change all the combinations to: .fields = (VMStateField[]){ The biggest problem (appart from aesthetics) was that checkpatch complained when we copy&pasted the code from one place to another. Signed-off-by: Juan Quintela <quintela@redhat.com> Acked-by: Alexey Kardashevskiy <aik@ozlabs.ru> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
* char/serial: Fix emptyness handlingDon Slutz2014-04-071-2/+4
| | | | | | | | | | | | | | The commit 88c1ee73d3231c74ff90bcfc084a7589670ec244 char/serial: Fix emptyness check Still causes extra NULL byte(s) to be sent. So if the fifo is empty, do not send an extra NULL byte. Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Don Slutz <dslutz@verizon.com> Message-id: 1395160174-16006-1-git-send-email-dslutz@verizon.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
* char/serial: Fix emptyness checkPeter Crosthwaite2014-02-151-1/+1
| | | | | | | | | | This was guarding against a full fifo rather than an empty fifo when popping. Fix. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* Merge remote-tracking branch 'stefanha/block' into stagingAnthony Liguori2013-08-261-11/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # By Alex Bligh (32) and others # Via Stefan Hajnoczi * stefanha/block: (42 commits) win32-aio: drop win32_aio_flush_cb() aio-win32: replace incorrect AioHandler->opaque usage with ->e aio / timers: remove dummy_io_handler_flush from tests/test-aio.c aio / timers: Remove legacy interface aio / timers: Switch entire codebase to the new timer API aio / timers: Add scripts/switch-timer-api aio / timers: Add test harness for AioContext timers aio / timers: convert block_job_sleep_ns and co_sleep_ns to new API aio / timers: Convert rtc_clock to be a QEMUClockType aio / timers: Remove main_loop_timerlist aio / timers: Rearrange timer.h & make legacy functions call non-legacy aio / timers: Add qemu_clock_get_ms and qemu_clock_get_ms aio / timers: Remove legacy qemu_clock_deadline & qemu_timerlist_deadline aio / timers: Remove alarm timers aio / timers: Add documentation and new format calls aio / timers: Use all timerlists in icount warp calculations aio / timers: Introduce new API timer_new and friends aio / timers: On timer modification, qemu_notify or aio_notify aio / timers: Convert mainloop to use timeout aio / timers: Convert aio_poll to use AioContext timers' deadline ... Message-id: 1377202298-22896-1-git-send-email-stefanha@redhat.com Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
| * aio / timers: Switch entire codebase to the new timer APIAlex Bligh2013-08-221-11/+11
| | | | | | | | | | | | | | | | | | | | | | This is an autogenerated patch using scripts/switch-timer-api. Switch the entire code base to using the new timer API. Note this patch may introduce some line length issues. Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* | Convert stderr message calling error_get_pretty() to error_report()Seiji Aguchi2013-08-201-2/+3
|/ | | | | | | | | | | | | | | | | | | | | | Convert stderr messages calling error_get_pretty() to error_report(). Timestamp is prepended by -msg timstamp option with it. Per Markus's comment below, A conversion from fprintf() to error_report() is always an improvement, regardless of error_get_pretty(). http://marc.info/?l=qemu-devel&m=137513283408601&w=2 But, it is not reasonable to convert them at one time because fprintf() is used everwhere in qemu. So, it should be done step by step with avoiding regression. Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
* memory: add owner argument to initialization functionsPaolo Bonzini2013-07-041-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* char/serial: fix copy&paste error (fifo8_is_full vs empty)Vladimir Senkov2013-06-171-1/+1
| | | | | | | | | Copy&paste error in serial.c causes a crash when attempting to read from UART (if there is no data to be read) Signed-off-by: Vladimir Senkov <hangup@gmail.com> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* Merge branch 'realize-isa.v2' of git://github.com/afaerber/qemu-cpuBlue Swirl2013-06-151-5/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 'realize-isa.v2' of git://github.com/afaerber/qemu-cpu: qdev: Drop FROM_QBUS() macro isa: QOM'ify ISADevice isa: QOM'ify ISABus i8259: Convert PICCommonState to use QOM realizefn kvm/i8259: QOM'ify some more i8259: QOM'ify some more i8254: Convert PITCommonState to QOM realizefn kvm/i8254: QOM'ify some more i8254: QOM'ify some more isa: Use realizefn for ISADevice cs4231a: QOM'ify some more gus: QOM'ify some more
| * isa: Use realizefn for ISADeviceAndreas Färber2013-06-071-5/+17
| | | | | | | | | | | | | | | | Drop ISADeviceClass::init and the resulting no-op initfn and let children implement their own realizefn. Adapt error handling. Split off an instance_init where sensible. Signed-off-by: Andreas Färber <afaerber@suse.de>
* | char/serial: serial_ioport_write: Factor out common codePeter Crosthwaite2013-06-111-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | These three lines are common to both FIFO and regular mode. Just factor them out to outside the if rather than replicate the same lines inside both if and else. Cc: qemu-trivial@nongnu.org Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | char/serial: Use generic Fifo8Peter Crosthwaite2013-06-111-64/+34
| | | | | | | | | | | | | | | | Use the generic Fifo8 helper provided by QEMU, rather than re-implement privately. Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | char/serial: cosmetic fixes.Peter Crosthwaite2013-06-111-11/+19
|/ | | | | | | | | | Some cosmetic fixes to char/serial fixing some checkpatch errors. Cc: qemu-trivial@nongnu.org Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* sysemu: avoid proliferation of include/ subdirectoriesPaolo Bonzini2013-04-151-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* hw: move target-independent files to subdirectoriesPaolo Bonzini2013-04-081-0/+789
This patch tackles all files that are compiled once, moving them to subdirectories of hw/. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
OpenPOWER on IntegriCloud