[Spice-devel] [RFCv2 01/21] qxl_ring: keep qxl pointer

Alon Levy alevy at redhat.com
Fri Apr 29 02:49:39 PDT 2011


Add a qxl_screen_t* member to qxl_ring to make generelizing outb to
ioport_write easier in the next patch. This means we do an extra deref
and addition for every outb, but it means the code becomes simpler for
doing outb in qxl_drv.so and a function call for spiceqxl_drv.so
---
 src/qxl.h        |    3 ++-
 src/qxl_driver.c |    6 +++---
 src/qxl_ring.c   |   12 +++++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/qxl.h b/src/qxl.h
index a2daa8b..594dd5b 100644
--- a/src/qxl.h
+++ b/src/qxl.h
@@ -208,7 +208,8 @@ void              qxl_cursor_init        (ScreenPtr               pScreen);
 struct qxl_ring * qxl_ring_create      (struct qxl_ring_header *header,
 					int                     element_size,
 					int                     n_elements,
-					int                     prod_notify);
+					int                     prod_notify,
+					qxl_screen_t            *qxl);
 void              qxl_ring_push        (struct qxl_ring        *ring,
 					const void             *element);
 Bool              qxl_ring_pop         (struct qxl_ring        *ring,
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index 08bf2d8..ce50a2a 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -908,13 +908,13 @@ qxl_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 
     qxl->command_ring = qxl_ring_create ((struct qxl_ring_header *)&(ram_header->cmd_ring),
 					 sizeof (struct QXLCommand),
-					 QXL_COMMAND_RING_SIZE, QXL_IO_NOTIFY_CMD);
+					 QXL_COMMAND_RING_SIZE, QXL_IO_NOTIFY_CMD, qxl);
     qxl->cursor_ring = qxl_ring_create ((struct qxl_ring_header *)&(ram_header->cursor_ring),
 					sizeof (struct QXLCommand),
-					QXL_CURSOR_RING_SIZE, QXL_IO_NOTIFY_CURSOR);
+					QXL_CURSOR_RING_SIZE, QXL_IO_NOTIFY_CURSOR, qxl);
     qxl->release_ring = qxl_ring_create ((struct qxl_ring_header *)&(ram_header->release_ring),
 					 sizeof (uint64_t),
-					 QXL_RELEASE_RING_SIZE, 0);
+					 QXL_RELEASE_RING_SIZE, 0, qxl);
 
     qxl->surface_cache = qxl_surface_cache_create (qxl);
     
diff --git a/src/qxl_ring.c b/src/qxl_ring.c
index b9a82e6..22d98ea 100644
--- a/src/qxl_ring.c
+++ b/src/qxl_ring.c
@@ -39,14 +39,16 @@ struct qxl_ring
     volatile struct ring *ring;
     int			element_size;
     int			n_elements;
-    int			prod_notify;
+    int			io_port_prod_notify;
+    qxl_screen_t    *qxl;
 };
 
 struct qxl_ring *
 qxl_ring_create (struct qxl_ring_header *header,
 		 int                     element_size,
 		 int                     n_elements,
-		 int			 prod_notify)
+		 int			 io_port_prod_notify,
+		 qxl_screen_t           *qxl)
 {
     struct qxl_ring *ring;
 
@@ -57,8 +59,8 @@ qxl_ring_create (struct qxl_ring_header *header,
     ring->ring = (volatile struct ring *)header;
     ring->element_size = element_size;
     ring->n_elements = n_elements;
-    ring->prod_notify = prod_notify;
-    
+    ring->io_port_prod_notify = io_port_prod_notify;
+    ring->qxl = qxl;
     return ring;
 }
 
@@ -87,7 +89,7 @@ qxl_ring_push (struct qxl_ring *ring,
     mem_barrier();
 
     if (header->prod == header->notify_on_prod)
-	outb (ring->prod_notify, 0);
+	outb (ring->qxl->io_base + ring->io_port_prod_notify, 0);
 }
 
 Bool
-- 
1.7.4.4



More information about the Spice-devel mailing list