[Spice-devel] [PATCH 00/17] Win32 driver thread safety

alexl at redhat.com alexl at redhat.com
Tue Sep 14 12:08:50 PDT 2010


From: Alexander Larsson <alexl at redhat.com>

With the addition of offscreen surfaces we get concurrency in the driver.
The msdn page for EngAssociateSurface says:

By default, when a driver supports device bitmaps by implementing
DrvCreateDeviceBitmap/DrvDeleteDeviceBitmap, GDI does not
automatically synchronize drawing calls to the device bitmap and to
the primary surface. For example, GDI can call the driver's DrvBitBlt
function to draw to a device bitmap, while another thread is drawing
to the primary surface by executing the driver's implementation of
DrvTextOut. The driver can even be called to draw to multiple device
bitmaps at the same time.

So, we obviously need to protect against concurrent threads
e.g. trying to send a command over the command ring, or any other
qxl hardware state.

Furthermore, we may get several PDevs for a single device. I don't
know the exact rules these have, other than that only one is active
at a time, meaning rendering to the main surface of that is
serialized. However, I believe we might still get for instance a
surface destroy for an inactive pdev, so we need to serialize between
multiple pdevs too.

Since I don't know the exact concurrency rules for drivers this
patchset takes a safe approach assumes full parallell access for all
calls both between different pdevs and between the same pdev.

Additionally there is some cleanups in the series.

Alexander Larsson (17):
  Make global_res be an array of pointers and Res a pointer
  Drop DevResDynamic
  Move cmd_sem and print_sem to global device info
  Protect all references to cmd_ring with cmd_sem
  Protect surface id allocation with semaphore
  Only look for streams on primary surface
  Fixed up cmd_sem use
  Add protection for cursor_ring
  Save FPU on stack, not in pdev
  Remove unused structure member
  Add semaphore to protect quic_data from concurrent access
  Make internal functions static
  Prepend QXL to public function CheckIfCacheImage
  Fix typos Chach -> Cache
  Protect image cache from concurrent access
  Protect cursor cache against concurrent access
  Protect palette cache agains concurrent access

 display/driver.c  |   37 +---
 display/qxldd.h   |   31 ++--
 display/res.c     |  552 +++++++++++++++++++++++++++++++----------------------
 display/res.h     |    2 +-
 display/rop.c     |   12 +-
 display/surface.c |    2 +-
 display/surface.h |   31 ++-
 7 files changed, 378 insertions(+), 289 deletions(-)

-- 
1.7.2.2



More information about the Spice-devel mailing list