drm/atomic: Stable sort for atomic request de-duplication
authorDaniel Stone <daniels@collabora.com>
Wed, 19 May 2021 10:05:22 +0000 (11:05 +0100)
committerDaniel Stone <daniels@collabora.com>
Fri, 4 Feb 2022 06:16:28 +0000 (06:16 +0000)
commit79fa377c8bdc84fde99c6a6ac17e554971c617be
treee670d8a671d0d408c320394091ef96e59b8f3140
parent7aede93ef9a755f4080cf047b7b263466f4381be
drm/atomic: Stable sort for atomic request de-duplication

Atomic request property lists are defined to be de-duplicated: an atomic
request can contain multiple sets for the same property on the same
object, and only the last one will take effect.

drmModeAtomicCommit already sorts the property set by object and
property ID. We were relying on qsort to also sort by cursor - i.e.
pointer value - when object and property ID are equal, however whilst
glibc does this, the sort order is explicitly undefined when the
comparator is equal. Using the pointer is also not stable on all
implementations.

Add an explicit 'cursor' member to each property set which is used as
the tie-breaker comparator.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Fixes: #46
xf86drmMode.c