xfree86: detach scanout pixmaps when detaching output GPUs

Commit 8f4640bdb9 fixed a bit of a
chicken-and-egg problem by detaching GPU screens when their providers
are destroyed, which happens before CloseScreen is called.  However,
this created a new problem: the GPU screen tears down its RandR crtc
objects during CloseScreen and if one of them is active, it tries to
detach the scanout pixmap then.  This crashes because
RRCrtcDetachScanoutPixmap tries to get the master screen's screen
pixmap, but crtc->pScreen->current_master is already NULL at that
point.

It doesn't make sense for an unbound GPU screen to still be scanning
out its former master screen's pixmap, so detach them first when the
provider is destroyed.

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Aaron Plattner 2013-04-30 14:14:23 -07:00 committed by Keith Packard
parent 43ac0491e3
commit bdd1e22cbd

View File

@ -1771,6 +1771,19 @@ xf86RandR12EnterVT(ScrnInfoPtr pScrn)
return RRGetInfo(pScreen, TRUE); /* force a re-probe of outputs and notify clients about changes */
}
static void
xf86DetachOutputGPU(ScreenPtr pScreen)
{
rrScrPrivPtr rp = rrGetScrPriv(pScreen);
int i;
/* make sure there are no attached shared scanout pixmaps first */
for (i = 0; i < rp->numCrtcs; i++)
RRCrtcDetachScanoutPixmap(rp->crtcs[i]);
DetachOutputGPU(pScreen);
}
static Bool
xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen,
RRProviderPtr provider,
@ -1780,7 +1793,7 @@ xf86RandR14ProviderSetOutputSource(ScreenPtr pScreen,
if (provider->output_source) {
ScreenPtr cmScreen = pScreen->current_master;
DetachOutputGPU(pScreen);
xf86DetachOutputGPU(pScreen);
AttachUnboundGPU(cmScreen, pScreen);
}
provider->output_source = NULL;
@ -1808,7 +1821,7 @@ xf86RandR14ProviderSetOffloadSink(ScreenPtr pScreen,
if (!sink_provider) {
if (provider->offload_sink) {
ScreenPtr cmScreen = pScreen->current_master;
DetachOutputGPU(pScreen);
xf86DetachOutputGPU(pScreen);
AttachUnboundGPU(cmScreen, pScreen);
}
@ -1899,7 +1912,7 @@ xf86RandR14ProviderDestroy(ScreenPtr screen, RRProviderPtr provider)
RRSetChanged(screen);
}
else if (config->randr_provider->output_source) {
DetachOutputGPU(screen);
xf86DetachOutputGPU(screen);
config->randr_provider->output_source = NULL;
RRSetChanged(screen);
}