Commit Graph

77 Commits

Author SHA1 Message Date
Frediano Ziglio
3f39e31a6f Synchronize display mode change and pushing drawables
Upon change of display mode the driver waits until all the
queued drawables pushed to the host or discarded. This eliminates
server warnings "rendering incorrect" in "get_drawable" when the
drawable command was created by guest driver just before change
of display mode and posted to the server during or after the change.

This patch and comments are heavily based on a patch sent by
Yuri Benditovich (with serialization code completely changed and
added generation to discard pending commands on old surface).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-05-05 12:54:58 +01:00
Yuri Benditovich
42a911e2e9 Move code for discarding drawable to separate procedure
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-05-05 11:23:16 +01:00
Frediano Ziglio
6041c81484 Move m_CustomMode field in QxlDevice
Only used by this class.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 15:49:26 +01:00
Frediano Ziglio
b83f6338bc Inline GetModeCount
As GetModeInfo is also inline there is no reason the derived class
could redefine the array anyway.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 15:49:24 +01:00
Frediano Ziglio
f013c0c5fc Remove unused UpdateArea method
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 15:49:15 +01:00
Frediano Ziglio
72d2105c92 Remove generation field from MemSlot
Not used beside during initialization of MemSlot itself

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2017-04-12 15:49:13 +01:00
Frediano Ziglio
06ef003435 Remove unused EmptyReleaseRing method
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 15:49:11 +01:00
Frediano Ziglio
94770833a4 Use inline attribute for VA and PA
Don't use the old style _inline specifier.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:19:01 +01:00
Frediano Ziglio
8a8c6c41c0 Compute dynamically slot_id in PA and VA functions
This make easier to change allocation of memory using different
memory Bars.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:18:50 +01:00
Frediano Ziglio
53fb38c92f Use normal pointer for VA addresses
As VA addresses are used as pointers there's no need to handle
them as 64-bit integer (which make the code more complicated)

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:17:50 +01:00
Frediano Ziglio
6ec0533a7d Allocate m_MemSlots statically inside QxlDevice
There were always 2 slots used so make no sense to allocate
always dynamically.
Also in this way m_MainMemSlot and m_SurfaceMemSlot become
constant making the code slightly smaller.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:17:47 +01:00
Frediano Ziglio
7e0642c3f2 Remove m_NumMemSlots member
Only used once

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:17:46 +01:00
Frediano Ziglio
1b674d86e2 Compute automatically memory space in FreeMem
This make easier to change allocation of memory using different
memory Bars.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-12 09:17:39 +01:00
yuri.benditovich@daynix.com
8fb1b0a23e qxl-wddm-dod: Non-forced memory allocations with VSync
In case of VSync is active (for the driver this means it shall take
in account watchdog policy and ensure fast execution of PresentDisplayOnly
callback) allocate bitmaps for drawable objects using non-forced requests.
If immediate allocation is not possible, place entire bitmap into memory
chunk allocated from the OS.
If bitmap is allocated from device memory, but one of later
chunks can't be allocated, allocate this and further chunks from
OS memory. All these 'delayed' allocations placed into linked list
which root entry is part of QXLOutput structure.
>From separate thread, before sending drawable objects down, review
the list of delayed chunks and allocate device memory (forced) to
all of them.
The cost of solution is 2 pointers added to each drawable or cursor
object.
Cursor commands currently do not use them; in future we have an option
to offload also cursor commands.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-12 08:21:01 +01:00
yuri.benditovich@daynix.com
043f4f275a qxl-wddm-dod: Implement non-forced bitmap allocation
Preparation for non-forced allocations.
Update bitmap creation procedure to allocate device memory forced
or non-forced.
In forced case it works as before.
In non-forced case, if allocation fails, the procedure allocates
memory from OS pool for entire bitmap and copies source data to it.
Later, before sending command, memory will be allocated from device
memory and copied from intermediate location to new one.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-12 08:21:01 +01:00
yuri.benditovich@daynix.com
5c4f4adc7a qxl-wddm-dod: Dedicated procedure for bitmap creation
Move bitmap creation to dedicated procedure. Currently it
uses only forced allocations, as before. Later it will
be used from different flows, forced and non-forced.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-12 08:21:01 +01:00
yuri.benditovich@daynix.com
9721a48dc9 qxl-wddm-dod: PutBytesAlign supports non-forced allocation
Preparation for offload of allocations from device's memory
to separate thread. Procedure PutBytesAlign is called to
allocate memory chunk from device memory and copy data to it.
With current commit the procedure (if called with non-NULL
linked list root entry parameter) can use non-forced allocation.
If such allocation fails, it allocates 'delayed' chunk from
OS memory and copies data to it. Later before sending drawable command
this chunk shall be processed, storage allocated from device memory
(forced) and data copied to it.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-12 08:20:58 +01:00
yuri.benditovich@daynix.com
6a01308788 qxl-wddm-dod: Prepare for failure to allocate memory
Preparation for further scenarios when memory allocation failure
can happen and we'll need to use fallback when possible.
Memory allocation can fail in following cases:
- when non-forced memory allocation used and the attempt to allocate
  the memory must be as fast as possible, without waits
