summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2013-04-30 14:14:23 -0700
committerKeith Packard <keithp@keithp.com>2013-07-25 11:15:53 -0700
commitbdd1e22cbde9ea2324e4e1991c9e152f22f88151 (patch)
tree61345c257f0c504978df8c312b6b354dc34baefc
parent43ac0491e36cdbb716b5c9d39c97d0aba3bebd75 (diff)
xfree86: detach scanout pixmaps when detaching output GPUs
Commit 8f4640bdb9d3988148e09a08d2c7e3bab1d538d6 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>
-rw-r--r--hw/xfree86/modes/xf86RandR12.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 2817aaa1f..76614de78 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -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);
}