diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c index 4a6643961..9362370c3 100644 --- a/hw/xfree86/drivers/modesetting/driver.c +++ b/hw/xfree86/drivers/modesetting/driver.c @@ -1838,8 +1838,6 @@ CloseScreen(ScreenPtr pScreen) ms->drmmode.shadow_fb2 = NULL; } - drmmode_terminate_leases(pScrn, &ms->drmmode); - drmmode_uevent_fini(pScrn, &ms->drmmode); drmmode_free_bos(pScrn, &ms->drmmode); diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c index 12a919fc0..f6f2e9fd1 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.c +++ b/hw/xfree86/drivers/modesetting/drmmode_display.c @@ -3327,23 +3327,6 @@ drmmode_terminate_lease(RRLeasePtr lease) } } -void -drmmode_terminate_leases(ScrnInfoPtr pScrn, drmmode_ptr drmmode) -{ - ScreenPtr screen = xf86ScrnToScreen(pScrn); - rrScrPrivPtr scr_priv = rrGetScrPriv(screen); - RRLeasePtr lease, next; - - xorg_list_for_each_entry_safe(lease, next, &scr_priv->leases, list) { - drmmode_lease_private_ptr lease_private = lease->devPrivate; - drmModeRevokeLease(drmmode->fd, lease_private->lessee_id); - free(lease_private); - lease->devPrivate = NULL; - RRLeaseTerminated(lease); - RRLeaseFree(lease); - } -} - static const xf86CrtcConfigFuncsRec drmmode_xf86crtc_config_funcs = { .resize = drmmode_xf86crtc_resize, .create_lease = drmmode_create_lease, diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h index e46a292d3..cde661450 100644 --- a/hw/xfree86/drivers/modesetting/drmmode_display.h +++ b/hw/xfree86/drivers/modesetting/drmmode_display.h @@ -272,8 +272,6 @@ extern Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn); extern void drmmode_uevent_init(ScrnInfoPtr scrn, drmmode_ptr drmmode); extern void drmmode_uevent_fini(ScrnInfoPtr scrn, drmmode_ptr drmmode); -extern void drmmode_terminate_leases(ScrnInfoPtr scrn, drmmode_ptr drmmode); - Bool drmmode_create_initial_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); void *drmmode_map_front_bo(drmmode_ptr drmmode); Bool drmmode_map_cursor_bos(ScrnInfoPtr pScrn, drmmode_ptr drmmode); diff --git a/randr/randr.c b/randr/randr.c index feb54bcc8..5db8b5ced 100644 --- a/randr/randr.c +++ b/randr/randr.c @@ -89,8 +89,12 @@ RRCloseScreen(ScreenPtr pScreen) { rrScrPriv(pScreen); int j; + RRLeasePtr lease, next; unwrap(pScrPriv, pScreen, CloseScreen); + + xorg_list_for_each_entry_safe(lease, next, &pScrPriv->leases, list) + RRTerminateLease(lease); for (j = pScrPriv->numCrtcs - 1; j >= 0; j--) RRCrtcDestroy(pScrPriv->crtcs[j]); for (j = pScrPriv->numOutputs - 1; j >= 0; j--) diff --git a/randr/randrstr.h b/randr/randrstr.h index f94174b54..2cede92e3 100644 --- a/randr/randrstr.h +++ b/randr/randrstr.h @@ -829,6 +829,9 @@ RRCrtcIsLeased(RRCrtcPtr crtc); extern _X_EXPORT Bool RROutputIsLeased(RROutputPtr output); +void +RRTerminateLease(RRLeasePtr lease); + Bool RRLeaseInit(void); diff --git a/randr/rrcrtc.c b/randr/rrcrtc.c index 74dc5a265..5d9026266 100644 --- a/randr/rrcrtc.c +++ b/randr/rrcrtc.c @@ -872,6 +872,17 @@ RRCrtcDestroyResource(void *value, XID pid) if (pScreen) { rrScrPriv(pScreen); int i; + RRLeasePtr lease, next; + + xorg_list_for_each_entry_safe(lease, next, &pScrPriv->leases, list) { + int c; + for (c = 0; c < lease->numCrtcs; c++) { + if (lease->crtcs[c] == crtc) { + RRTerminateLease(lease); + break; + } + } + } for (i = 0; i < pScrPriv->numCrtcs; i++) { if (pScrPriv->crtcs[i] == crtc) { diff --git a/randr/rrlease.c b/randr/rrlease.c index b4a8827cc..e25d9ca99 100644 --- a/randr/rrlease.c +++ b/randr/rrlease.c @@ -169,7 +169,7 @@ RRLeaseFree(RRLeasePtr lease) * finished, which may be some time after this function returns * if the driver operation is asynchronous */ -static void +void RRTerminateLease(RRLeasePtr lease) { ScreenPtr screen = lease->screen; diff --git a/randr/rroutput.c b/randr/rroutput.c index 33300e1cc..e52ad7671 100644 --- a/randr/rroutput.c +++ b/randr/rroutput.c @@ -379,6 +379,17 @@ RROutputDestroyResource(void *value, XID pid) if (pScreen) { rrScrPriv(pScreen); int i; + RRLeasePtr lease, next; + + xorg_list_for_each_entry_safe(lease, next, &pScrPriv->leases, list) { + int o; + for (o = 0; o < lease->numOutputs; o++) { + if (lease->outputs[o] == output) { + RRTerminateLease(lease); + break; + } + } + } if (pScrPriv->primaryOutput == output) pScrPriv->primaryOutput = NULL;