- when forced memory allocation used, but the driver already received
  stop command and waits for thread termination. Note that in case
  the VSync control is enabled stop command may happen even after the video
  subsystem executes switch to VGA mode. In such case QEMU will not return
  previously allocated objects (assuming the QXL driver already disabled
  and ignoring callbacks from Spice server in VGA mode).

In case of forced memory allocation the allocation routine waits
unpredictable time until the request is satisfied. In current commit
we do not acquire m_MemLock mutex for all this time, but release it
when entering long wait to allow another caller to try allocating memory.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-12 08:20:54 +01:00
yuri.benditovich@daynix.com
f86a615e52 qxl-wddm-dod: Debug warning on long wait on event
In release build this does not affect the code.
In debug build we will have a warning printout when waiting
on event is close to 2 seconds - this can be a cause of following
stop by OS. The printout contains name of related event variable.
There is one event (in offload thread) that long wait on it
does not affect any functionality, for it this warning is disabled.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:14:05 +01:00
yuri.benditovich@daynix.com
d8e645c751 qxl-wddm-dod: Introduce TimeMeasurement class for timing debugging
In release build this class resolved to empty statements.
In debug build it is useful for measurement of execution time.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:14:03 +01:00
yuri.benditovich@daynix.com
0987a61bff qxl-wddm-dod: Use rendering offload thread
Instead of sending drawable commands down from presentation
callback, collect drawables objects and pass them to dedicated
thread for processing. This reduce peak load of presentation
callback.

Signed-off-by: Javier Celaya <javier.celaya@flexvdi.com>
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:14:01 +01:00
yuri.benditovich@daynix.com
7ca13f4f48 qxl-wddm-dod: Prepare system thread for rendering
Create rendering thread upon device start and terminate it upon
stop. The dedicated thread is normally pending for display commands
to be sent to the host. Currently only single NULL (termination)
command is placed to the ring where the thread consumes events from.

Signed-off-by: Javier Celaya <javier.celaya@flexvdi.com>
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:13:54 +01:00
yuri.benditovich@daynix.com
db40bfd439 qxl-wddm-dod: Timer-based VSync interrupt indication
In case the driver supports VSync control feature, it
maintains timer for VSync interrupt indication.
In further commits this timer will be started upon
class driver request. The interrupt notification and
related DPC do not access device registers.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-22 16:38:28 +00:00
yuri.benditovich@daynix.com
a2b58d1557 qxl-wddm-dod: Simplify interrupt handling for rev4 device
Do not clear interrupt mask upon interrupt.
Instead clear pending interrupt status and write
QXL_IO_UPDATE_IRQ register (this drops interrupt level).
There are 3 advantages:
1. We do not need to wake the host to enable interrupt
mask in DPC procedure (1 wake per interrupt instead of 2)
2. The driver is not sensitive to failure when queues DPC, as
already queued DPC will process this interrupt when executed.
3. When we implement VSync interrupt simulation, we do not
need to touch registers neither when notify the OS nor when
process DPC related to this notification.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-22 16:38:28 +00:00
yuri.benditovich@daynix.com
02c1ed6065 qxl-wddm-dod: Option to provide frequency data to the OS
Concentrate filling of signal info in single procedure.
Fill signal info with specific or default frequency data
according to the global flag of VSync support.
Note that the state of this flobal flag must be defined only
on driver startup (based on OS version or any other information
available at DriverEntry) and can't be changed later.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-22 16:38:28 +00:00
Frediano Ziglio
b621c297bd Do not take into account move operations for mapping
This is a follow up of 31ca5d035d
("Implements screen to screen move correctly").

