diff --git a/0001-Revert-damage-Make-damageRegionProcessPending-take-a.patch b/0001-Revert-damage-Make-damageRegionProcessPending-take-a.patch new file mode 100644 index 0000000..a924bf3 --- /dev/null +++ b/0001-Revert-damage-Make-damageRegionProcessPending-take-a.patch @@ -0,0 +1,517 @@ +From 32e632e85894eddc3ace83f16f1e973b1be478fe Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Mon, 12 Dec 2016 13:08:17 -0500 +Subject: [PATCH xserver] Revert "damage: Make damageRegionProcessPending take + a damage not a drawable" + +The commit message makes the assertion that the code below damage is not +allowed to change whether there's a damage monitor for the drawable. +That turns out not to be the case! exa's mixed code, at least, will +create and destroy a damage in PrepareAccess. The destroy path can then +be catastrophic, as damageRegionProcessPending will attempt to +RegionEmpty memory from the middle of a freed block. + +I'd wanted that invariant for performance, but faster isn't worth +broken, so revert it. I think what exa's doing is reasonable, so the +better way to improve performance for the unmonitored case is to either +revisit dynamically wrapping into the GC, or inline damage into dix. + +This reverts commit 4e124203f2260daaf54155f4a05fe469733e0b97. + +Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1389886 +Signed-off-by: Adam Jackson +--- + miext/damage/damage.c | 121 +++++++++++++++++++++++++------------------------- + 1 file changed, 60 insertions(+), 61 deletions(-) + +diff --git a/miext/damage/damage.c b/miext/damage/damage.c +index 17c2abf..d6a3614 100644 +--- a/miext/damage/damage.c ++++ b/miext/damage/damage.c +@@ -282,8 +282,10 @@ damageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, + } + + static void +-damageRegionProcessPending(DamagePtr pDamage) ++damageRegionProcessPending(DrawablePtr pDrawable) + { ++ drawableDamage(pDrawable); ++ + for (; pDamage != NULL; pDamage = pDamage->pNext) { + if (pDamage->reportAfter) { + /* It's possible that there is only interest in postRendering reporting. */ +@@ -358,7 +360,6 @@ damageCreateGC(GCPtr pGC) + + #define DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable) \ + damageGCPriv(pGC); \ +- drawableDamage(pDrawable); \ + const GCFuncs *oldFuncs = pGC->funcs; \ + unwrap(pGCPriv, pGC, funcs); \ + unwrap(pGCPriv, pGC, ops); \ +@@ -456,7 +457,7 @@ damageDestroyClip(GCPtr pGC) + #define BOX_NOT_EMPTY(box) \ + (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) + +-#define checkGCDamage(d,g) (d && \ ++#define checkGCDamage(d,g) (getDrawableDamage(d) && \ + (!g->pCompositeClip ||\ + RegionNotEmpty(g->pCompositeClip))) + +@@ -468,7 +469,8 @@ damageDestroyClip(GCPtr pGC) + if(box.y2 > extents->y2) box.y2 = extents->y2; \ + } + +-#define checkPictureDamage(d, p) (d && RegionNotEmpty(p->pCompositeClip)) ++#define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \ ++ RegionNotEmpty(p->pCompositeClip)) + + static void + damageComposite(CARD8 op, +@@ -485,9 +487,8 @@ damageComposite(CARD8 op, + PictureScreenPtr ps = GetPictureScreen(pScreen); + + damageScrPriv(pScreen); +- drawableDamage(pDst->pDrawable); + +- if (checkPictureDamage(pDamage, pDst)) { ++ if (checkPictureDamage(pDst)) { + BoxRec box; + + box.x1 = xDst + pDst->pDrawable->x; +@@ -504,7 +505,7 @@ damageComposite(CARD8 op, + pMask, + pDst, + xSrc, ySrc, xMask, yMask, xDst, yDst, width, height); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDst->pDrawable); + wrap(pScrPriv, ps, Composite, damageComposite); + } + +@@ -520,9 +521,8 @@ damageGlyphs(CARD8 op, + PictureScreenPtr ps = GetPictureScreen(pScreen); + + damageScrPriv(pScreen); +- drawableDamage(pDst->pDrawable); + +- if (checkPictureDamage(pDamage, pDst)) { ++ if (checkPictureDamage(pDst)) { + int nlistTmp = nlist; + GlyphListPtr listTmp = list; + GlyphPtr *glyphsTmp = glyphs; +@@ -567,7 +567,7 @@ damageGlyphs(CARD8 op, + } + unwrap(pScrPriv, ps, Glyphs); + (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDst->pDrawable); + wrap(pScrPriv, ps, Glyphs, damageGlyphs); + } + +@@ -579,9 +579,8 @@ damageAddTraps(PicturePtr pPicture, + PictureScreenPtr ps = GetPictureScreen(pScreen); + + damageScrPriv(pScreen); +- drawableDamage(pPicture->pDrawable); + +- if (checkPictureDamage(pDamage, pPicture)) { ++ if (checkPictureDamage(pPicture)) { + BoxRec box; + int i; + int x, y; +@@ -616,7 +615,7 @@ damageAddTraps(PicturePtr pPicture, + } + unwrap(pScrPriv, ps, AddTraps); + (*ps->AddTraps) (pPicture, x_off, y_off, ntrap, traps); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pPicture->pDrawable); + wrap(pScrPriv, ps, AddTraps, damageAddTraps); + } + +@@ -628,7 +627,7 @@ damageFillSpans(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (npt && checkGCDamage(pDamage, pGC)) { ++ if (npt && checkGCDamage(pDrawable, pGC)) { + int nptTmp = npt; + DDXPointPtr pptTmp = ppt; + int *pwidthTmp = pwidth; +@@ -664,7 +663,7 @@ damageFillSpans(DrawablePtr pDrawable, + + (*pGC->ops->FillSpans) (pDrawable, pGC, npt, ppt, pwidth, fSorted); + +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -676,7 +675,7 @@ damageSetSpans(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (npt && checkGCDamage(pDamage, pGC)) { ++ if (npt && checkGCDamage(pDrawable, pGC)) { + DDXPointPtr pptTmp = ppt; + int *pwidthTmp = pwidth; + int nptTmp = npt; +@@ -710,7 +709,7 @@ damageSetSpans(DrawablePtr pDrawable, + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->SetSpans) (pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -722,7 +721,7 @@ damagePutImage(DrawablePtr pDrawable, + int y, int w, int h, int leftPad, int format, char *pImage) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); +- if (checkGCDamage(pDamage, pGC)) { ++ if (checkGCDamage(pDrawable, pGC)) { + BoxRec box; + + box.x1 = x + pDrawable->x; +@@ -736,7 +735,7 @@ damagePutImage(DrawablePtr pDrawable, + } + (*pGC->ops->PutImage) (pDrawable, pGC, depth, x, y, w, h, + leftPad, format, pImage); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -750,7 +749,7 @@ damageCopyArea(DrawablePtr pSrc, + + DAMAGE_GC_OP_PROLOGUE(pGC, pDst); + +- if (checkGCDamage(pDamage, pGC)) { ++ if (checkGCDamage(pDst, pGC)) { + BoxRec box; + + box.x1 = dstx + pDst->x; +@@ -765,7 +764,7 @@ damageCopyArea(DrawablePtr pSrc, + + ret = (*pGC->ops->CopyArea) (pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDst); + DAMAGE_GC_OP_EPILOGUE(pGC, pDst); + return ret; + } +@@ -783,7 +782,7 @@ damageCopyPlane(DrawablePtr pSrc, + + DAMAGE_GC_OP_PROLOGUE(pGC, pDst); + +- if (checkGCDamage(pDamage, pGC)) { ++ if (checkGCDamage(pDst, pGC)) { + BoxRec box; + + box.x1 = dstx + pDst->x; +@@ -799,7 +798,7 @@ damageCopyPlane(DrawablePtr pSrc, + ret = (*pGC->ops->CopyPlane) (pSrc, pDst, + pGC, srcx, srcy, width, height, dstx, dsty, + bitPlane); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDst); + DAMAGE_GC_OP_EPILOGUE(pGC, pDst); + return ret; + } +@@ -810,7 +809,7 @@ damagePolyPoint(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (npt && checkGCDamage(pDamage, pGC)) { ++ if (npt && checkGCDamage(pDrawable, pGC)) { + BoxRec box; + int nptTmp = npt; + xPoint *pptTmp = ppt; +@@ -840,7 +839,7 @@ damagePolyPoint(DrawablePtr pDrawable, + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, ppt); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -850,7 +849,7 @@ damagePolylines(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (npt && checkGCDamage(pDamage, pGC)) { ++ if (npt && checkGCDamage(pDrawable, pGC)) { + int nptTmp = npt; + DDXPointPtr pptTmp = ppt; + BoxRec box; +@@ -913,7 +912,7 @@ damagePolylines(DrawablePtr pDrawable, + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->Polylines) (pDrawable, pGC, mode, npt, ppt); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -922,7 +921,7 @@ damagePolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSeg, xSegment * pSeg) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (nSeg && checkGCDamage(pDamage, pGC)) { ++ if (nSeg && checkGCDamage(pDrawable, pGC)) { + BoxRec box; + int extra = pGC->lineWidth; + int nsegTmp = nSeg; +@@ -992,7 +991,7 @@ damagePolySegment(DrawablePtr pDrawable, GCPtr pGC, int nSeg, xSegment * pSeg) + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PolySegment) (pDrawable, pGC, nSeg, pSeg); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1002,7 +1001,7 @@ damagePolyRectangle(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (nRects && checkGCDamage(pDamage, pGC)) { ++ if (nRects && checkGCDamage(pDrawable, pGC)) { + BoxRec box; + int offset1, offset2, offset3; + int nRectsTmp = nRects; +@@ -1051,7 +1050,7 @@ damagePolyRectangle(DrawablePtr pDrawable, + } + } + (*pGC->ops->PolyRectangle) (pDrawable, pGC, nRects, pRects); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1060,7 +1059,7 @@ damagePolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (nArcs && checkGCDamage(pDamage, pGC)) { ++ if (nArcs && checkGCDamage(pDrawable, pGC)) { + int extra = pGC->lineWidth >> 1; + BoxRec box; + int nArcsTmp = nArcs; +@@ -1098,7 +1097,7 @@ damagePolyArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PolyArc) (pDrawable, pGC, nArcs, pArcs); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1108,7 +1107,7 @@ damageFillPolygon(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (npt > 2 && checkGCDamage(pDamage, pGC)) { ++ if (npt > 2 && checkGCDamage(pDrawable, pGC)) { + DDXPointPtr pptTmp = ppt; + int nptTmp = npt; + BoxRec box; +@@ -1157,7 +1156,7 @@ damageFillPolygon(DrawablePtr pDrawable, + } + + (*pGC->ops->FillPolygon) (pDrawable, pGC, shape, mode, npt, ppt); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1166,7 +1165,7 @@ damagePolyFillRect(DrawablePtr pDrawable, + GCPtr pGC, int nRects, xRectangle *pRects) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); +- if (nRects && checkGCDamage(pDamage, pGC)) { ++ if (nRects && checkGCDamage(pDrawable, pGC)) { + BoxRec box; + xRectangle *pRectsTmp = pRects; + int nRectsTmp = nRects; +@@ -1193,7 +1192,7 @@ damagePolyFillRect(DrawablePtr pDrawable, + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PolyFillRect) (pDrawable, pGC, nRects, pRects); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1202,7 +1201,7 @@ damagePolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + +- if (nArcs && checkGCDamage(pDamage, pGC)) { ++ if (nArcs && checkGCDamage(pDrawable, pGC)) { + BoxRec box; + int nArcsTmp = nArcs; + xArc *pArcsTmp = pArcs; +@@ -1229,7 +1228,7 @@ damagePolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int nArcs, xArc * pArcs) + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PolyFillArc) (pDrawable, pGC, nArcs, pArcs); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1278,9 +1277,12 @@ damageDamageChars(DrawablePtr pDrawable, + #define TT_IMAGE16 3 + + static void +-damageText(DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned long count, +- char *chars, FontEncoding fontEncoding, DamagePtr pDamage, +- Bool textType) ++damageText(DrawablePtr pDrawable, ++ GCPtr pGC, ++ int x, ++ int y, ++ unsigned long count, ++ char *chars, FontEncoding fontEncoding, Bool textType) + { + CharInfoPtr *charinfo; + unsigned long i; +@@ -1289,7 +1291,7 @@ damageText(DrawablePtr pDrawable, GCPtr pGC, int x, int y, unsigned long count, + + imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); + +- if (!pDamage) ++ if (!checkGCDamage(pDrawable, pGC)) + return; + + charinfo = xallocarray(count, sizeof(CharInfoPtr)); +@@ -1314,9 +1316,9 @@ damagePolyText8(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageText(pDrawable, pGC, x, y, (unsigned long) count, chars, Linear8Bit, +- pDamage, TT_POLY8); ++ TT_POLY8); + x = (*pGC->ops->PolyText8) (pDrawable, pGC, x, y, count, chars); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + return x; + } +@@ -1328,9 +1330,9 @@ damagePolyText16(DrawablePtr pDrawable, + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageText(pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, + FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, +- pDamage, TT_POLY16); ++ TT_POLY16); + x = (*pGC->ops->PolyText16) (pDrawable, pGC, x, y, count, chars); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + return x; + } +@@ -1341,9 +1343,9 @@ damageImageText8(DrawablePtr pDrawable, + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageText(pDrawable, pGC, x, y, (unsigned long) count, chars, Linear8Bit, +- pDamage, TT_IMAGE8); ++ TT_IMAGE8); + (*pGC->ops->ImageText8) (pDrawable, pGC, x, y, count, chars); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1354,9 +1356,9 @@ damageImageText16(DrawablePtr pDrawable, + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); + damageText(pDrawable, pGC, x, y, (unsigned long) count, (char *) chars, + FONTLASTROW(pGC->font) == 0 ? Linear16Bit : TwoD16Bit, +- pDamage, TT_IMAGE16); ++ TT_IMAGE16); + (*pGC->ops->ImageText16) (pDrawable, pGC, x, y, count, chars); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1371,7 +1373,7 @@ damageImageGlyphBlt(DrawablePtr pDrawable, + damageDamageChars(pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, TRUE, pGC->subWindowMode); + (*pGC->ops->ImageGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1386,7 +1388,7 @@ damagePolyGlyphBlt(DrawablePtr pDrawable, + damageDamageChars(pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, FALSE, pGC->subWindowMode); + (*pGC->ops->PolyGlyphBlt) (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1396,7 +1398,7 @@ damagePushPixels(GCPtr pGC, + DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg) + { + DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); +- if (checkGCDamage(pDamage, pGC)) { ++ if (checkGCDamage(pDrawable, pGC)) { + BoxRec box; + + box.x1 = xOrg; +@@ -1415,7 +1417,7 @@ damagePushPixels(GCPtr pGC, + damageDamageBox(pDrawable, &box, pGC->subWindowMode); + } + (*pGC->ops->PushPixels) (pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); + } + +@@ -1480,7 +1482,6 @@ damageCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) + ScreenPtr pScreen = pWindow->drawable.pScreen; + + damageScrPriv(pScreen); +- drawableDamage(&pWindow->drawable); + + if (getWindowDamage(pWindow)) { + int dx = pWindow->drawable.x - ptOldOrg.x; +@@ -1496,7 +1497,7 @@ damageCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) + } + unwrap(pScrPriv, pScreen, CopyWindow); + (*pScreen->CopyWindow) (pWindow, ptOldOrg, prgnSrc); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(&pWindow->drawable); + wrap(pScrPriv, pScreen, CopyWindow, damageCopyWindow); + } + +@@ -1870,22 +1871,20 @@ DamageRegionAppend(DrawablePtr pDrawable, RegionPtr pRegion) + void + DamageRegionProcessPending(DrawablePtr pDrawable) + { +- drawableDamage(pDrawable); +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + } + + /* This call is very odd, i'm leaving it intact for API sake, but please don't use it. */ + void + DamageDamageRegion(DrawablePtr pDrawable, RegionPtr pRegion) + { +- drawableDamage(pDrawable); + damageRegionAppend(pDrawable, pRegion, FALSE, -1); + + /* Go back and report this damage for DamagePtrs with reportAfter set, since + * this call isn't part of an in-progress drawing op in the call chain and + * the DDX probably just wants to know about it right away. + */ +- damageRegionProcessPending(pDamage); ++ damageRegionProcessPending(pDrawable); + } + + void +-- +2.9.3 + diff --git a/0001-xfree86-Free-devlist-returned-by-xf86MatchDevice.patch b/0001-xfree86-Free-devlist-returned-by-xf86MatchDevice.patch new file mode 100644 index 0000000..36a3730 --- /dev/null +++ b/0001-xfree86-Free-devlist-returned-by-xf86MatchDevice.patch @@ -0,0 +1,39 @@ +From c57c1e53ea3d76ebba5b2a23b7260817d3e6b921 Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:12 +0100 +Subject: [PATCH xserver 1/6] xfree86: Free devlist returned by xf86MatchDevice + +xf86MatchDevice returns a dynamically allocated list of GDevPtr-s, +free this when we're done with it. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 063e81c..16d934f 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -479,6 +479,8 @@ xf86platformProbeDev(DriverPtr drvp) + isGPUDevice(devList[i]) ? PLATFORM_PROBE_GPU_SCREEN : 0); + } + ++ free(devList); ++ + return foundScreen; + } + +@@ -505,6 +507,8 @@ xf86platformAddGPUDevices(DriverPtr drvp) + } + } + ++ free(devList); ++ + return foundScreen; + } + +-- +2.9.3 + diff --git a/0002-xfree86-Make-OutputClassMatches-take-a-xf86_platform.patch b/0002-xfree86-Make-OutputClassMatches-take-a-xf86_platform.patch new file mode 100644 index 0000000..89ce17c --- /dev/null +++ b/0002-xfree86-Make-OutputClassMatches-take-a-xf86_platform.patch @@ -0,0 +1,45 @@ +From 08b84d72878e43401e99059c3c926dfa42a360c3 Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:13 +0100 +Subject: [PATCH xserver 2/6] xfree86: Make OutputClassMatches take a + xf86_platform_device + +Make OutputClassMatches directly take a xf86_platform_device as argument, +rather then an index into xf86_platform_devices. This makes things +easier for callers which already have a xf86_platform_device pointer. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 16d934f..25a9040 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -214,9 +214,10 @@ MatchToken(const char *value, struct xorg_list *patterns, + } + + static Bool +-OutputClassMatches(const XF86ConfOutputClassPtr oclass, int index) ++OutputClassMatches(const XF86ConfOutputClassPtr oclass, ++ struct xf86_platform_device *dev) + { +- char *driver = xf86_platform_odev_attributes(index)->driver; ++ char *driver = dev->attribs->driver; + + if (!MatchToken(driver, &oclass->match_driver, strcmp)) + return FALSE; +@@ -234,7 +235,7 @@ xf86OutputClassDriverList(int index, char *matches[], int nmatches) + return 0; + + for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) { +- if (OutputClassMatches(cl, index)) { ++ if (OutputClassMatches(cl, &xf86_platform_devices[index])) { + char *path = xf86_platform_odev_attributes(index)->path; + + xf86Msg(X_INFO, "Applying OutputClass \"%s\" to %s\n", +-- +2.9.3 + diff --git a/0003-xfree86-Add-options-support-for-OutputClass-Options.patch b/0003-xfree86-Add-options-support-for-OutputClass-Options.patch new file mode 100644 index 0000000..b18f9b9 --- /dev/null +++ b/0003-xfree86-Add-options-support-for-OutputClass-Options.patch @@ -0,0 +1,190 @@ +From 9cd3cc75269d9196898487b5712ee47b8291e077 Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:14 +0100 +Subject: [PATCH xserver 3/6] xfree86: Add options support for OutputClass + Options + +Add support for setting options in OutputClass Sections and having these +applied to any matching output devices. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86Option.c | 5 ++++- + hw/xfree86/common/xf86platformBus.c | 42 +++++++++++++++++++++++++++++++++++++ + hw/xfree86/common/xf86platformBus.h | 2 ++ + hw/xfree86/man/xorg.conf.man | 10 +++++++++ + hw/xfree86/parser/OutputClass.c | 6 ++++++ + hw/xfree86/parser/xf86Parser.h | 1 + + 6 files changed, 65 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c +index 0e8bc1f..929724d 100644 +--- a/hw/xfree86/common/xf86Option.c ++++ b/hw/xfree86/common/xf86Option.c +@@ -44,6 +44,7 @@ + #include "xf86Xinput.h" + #include "xf86Optrec.h" + #include "xf86Parser.h" ++#include "xf86platformBus.h" /* For OutputClass functions */ + #include "optionstr.h" + + static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, +@@ -64,7 +65,7 @@ static Bool ParseOptionValue(int scrnIndex, XF86OptionPtr options, + * + * The order of precedence for options is: + * +- * extraOpts, display, confScreen, monitor, device ++ * extraOpts, display, confScreen, monitor, device, outputClassOptions + */ + + void +@@ -79,6 +80,8 @@ xf86CollectOptions(ScrnInfoPtr pScrn, XF86OptionPtr extraOpts) + pScrn->options = NULL; + + for (i = pScrn->numEntities - 1; i >= 0; i--) { ++ xf86MergeOutputClassOptions(pScrn->entityList[i], &pScrn->options); ++ + device = xf86GetDevFromEntity(pScrn->entityList[i], + pScrn->entityInstanceList[i]); + if (device && device->options) { +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 25a9040..a698c6c 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -310,6 +310,48 @@ xf86platformProbe(void) + return 0; + } + ++void ++xf86MergeOutputClassOptions(int entityIndex, void **options) ++{ ++ const EntityPtr entity = xf86Entities[entityIndex]; ++ struct xf86_platform_device *dev = NULL; ++ XF86ConfOutputClassPtr cl; ++ XF86OptionPtr classopts; ++ int i = 0; ++ ++ switch (entity->bus.type) { ++ case BUS_PLATFORM: ++ dev = entity->bus.id.plat; ++ break; ++ case BUS_PCI: ++ for (i = 0; i < xf86_num_platform_devices; i++) { ++ if (MATCH_PCI_DEVICES(xf86_platform_devices[i].pdev, ++ entity->bus.id.pci)) { ++ dev = &xf86_platform_devices[i]; ++ break; ++ } ++ } ++ break; ++ default: ++ xf86Msg(X_DEBUG, "xf86MergeOutputClassOptions unsupported bus type %d\n", ++ entity->bus.type); ++ } ++ ++ if (!dev) ++ return; ++ ++ for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) { ++ if (!OutputClassMatches(cl, dev) || !cl->option_lst) ++ continue; ++ ++ xf86Msg(X_INFO, "Applying OutputClass \"%s\" options to %s\n", ++ cl->identifier, dev->attribs->path); ++ ++ classopts = xf86optionListDup(cl->option_lst); ++ *options = xf86optionListMerge(*options, classopts); ++ } ++} ++ + static int + xf86ClaimPlatformSlot(struct xf86_platform_device * d, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active) +diff --git a/hw/xfree86/common/xf86platformBus.h b/hw/xfree86/common/xf86platformBus.h +index 0f5c0ef..70d9ec8 100644 +--- a/hw/xfree86/common/xf86platformBus.h ++++ b/hw/xfree86/common/xf86platformBus.h +@@ -42,6 +42,7 @@ struct xf86_platform_device { + int xf86platformProbe(void); + int xf86platformProbeDev(DriverPtr drvp); + int xf86platformAddGPUDevices(DriverPtr drvp); ++void xf86MergeOutputClassOptions(int entityIndex, void **options); + + extern int xf86_num_platform_devices; + extern struct xf86_platform_device *xf86_platform_devices; +@@ -161,6 +162,7 @@ extern void xf86platformPrimary(void); + #else + + static inline int xf86platformAddGPUDevices(DriverPtr drvp) { return FALSE; } ++static inline void xf86MergeOutputClassOptions(int index, void **options) {} + + #endif + +diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man +index 7d0c524..8928a53 100644 +--- a/hw/xfree86/man/xorg.conf.man ++++ b/hw/xfree86/man/xorg.conf.man +@@ -1280,6 +1280,16 @@ For example: + Check the case-sensitive string + .RI \*q matchdriver \*q + against the kernel driver of the device. ++.PP ++When an output device has been matched to the ++.B OutputClass ++section, any ++.B Option ++entries are applied to the device. See the ++.B Device ++section below for a description of the remaining ++.B Option ++entries. + .SH "DEVICE SECTION" + The config file may have multiple + .B Device +diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c +index 8064e0c..f813ee6 100644 +--- a/hw/xfree86/parser/OutputClass.c ++++ b/hw/xfree86/parser/OutputClass.c +@@ -36,6 +36,7 @@ static const xf86ConfigSymTabRec OutputClassTab[] = { + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {DRIVER, "driver"}, ++ {OPTION, "option"}, + {MATCH_DRIVER, "matchdriver"}, + {-1, ""}, + }; +@@ -60,6 +61,8 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr) + free(group); + } + ++ xf86optionListFree(ptr->option_lst); ++ + prev = ptr; + ptr = ptr->list.next; + free(prev); +@@ -112,6 +115,9 @@ xf86parseOutputClassSection(void) + else + ptr->driver = xf86_lex_val.str; + break; ++ case OPTION: ++ ptr->option_lst = xf86parseOption(ptr->option_lst); ++ break; + case MATCH_DRIVER: + if (xf86getSubToken(&(ptr->comment)) != STRING) + Error(QUOTE_MSG, "MatchDriver"); +diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h +index 9c4b403..897edab 100644 +--- a/hw/xfree86/parser/xf86Parser.h ++++ b/hw/xfree86/parser/xf86Parser.h +@@ -338,6 +338,7 @@ typedef struct { + char *identifier; + char *driver; + struct xorg_list match_driver; ++ XF86OptionPtr option_lst; + char *comment; + } XF86ConfOutputClassRec, *XF86ConfOutputClassPtr; + +-- +2.9.3 + diff --git a/0004-xfree86-xf86platformProbe-split-finding-pci-info-and.patch b/0004-xfree86-xf86platformProbe-split-finding-pci-info-and.patch new file mode 100644 index 0000000..03d404e --- /dev/null +++ b/0004-xfree86-xf86platformProbe-split-finding-pci-info-and.patch @@ -0,0 +1,61 @@ +From ab1a65b7755d081b41188104b21f4d21eaa3187b Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:15 +0100 +Subject: [PATCH xserver 4/6] xfree86: xf86platformProbe: split finding + pci-info and setting primary GPU + +This is a preparation patch for allowing an OutputClass section to +override the default primary GPU device selection. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 23 +++++++++++++++-------- + 1 file changed, 15 insertions(+), 8 deletions(-) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index a698c6c..39b3248 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -145,16 +145,9 @@ platform_find_pci_info(struct xf86_platform_device *pd, char *busid) + + iter = pci_slot_match_iterator_create(&devmatch); + info = pci_device_next(iter); +- if (info) { ++ if (info) + pd->pdev = info; +- pci_device_probe(info); +- if (pci_device_is_boot_vga(info)) { +- primaryBus.type = BUS_PLATFORM; +- primaryBus.id.plat = pd; +- } +- } + pci_iterator_destroy(iter); +- + } + + static Bool +@@ -307,6 +300,20 @@ xf86platformProbe(void) + platform_find_pci_info(&xf86_platform_devices[i], busid); + } + } ++ ++ for (i = 0; i < xf86_num_platform_devices; i++) { ++ struct xf86_platform_device *dev = &xf86_platform_devices[i]; ++ ++ if (!dev->pdev) ++ continue; ++ ++ pci_device_probe(dev->pdev); ++ if (pci_device_is_boot_vga(dev->pdev)) { ++ primaryBus.type = BUS_PLATFORM; ++ primaryBus.id.plat = dev; ++ } ++ } ++ + return 0; + } + +-- +2.9.3 + diff --git a/0005-xfree86-Allow-overriding-primary-GPU-detection-from-.patch b/0005-xfree86-Allow-overriding-primary-GPU-detection-from-.patch new file mode 100644 index 0000000..afa47e4 --- /dev/null +++ b/0005-xfree86-Allow-overriding-primary-GPU-detection-from-.patch @@ -0,0 +1,91 @@ +From d75ffcdbf8c1e3c8e0d46debcd533a9f2560f0a8 Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:16 +0100 +Subject: [PATCH xserver 5/6] xfree86: Allow overriding primary GPU detection + from an OutputClass section + +Allow using: + +Option "PrimaryGPU" "yes" + +In an OutputClass section to override the default primary GPU device +selection which selects the GPU used as output by the firmware. + +If multiple output devices match an OutputClass section with +the PrimaryGPU option set, the first one enumerated becomes the +primary GPU. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 19 +++++++++++++++++++ + hw/xfree86/man/xorg.conf.man | 12 +++++++++++- + 2 files changed, 30 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 39b3248..fc17d15 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -286,6 +286,7 @@ xf86platformProbe(void) + { + int i; + Bool pci = TRUE; ++ XF86ConfOutputClassPtr cl; + + config_odev_probe(xf86PlatformDeviceProbe); + +@@ -301,6 +302,24 @@ xf86platformProbe(void) + } + } + ++ /* First see if there is an OutputClass match marking a device as primary */ ++ for (i = 0; i < xf86_num_platform_devices; i++) { ++ struct xf86_platform_device *dev = &xf86_platform_devices[i]; ++ for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) { ++ if (!OutputClassMatches(cl, dev)) ++ continue; ++ ++ if (xf86CheckBoolOption(cl->option_lst, "PrimaryGPU", FALSE)) { ++ xf86Msg(X_CONFIG, "OutputClass \"%s\" setting %s as PrimaryGPU\n", ++ cl->identifier, dev->attribs->path); ++ primaryBus.type = BUS_PLATFORM; ++ primaryBus.id.plat = dev; ++ return 0; ++ } ++ } ++ } ++ ++ /* Then check for pci_device_is_boot_vga() */ + for (i = 0; i < xf86_num_platform_devices; i++) { + struct xf86_platform_device *dev = &xf86_platform_devices[i]; + +diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man +index 8928a53..79b71a8 100644 +--- a/hw/xfree86/man/xorg.conf.man ++++ b/hw/xfree86/man/xorg.conf.man +@@ -1285,11 +1285,21 @@ When an output device has been matched to the + .B OutputClass + section, any + .B Option +-entries are applied to the device. See the ++entries are applied to the device. One ++.B OutputClass ++specific ++.B Option ++is recognized. See the + .B Device + section below for a description of the remaining + .B Option + entries. ++.TP 7 ++.BI "Option \*qPrimaryGPU\*q \*q" boolean \*q ++This option specifies that the matched device should be treated as the ++primary GPU, replacing the selection of the GPU used as output by the ++firmware. If multiple output devices match an OutputClass section with ++the PrimaryGPU option set, the first one enumerated becomes the primary GPU. + .SH "DEVICE SECTION" + The config file may have multiple + .B Device +-- +2.9.3 + diff --git a/0006-xfree86-Add-ModulePath-support-for-OutputClass-confi.patch b/0006-xfree86-Add-ModulePath-support-for-OutputClass-confi.patch new file mode 100644 index 0000000..6ba4018 --- /dev/null +++ b/0006-xfree86-Add-ModulePath-support-for-OutputClass-confi.patch @@ -0,0 +1,183 @@ +From b5dffbbac193aa640ffcfa0a431c21b862854e53 Mon Sep 17 00:00:00 2001 +From: Hans De Goede +Date: Mon, 12 Dec 2016 17:03:17 +0100 +Subject: [PATCH xserver 6/6] xfree86: Add ModulePath support for OutputClass + config Sections + +Allow OutputClass config snippets to modify the module-path. + +Note that any specified ModulePaths will be pre-pended to the normal +ModulePath. The idea behind this is that any output hardware specific +modules should have preference over the normal modules. + +One use-case for this is the nvidia binary driver, this allows a +config snippet like this: + +Section "OutputClass" + MatchDriver "nvidia" + Modulepath "/usr/lib64/nvidia/modules" +EndSection + +To get the nvidia glx specific glx module loaded, but only when the +nvidia kernel driver is loaded. + +Together with the glvnd work done recently, this allows the nouveau ++ mesa and nvidia-binary userspace stacks to co-exist on the same +system without any ldconfig / xorg.conf tweaking and the xserver will +automatically do the right thing depending on which kernel driver +(nouveau or nvidia) is loaded. + +Reviewed-by: Adam Jackson +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 23 +++++++++++++++++++++++ + hw/xfree86/loader/loadmod.c | 1 + + hw/xfree86/man/xorg.conf.man | 16 ++++++++++++++++ + hw/xfree86/parser/OutputClass.c | 15 +++++++++++++++ + hw/xfree86/parser/xf86Parser.h | 1 + + 5 files changed, 56 insertions(+) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index fc17d15..0b5795f 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -40,6 +40,7 @@ + #include "hotplug.h" + #include "systemd-logind.h" + ++#include "loaderProcs.h" + #include "xf86.h" + #include "xf86_OSproc.h" + #include "xf86Priv.h" +@@ -287,6 +288,7 @@ xf86platformProbe(void) + int i; + Bool pci = TRUE; + XF86ConfOutputClassPtr cl; ++ char *old_path, *path = NULL; + + config_odev_probe(xf86PlatformDeviceProbe); + +@@ -300,8 +302,29 @@ xf86platformProbe(void) + if (pci && (strncmp(busid, "pci:", 4) == 0)) { + platform_find_pci_info(&xf86_platform_devices[i], busid); + } ++ ++ /* ++ * Deal with OutputClass ModulePath directives, these must be ++ * processed before we do any module loading. ++ */ ++ for (cl = xf86configptr->conf_outputclass_lst; cl; cl = cl->list.next) { ++ if (!OutputClassMatches(cl, &xf86_platform_devices[i])) ++ continue; ++ ++ if (cl->modulepath && xf86ModPathFrom != X_CMDLINE) { ++ old_path = path; ++ XNFasprintf(&path, "%s,%s", cl->modulepath, ++ path ? path : xf86ModulePath); ++ free(old_path); ++ xf86Msg(X_CONFIG, "OutputClass \"%s\" ModulePath extended to \"%s\"\n", ++ cl->identifier, path); ++ LoaderSetPath(path); ++ } ++ } + } + ++ free(path); ++ + /* First see if there is an OutputClass match marking a device as primary */ + for (i = 0; i < xf86_num_platform_devices; i++) { + struct xf86_platform_device *dev = &xf86_platform_devices[i]; +diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c +index 8bf6836..940f5fc 100644 +--- a/hw/xfree86/loader/loadmod.c ++++ b/hw/xfree86/loader/loadmod.c +@@ -184,6 +184,7 @@ LoaderSetPath(const char *path) + if (!path) + return; + ++ FreeStringList(defaultPathList); + defaultPathList = InitPathList(path); + } + +diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man +index 79b71a8..00ebf56 100644 +--- a/hw/xfree86/man/xorg.conf.man ++++ b/hw/xfree86/man/xorg.conf.man +@@ -1300,6 +1300,22 @@ This option specifies that the matched device should be treated as the + primary GPU, replacing the selection of the GPU used as output by the + firmware. If multiple output devices match an OutputClass section with + the PrimaryGPU option set, the first one enumerated becomes the primary GPU. ++.PP ++A ++.B OutputClass ++Section may contain ++.B ModulePath ++entries. When an output device matches an ++.B OutputClass ++section, any ++.B ModulePath ++entries in that ++.B OutputClass ++are pre-pended to the search path for loadable Xorg server modules. See ++.B ModulePath ++in the ++.B Files ++section for more info. + .SH "DEVICE SECTION" + The config file may have multiple + .B Device +diff --git a/hw/xfree86/parser/OutputClass.c b/hw/xfree86/parser/OutputClass.c +index f813ee6..01b348f 100644 +--- a/hw/xfree86/parser/OutputClass.c ++++ b/hw/xfree86/parser/OutputClass.c +@@ -36,6 +36,7 @@ static const xf86ConfigSymTabRec OutputClassTab[] = { + {ENDSECTION, "endsection"}, + {IDENTIFIER, "identifier"}, + {DRIVER, "driver"}, ++ {MODULEPATH, "modulepath"}, + {OPTION, "option"}, + {MATCH_DRIVER, "matchdriver"}, + {-1, ""}, +@@ -53,6 +54,7 @@ xf86freeOutputClassList(XF86ConfOutputClassPtr ptr) + TestFree(ptr->identifier); + TestFree(ptr->comment); + TestFree(ptr->driver); ++ TestFree(ptr->modulepath); + + xorg_list_for_each_entry_safe(group, next, &ptr->match_driver, entry) { + xorg_list_del(&group->entry); +@@ -115,6 +117,19 @@ xf86parseOutputClassSection(void) + else + ptr->driver = xf86_lex_val.str; + break; ++ case MODULEPATH: ++ if (xf86getSubToken(&(ptr->comment)) != STRING) ++ Error(QUOTE_MSG, "ModulePath"); ++ if (ptr->modulepath) { ++ char *path; ++ XNFasprintf(&path, "%s,%s", ptr->modulepath, xf86_lex_val.str); ++ free(xf86_lex_val.str); ++ free(ptr->modulepath); ++ ptr->modulepath = path; ++ } else { ++ ptr->modulepath = xf86_lex_val.str; ++ } ++ break; + case OPTION: + ptr->option_lst = xf86parseOption(ptr->option_lst); + break; +diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h +index 897edab..e014048 100644 +--- a/hw/xfree86/parser/xf86Parser.h ++++ b/hw/xfree86/parser/xf86Parser.h +@@ -337,6 +337,7 @@ typedef struct { + GenericListRec list; + char *identifier; + char *driver; ++ char *modulepath; + struct xorg_list match_driver; + XF86OptionPtr option_lst; + char *comment; +-- +2.9.3 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index ca6f269..e3948c9 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -45,7 +45,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.19.0 -Release: 1%{?gitdate:.%{gitdate}}%{dist} +Release: 2%{?gitdate:.%{gitdate}}%{dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -87,11 +87,22 @@ Patch6: 0001-xwayland-Fix-use-after-free-of-cursors.patch Patch7: 0001-randr-rrCheckPixmapBounding-Do-not-substract-crtc-no.patch Patch8: 0002-randr-rrCheckPixmapBounding-do-not-shrink-the-screen.patch +# Patches for better integration with the nvidia driver, pending upstream +Patch11: 0001-xfree86-Free-devlist-returned-by-xf86MatchDevice.patch +Patch12: 0002-xfree86-Make-OutputClassMatches-take-a-xf86_platform.patch +Patch13: 0003-xfree86-Add-options-support-for-OutputClass-Options.patch +Patch14: 0004-xfree86-xf86platformProbe-split-finding-pci-info-and.patch +Patch15: 0005-xfree86-Allow-overriding-primary-GPU-detection-from-.patch +Patch16: 0006-xfree86-Add-ModulePath-support-for-OutputClass-confi.patch + +# https://bugzilla.redhat.com/show_bug.cgi?id=1389886 +Patch21: 0001-Revert-damage-Make-damageRegionProcessPending-take-a.patch + #Patch6044: xserver-1.6.99-hush-prerelease-warning.patch Patch7025: 0001-Always-install-vbe-and-int10-sdk-headers.patch -# Submitted upstream, pending +# Submitted upstream, but not going anywhere Patch7027: xserver-autobind-hotplug.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1384432 @@ -593,6 +604,10 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Thu Dec 15 2016 Hans de Goede - 1.19.0-2 +- Add some patches for better integration with the nvidia binary driver +- Add a patch from upstream fixing a crash (rhbz#1389886) + * Wed Nov 23 2016 Olivier Fourdan 1.19.0-1 - xserver 1.19.0 - Fix use after free of cursors in Xwayland (rhbz#1385258) diff --git a/xserver-autobind-hotplug.patch b/xserver-autobind-hotplug.patch index 43d8e66..8025cbd 100644 --- a/xserver-autobind-hotplug.patch +++ b/xserver-autobind-hotplug.patch @@ -1,7 +1,7 @@ -From 5b6faa0534453ea362de32a5bda0c4466c8e45b9 Mon Sep 17 00:00:00 2001 +From 4471df41ea6e94834a2b10643ca7fcd69682d276 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 17 Aug 2012 09:49:24 +1000 -Subject: [PATCH xserver v2] autobind GPUs to the screen +Subject: [PATCH xserver v3] autobind GPUs to the screen This is a modified version of a patch we've been carry-ing in Fedora and RHEL for years now. This patch automatically adds secondary GPUs to the @@ -32,30 +32,35 @@ they can disable the servers autobinding through the servers cmdline or a xorg.conf snippet. Signed-off-by: Dave Airlie -[hdegoede@redhat.com: Make configurable, submit upstream] +[hdegoede@redhat.com: Make configurable, fix with nvidia, submit upstream] Signed-off-by: Hans de Goede --- Changes in v2: -Make the default enabled instead of installing a xorg.conf snippet which enables it unconditionally +Changes in v3: +-Handle GPUScreen autoconfig in randr/rrprovider.c, looking at + rrScrPriv->provider, rather then in hw/xfree86/modes/xf86Crtc.c + looking at xf86CrtcConfig->provider. This fixes the autoconfig not + working with the nvidia binary driver --- hw/xfree86/common/xf86Config.c | 19 +++++++++++++++++++ hw/xfree86/common/xf86Globals.c | 2 ++ - hw/xfree86/common/xf86Init.c | 16 ++++++++++++++++ + hw/xfree86/common/xf86Init.c | 20 ++++++++++++++++++++ hw/xfree86/common/xf86Priv.h | 1 + hw/xfree86/common/xf86Privstr.h | 1 + - hw/xfree86/common/xf86platformBus.c | 2 ++ + hw/xfree86/common/xf86platformBus.c | 4 ++++ hw/xfree86/man/Xorg.man | 7 +++++++ hw/xfree86/man/xorg.conf.man | 6 ++++++ - hw/xfree86/modes/xf86Crtc.c | 28 ++++++++++++++++++++++++++++ - hw/xfree86/modes/xf86Crtc.h | 3 +++ + randr/randrstr.h | 3 +++ + randr/rrprovider.c | 22 ++++++++++++++++++++++ 10 files changed, 85 insertions(+) diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c -index 560e2ea..31b34a2 100644 +index 21daf1a..df3ca50 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c -@@ -720,6 +720,7 @@ typedef enum { +@@ -719,6 +719,7 @@ typedef enum { FLAG_DRI2, FLAG_USE_SIGIO, FLAG_AUTO_ADD_GPU, @@ -63,7 +68,7 @@ index 560e2ea..31b34a2 100644 FLAG_MAX_CLIENTS, FLAG_IGLX, } FlagValues; -@@ -781,6 +782,8 @@ static OptionInfoRec FlagOptions[] = { +@@ -778,6 +779,8 @@ static OptionInfoRec FlagOptions[] = { {0}, FALSE}, {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN, {0}, FALSE}, @@ -72,7 +77,7 @@ index 560e2ea..31b34a2 100644 {FLAG_MAX_CLIENTS, "MaxClients", OPTV_INTEGER, {0}, FALSE }, {FLAG_IGLX, "IndirectGLX", OPTV_BOOLEAN, -@@ -860,6 +863,22 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) +@@ -857,6 +860,22 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) } xf86Msg(from, "%sutomatically adding GPU devices\n", xf86Info.autoAddGPU ? "A" : "Not a"); @@ -96,7 +101,7 @@ index 560e2ea..31b34a2 100644 * Set things up based on the config file information. Some of these * settings may be overridden later when the command line options are diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c -index 07cfabf..072c3fc 100644 +index e962b75..0d1e31b 100644 --- a/hw/xfree86/common/xf86Globals.c +++ b/hw/xfree86/common/xf86Globals.c @@ -136,6 +136,7 @@ xf86InfoRec xf86Info = { @@ -107,7 +112,7 @@ index 07cfabf..072c3fc 100644 }; const char *xf86ConfigFile = NULL; -@@ -196,6 +197,7 @@ Bool xf86FlipPixels = FALSE; +@@ -197,6 +198,7 @@ Bool xf86FlipPixels = FALSE; Gamma xf86Gamma = { 0.0, 0.0, 0.0 }; Bool xf86AllowMouseOpenFail = FALSE; @@ -116,7 +121,7 @@ index 07cfabf..072c3fc 100644 #ifdef XF86VIDMODE Bool xf86VidModeDisabled = FALSE; diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c -index a544b65..70c5b7a 100644 +index a544b65..b0cba3d 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c @@ -76,6 +76,7 @@ @@ -127,7 +132,7 @@ index a544b65..70c5b7a 100644 #include "picturestr.h" #include "xf86Bus.h" -@@ -298,6 +299,15 @@ xf86PrivsElevated(void) +@@ -298,6 +299,19 @@ xf86PrivsElevated(void) } static void @@ -135,15 +140,19 @@ index a544b65..70c5b7a 100644 +{ + int i; + ++ if (!xf86Info.autoBindGPU) ++ return; ++ + for (i = 0; i < xf86NumGPUScreens; i++) -+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]); ++ RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]), ++ xf86ScrnToScreen(xf86Screens[0])); +} + +static void InstallSignalHandlers(void) { /* -@@ -871,6 +881,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) +@@ -871,6 +885,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) for (i = 0; i < xf86NumGPUScreens; i++) AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); @@ -152,7 +161,7 @@ index a544b65..70c5b7a 100644 xf86VGAarbiterWrapFunctions(); if (sigio_blocked) input_unlock(); -@@ -1389,6 +1401,10 @@ ddxProcessArgument(int argc, char **argv, int i) +@@ -1389,6 +1405,10 @@ ddxProcessArgument(int argc, char **argv, int i) xf86Info.iglxFrom = X_CMDLINE; return 0; } @@ -176,10 +185,10 @@ index c1f8a18..9a3d0df 100644 #ifdef XF86VIDMODE extern _X_EXPORT Bool xf86VidModeDisabled; diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h -index 9e327b9..a0a98aa 100644 +index c29b3cc..4c5f54b 100644 --- a/hw/xfree86/common/xf86Privstr.h +++ b/hw/xfree86/common/xf86Privstr.h -@@ -104,6 +104,7 @@ typedef struct { +@@ -102,6 +102,7 @@ typedef struct { MessageType dri2From; Bool autoAddGPU; @@ -188,7 +197,7 @@ index 9e327b9..a0a98aa 100644 #ifdef DPMSExtension diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c -index 39fb1dd..3e2264f 100644 +index 063e81c..42789ca 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c @@ -48,6 +48,7 @@ @@ -199,11 +208,13 @@ index 39fb1dd..3e2264f 100644 #include "randrstr.h" int platformSlotClaimed; -@@ -560,6 +561,7 @@ xf86platformAddDevice(int index) +@@ -579,6 +580,9 @@ xf86platformAddDevice(int index) } /* attach unbound to 0 protocol screen */ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); -+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]); ++ if (xf86Info.autoBindGPU) ++ RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]), ++ xf86ScrnToScreen(xf86Screens[0])); RRResourcesChanged(xf86Screens[0]->pScreen); RRTellChanged(xf86Screens[0]->pScreen); @@ -226,10 +237,10 @@ index def9bfc..8df6b7d 100644 Disable Silken Mouse support. .TP 8 diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man -index 94b199e..bdc121a 100644 +index 7d0c524..3e596e4 100644 --- a/hw/xfree86/man/xorg.conf.man +++ b/hw/xfree86/man/xorg.conf.man -@@ -676,6 +676,12 @@ Enabled by default. +@@ -673,6 +673,12 @@ Enabled by default. If this option is disabled, then no GPU devices will be added from the udev backend. Enabled by default. (May need to be disabled to setup Xinerama). .TP 7 @@ -242,54 +253,50 @@ index 94b199e..bdc121a 100644 .BI "Option \*qLog\*q \*q" string \*q This option controls whether the log is flushed and/or synced to disk after each message. -diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c -index 966a168..4960678 100644 ---- a/hw/xfree86/modes/xf86Crtc.c -+++ b/hw/xfree86/modes/xf86Crtc.c -@@ -3462,3 +3462,31 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn) - crtc->x = crtc->y = 0; - } +diff --git a/randr/randrstr.h b/randr/randrstr.h +index 706e9a7..66999d5 100644 +--- a/randr/randrstr.h ++++ b/randr/randrstr.h +@@ -976,6 +976,9 @@ RRProviderLookup(XID id, RRProviderPtr *provider_p); + extern _X_EXPORT void + RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider); + ++extern _X_EXPORT void ++RRProviderAutoConfigGpuScreen(ScreenPtr pScreen, ScreenPtr masterScreen); ++ + /* rrproviderproperty.c */ + + extern _X_EXPORT void +diff --git a/randr/rrprovider.c b/randr/rrprovider.c +index f9df67e..abc5685 100644 +--- a/randr/rrprovider.c ++++ b/randr/rrprovider.c +@@ -482,3 +482,25 @@ RRDeliverProviderEvent(ClientPtr client, WindowPtr pWin, RRProviderPtr provider) + + WriteEventsToClient(client, 1, (xEvent *) &pe); } + -+void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master) ++void ++RRProviderAutoConfigGpuScreen(ScreenPtr pScreen, ScreenPtr masterScreen) +{ -+ RRProviderPtr master_provider; -+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master); -+ xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn); ++ rrScrPrivPtr pScrPriv = rrGetScrPriv(pScreen); ++ rrScrPrivPtr masterPriv = rrGetScrPriv(masterScreen); ++ RRProviderPtr provider = pScrPriv->provider; ++ RRProviderPtr master_provider = masterPriv->provider; + -+ if (!xf86Info.autoBindGPU) -+ return; -+ -+ if (!config || !slave_config) ++ if (!provider || !master_provider) + return; + -+ master_provider = config->randr_provider; -+ -+ if ((master->capabilities & RR_Capability_SinkOffload) && -+ pScrn->capabilities & RR_Capability_SourceOffload) { -+ /* source offload */ -+ AttachOffloadGPU(master->pScreen, pScrn->pScreen); -+ slave_config->randr_provider->offload_sink = master_provider; -+ } -+ if ((master->capabilities & RR_Capability_SourceOutput) && -+ pScrn->capabilities & RR_Capability_SinkOutput) { -+ /* sink offload */ -+ AttachOutputGPU(master->pScreen, pScrn->pScreen); -+ slave_config->randr_provider->output_source = master_provider; ++ if ((provider->capabilities & RR_Capability_SinkOutput) && ++ (master_provider->capabilities & RR_Capability_SourceOutput)) { ++ pScrPriv->rrProviderSetOutputSource(pScreen, provider, master_provider); ++ RRInitPrimeSyncProps(pScreen); + } -+} -diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h -index 14ba9d7..6cf7e89 100644 ---- a/hw/xfree86/modes/xf86Crtc.h -+++ b/hw/xfree86/modes/xf86Crtc.h -@@ -1051,4 +1051,7 @@ xf86ProviderSetup(ScrnInfoPtr scrn, - extern _X_EXPORT void - xf86DetachAllCrtc(ScrnInfoPtr scrn); - -+extern _X_EXPORT void -+xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master); + - #endif /* _XF86CRTC_H_ */ ++ if ((provider->capabilities & RR_Capability_SourceOffload) && ++ (master_provider->capabilities & RR_Capability_SinkOffload)) ++ pScrPriv->rrProviderSetOffloadSink(pScreen, provider, master_provider); ++} -- 2.9.3