Commit Graph
20 Commits
Author SHA1 Message Date
Yuri Benditovich ffbec45e78 vioserial: fix mistake in command length
https://bugzilla.redhat.com/show_bug.cgi?id=1783880
Wrong command length causes loss of functionality of x86 driver.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-18 23:01:27 +02:00
Yuri Benditovich 01be658e0f vioserial: Use VirtIO DMA API for control queue
Currently the driver uses memory structure on the stack
as DMA buffer. To be compatible with IOMMU, we change it
to use common DMA buffer. On D0 entry the driver allocates
single 4K block and uses slices from it for control queue
commands. The entry is 8 bytes, so the buffer is enough
for 512 entries. The driver usually uses just one entry
as control commands do not happen often.

Signed-off-by: Yuri Benditovich <[email protected]>
2019-12-11 13:55:04 +01:00
Ilya Rudakov 178e165984 serial: change timeout for KeDelayExecutionThread
Zero interval makes KeDelayExecutionThread to call NtYieldExecution with
minimal additional actions, but it is not documented. It is changed to minimal relative
interval value (-1).
2017-11-05 10:27:25 +02:00
Ilya Rudakov be56c43a24 serial: Replace KeStallExecutionProcessor with KeDelayExecutionThread
Using KeDelayExecutionThread with zero timeout interval cause current thread
to relinquish the remainder of its time slice to other thread in most cases.
This allows to make small delay on PASSIVE_LEVEL and optimize CPU usage.
It looks slightly more efficient then using KeDelayExecutionThread which is
actually a busy loop.

Signed-off-by: Ilya Rudakov <[email protected]>
2017-11-05 10:27:25 +02:00
Ilya Rudakov abe1137719 serial: remove unused variable
Counter variable (int cnt) is now unused and should be deleted

Signed-off-by: Ilya Rudakov <[email protected]>
2017-11-05 10:27:25 +02:00
Ilya Rudakov 633d81b90b serial: remove RETRY_THRESHOLD limit from c_ovq poll loop
This patch is a fix for very annoying problem in the production. It was
very hard to understand what is going on and why. From the user point
of view the situation looks like

	dev: virtserialport, id "channel0"
	chardev = "charchannel0"
	nr = 1 (0x1)
	name = "org.qemu.guest_agent.0"
	port 1, guest off, host off, throttle off

and the device comes into this state under unknown circumstances.

We've found out that this problem is caused by a breakdown in the
control channel. The host has stopped responding to the control messages
at some moment. Sometimes channel could be fixed after qemu-qa service
restart, sometimes not. From the technical point of view there is the
following problem:

The amount of virtqueue_get_buf calls from VIOSerialSendCtrlMsg is
limited to RETRY_THRESHOLD times(400). Usually this is more than enough.
The amount of retries in the common case in 1-2. But unfortunately
sometimes host needs MUCH more time to handle message. Thus there is
a probability that the polling counter will exceeds RETRY_THRESHOLD.
In our production and load testing this probability fires 1-2 times
a week. Thus here loop ends, but the queue still contains the element
with the address on VIOSerialSendCtrlMsg stack. This buffer will become
invalid after the return from the function. Obviously QEMU will see the
garbage once it will get a chance to process such orphaned message.
It ignores it without guest notification and thus the vioserial is
stuck in some intermediate state.

We can't just remove RETRY_THRESHOLD limit. In this case there is a
risk of getting DPC_WATCHDOG bugcheck due to long spin wait on
DPC_LEVEL.

This patch splits in/out queues lock CVqLock on two, with WaitLock
COutVqLock being used for c_ovq. In this case virtqueue_get_buf poll
loop is executed on PASSIVE_LEVEL. The restriction to the amount of
retries is removed accordingly. WorkItem is used to low the current
IRQL where necessary.

Spinlock is better solution to synchronize such a small and fast code
and was rightfully used to lock c_ivq and c_ovq access. Thus it is kept
for CInVqLock to lock c_ivq. Using WaitLock for c_ovq leads to
insignificant decrease of the control message sending rate due to
walking through dispatcher every time on lock acquire/free and a possible
thread preemtion while running locked code, but reliability is more
important than control channel speed.

Signed-off-by: Ilya Rudakov <[email protected]>
Signed-off-by: Denis V. Lunev <[email protected]>
2017-10-15 17:33:35 +03:00
Ladi Prosek c7c8faf799 vioser: Spelling fixes 2017-01-20 21:08:23 +11:00
Julius Rus 3174111382 Update vioserial to use the linux virtio API 2014-07-30 13:13:37 -07:00
Gal Hammer 3d6db65653 serial: (related to bz#858687) add a spin lock to the control queue. 2013-08-05 20:49:19 +10:00
Gal Hammer dc8bc70f86 [virtio-serial] fix host notification when msi is disabled.
Related to commit 8fe2811b. If msi was not enabled (e.g. Windows
XP), an invalid interrupt object was used when sending notification
that the host is connected.
2013-04-11 15:19:51 +03:00
Gal Hammer f5e2779052 [virtio-serial] bz#823818: rewrote the driver's write function.
The previous write function didn't handle well the case when the
virtqueue was full and caused the guest to stop responding. New
implementation fixed that and add a support for a non-blocking
write (returns immediately if write will block).
2013-04-04 12:20:03 +03:00
Yan Vugenfirer 9ba3de70c1 [virtio-serial] Syncing. Windows 8 support and latest bug fixes. 2012-10-03 19:23:48 +02:00
Vadim Rozenfeld ba2d2b29b6 [vioserial] add traces for better code execution
tracebilit.
2012-04-10 16:30:14 +02:00
Yan Vugenfirer 228831dd9d [virtio-serial] Adaptation for unified library. 2012-02-07 02:12:44 +02:00
Yan Vugenfirer e99a4f514a [vioserial] Pass memory allocation functions to virtio libarary. Merging Arkady's Frenkel commit 2011-12-06 18:29:33 +02:00
Yan Vugenfirer 3b8d8d1fc5 [vioserial] Clean out white spaces before merging memory allocation changes in virtio library 2011-12-06 17:17:18 +02:00
Yan Vugenfirer bd10c3ec3c Sync with Vadim's repository 2011-11-10 14:28:24 +02:00
Yan Vugenfirer 9f49609691 This repository only for the virtio library and NetKVM driver 2011-10-25 15:53:09 +02:00
Yan Vugenfirer 30c0ec8a4e [Guest drivers] syncing the repositories. 2011-03-09 10:27:32 +02:00
Yan Vugenfirer 76380b33a7 Merge latest vioserial code 2010-10-03 22:34:00 +02:00