As now we don't copy memory to implement moves there's no
reason to take into account these area for memory mappings
as memory is not accessed anymore.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-01-29 11:59:39 +00:00
Yuri Benditovich
53ca7ce4cd qxl-wddm-dod: Fix for screen not shown after driver disabled
https://bugzilla.redhat.com/show_bug.cgi?id=1411340
Do not set SupportNonVGA field for device rev.4 and higher.
Then the class driver will not call miniport's procedure
StopDeviceAndReleasePostDisplayOwnership upon PnP stop.
QXL device modes are not compatible with VGA ones; the
driver in this procedure returns display information related
to QXL mode which later used by BasicDisplay driver and causes
it to show the screen incorrectly or fail to show it at all.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-01-26 11:27:01 +00:00
Frediano Ziglio
31ca5d035d Implements screen to screen move correctly
Doing some fast check on Windows 8.1 you could note that
moving windows you got a weird effect were windows were a
bit misaligned.
As documented in DXGKARG_PRESENT_DISPLAYONLY page
NumMoves/pMoves fields point to an array of screen-to-screen
moves while our code implemented them as an image drawing
(the same implementation of dirty rects) causing the weird
effect mentioned.
This patch implement the moves using QXL_COPY_BITS operation
instead of a QXL_DRAW_COPY fixing the issue and avoiding sending
image to the server making the move/scroll operations on the
guest faster (and taking less bandwidth).
It seems that Windows 10 doesn't send the move commands but
instead send only dirty rects so you can't note this problem
using Windows 10.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2016-12-06 06:44:24 +00:00
Javier Celaya
1af6eb074c Remove unused code
Signed-off-by: Javier Celaya <javier.celaya@flexvdi.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-23 18:23:14 +00:00
Yuri Benditovich
da0680c8d5 qxl-wddm-dod: Enable hardware pointer acceleration
Windows disables hw pointer acceleration and draws the cursor
in frame buffer if the driver does not report pointer capabilities
in QueryAdapterInfo. In this mode OS usually does not send pointer
commands to the driver or does it with pointer set to invisible
state. This mode of operation consumes CPU time and device-to-host
traffic. Now we enable pointer hardware acceleration.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-21 14:05:49 +00:00
Christophe Fergeau
4332d07c73 Change licence to Apache v2
A more permissive licence is more in line with what Microsoft requires
for its WHQL certification

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 11:18:09 +00:00
Frediano Ziglio
a86ef3acf8 Mark all functions that should go to non paged sections
This make sure that these function goes into the non
paged section.
Also this change is much shorter than marking code if
can be paged as almost code can be paged.
It's also coherent with other source files.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Sameeh Jubran <sameeh@daynix.com>
2016-10-19 17:39:15 +01:00
Sameeh Jubran
14e2a147df Fixing black-white screen in installation when qxl revision = 3
When qxl revision is 3, the vga driver is the one that is running.
While installing the driver the function VgaDevice::HWInit
has displayInfo structure zeroed out. The displayInfo should be
initialized using DxgkCbAcquirePostDisplayOwnership and thus it
should be called before calling HWInit.

Please note that we can't just move the call to "DxgkCbAcquirePostDisplayOwnership"
before calling HWInit as the m_Id isn't initialized for QxlDevice until the call to HWinit is over.

