Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2017 Keith Packard
|
|
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
|
*/
|
2024-03-07 17:07:04 +01:00
|
|
|
#include <dix-config.h>
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
2024-03-07 17:07:04 +01:00
|
|
|
#include "dix/dix_priv.h"
|
|
|
|
|
#include "randr/randrstr_priv.h"
|
2025-02-13 18:25:56 +01:00
|
|
|
#include "os/client_priv.h"
|
2024-03-07 17:07:04 +01:00
|
|
|
|
|
|
|
|
#include "swaprep.h"
|
|
|
|
|
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
RESTYPE RRLeaseType;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Notify of some lease change
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
RRDeliverLeaseEvent(ClientPtr client, WindowPtr window)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = window->drawable.pScreen;
|
|
|
|
|
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
|
|
|
|
|
UpdateCurrentTimeIf();
|
|
|
|
|
xorg_list_for_each_entry(lease, &scr_priv->leases, list) {
|
|
|
|
|
if (lease->id != None && (lease->state == RRLeaseCreating ||
|
|
|
|
|
lease->state == RRLeaseTerminating))
|
|
|
|
|
{
|
|
|
|
|
xRRLeaseNotifyEvent le = (xRRLeaseNotifyEvent) {
|
|
|
|
|
.type = RRNotify + RREventBase,
|
|
|
|
|
.subCode = RRNotify_Lease,
|
|
|
|
|
.timestamp = currentTime.milliseconds,
|
|
|
|
|
.window = window->drawable.id,
|
|
|
|
|
.lease = lease->id,
|
|
|
|
|
.created = lease->state == RRLeaseCreating,
|
|
|
|
|
};
|
|
|
|
|
WriteEventsToClient(client, 1, (xEvent *) &le);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Change the state of a lease and let anyone watching leases know
|
|
|
|
|
*/
|
|
|
|
|
static void
|
|
|
|
|
RRLeaseChangeState(RRLeasePtr lease, RRLeaseState old, RRLeaseState new)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = lease->screen;
|
|
|
|
|
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
|
|
|
|
|
lease->state = old;
|
|
|
|
|
scr_priv->leasesChanged = TRUE;
|
|
|
|
|
RRSetChanged(lease->screen);
|
|
|
|
|
RRTellChanged(lease->screen);
|
|
|
|
|
scr_priv->leasesChanged = FALSE;
|
|
|
|
|
lease->state = new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Allocate and initialize a lease
|
|
|
|
|
*/
|
|
|
|
|
static RRLeasePtr
|
|
|
|
|
RRLeaseAlloc(ScreenPtr screen, RRLease lid, int numCrtcs, int numOutputs)
|
|
|
|
|
{
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
lease = calloc(1,
|
|
|
|
|
sizeof(RRLeaseRec) +
|
|
|
|
|
numCrtcs * sizeof (RRCrtcPtr) +
|
|
|
|
|
numOutputs * sizeof(RROutputPtr));
|
|
|
|
|
if (!lease)
|
|
|
|
|
return NULL;
|
|
|
|
|
lease->screen = screen;
|
|
|
|
|
xorg_list_init(&lease->list);
|
|
|
|
|
lease->id = lid;
|
|
|
|
|
lease->state = RRLeaseCreating;
|
|
|
|
|
lease->numCrtcs = numCrtcs;
|
|
|
|
|
lease->numOutputs = numOutputs;
|
|
|
|
|
lease->crtcs = (RRCrtcPtr *) (lease + 1);
|
|
|
|
|
lease->outputs = (RROutputPtr *) (lease->crtcs + numCrtcs);
|
|
|
|
|
return lease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check if a crtc is leased
|
|
|
|
|
*/
|
|
|
|
|
Bool
|
|
|
|
|
RRCrtcIsLeased(RRCrtcPtr crtc)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = crtc->pScreen;
|
|
|
|
|
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
int c;
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(lease, &scr_priv->leases, list) {
|
|
|
|
|
for (c = 0; c < lease->numCrtcs; c++)
|
|
|
|
|
if (lease->crtcs[c] == crtc)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Check if an output is leased
|
|
|
|
|
*/
|
|
|
|
|
Bool
|
|
|
|
|
RROutputIsLeased(RROutputPtr output)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = output->pScreen;
|
|
|
|
|
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
int o;
|
|
|
|
|
|
|
|
|
|
xorg_list_for_each_entry(lease, &scr_priv->leases, list) {
|
|
|
|
|
for (o = 0; o < lease->numOutputs; o++)
|
|
|
|
|
if (lease->outputs[o] == output)
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A lease has been terminated.
|
|
|
|
|
* The driver is responsible for noticing and
|
|
|
|
|
* calling this function when that happens
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RRLeaseTerminated(RRLeasePtr lease)
|
|
|
|
|
{
|
|
|
|
|
/* Notify clients with events, but only if this isn't during lease creation */
|
|
|
|
|
if (lease->state == RRLeaseRunning)
|
|
|
|
|
RRLeaseChangeState(lease, RRLeaseTerminating, RRLeaseTerminating);
|
|
|
|
|
|
|
|
|
|
if (lease->id != None)
|
2024-03-04 15:08:32 +01:00
|
|
|
FreeResource(lease->id, X11_RESTYPE_NONE);
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
|
|
|
|
|
xorg_list_del(&lease->list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A lease is completely shut down and is
|
|
|
|
|
* ready to be deallocated
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
RRLeaseFree(RRLeasePtr lease)
|
|
|
|
|
{
|
|
|
|
|
free(lease);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Ask the driver to terminate a lease. The
|
|
|
|
|
* driver will call RRLeaseTerminated when that has
|
|
|
|
|
* finished, which may be some time after this function returns
|
|
|
|
|
* if the driver operation is asynchronous
|
|
|
|
|
*/
|
2018-06-26 09:20:00 -07:00
|
|
|
void
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
RRTerminateLease(RRLeasePtr lease)
|
|
|
|
|
{
|
|
|
|
|
ScreenPtr screen = lease->screen;
|
|
|
|
|
rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
|
|
|
|
|
scr_priv->rrTerminateLease(screen, lease);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Destroy a lease resource ID. All this
|
|
|
|
|
* does is note that the lease no longer has an ID, and
|
|
|
|
|
* so doesn't appear over the protocol anymore.
|
|
|
|
|
*/
|
|
|
|
|
static int
|
|
|
|
|
RRLeaseDestroyResource(void *value, XID pid)
|
|
|
|
|
{
|
|
|
|
|
RRLeasePtr lease = value;
|
|
|
|
|
|
|
|
|
|
lease->id = None;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Create the lease resource type during server initialization
|
|
|
|
|
*/
|
|
|
|
|
Bool
|
|
|
|
|
RRLeaseInit(void)
|
|
|
|
|
{
|
|
|
|
|
RRLeaseType = CreateNewResourceType(RRLeaseDestroyResource, "LEASE");
|
|
|
|
|
if (!RRLeaseType)
|
|
|
|
|
return FALSE;
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ProcRRCreateLease(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
REQUEST(xRRCreateLeaseReq);
|
2025-06-11 13:43:47 -07:00
|
|
|
xRRCreateLeaseReply rep;
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
WindowPtr window;
|
|
|
|
|
ScreenPtr screen;
|
|
|
|
|
rrScrPrivPtr scr_priv;
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
RRCrtc *crtcIds;
|
|
|
|
|
RROutput *outputIds;
|
|
|
|
|
int fd;
|
|
|
|
|
int rc;
|
|
|
|
|
unsigned long len;
|
|
|
|
|
int c, o;
|
|
|
|
|
|
|
|
|
|
REQUEST_AT_LEAST_SIZE(xRRCreateLeaseReq);
|
|
|
|
|
|
|
|
|
|
LEGAL_NEW_RESOURCE(stuff->lid, client);
|
|
|
|
|
|
|
|
|
|
rc = dixLookupWindow(&window, stuff->window, client, DixGetAttrAccess);
|
|
|
|
|
if (rc != Success)
|
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
|
|
len = client->req_len - bytes_to_int32(sizeof(xRRCreateLeaseReq));
|
|
|
|
|
|
|
|
|
|
if (len != stuff->nCrtcs + stuff->nOutputs)
|
|
|
|
|
return BadLength;
|
|
|
|
|
|
|
|
|
|
screen = window->drawable.pScreen;
|
|
|
|
|
scr_priv = rrGetScrPriv(screen);
|
|
|
|
|
|
|
|
|
|
if (!scr_priv)
|
|
|
|
|
return BadMatch;
|
|
|
|
|
|
2021-12-02 13:22:53 +01:00
|
|
|
if (!scr_priv->rrCreateLease && !scr_priv->rrRequestLease)
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
return BadMatch;
|
|
|
|
|
|
2021-12-02 13:22:53 +01:00
|
|
|
if (scr_priv->rrGetLease) {
|
|
|
|
|
scr_priv->rrGetLease(client, screen, &lease, &fd);
|
|
|
|
|
if (lease) {
|
|
|
|
|
if (fd >= 0)
|
|
|
|
|
goto leaseReturned;
|
|
|
|
|
else
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
/* Allocate a structure to hold all of the lease information */
|
|
|
|
|
|
|
|
|
|
lease = RRLeaseAlloc(screen, stuff->lid, stuff->nCrtcs, stuff->nOutputs);
|
|
|
|
|
if (!lease)
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
|
|
|
|
|
/* Look up all of the crtcs */
|
|
|
|
|
crtcIds = (RRCrtc *) (stuff + 1);
|
|
|
|
|
for (c = 0; c < stuff->nCrtcs; c++) {
|
|
|
|
|
RRCrtcPtr crtc;
|
|
|
|
|
|
|
|
|
|
rc = dixLookupResourceByType((void **)&crtc, crtcIds[c],
|
|
|
|
|
RRCrtcType, client, DixSetAttrAccess);
|
|
|
|
|
|
|
|
|
|
if (rc != Success) {
|
|
|
|
|
client->errorValue = crtcIds[c];
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RRCrtcIsLeased(crtc)) {
|
|
|
|
|
client->errorValue = crtcIds[c];
|
|
|
|
|
rc = BadAccess;
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lease->crtcs[c] = crtc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Look up all of the outputs */
|
|
|
|
|
outputIds = (RROutput *) (crtcIds + stuff->nCrtcs);
|
|
|
|
|
for (o = 0; o < stuff->nOutputs; o++) {
|
|
|
|
|
RROutputPtr output;
|
|
|
|
|
|
|
|
|
|
rc = dixLookupResourceByType((void **)&output, outputIds[o],
|
|
|
|
|
RROutputType, client, DixSetAttrAccess);
|
|
|
|
|
if (rc != Success) {
|
|
|
|
|
client->errorValue = outputIds[o];
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RROutputIsLeased(output)) {
|
|
|
|
|
client->errorValue = outputIds[o];
|
|
|
|
|
rc = BadAccess;
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lease->outputs[o] = output;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-02 13:22:53 +01:00
|
|
|
if (scr_priv->rrRequestLease) {
|
|
|
|
|
rc = scr_priv->rrRequestLease(client, screen, lease);
|
|
|
|
|
if (rc == Success)
|
|
|
|
|
return Success;
|
|
|
|
|
else
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
} else {
|
|
|
|
|
rc = scr_priv->rrCreateLease(screen, lease, &fd);
|
|
|
|
|
if (rc != Success)
|
|
|
|
|
goto bail_lease;
|
|
|
|
|
}
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
|
2021-12-02 13:22:53 +01:00
|
|
|
leaseReturned:
|
Fix RandR leasing for more than 1 simultaneously active lease.
Due to a switched order of parameters in the xorg_list_add()
call inside ProcRRCreateLease(), adding a new lease for RandR
output leasing does not actually add the new RRLeasePtr lease
record to the list of existing leases for a X-Screen, but instead
replaces the existing list with a new list that has the new lease
as the only element, and probably leaks a bit of memory.
Therefore the server "forgets" all active leases for a screen,
except for the last added lease. If multiple leases are created
in a session, then destruction of all leases but the last one
will fail in many cases, e.g., during server shutdown in
RRCloseScreen(), or resource destruction, e.g., in
RRCrtcDestroyResource().
Most importantly, it fails if a client simply close(fd)'es the
DRM master descriptor to release a lease, quits, gets killed or
crashes. In this case the kernel will destroy the lease and shut
down the display output, then send a lease event via udev to the
ddx, which e.g., in the modesetting-ddx will trigger a call to
drmmode_validate_leases().
That function is supposed to detect the released lease and tell
the server to terminate the lease on the server side as well,
via xf86CrtcLeaseTerminated(), but this doesn't happen for all
the leases the server has forgotten. The end result is a dead
video output, as the server won't reinitialize the crtc's
corresponding to the terminated but forgotten lease.
This bug was observed when using the amdvlk AMD OSS Vulkan
driver and trying to lease multiple VKDisplay's, and also
under Mesa radv, as both Mesa Vulkan/WSI/Display and amdvlk
terminate leases by simply close()ing the lease fd, not by
sending explicit RandR protocol requests to free leases.
Leasing worked, but ending a session with multiple active
leases ended in a lot of unpleasant darkness.
Fixing the wrong argument order to xorg_list_add() fixes the
problem. Tested on single-X-Screen and dual-X-Screen setups,
with one, two or three active leases.
Please merge this for the upcoming server 21.1 branch.
Merging into server 1.20 would also make a lot of sense.
Fixes: e4e3447603b5fd3a38a92c3f972396d1f81168ad
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Keith Packard <keithp@keithp.com>
2021-10-18 08:14:04 +02:00
|
|
|
xorg_list_add(&lease->list, &scr_priv->leases);
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
|
|
|
|
|
if (!AddResource(stuff->lid, RRLeaseType, lease)) {
|
|
|
|
|
close(fd);
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (WriteFdToClient(client, fd, TRUE) < 0) {
|
|
|
|
|
RRTerminateLease(lease);
|
|
|
|
|
close(fd);
|
|
|
|
|
return BadAlloc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RRLeaseChangeState(lease, RRLeaseCreating, RRLeaseRunning);
|
|
|
|
|
|
2025-06-11 13:43:47 -07:00
|
|
|
rep = (xRRCreateLeaseReply) {
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
.type = X_Reply,
|
|
|
|
|
.nfd = 1,
|
|
|
|
|
.sequenceNumber = client->sequence,
|
2025-06-11 13:43:47 -07:00
|
|
|
.length = 0,
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (client->swapped) {
|
|
|
|
|
swaps(&rep.sequenceNumber);
|
|
|
|
|
swapl(&rep.length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WriteToClient(client, sizeof (rep), &rep);
|
|
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
|
|
|
|
|
bail_lease:
|
|
|
|
|
free(lease);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ProcRRFreeLease(ClientPtr client)
|
|
|
|
|
{
|
|
|
|
|
REQUEST(xRRFreeLeaseReq);
|
|
|
|
|
RRLeasePtr lease;
|
|
|
|
|
|
|
|
|
|
REQUEST_SIZE_MATCH(xRRFreeLeaseReq);
|
|
|
|
|
|
|
|
|
|
VERIFY_RR_LEASE(stuff->lid, lease, DixDestroyAccess);
|
|
|
|
|
|
|
|
|
|
if (stuff->terminate)
|
|
|
|
|
RRTerminateLease(lease);
|
|
|
|
|
else
|
|
|
|
|
/* Get rid of the resource database entry */
|
2024-03-04 15:08:32 +01:00
|
|
|
FreeResource(stuff->lid, X11_RESTYPE_NONE);
|
Add RandR leases with modesetting driver support [v6]
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.
v2: Restore CRTC mode when leases terminate
When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.
v3: Report RR_Rotate_0 rotations for leased crtcs.
Ignore leased CRTCs when selecting screen size.
Stop leasing encoders, the kernel doesn't do that anymore.
Turn off crtc->enabled while leased so that modesetting
ignores them.
Check lease status before calling any driver mode functions
When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.
When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.
This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).
v4: Report RR_Rotate_0 rotation for leased crtcs.
v5: Terminate all leases on server reset.
Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.
Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.
Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that
modesetting: Validate leases on VT enter
The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.
xfree86: hide disabled cursors when resetting after lease termination
The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.
v6: Add meson build infrastructure
[Also bumped libdrm requirement - ajax]
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2018-02-12 13:51:56 -08:00
|
|
|
|
|
|
|
|
return Success;
|
|
|
|
|
}
|