Commit Graph

185 Commits

Author SHA1 Message Date
yuri.benditovich@daynix.com
06a4f7a846 qxl-wddm-dod: Optimize allocation of memory chunks
Increased size of allocation to reduce number of allocation per
bitmap. Before change the procedure ignored 'alloc_size' parameter
and always allocated memory chunk according to 'size' parameter.
As a result, first chunk could be up to 64K and all following are
limited by line size. For example, for bitmap 1280x1024 there was
more than 1008 chunks allocated, for bitmap 128x1024 - 897 chunks.
We change the procedure to use chunk size up to 64K (similar to first
chunk). This reduces in described examples number of allocation from
1008 to 64 and from 897 to 8 respectively.

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
Frediano Ziglio
3437f04cea Pass 0 to level argument of KeInitializeMutex
As documented by Microsoft this reserved argument should be set
to 0.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Yuri Benditovich <yuri.benditovich@daynix.com>
2017-04-11 17:21:55 +01:00
yuri.benditovich@daynix.com
9460db8760 qxl-wddm-dod: Set VSync indication period to 200ms
Default indication period (13-17ms) from the driver to OS
increases total CPU consumption during presentation operations.
Reducing indication frequency to 200 ms reduces cost of this
feature. Till now we do not see any negative impact of this.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:15:44 +01:00
yuri.benditovich@daynix.com
074cc3ef58 qxl-wddm-dod: Registry-based control over VSync
Registry override of default behavior (disabling when enabled
by default) provided for support and troubleshooting only in case
this feature affects specific user.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:14:40 +01:00
yuri.benditovich@daynix.com
223fe90a00 qxl-wddm-dod: Reduce amount of unnecessary printouts
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-04-03 10:14:07 +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
c0506bcf5d qxl-wddm-dod: Preparation for VSync activation
Prepare all the procedures needed for VSync feature but
do not turn it on yet. Manual uncomment still required to
enable it.
Advanced users may enable VSync feature and report functional
problem with it. The driver is expected to pass all the formal
tests under HLK 1607 with device rev.3 and rev.4 but with
device rev.4 on setups with high load or long round-trip delay
video system may detect timeout during rendering operation
and disable the driver with error 43.

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
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
58b3a7a75b qxl-wddm-dod: Fix video modes enumeration
When the video mode is changed and then the driver disabled and
enabled, it did not enumerate available video modes with lower
resolution than current one. All modes starting from 1024x768
should be available regardless what is current resolution
on driver startup

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
yuri.benditovich@daynix.com
72ed815334 qxl-wddm-dod: Return EDID data to the OS
Solves failure of HLK "Test for EDID requirements"
EDID contains capabilities and manufacturer data of
the emulated display device. Parsed EDID data presented
in the source file.

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
93c66603f0 qxl-wddm-dod: Updated Changelog for v0.16 2017-02-20 11:47:58 +02:00
yuri.benditovich@daynix.com
9ae81b279d qxl-wddm-dod: Startup case when OS does not supply frame buffer address
https://bugzilla.redhat.com/show_bug.cgi?id=1417448
When the OS does not provide physical address of the frame buffer,
the driver retrieves it from allocated PCI resource for BAR0.
https://msdn.microsoft.com/en-us/library/hh451339(v=vs.85).aspx
In DxgkCbAcquirePostDisplayOwnership OS not always fills
the DXGK_DISPLAY_INFORMATION structure with valid data.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-07 11:01:08 +00:00
Yuri Benditovich
12efc9b81b qxl-wddm-dod: Use 32 bpp for fallback mode
The driver uses fallback mode when it does not receive
startup display information from the OS. This change
allows solution for https://bugzilla.redhat.com/show_bug.cgi?id=1417448
without fix in qemu for video mode switch from 32 bpp to 24 bpp.

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-06 11:04:53 +00:00
Yuri Benditovich
12d9eec8cd qxl-wddm-dod: Allow easy modification of fallback setting
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-06 11:04:52 +00:00
Yuri Benditovich
ec133ae0a6 qxl-wddm-dod: Discard meaningless copy of value
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2017-02-06 11:04:52 +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
Yuri Benditovich
89b399e6be qxl-wddm-dod: Add Changelog file
Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-12-08 11:45:28 +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
a495c21748 Fix default mode pitch
Signed-off-by: Javier Celaya <javier.celaya@flexvdi.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-23 18:23:35 +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
Javier Celaya
0ee4b29ea5 Send HIDE command when pointer is not visible
This avoids having 2 pointers (client and server) if Windows decides
to render the mouse by itself. This happens, for instance, when moving
windows around.

