diff mbox

[9/9] sm501: make display updates thread safe

Message ID 20170421091632.30900-10-kraxel@redhat.com
State New
Headers show

Commit Message

Gerd Hoffmann April 21, 2017, 9:16 a.m. UTC
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/display/sm501.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

Comments

BALATON Zoltan April 21, 2017, 10:42 a.m. UTC | #1
On Fri, 21 Apr 2017, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> hw/display/sm501.c | 23 ++++++-----------------
> 1 file changed, 6 insertions(+), 17 deletions(-)

Hold on with this please too. I have a series pending that changes this.

Regards,
BALATON Zoltan
Peter Maydell April 24, 2017, 12:09 p.m. UTC | #2
On 21 April 2017 at 11:42, BALATON Zoltan <balaton@eik.bme.hu> wrote:
> On Fri, 21 Apr 2017, Gerd Hoffmann wrote:
>>
>> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
>> ---
>> hw/display/sm501.c | 23 ++++++-----------------
>> 1 file changed, 6 insertions(+), 17 deletions(-)
>
>
> Hold on with this please too. I have a series pending that changes this.

Gerd: I've now applied Zoltan's patchset to git master, so you'll
want to rebase your changes on it.

thanks
-- PMM
Gerd Hoffmann April 24, 2017, 12:30 p.m. UTC | #3
On Mo, 2017-04-24 at 13:09 +0100, Peter Maydell wrote:
> On 21 April 2017 at 11:42, BALATON Zoltan <balaton@eik.bme.hu> wrote:
> > On Fri, 21 Apr 2017, Gerd Hoffmann wrote:
> >>
> >> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> >> ---
> >> hw/display/sm501.c | 23 ++++++-----------------
> >> 1 file changed, 6 insertions(+), 17 deletions(-)
> >
> >
> > Hold on with this please too. I have a series pending that changes this.
> 
> Gerd: I've now applied Zoltan's patchset to git master, so you'll
> want to rebase your changes on it.

Pull request for the first batch is just out of the door, without sm501
+ tcx + cg3 to avoid conflicts.  They will follow with the next batch,
which then should also able to revert the temporary workaround.

cheers,
  Gerd
diff mbox

Patch

diff --git a/hw/display/sm501.c b/hw/display/sm501.c
index 040a0b93f2..1987a537c0 100644
--- a/hw/display/sm501.c
+++ b/hw/display/sm501.c
@@ -1259,6 +1259,7 @@  static inline int get_depth_index(DisplaySurface *surface)
 static void sm501_draw_crt(SM501State * s)
 {
     DisplaySurface *surface = qemu_console_surface(s->con);
+    DirtyBitmapSnapshot *snap;
     int y;
     int width = (s->dc_crt_h_total & 0x00000FFF) + 1;
     int height = (s->dc_crt_v_total & 0x00000FFF) + 1;
@@ -1274,8 +1275,6 @@  static void sm501_draw_crt(SM501State * s)
     draw_hwc_line_func * draw_hwc_line = NULL;
     int full_update = 0;
     int y_start = -1;
-    ram_addr_t page_min = ~0l;
-    ram_addr_t page_max = 0l;
     ram_addr_t offset = 0;
 
     /* choose draw_line function */
@@ -1326,15 +1325,15 @@  static void sm501_draw_crt(SM501State * s)
 
     /* draw each line according to conditions */
     memory_region_sync_dirty_bitmap(&s->local_mem_region);
+    snap = memory_region_snapshot_and_clear_dirty(&s->local_mem_region,
+              offset, width * height * src_bpp, DIRTY_MEMORY_VGA);
     for (y = 0; y < height; y++) {
 	int update_hwc = draw_hwc_line ? within_hwc_y_range(s, y, 1) : 0;
 	int update = full_update || update_hwc;
-        ram_addr_t page0 = offset;
-        ram_addr_t page1 = offset + width * src_bpp - 1;
 
 	/* check dirty flags for each line */
-        update = memory_region_get_dirty(&s->local_mem_region, page0,
-                                         page1 - page0, DIRTY_MEMORY_VGA);
+        update = memory_region_snapshot_get_dirty(&s->local_mem_region, snap,
+                                                  offset, width * src_bpp);
 
 	/* draw line and change status */
 	if (update) {
@@ -1351,10 +1350,6 @@  static void sm501_draw_crt(SM501State * s)
 
 	    if (y_start < 0)
 		y_start = y;
-	    if (page0 < page_min)
-		page_min = page0;
-	    if (page1 > page_max)
-		page_max = page1;
 	} else {
 	    if (y_start >= 0) {
 		/* flush to display */
@@ -1366,17 +1361,11 @@  static void sm501_draw_crt(SM501State * s)
 	src += width * src_bpp;
 	offset += width * src_bpp;
     }
+    g_free(snap);
 
     /* complete flush to display */
     if (y_start >= 0)
         dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
-
-    /* clear dirty flags */
-    if (page_min != ~0l) {
-	memory_region_reset_dirty(&s->local_mem_region,
-                                  page_min, page_max + TARGET_PAGE_SIZE,
-                                  DIRTY_MEMORY_VGA);
-    }
 }
 
 static void sm501_update_display(void *opaque)