[PATCH] modesetting: Update fb_id from shadow allocate and destroy if not set

Tony Lindgren tony at atomide.com
Fri Feb 9 15:14:24 UTC 2018


* Keith Packard <keithp at keithp.com> [180203 20:33]:
> I think the right place to fix this is in dispatch_dirty_regions, which
> should be walking the set of active CTRCs and damaging the appropriate
> fb_id for each one?

So is the following test patch at all along the lines you were
thinking?

I wonder if we should also have drmmode_crtc->rotate_dirty_enabled
in addition to ms->dirty_enabled so we we could stop the ioctl
on per *fb_id basis if not needed?

Or maybe we could have drmmode_crtc->current_fb_id that would
just get overwritten by drmModeAddFB() or some other logic?

Regards,

Tony

8< ------------------
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -531,12 +531,11 @@ dispatch_dirty_region(ScrnInfoPtr scrn,
 }
 
 static void
-dispatch_dirty(ScreenPtr pScreen)
+dispatch_dirty_fb_id(ScreenPtr pScreen, int fb_id)
 {
     ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
     modesettingPtr ms = modesettingPTR(scrn);
     PixmapPtr pixmap = pScreen->GetScreenPixmap(pScreen);
-    int fb_id = ms->drmmode.fb_id;
     int ret;
 
     ret = dispatch_dirty_region(scrn, pixmap, ms->damage, fb_id);
@@ -547,7 +546,43 @@ dispatch_dirty(ScreenPtr pScreen)
         ms->damage = NULL;
         xf86DrvMsg(scrn->scrnIndex, X_INFO,
                    "Disabling kernel dirty updates, not required.\n");
-        return;
+    }
+}
+
+static void
+dispatch_dirty(ScreenPtr pScreen)
+{
+    ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+    modesettingPtr ms = modesettingPTR(scrn);
+    modesettingEntPtr ms_ent = ms_ent_priv(scrn);
+    xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
+    xf86CrtcPtr crtc;
+    drmmode_crtc_private_ptr drmmode_crtc;
+    unsigned int mask;
+
+    mask = ms_ent->assigned_crtcs;
+
+    while (mask) {
+        int i, fb_id = 0;
+
+        i = ffs(mask) - 1;
+
+        crtc = xf86_config->crtc[i];
+        if (!ms_crtc_on(crtc))
+            goto skip;
+
+        drmmode_crtc = crtc->driver_private;
+
+        if (drmmode_crtc->rotate_fb_id)
+            fb_id = drmmode_crtc->rotate_fb_id;
+        else
+            fb_id = ms->drmmode.fb_id;
+
+        if (fb_id)
+            dispatch_dirty_fb_id(pScreen, fb_id);
+
+    skip:
+        mask &= ~(1 << i);
     }
 }
 
-- 
2.16.1


More information about the xorg-devel mailing list