Signed-off-by: Javier Celaya <javier.celaya@flexvdi.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-21 15:11:02 +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
Frediano Ziglio
3fe5c540f7 Update some file copyright statements
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2016-11-07 09:45:14 +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
Yuri Benditovich
6caff25931 Configurable version information in binary and INF
Version information in INF file is configured by
environment variables.
The same version information placed in driver binary.
To set required version from external build engine,
define following environment variables:
VERSION_V1, VERSION_V2, VERSION_V3, VERSION_V4

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
Acked-by: Dmitry Fleytman <dmitry@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 08:50:50 +00:00
Sameeh Jubran
4cba150eee Fixing indentation
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
2016-10-31 09:34:45 +00:00
Pavel Grunt
0597b685cb Update README
Change URL for binaries and heading

Closes #2

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Victor Toso <victortoso@redhat.com>
2016-10-25 17:16:48 +02:00
Sameeh Jubran
1afadc7aeb Indicate all Qxl devices as VGA
Currently the qxl device with id 0 is being set as an internal display
while all the rest are set as VGA connector. This commit solves this
issue that was discussed in detail here:
https://bugzilla.redhat.com/show_bug.cgi?id=1314600

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-19 17:58:55 +01:00
Sameeh Jubran
9501316d4c Code Analysis fix
Remove specifier that was causing a warning.

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-10-19 17:45:21 +01:00
Frediano Ziglio
de8062e7b6 Use MmMapIoSpaceEx instead of MmMapIoSpace
Disable execution bit on mapping improving security.

MmMapIoSpaceEx is available only in Windows 10 so
to provide binary compatibility detect the new
function dynamically.
Added a separate compatibility file.

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

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-19 17:39:42 +01: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
Frediano Ziglio
8eecca8c75 Add missing calls to PAGED_CODE
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-19 17:34:50 +01:00
Sameeh Jubran
93cb3c8caf Call "DxgkCbAcquirePostDisplayOwnership" when changing Power State to D0
Starting with Windows Display Driver Model (WDDM) 1.2, if the
DevicePowerState parameter is set to PowerDeviceD0, the display miniport
driver should call DxgkCbAcquirePostDisplayOwnership to query the
information about the display mode.

This patch fixies this bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1202267

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-10-19 17:20:37 +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
725c0827bf Code Analysis and style fix
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-28 13:00:21 +01:00
Sameeh Jubran
f2c637c96d Use PAGED_CODE() at the beginning of each pageable method
The PAGED_CODE macro ensures that the calling thread is running at an
IRQL that is low enough to permit paging. A call to this macro should be
made at the beginning of every driver routine that either contains
pageable code or accesses pageable code

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-28 12:53:42 +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
54e2f808c9 Fixing framebuffer usage logic
This patch fixes 2 issues:

  1. Framebuffer should only be used in vga mode,
     therefore when QxlDevice is active
     FrameBufferIsActive flag shouldn't be checked;
  2. FrameBufferIsActive flag should be set true
     on successfull frame buffer allocation only.

Signed-off-by: Dmitry Fleytman <dmitry@daynix.com>
Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
2016-09-28 11:43:19 +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
f5527d0ae3 Removing unnecessary call to BlackOutScreen
This call to BlackOutScreen is not needed since the actual
display surface is destroyed and created (redrawn) again.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-26 16:33:46 +01:00
Sameeh Jubran
f87019cb01 Fixing possible BSOD
Interrupts seem to arrive to the driver before the initialization phase
is over (m_pHWDevice = NULL), in that case we can't handle interrupts yet.
Even when m_pHWDevice isn't NULL, other fields aren't necessarily fully
initialized till the StartDevice function has finished initialization,
thus the flag DriverStarted should be checked upon interrupts.

Note: There is no way provided by Microsoft to disable interrupts in WDDM
drivers.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-09-26 15:37:32 +01:00
Sameeh Jubran
f6e099db39 Use the second bar (VRAM) for qxl command buffer.
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:20:10 +01:00