This patch fixes a bug similar to the one found here:
https://bugzilla.redhat.com/show_bug.cgi?id=1202267
However this one occurs when installing the driver.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-19 17:17:43 +01:00
Sameeh Jubran
bcff8a6d4e Fix source buffer mapping in PresentDisplayOnly
Part of source image mapped by PresentDisplayOnly
should be big enough to cover all rectangles being
transferred.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-28 12:31:38 +01:00
Sameeh Jubran
2ab3b7a1fc Use frame buffer in VGA mode only
Framebuffer should only be used in VGA mode, as WDDM DOD
driver doesn't use the frame buffer (bar0), so no
reason to map in into memory. However the mode is only known
at runtime therefore framebuffer logic should be active when the
driver is operating in vga mode only.

There were rare BSOD failures when the mapping failed.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
2016-09-26 16:53:52 +01:00
Sameeh Jubran
af4947793e Add arbitrary resolution and monitors_config Escape
This patch adds support for arbitrary resolution and updating
monitor configurations using custom ioctls.

This patch doesn't make any restriction for minimal resolution at all
as Windows can handle low resolution just fine, moreover the old (XPDM)
driver behaves like this too.

Based on a patch by Sandy Stutsman <sstutsma@redhat.com>

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-12 10:13:33 +01:00
Sameeh Jubran
ed816593b6 Fixed misspelling
Fixed misspelling: HwDeviceInterface
Fixed misspelling: GetDxgkInterface

Based on a patch by Sandy Stutsman <sstutsma@redhat.com>

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-11 22:42:35 +01:00
Sameeh Jubran
27713ea765 Fixing Move rectangles implementation
As documented in MSDN, "DxgkDdiPresentDisplayOnly" should copy
each "move rectangle" from a given source point in the source buffer
to the destination. The current implementation doesn't take into account
the shift of the given source point at all. This patch fixies the issue.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-09 14:15:18 +01:00
Sameeh Jubran
7383452757 Replacing tabs with spaces
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-09 11:17:42 +01:00
Frediano Ziglio
06ab9c9595 Normalise line ending
Some files had different line ending (some lines DOS while some others
UNIX). Use the same line ending using the nearest ending.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-09-09 10:49:09 +01:00
Reza Jelveh
f1cee95ea2 move cursor to cursor channel 2015-07-20 21:45:32 +10:00
Vadim Rozenfeld
89e4d5dd6f Merge remote-tracking branch 'remotes/qxl-wddm-next/work'
Conflicts:
	qxldod/BaseObject.cpp
	qxldod/QxlDod.cpp
	qxldod/QxlDod.h
	qxldod/callVisualStudio.bat
	qxldod/checkWin8Tools.bat
	qxldod/driver.cpp
	qxldod/driver.h
	qxldod/getVisualStudioCmdLine.vbs
	qxldod/qxldod.vcxproj
	qxldod/qxldod.vcxproj.filters
2015-04-10 15:30:05 +10:00
Vadim Rozenfeld
165b53d48b fix BSOD when disabling device 2015-03-30 22:57:12 +11:00
Vadim Rozenfeld
4b168bbbef trivial cleanups 2015-03-24 17:22:45 +11:00
Vadim Rozenfeld
4fc48d370f fix crashes when verifier is running 2015-03-24 16:41:58 +11:00
Vadim Rozenfeld
5f7bba4cbc fix resize problem (reported and fixed by Sandy Stutsman 2015-03-18 22:58:25 +11:00
Vadim Rozenfeld
f059ee240e fix resolution mismatch when switching between VGA and QXL modes
(cherry picked from commit b2a0aef4a5)
2015-02-19 21:09:45 +11:00
Vadim Rozenfeld
b2a0aef4a5 fix resolution mismatch when switching between VGA and QXL modes 2015-02-19 21:07:24 +11:00
Vadim Rozenfeld
fa8291cf37 publish adding a new resolution
(cherry picked from commit 7693d4153c)
2015-02-18 21:07:52 +11:00
Vadim Rozenfeld
8d33c3072e implement Escape handler
(cherry picked from commit 170be1696a)
2015-02-18 21:07:34 +11:00